diff --git a/docs/architecture/02-mainchain/04-mainchain_api.md b/docs/architecture/02-mainchain/04-mainchain_api.md index f88cdce..363a476 100644 --- a/docs/architecture/02-mainchain/04-mainchain_api.md +++ b/docs/architecture/02-mainchain/04-mainchain_api.md @@ -355,8 +355,17 @@ pub type Pubs = Vec<[u8; 32]>; #### settlementUltrahonkPallet Types ```rust -pub type Proof = Vec; -pub type Vk = [u8; 1760]; +// Auxiliary type +// Vector size is limited by the evaluation domain size +pub enum Proof { + ZK(Vec), + Plain(Vec), +} + +pub enum VersionedProof { + V3_0(Proof), +} +pub type Vk = [u8; 1888]; pub type Pubs = Vec<[u8; 32]>; ``` diff --git a/docs/architecture/07-verification_pallets/09-ultrahonk.md b/docs/architecture/07-verification_pallets/09-ultrahonk.md index 5f729c6..3e65cff 100644 --- a/docs/architecture/07-verification_pallets/09-ultrahonk.md +++ b/docs/architecture/07-verification_pallets/09-ultrahonk.md @@ -17,4 +17,4 @@ This pallet implements a verifier for UltraHonk proofs generated with [barretenb 2. only Keccak256 is supported as the hash function for transcript generation; 3. recursion is not supported. -- `verify_proof()` uses the [ultrahonk_verifier](https://github.com/zkVerify/ultrahonk_verifier/tree/v0.1.0) crate to verify proofs. +- `verify_proof()` uses the [ultrahonk_verifier](https://github.com/zkVerify/ultrahonk_verifier/tree/v0.3.0) crate to verify proofs. diff --git a/docs/architecture/09-supported_proofs.md b/docs/architecture/09-supported_proofs.md index b4f47ce..238dae0 100644 --- a/docs/architecture/09-supported_proofs.md +++ b/docs/architecture/09-supported_proofs.md @@ -3,10 +3,10 @@ | Proof Type | Supported Versions / Curves | Limits | | -------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------ | | **EZKL** | Reusable Verifier only (v0.1.0), BN254 (Curve), BDFG21 (batch opening scheme), no accumulator | **Max number of Public Inputs:** 32 | -| **Fflonk** | BN128 | **Public Inputs:** 1 | -| **Groth16** | BLS12-381, BN128, BN254 | **Public Inputs:** 64 | -| **Noir UltraHonk** | Noir v1.0.0-beta.6, v0.84.0 \<\= bb \< v0.86.* and 0.84.0 \<\= bb.js \< v0.86.*, both ZK and non-ZK variants, Keccak256 only | **Public Inputs:** 32 | -| **Noir UltraPlonk** | \>\= v0.31.0, bbup \<\= v0.76.4 | **Public Inputs:** 32 | +| **Fflonk** | BN128 | **Max number of Public Inputs:** 1 | +| **Groth16** | BLS12-381, BN128, BN254 | **Max number of Public Inputs:** 64 | +| **Noir UltraHonk** | Noir ≥ v1.0.0-beta.14, bb ≥ v3.0.0 and bb.js ≥ v3.0.0, both ZK and non-ZK variants, Keccak256 only | **Max number of Public Inputs:** 32, **Max Evaluation Domain Size:** $2^{25}$ | +| **Noir UltraPlonk** | Noir ≥ v0.31.0, bb ≤ v0.76.4 | **Max number of Public Inputs:** 32 | | **Risc0** | v2.1, v2.2, v2.3 | **Max Public Inputs Size:** 2052 bytes (2048 bytes user input), **Format:** cbor | | **Plonky2** | Keccak256, Poseidon | **Max number of Public Inputs:** 64, **Max Proof Size:** 256 KiB, **Max Verification Key Size:** 50 KB | | **SP1** | v5.x | **Max Public Inputs Size:** 2048 bytes | diff --git a/docs/overview/02-getting-started/04-generating-proof.md b/docs/overview/02-getting-started/04-generating-proof.md index d52c1ff..79699b9 100644 --- a/docs/overview/02-getting-started/04-generating-proof.md +++ b/docs/overview/02-getting-started/04-generating-proof.md @@ -93,7 +93,7 @@ curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/head ``` :::warning -Our verifier is currently compatible with Noir proofs generated through `bb` and `bb.js` versions `v0.84.0` and later, up to but not including version `v0.86.*`. +Our verifier is currently compatible with Noir proofs generated through `bb` and `bb.js` versions `3.0.0` and later. ::: 4. Install Barretenberg's Backend by running bbup command: @@ -129,28 +129,42 @@ Once we have generated our witness, we can generate proof and vk using the `bb` ```bash -# To generate zero-knowledge proof -bb prove -s ultra_honk -b ./target/hello_world.json -w ./target/hello_world.gz -o ./target --oracle_hash keccak --zk +# To generate zero-knowledge proof (using Keccak as the hash function) +bb prove -t evm -b "./target/hello_world.json" -w "./target/hello_world.gz" -o ./target ``` ```bash -# To generate a plain proof -bb prove -s ultra_honk -b ./target/hello_world.json -w ./target/hello_world.gz -o ./target --oracle_hash keccak +# To generate a plain proof (using Keccak as the hash function) +bb prove -t evm-no-zk -b "./target/hello_world.json" -w "./target/hello_world.gz" -o ./target ``` -Generating the `vk` is the same regardless of which flavor you picked: +Then proceed to generating a `vk` depending on the flavor that you picked: + + + ```bash -# To generate vk -bb write_vk -s ultra_honk -b ./target/hello_world.json -o ./target --oracle_hash keccak +# Generate vk for ZK proof (using Keccak as the hash function) +bb write_vk -t evm -b "./target/hello_world.json" -o ./target +``` + + + + +```bash +# Generate vk for Plain proof (using Keccak as the hash function) +bb write_vk -t evm-no-zk -b "./target/hello_world.json" -o ./target ``` + + + After running these commands, you will have three files, namely: `proof`, `public_inputs`, and `vk` inside the `target` folder which will be used for verification. As a final step, we will convert them to a format compatible with direct use with zkVerify. zkVerify supports both flavors for UltraHonk proofs, but you will need to explicitly convey which flavor was used to generate your proof during this final step. You can do this by setting the `PROOF_TYPE` variable in the script that follows to either `ZK` or `Plain`. To convert the three files into hex format, run the following Bash script: @@ -158,44 +172,54 @@ To convert the three files into hex format, run the following Bash script: ```bash #!/usr/bin/env bash -PROOF_TYPE="ZK" # Set to "Plain" if you are using the non-zk variant of UltraHonk -PROOF_FILE_PATH="./target/proof" # Adjust path depending on where the Noir-generated proof file is -VK_FILE_PATH="./target/vk" # Adjust path depending on where the Noir-generated vk file is -PUBS_FILE_PATH="./target/public_inputs" # Adjust path depending on where the Noir-generated public_inputs file is +PROOF_TYPE="ZK" # Set to "Plain" if you are using the non-zk variant of UltraHonk +ARTIFACT_DIR_PATH="./target" # Adjust path depending on where the Noir-generated artifacts are +OUTPUT_DIR_PATH="./target" # Adjust path based on where you would like the zkv-ready artifacts to be placed # You may ignore these: -ZKV_PROOF_HEX_FILE_PATH="./target/zkv_proof.hex" -ZKV_VK_HEX_FILE_PATH="./target/zkv_vk.hex" -ZKV_PUBS_HEX_FILE_PATH="./target/zkv_pubs.hex" - -# Convert proof to hexadecimal format -{ - if [ -f "$PROOF_FILE_PATH" ]; then - PROOF_BYTES=$(xxd -p -c 256 "$PROOF_FILE_PATH" | tr -d '\n') - printf '`{\n "%s:" "0x%s"\n}`\n' "$PROOF_TYPE" "$PROOF_BYTES" > "$ZKV_PROOF_HEX_FILE_PATH" - echo "✅ 'proof' hex file generated at ${ZKV_PROOF_HEX_FILE_PATH}." - else - echo "❌ Error: Proof file '$PROOF_FILE_PATH' not found. Skipping." >&2 - fi -} +PROOF_FILE_PATH="${ARTIFACT_DIR_PATH}/proof" +VK_FILE_PATH="${ARTIFACT_DIR_PATH}/vk" +PUBS_FILE_PATH="${ARTIFACT_DIR_PATH}/public_inputs" +ZKV_PROOF_HEX_FILE_PATH="${OUTPUT_DIR_PATH}/zkv_proof.hex" +ZKV_VK_HEX_FILE_PATH="${OUTPUT_DIR_PATH}/zkv_vk.hex" +ZKV_PUBS_HEX_FILE_PATH="${OUTPUT_DIR_PATH}/zkv_pubs.hex" + +# Get bb version and format it (e.g., 3.0.3 -> V3_0) +BB_VERSION_FULL=$(bb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') +# Extract major and minor, then join with underscore +BB_VERSION_KEY=$(echo "$BB_VERSION_FULL" | awk -F. '{print "V" $1 "_" $2}') + +# Convert proof to valid JSON +if [ -f "${PROOF_FILE_PATH}" ]; then + PROOF_BYTES=$(xxd -p -c 1000000 "${PROOF_FILE_PATH}" | tr -d '\n') + + printf '{\n "%s": {\n "%s": "0x%s"\n }\n}\n' \ + "${BB_VERSION_KEY}" \ + "${PROOF_TYPE}" \ + "${PROOF_BYTES}" > "${ZKV_PROOF_HEX_FILE_PATH}" + + echo "✅ Generated ${ZKV_PROOF_HEX_FILE_PATH} with version key ${BB_VERSION_KEY}" +else + echo "❌ Error: Proof file not found." >&2 +fi # Convert vk to hexadecimal format { - if [ -f "$VK_FILE_PATH" ]; then - printf "\"0x%s\"\n" "$(xxd -p -c 0 "$VK_FILE_PATH")" > "$ZKV_VK_HEX_FILE_PATH" + if [ -f "${VK_FILE_PATH}" ]; then + printf "\"0x%s\"\n" "$(xxd -p -c 0 "${VK_FILE_PATH}")" > "${ZKV_VK_HEX_FILE_PATH}" echo "✅ 'vk' hex file generated at ${ZKV_VK_HEX_FILE_PATH}." else - echo "❌ Error: Verification key file '$VK_FILE_PATH' not found. Skipping." >&2 + echo "❌ Error: Verification key file '${VK_FILE_PATH}' not found. Skipping." >&2 fi } # Convert public inputs to hexadecimal format { - if [ -f "$PUBS_FILE_PATH" ]; then - xxd -p -c 32 "$PUBS_FILE_PATH" | sed 's/.*/"0x&"/' | paste -sd, - | sed 's/.*/[&]/' > "$ZKV_PUBS_HEX_FILE_PATH" + if [ -f "${PUBS_FILE_PATH}" ]; then + xxd -p -c 32 "${PUBS_FILE_PATH}" | sed 's/.*/"0x&"/' | paste -sd, - | sed 's/.*/[&]/' > "${ZKV_PUBS_HEX_FILE_PATH}" echo "✅ 'pubs' hex file generated at ${ZKV_PUBS_HEX_FILE_PATH}." else - echo "❌ Error: Public inputs file '$PUBS_FILE_PATH' not found. Skipping." >&2 + echo "❌ Error: Public inputs file '${PUBS_FILE_PATH}' not found. Skipping." >&2 fi }