Skip to main content

Ultraplonk Verifier

settlementUltraplonkPallet

Statement hash components

  • context: keccak256(b"ultraplonk")
  • vk: keccak256(vk.encode())
  • pubs: keccak256(pubs)

Verifier implementation

The UltraPlonk zk-SNARK verifier is a wrapper around the barretenberg library. This library is part of the Aztec Protocol's suite of cryptographic tools. The Noir compiler generates UltraPlonk zk-SNARK proofs using the barretenberg library as the backend. To generate proofs from Noir code, the nargo tool is used.

  • verify_proof() uses the ultraplonk_verifier crate to deserialize the proof and public inputs, verifying them against the provided verification key. The noir-cli tool transforms the proving artifacts from the Noir compiler to a format compatible with the verifier.

  • To obtain the proving artifacts, run the following commands:

    noir-cli key --input ./resources/proves/verifier.sol --output ./target/vk.bin 
    noir-cli proof-data --input-json ./resources/proves/proof.json --output-proof ./target/proof.bin --output-pubs ./target/pubs.bin
    noir-cli verify --key ./target/vk.bin --proof ./target/proof.bin --pubs ./target/pubs.bin

    Where:

    • ./resources/proves/verifier.sol is the Solidity file containing the verifier contract generated by Nargo.
    • ./resources/proves/proof.json is the JSON file containing the proof and public inputs.
  • Define the following types:

    pub type Proof = Vec<u8>;
    pub type Pubs = Vec<[u8; 32]>;
    pub type Vk = [u8; 1719];
  • The hash context data is b"ultraplonk".

  • The public input bytes are the input ones.

  • validate_vk checks the verification key format is valid.

Result

The pallet's verification duties are summarized in the following code snippet:

let vk = load_verification_key();
let proof = load_proof_data();
let pubs = load_public_inputs();

match verify(&vk, &proof, &pubs) {
Ok(()) => println!("Proof is valid"),
Err(e) => println!("Verification failed with error: {:?}", e),
}