diff --git a/barretenberg/acir_tests/bbjs-test/src/index.ts b/barretenberg/acir_tests/bbjs-test/src/index.ts index 0de55331326e..7a50b1a1c787 100644 --- a/barretenberg/acir_tests/bbjs-test/src/index.ts +++ b/barretenberg/acir_tests/bbjs-test/src/index.ts @@ -7,11 +7,12 @@ import assert from "assert"; createDebug.enable("*"); const debug = createDebug("bbjs-test"); -const UH_PROOF_FIELDS_LENGTH = 440; +const UH_PROOF_FIELDS_LENGTH = 456; const BYTES_PER_FIELD = 32; const UH_PROOF_LENGTH_IN_BYTES = UH_PROOF_FIELDS_LENGTH * BYTES_PER_FIELD; const proofPath = (dir: string) => path.join(dir, "proof"); +const proofAsFieldsPath = (dir: string) => path.join(dir, "proof_fields.json"); const publicInputsAsFieldsPath = (dir: string) => path.join(dir, "public_inputs_fields.json"); const vkeyPath = (dir: string) => path.join(dir, "vk"); @@ -29,7 +30,7 @@ async function generateProof({ oracleHash?: string; multiThreaded?: boolean; }) { - const { UltraHonkBackend } = await import("@aztec/bb.js"); + const { UltraHonkBackend, deflattenFields } = await import("@aztec/bb.js"); debug(`Generating proof for ${bytecodePath}...`); const circuitArtifact = await fs.readFile(bytecodePath); @@ -58,6 +59,11 @@ async function generateProof({ "Public inputs written to " + publicInputsAsFieldsPath(outputDirectory) ); + await fs.writeFile( + proofAsFieldsPath(outputDirectory), + JSON.stringify(deflattenFields(proof.proof)) + ); + const verificationKey = await backend.getVerificationKey({ keccak: oracleHash === "keccak", }); @@ -75,7 +81,7 @@ async function verifyProof({ directory }: { directory: string }) { const proof = await fs.readFile(proofPath(directory)); assert( proof.length === UH_PROOF_LENGTH_IN_BYTES, - `Unexpected proof length ${proof.length}` + `Unexpected proof length ${proof.length}, expected ${UH_PROOF_LENGTH_IN_BYTES}` ); const publicInputs = JSON.parse( diff --git a/barretenberg/acir_tests/bootstrap.sh b/barretenberg/acir_tests/bootstrap.sh index 1a1e6f36b369..03816b07306c 100755 --- a/barretenberg/acir_tests/bootstrap.sh +++ b/barretenberg/acir_tests/bootstrap.sh @@ -179,8 +179,8 @@ function test_cmds_internal { for t in $honk_tests; do echo SYS=ultra_honk FLOW=prove_then_verify $run_test $(basename $t) done - echo SYS=ultra_honk FLOW=prove_then_verify RECURSIVE=true $run_test assert_statement - echo SYS=ultra_honk FLOW=prove_then_verify RECURSIVE=true $run_test double_verify_honk_proof + echo SYS=ultra_honk FLOW=prove_then_verify $run_test assert_statement + echo SYS=ultra_honk FLOW=prove_then_verify $run_test double_verify_honk_proof echo SYS=ultra_honk FLOW=prove_then_verify HASH=keccak $run_test assert_statement echo SYS=ultra_honk FLOW=prove_then_verify ROLLUP=true $run_test verify_rollup_honk_proof diff --git a/barretenberg/acir_tests/flows/bbjs_prove_sol_verify.sh b/barretenberg/acir_tests/flows/bbjs_prove_sol_verify.sh index 0d4a9fb5f301..fb85352d9959 100755 --- a/barretenberg/acir_tests/flows/bbjs_prove_sol_verify.sh +++ b/barretenberg/acir_tests/flows/bbjs_prove_sol_verify.sh @@ -31,6 +31,7 @@ $BIN write_solidity_verifier --scheme ultra_honk -k $VK -o $VERIFIER_PATH # Verify the proof using the solidity verifier export PROOF=$output_dir/proof +export PROOF_AS_FIELDS=$output_dir/proof_fields.json export PUBLIC_INPUTS_AS_FIELDS=$output_dir/public_inputs_fields.json export TEST_PATH=$(realpath "../../sol-test/HonkTest.sol") export TESTING_HONK="true" diff --git a/barretenberg/acir_tests/flows/sol_honk.sh b/barretenberg/acir_tests/flows/sol_honk.sh index 3f961e75d72a..eeec6940b08c 100755 --- a/barretenberg/acir_tests/flows/sol_honk.sh +++ b/barretenberg/acir_tests/flows/sol_honk.sh @@ -4,7 +4,6 @@ set -eu VFLAG=${VERBOSE:+-v} BFLAG="-b ./target/program.json" FLAGS="-c $CRS_PATH $VFLAG --scheme ultra_honk" -[ "${RECURSIVE}" = "true" ] && FLAGS+=" --recursive" PROVE_FLAGS="$FLAGS $BFLAG --oracle_hash keccak --output_format bytes_and_fields --write_vk --input_type single_circuit" VERIFY_FLAGS="$FLAGS --oracle_hash keccak" diff --git a/barretenberg/acir_tests/flows/sol_honk_zk.sh b/barretenberg/acir_tests/flows/sol_honk_zk.sh index a7c25f7a4853..d2cb24543aee 100755 --- a/barretenberg/acir_tests/flows/sol_honk_zk.sh +++ b/barretenberg/acir_tests/flows/sol_honk_zk.sh @@ -4,7 +4,6 @@ set -eux VFLAG=${VERBOSE:+-v} BFLAG="-b ./target/program.json" FLAGS="-c $CRS_PATH $VFLAG --scheme ultra_honk --zk" -[ "${RECURSIVE}" = "true" ] && FLAGS+=" --recursive" PROTOCOL_FLAGS=" --honk_recursion 1 --oracle_hash keccak" outdir=$(mktemp -d) diff --git a/barretenberg/acir_tests/sol-test/src/index.js b/barretenberg/acir_tests/sol-test/src/index.js index bca0dc52d6e8..ff568a3c0415 100644 --- a/barretenberg/acir_tests/sol-test/src/index.js +++ b/barretenberg/acir_tests/sol-test/src/index.js @@ -225,19 +225,11 @@ try { const proof = readFileSync(proofPath); proofStr = proof.toString("hex"); - let publicInputsAsFieldsPath; // PUBLIC_INPUTS_AS_FIELDS is not defined for bb plonk, but is for bb honk and bbjs honk. - try { - publicInputsAsFieldsPath = getEnvVar("PUBLIC_INPUTS_AS_FIELDS"); - } catch (e) { - // noop - } + let publicInputsAsFieldsPath = getEnvVarCanBeUndefined( + "PUBLIC_INPUTS_AS_FIELDS" + ); // PUBLIC_INPUTS_AS_FIELDS is not defined for bb plonk, but is for bb honk and bbjs honk. var publicInputs; - let proofAsFieldsPath; // PROOF_AS_FIELDS is not defined for bbjs, but is for bb plonk and bb honk. - try { - proofAsFieldsPath = getEnvVar("PROOF_AS_FIELDS"); - } catch (e) { - // noop - } + let proofAsFieldsPath = getEnvVarCanBeUndefined("PROOF_AS_FIELDS"); // PROOF_AS_FIELDS is not defined for bbjs, but is for bb plonk and bb honk. let numExtraPublicInputs = 0; let extraPublicInputs = []; if (proofAsFieldsPath) { diff --git a/barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp b/barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp index 8ab44ebb682b..3ec7ea54d932 100644 --- a/barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp +++ b/barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp @@ -20,9 +20,7 @@ namespace bb { extern std::string CRS_PATH; template -Circuit _compute_circuit(const std::string& bytecode_path, - const std::string& witness_path, - const bool init_kzg_accumulator) +Circuit _compute_circuit(const std::string& bytecode_path, const std::string& witness_path) { uint32_t honk_recursion = 0; if constexpr (IsAnyOf) { @@ -34,7 +32,7 @@ Circuit _compute_circuit(const std::string& bytecode_path, // TODO(https://github.com/AztecProtocol/barretenberg/issues/1180): Don't init grumpkin crs when unnecessary. init_grumpkin_crs(1 << CONST_ECCVM_LOG_N); - const acir_format::ProgramMetadata metadata{ .recursive = init_kzg_accumulator, .honk_recursion = honk_recursion }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = honk_recursion }; acir_format::AcirProgram program{ get_constraint_system(bytecode_path, metadata.honk_recursion) }; if (!witness_path.empty()) { @@ -44,11 +42,9 @@ Circuit _compute_circuit(const std::string& bytecode_path, } template -UltraProver_ _compute_prover(const std::string& bytecode_path, - const std::string& witness_path, - const bool init_kzg_accumulator) +UltraProver_ _compute_prover(const std::string& bytecode_path, const std::string& witness_path) { - auto prover = UltraProver_{ _compute_circuit(bytecode_path, witness_path, init_kzg_accumulator) }; + auto prover = UltraProver_{ _compute_circuit(bytecode_path, witness_path) }; size_t required_crs_size = prover.proving_key->proving_key.circuit_size; if constexpr (Flavor::HasZK) { @@ -59,27 +55,23 @@ UltraProver_ _compute_prover(const std::string& bytecode_path, } template -PubInputsProofAndKey _compute_vk(const bool init_kzg_accumulator, - const std::filesystem::path& bytecode_path, +PubInputsProofAndKey _compute_vk(const std::filesystem::path& bytecode_path, const std::filesystem::path& witness_path) { - auto prover = _compute_prover(bytecode_path.string(), witness_path.string(), init_kzg_accumulator); + auto prover = _compute_prover(bytecode_path.string(), witness_path.string()); return { PublicInputsVector{}, HonkProof{}, std::make_shared(prover.proving_key->proving_key) }; } template PubInputsProofAndKey _prove(const bool compute_vk, - const bool init_kzg_accumulator, const std::filesystem::path& bytecode_path, const std::filesystem::path& witness_path) { - auto prover = _compute_prover(bytecode_path.string(), witness_path.string(), init_kzg_accumulator); + auto prover = _compute_prover(bytecode_path.string(), witness_path.string()); HonkProof concat_pi_and_proof = prover.construct_proof(); size_t num_inner_public_inputs = prover.proving_key->proving_key.num_public_inputs; - if (init_kzg_accumulator) { - ASSERT(num_inner_public_inputs >= PAIRING_POINT_ACCUMULATOR_SIZE); - num_inner_public_inputs -= PAIRING_POINT_ACCUMULATOR_SIZE; - } + ASSERT(num_inner_public_inputs >= PAIRING_POINT_ACCUMULATOR_SIZE); + num_inner_public_inputs -= PAIRING_POINT_ACCUMULATOR_SIZE; if constexpr (HasIPAAccumulator) { ASSERT(num_inner_public_inputs >= IPA_CLAIM_SIZE); num_inner_public_inputs -= IPA_CLAIM_SIZE; @@ -167,16 +159,14 @@ void UltraHonkAPI::prove(const Flags& flags, write(_prove_output, flags.output_format, flags.write_vk ? "proof_and_vk" : "proof", output_dir); }; - const bool init = flags.init_kzg_accumulator; - if (flags.ipa_accumulation) { - _write(_prove(flags.write_vk, init, bytecode_path, witness_path)); + _write(_prove(flags.write_vk, bytecode_path, witness_path)); } else if (flags.oracle_hash_type == "poseidon2") { - _write(_prove(flags.write_vk, init, bytecode_path, witness_path)); + _write(_prove(flags.write_vk, bytecode_path, witness_path)); } else if (flags.oracle_hash_type == "keccak" && !flags.zk) { - _write(_prove(flags.write_vk, init, bytecode_path, witness_path)); + _write(_prove(flags.write_vk, bytecode_path, witness_path)); } else if (flags.oracle_hash_type == "keccak" && flags.zk) { - _write(_prove(flags.write_vk, init, bytecode_path, witness_path)); + _write(_prove(flags.write_vk, bytecode_path, witness_path)); } else { throw_or_abort("Invalid proving options specified in _prove"); } @@ -217,16 +207,14 @@ void UltraHonkAPI::write_vk(const Flags& flags, { const auto _write = [&](auto&& _prove_output) { write(_prove_output, flags.output_format, "vk", output_path); }; - const bool init = flags.init_kzg_accumulator; - if (flags.ipa_accumulation) { - _write(_compute_vk(init, bytecode_path, "")); + _write(_compute_vk(bytecode_path, "")); } else if (flags.oracle_hash_type == "poseidon2") { - _write(_compute_vk(init, bytecode_path, "")); + _write(_compute_vk(bytecode_path, "")); } else if (flags.oracle_hash_type == "keccak" && !flags.zk) { - _write(_compute_vk(init, bytecode_path, "")); + _write(_compute_vk(bytecode_path, "")); } else if (flags.oracle_hash_type == "keccak" && flags.zk) { - _write(_compute_vk(init, bytecode_path, "")); + _write(_compute_vk(bytecode_path, "")); } else { throw_or_abort("Invalid proving options specified in _prove"); } @@ -235,7 +223,7 @@ void UltraHonkAPI::write_vk(const Flags& flags, void UltraHonkAPI::gates([[maybe_unused]] const Flags& flags, [[maybe_unused]] const std::filesystem::path& bytecode_path) { - gate_count(bytecode_path, flags.recursive, flags.honk_recursion, flags.include_gates_per_opcode); + gate_count(bytecode_path, /*useless=*/false, flags.honk_recursion, flags.include_gates_per_opcode); } void UltraHonkAPI::write_solidity_verifier(const Flags& flags, @@ -273,7 +261,7 @@ void write_recursion_inputs_ultra_honk(const std::string& bytecode_path, init_grumpkin_crs(1 << CONST_ECCVM_LOG_N); ipa_accumulation = true; } - const acir_format::ProgramMetadata metadata{ .recursive = true, .honk_recursion = honk_recursion }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = honk_recursion }; acir_format::AcirProgram program; program.constraints = get_constraint_system(bytecode_path, metadata.honk_recursion); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index 5939df0997bd..3ba2b754179d 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -269,7 +269,7 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta !constraint_system.avm_recursion_constraints.empty()) { ASSERT(metadata.honk_recursion != 0); current_aggregation_object.set_public(); - } else if (metadata.honk_recursion != 0 && builder.is_recursive_circuit) { + } else if (metadata.honk_recursion != 0) { // Make sure the verification key records the public input indices of the // final recursion output. current_aggregation_object.set_public(); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 8c224bbb0d6d..0f5aebe0a228 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -64,12 +64,9 @@ WASM_EXPORT void acir_create_proof( *out = to_heap_buffer(proof_data); } -WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* acir_vec, - bool const* recursive, - uint8_t const* witness_vec, - bool* result) +WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, bool* result) { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = 1 }; acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), metadata.honk_recursion), acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)) @@ -87,12 +84,9 @@ WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* acir_vec, info("verified: ", *result); } -WASM_EXPORT void acir_prove_and_verify_mega_honk(uint8_t const* acir_vec, - bool const* recursive, - uint8_t const* witness_vec, - bool* result) +WASM_EXPORT void acir_prove_and_verify_mega_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, bool* result) { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 0 }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = 0 }; acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), metadata.honk_recursion), @@ -309,14 +303,11 @@ WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t cons *result = ClientIVC::verify(proof, vk); } -WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, - bool const* recursive, - uint8_t const* witness_vec, - uint8_t** out) +WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out) { // Lambda function to ensure things get freed before proving. UltraProver prover = [&] { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = 1 }; acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( from_buffer>(acir_vec), metadata.honk_recursion), acir_format::witness_buf_to_witness_data( @@ -330,14 +321,11 @@ WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, *out = to_heap_buffer(to_buffer(proof)); } -WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, - bool const* recursive, - uint8_t const* witness_vec, - uint8_t** out) +WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out) { // Lambda function to ensure things get freed before proving. UltraKeccakProver prover = [&] { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = 1 }; acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( from_buffer>(acir_vec), metadata.honk_recursion), acir_format::witness_buf_to_witness_data( @@ -380,13 +368,13 @@ WASM_EXPORT void acir_verify_ultra_keccak_honk(uint8_t const* proof_buf, uint8_t *result = verifier.verify_proof(proof); } -WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out) +WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, uint8_t** out) { using DeciderProvingKey = DeciderProvingKey_; using VerificationKey = UltraFlavor::VerificationKey; // lambda to free the builder DeciderProvingKey proving_key = [&] { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = 1 }; acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( from_buffer>(acir_vec), metadata.honk_recursion) }; auto builder = acir_format::create_circuit(program, metadata); @@ -397,14 +385,14 @@ WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* r *out = to_heap_buffer(to_buffer(vk)); } -WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out) +WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t** out) { using DeciderProvingKey = DeciderProvingKey_; using VerificationKey = UltraKeccakFlavor::VerificationKey; // lambda to free the builder DeciderProvingKey proving_key = [&] { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + const acir_format::ProgramMetadata metadata{ .honk_recursion = 1 }; acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( from_buffer>(acir_vec), metadata.honk_recursion) }; auto builder = acir_format::create_circuit(program, metadata); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp index 033579e4515e..ac6303fc9405 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -36,7 +36,6 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, * */ WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* constraint_system_buf, - bool const* recursive, uint8_t const* witness_buf, bool* result); @@ -45,7 +44,6 @@ WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* constraint_syst * @deprecated */ WASM_EXPORT void acir_prove_and_verify_mega_honk(uint8_t const* constraint_system_buf, - bool const* recursive, uint8_t const* witness_buf, bool* result); @@ -60,15 +58,6 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result); -/** - * @brief Fold and verify a set of circuits using ClientIvc - * - */ -WASM_EXPORT void acir_fold_and_verify_program_stack(uint8_t const* constraint_system_buf, - bool const* recursive, - uint8_t const* witness_buf, - bool* result); - WASM_EXPORT void acir_load_verification_key(in_ptr acir_composer_ptr, uint8_t const* vk_buf); WASM_EXPORT void acir_init_verification_key(in_ptr acir_composer_ptr); @@ -94,20 +83,14 @@ WASM_EXPORT void acir_serialize_verification_key_into_fields(in_ptr acir_compose fr::vec_out_buf out_vkey, fr::out_buf out_key_hash); -WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, - bool const* recursive, - uint8_t const* witness_vec, - uint8_t** out); -WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, - bool const* recursive, - uint8_t const* witness_vec, - uint8_t** out); +WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out); +WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out); WASM_EXPORT void acir_verify_ultra_honk(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result); WASM_EXPORT void acir_verify_ultra_keccak_honk(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result); -WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out); -WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out); +WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, uint8_t** out); +WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t** out); WASM_EXPORT void acir_proof_as_fields_ultra_honk(uint8_t const* proof_buf, fr::vec_out_buf out); diff --git a/barretenberg/ts/src/barretenberg/backend.ts b/barretenberg/ts/src/barretenberg/backend.ts index ffe15fce9869..2aee4496bcdf 100644 --- a/barretenberg/ts/src/barretenberg/backend.ts +++ b/barretenberg/ts/src/barretenberg/backend.ts @@ -5,10 +5,10 @@ import { deflattenFields, flattenFieldsAsArray, ProofData, - ProofDataForRecursion, reconstructHonkProof, reconstructUltraPlonkProof, splitHonkProof, + AGGREGATION_OBJECT_LENGTH, } from '../proof/index.js'; export class AztecClientBackendError extends Error { @@ -202,61 +202,22 @@ export class UltraHonkBackend { ? this.api.acirProveUltraKeccakHonk.bind(this.api) : this.api.acirProveUltraHonk.bind(this.api); - const proofWithPublicInputs = await proveUltraHonk( - this.acirUncompressedBytecode, - this.circuitOptions.recursive, - gunzip(compressedWitness), - ); + const proofWithPublicInputs = await proveUltraHonk(this.acirUncompressedBytecode, gunzip(compressedWitness)); // Write VK to get the number of public inputs const writeVKUltraHonk = options?.keccak ? this.api.acirWriteVkUltraKeccakHonk.bind(this.api) : this.api.acirWriteVkUltraHonk.bind(this.api); - const vk = await writeVKUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); + const vk = await writeVKUltraHonk(this.acirUncompressedBytecode); const vkAsFields = await this.api.acirVkAsFieldsUltraHonk(new RawBuffer(vk)); // Item at index 1 in VK is the number of public inputs - const numPublicInputs = Number(vkAsFields[1].toString()); - - const { proof, publicInputs: publicInputsBytes } = splitHonkProof(proofWithPublicInputs, numPublicInputs); - const publicInputs = deflattenFields(publicInputsBytes); - - return { proof, publicInputs }; - } - - async generateProofForRecursiveAggregation( - compressedWitness: Uint8Array, - options?: UltraHonkBackendOptions, - ): Promise { - await this.instantiate(); - - const proveUltraHonk = options?.keccak - ? this.api.acirProveUltraKeccakHonk.bind(this.api) - : this.api.acirProveUltraHonk.bind(this.api); - - const proofWithPublicInputs = await proveUltraHonk( - this.acirUncompressedBytecode, - this.circuitOptions.recursive, - gunzip(compressedWitness), - ); - // Write VK to get the number of public inputs - const writeVKUltraHonk = options?.keccak - ? this.api.acirWriteVkUltraKeccakHonk.bind(this.api) - : this.api.acirWriteVkUltraHonk.bind(this.api); - - const vk = await writeVKUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); - const vkAsFields = await this.api.acirVkAsFieldsUltraHonk(new RawBuffer(vk)); - - // some public inputs are handled specially - const numKZGAccumulatorFieldElements = 16; const publicInputsSizeIndex = 1; // index into VK for numPublicInputs - const numPublicInputs = Number(vkAsFields[publicInputsSizeIndex].toString()) - numKZGAccumulatorFieldElements; - - const { proof: proofBytes, publicInputs: publicInputsBytes } = splitHonkProof(proofWithPublicInputs, numPublicInputs); + const numPublicInputs = Number(vkAsFields[publicInputsSizeIndex].toString()) - AGGREGATION_OBJECT_LENGTH; + const { proof, publicInputs: publicInputsBytes } = splitHonkProof(proofWithPublicInputs, numPublicInputs); const publicInputs = deflattenFields(publicInputsBytes); - const proof = deflattenFields(proofBytes); return { proof, publicInputs }; } @@ -273,22 +234,21 @@ export class UltraHonkBackend { ? this.api.acirVerifyUltraKeccakHonk.bind(this.api) : this.api.acirVerifyUltraHonk.bind(this.api); - const vkBuf = await writeVkUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); + const vkBuf = await writeVkUltraHonk(this.acirUncompressedBytecode); return await verifyUltraHonk(proof, new RawBuffer(vkBuf)); } async getVerificationKey(options?: UltraHonkBackendOptions): Promise { await this.instantiate(); return options?.keccak - ? await this.api.acirWriteVkUltraKeccakHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive) - : await this.api.acirWriteVkUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); + ? await this.api.acirWriteVkUltraKeccakHonk(this.acirUncompressedBytecode) + : await this.api.acirWriteVkUltraHonk(this.acirUncompressedBytecode); } /** @description Returns a solidity verifier */ async getSolidityVerifier(vk?: Uint8Array): Promise { await this.instantiate(); - const vkBuf = - vk ?? (await this.api.acirWriteVkUltraKeccakHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive)); + const vkBuf = vk ?? (await this.api.acirWriteVkUltraKeccakHonk(this.acirUncompressedBytecode)); return await this.api.acirHonkSolidityVerifier(this.acirUncompressedBytecode, new RawBuffer(vkBuf)); } @@ -310,7 +270,7 @@ export class UltraHonkBackend { // TODO: perhaps we should put this in the init function. Need to benchmark // TODO how long it takes. - const vkBuf = await this.api.acirWriteVkUltraHonk(this.acirUncompressedBytecode, this.circuitOptions.recursive); + const vkBuf = await this.api.acirWriteVkUltraHonk(this.acirUncompressedBytecode); const vk = await this.api.acirVkAsFieldsUltraHonk(vkBuf); return { diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 55a7e72377f9..e08ab1f9bd0f 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -447,10 +447,9 @@ export class BarretenbergApi { async acirProveAndVerifyUltraHonk( constraintSystemBuf: Uint8Array, - recursive: boolean, witnessBuf: Uint8Array, ): Promise { - const inArgs = [constraintSystemBuf, recursive, witnessBuf].map(serializeBufferable); + const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_prove_and_verify_ultra_honk', @@ -463,10 +462,9 @@ export class BarretenbergApi { async acirProveAndVerifyMegaHonk( constraintSystemBuf: Uint8Array, - recursive: boolean, witnessBuf: Uint8Array, ): Promise { - const inArgs = [constraintSystemBuf, recursive, witnessBuf].map(serializeBufferable); + const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_prove_and_verify_mega_honk', @@ -477,22 +475,6 @@ export class BarretenbergApi { return out[0]; } - async acirFoldAndVerifyProgramStack( - constraintSystemBuf: Uint8Array, - recursive: boolean, - witnessBuf: Uint8Array, - ): Promise { - const inArgs = [constraintSystemBuf, recursive, witnessBuf].map(serializeBufferable); - const outTypes: OutputType[] = [BoolDeserializer()]; - const result = await this.wasm.callWasmExport( - 'acir_fold_and_verify_program_stack', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - async acirLoadVerificationKey(acirComposerPtr: Ptr, vkBuf: Uint8Array): Promise { const inArgs = [acirComposerPtr, vkBuf].map(serializeBufferable); const outTypes: OutputType[] = []; @@ -629,8 +611,8 @@ export class BarretenbergApi { return out[0]; } - async acirProveUltraHonk(acirVec: Uint8Array, recursive: boolean, witnessVec: Uint8Array): Promise { - const inArgs = [acirVec, recursive, witnessVec].map(serializeBufferable); + async acirProveUltraHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Promise { + const inArgs = [acirVec, witnessVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_prove_ultra_honk', @@ -641,8 +623,8 @@ export class BarretenbergApi { return out[0]; } - async acirProveUltraKeccakHonk(acirVec: Uint8Array, recursive: boolean, witnessVec: Uint8Array): Promise { - const inArgs = [acirVec, recursive, witnessVec].map(serializeBufferable); + async acirProveUltraKeccakHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Promise { + const inArgs = [acirVec, witnessVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_prove_ultra_keccak_honk', @@ -677,8 +659,8 @@ export class BarretenbergApi { return out[0]; } - async acirWriteVkUltraHonk(acirVec: Uint8Array, recursive: boolean): Promise { - const inArgs = [acirVec, recursive].map(serializeBufferable); + async acirWriteVkUltraHonk(acirVec: Uint8Array): Promise { + const inArgs = [acirVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_write_vk_ultra_honk', @@ -689,8 +671,8 @@ export class BarretenbergApi { return out[0]; } - async acirWriteVkUltraKeccakHonk(acirVec: Uint8Array, recursive: boolean): Promise { - const inArgs = [acirVec, recursive].map(serializeBufferable); + async acirWriteVkUltraKeccakHonk(acirVec: Uint8Array): Promise { + const inArgs = [acirVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_write_vk_ultra_keccak_honk', @@ -1146,8 +1128,8 @@ export class BarretenbergApiSync { return out[0]; } - acirProveAndVerifyUltraHonk(constraintSystemBuf: Uint8Array, recursive: boolean, witnessBuf: Uint8Array): boolean { - const inArgs = [constraintSystemBuf, recursive, witnessBuf].map(serializeBufferable); + acirProveAndVerifyUltraHonk(constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): boolean { + const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = this.wasm.callWasmExport( 'acir_prove_and_verify_ultra_honk', @@ -1158,8 +1140,8 @@ export class BarretenbergApiSync { return out[0]; } - acirProveAndVerifyMegaHonk(constraintSystemBuf: Uint8Array, recursive: boolean, witnessBuf: Uint8Array): boolean { - const inArgs = [constraintSystemBuf, recursive, witnessBuf].map(serializeBufferable); + acirProveAndVerifyMegaHonk(constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): boolean { + const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = this.wasm.callWasmExport( 'acir_prove_and_verify_mega_honk', @@ -1170,18 +1152,6 @@ export class BarretenbergApiSync { return out[0]; } - acirFoldAndVerifyProgramStack(constraintSystemBuf: Uint8Array, recursive: boolean, witnessBuf: Uint8Array): boolean { - const inArgs = [constraintSystemBuf, recursive, witnessBuf].map(serializeBufferable); - const outTypes: OutputType[] = [BoolDeserializer()]; - const result = this.wasm.callWasmExport( - 'acir_fold_and_verify_program_stack', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - acirLoadVerificationKey(acirComposerPtr: Ptr, vkBuf: Uint8Array): void { const inArgs = [acirComposerPtr, vkBuf].map(serializeBufferable); const outTypes: OutputType[] = []; @@ -1278,8 +1248,8 @@ export class BarretenbergApiSync { return out as any; } - acirProveUltraHonk(acirVec: Uint8Array, recursive: boolean, witnessVec: Uint8Array): Uint8Array { - const inArgs = [acirVec, recursive, witnessVec].map(serializeBufferable); + acirProveUltraHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Uint8Array { + const inArgs = [acirVec, witnessVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = this.wasm.callWasmExport( 'acir_prove_ultra_honk', @@ -1302,8 +1272,8 @@ export class BarretenbergApiSync { return out[0]; } - acirWriteVkUltraHonk(acirVec: Uint8Array, recursive: boolean): Uint8Array { - const inArgs = [acirVec, recursive].map(serializeBufferable); + acirWriteVkUltraHonk(acirVec: Uint8Array): Uint8Array { + const inArgs = [acirVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = this.wasm.callWasmExport( 'acir_write_vk_ultra_honk', diff --git a/barretenberg/ts/src/index.ts b/barretenberg/ts/src/index.ts index 23159ba7ff9f..b07efdb217b6 100644 --- a/barretenberg/ts/src/index.ts +++ b/barretenberg/ts/src/index.ts @@ -10,4 +10,4 @@ export { } from './barretenberg/index.js'; export { RawBuffer, Fr } from './types/index.js'; -export { splitHonkProof, reconstructHonkProof, ProofData } from './proof/index.js'; +export { splitHonkProof, reconstructHonkProof, deflattenFields, ProofData } from './proof/index.js'; diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index 3938f5688b3a..7dd6c6d78e37 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -108,12 +108,13 @@ async function initUltraPlonk( return { api, acirComposer, circuitSize, subgroupSize }; } -async function initUltraHonk(bytecodePath: string, recursive: boolean, crsPath: string) { +async function initUltraHonk(bytecodePath: string, crsPath: string) { const api = await Barretenberg.new({ threads }); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraHonk function - const circuitSize = await getGatesUltra(bytecodePath, recursive, /*honkRecursion=*/ true, api); + // recursive here is useless for UH, as it does not affect anything + const circuitSize = await getGatesUltra(bytecodePath, /*recursive=*/ false, /*honkRecursion=*/ true, api); // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin const dyadicCircuitSize = Math.pow(2, Math.ceil(Math.log2(circuitSize))); @@ -185,17 +186,16 @@ export async function proveAndVerify(bytecodePath: string, recursive: boolean, w export async function proveAndVerifyUltraHonk( bytecodePath: string, - recursive: boolean, witnessPath: string, crsPath: string, ) { /* eslint-disable camelcase */ - const { api } = await initUltraHonk(bytecodePath, false, crsPath); + const { api } = await initUltraHonk(bytecodePath, crsPath); try { const bytecode = getBytecode(bytecodePath); const witness = getWitness(witnessPath); - const verified = await api.acirProveAndVerifyUltraHonk(bytecode, recursive, witness); + const verified = await api.acirProveAndVerifyUltraHonk(bytecode, witness); return verified; } finally { await api.destroy(); @@ -205,7 +205,6 @@ export async function proveAndVerifyUltraHonk( export async function proveAndVerifyMegaHonk( bytecodePath: string, - recursive: boolean, witnessPath: string, crsPath: string, ) { @@ -215,7 +214,7 @@ export async function proveAndVerifyMegaHonk( const bytecode = getBytecode(bytecodePath); const witness = getWitness(witnessPath); - const verified = await api.acirProveAndVerifyMegaHonk(bytecode, recursive, witness); + const verified = await api.acirProveAndVerifyMegaHonk(bytecode, witness); return verified; } finally { await api.destroy(); @@ -239,27 +238,6 @@ export async function proveAndVerifyAztecClient(bytecodePath: string, witnessPat /* eslint-enable camelcase */ } -export async function foldAndVerifyProgram( - bytecodePath: string, - recursive: boolean, - witnessPath: string, - crsPath: string, -) { - /* eslint-disable camelcase */ - const { api } = await initClientIVC(crsPath); - try { - const bytecode = getBytecode(bytecodePath); - const witness = getWitness(witnessPath); - - const verified = await api.acirFoldAndVerifyProgramStack(bytecode, recursive, witness); - debug(`Verification ${verified ? 'successful' : 'failed'}`); - return verified; - } finally { - await api.destroy(); - } - /* eslint-enable camelcase */ -} - export async function prove( bytecodePath: string, recursive: boolean, @@ -335,7 +313,7 @@ export async function contract(outputPath: string, vkPath: string, crsPath: stri } export async function contractUltraHonk(bytecodePath: string, vkPath: string, crsPath: string, outputPath: string) { - const { api } = await initUltraHonk(bytecodePath, false, crsPath); + const { api } = await initUltraHonk(bytecodePath, crsPath); try { debug(`Creating UltraHonk verifier contract bytecode=${bytecodePath} vk=${vkPath}`); const bytecode = getBytecode(bytecodePath); @@ -444,22 +422,21 @@ export async function vkAsFields(vkPath: string, vkeyOutputPath: string, crsPath export async function proveUltraHonk( bytecodePath: string, - recursive: boolean, witnessPath: string, crsPath: string, outputPath: string, options?: UltraHonkBackendOptions, ) { - const { api } = await initUltraHonk(bytecodePath, recursive, crsPath); + const { api } = await initUltraHonk(bytecodePath, crsPath); try { - debug(`Creating UltraHonk proof bytecode=${bytecodePath} recursive=${recursive}`); + debug(`Creating UltraHonk proof bytecode=${bytecodePath}`); const bytecode = getBytecode(bytecodePath); const witness = getWitness(witnessPath); const acirProveUltraHonk = options?.keccak ? api.acirProveUltraKeccakHonk.bind(api) : api.acirProveUltraHonk.bind(api); - const proof = await acirProveUltraHonk(bytecode, recursive, witness); + const proof = await acirProveUltraHonk(bytecode, witness); if (outputPath === '-') { process.stdout.write(proof); @@ -475,20 +452,19 @@ export async function proveUltraHonk( export async function writeVkUltraHonk( bytecodePath: string, - recursive: boolean, crsPath: string, outputPath: string, options?: UltraHonkBackendOptions, ) { - const { api } = await initUltraHonk(bytecodePath, recursive, crsPath); + const { api } = await initUltraHonk(bytecodePath, crsPath); try { const bytecode = getBytecode(bytecodePath); - debug(`Initializing UltraHonk verification key bytecode=${bytecodePath} recursive=${recursive}`); + debug(`Initializing UltraHonk verification key bytecode=${bytecodePath}`); const acirWriteVkUltraHonk = options?.keccak ? api.acirWriteVkUltraKeccakHonk.bind(api) : api.acirWriteVkUltraHonk.bind(api); - const vk = await acirWriteVkUltraHonk(bytecode, recursive); + const vk = await acirWriteVkUltraHonk(bytecode); if (outputPath === '-') { process.stdout.write(vk); @@ -592,11 +568,10 @@ program .command('prove_and_verify_ultra_honk') .description('Generate an UltraHonk proof and verify it. Process exits with success or failure code.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Whether to use a SNARK friendly proof', false) .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .action(async ({ bytecodePath, recursive, witnessPath }) => { + .action(async ({ bytecodePath, witnessPath }) => { const { crsPath } = handleGlobalOptions(); - const result = await proveAndVerifyUltraHonk(bytecodePath, recursive, witnessPath, crsPath); + const result = await proveAndVerifyUltraHonk(bytecodePath, witnessPath, crsPath); process.exit(result ? 0 : 1); }); @@ -604,11 +579,10 @@ program .command('prove_and_verify_mega_honk') .description('Generate a MegaHonk proof and verify it. Process exits with success or failure code.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Whether to use a SNARK friendly proof', false) .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .action(async ({ bytecodePath, recursive, witnessPath }) => { + .action(async ({ bytecodePath, witnessPath }) => { const { crsPath } = handleGlobalOptions(); - const result = await proveAndVerifyMegaHonk(bytecodePath, recursive, witnessPath, crsPath); + const result = await proveAndVerifyMegaHonk(bytecodePath, witnessPath, crsPath); process.exit(result ? 0 : 1); }); @@ -623,18 +597,6 @@ program process.exit(result ? 0 : 1); }); -program - .command('fold_and_verify_program') - .description('Accumulate a set of circuits using ClientIvc then verify. Process exits with success or failure code.') - .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Create a SNARK friendly proof', false) - .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .action(async ({ bytecodePath, recursive, witnessPath }) => { - const { crsPath } = handleGlobalOptions(); - const result = await foldAndVerifyProgram(bytecodePath, recursive, witnessPath, crsPath); - process.exit(result ? 0 : 1); - }); - program .command('prove') .description('Generate a proof and write it to a file.') @@ -738,46 +700,42 @@ program .command('prove_ultra_honk') .description('Generate a proof and write it to a file.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Create a SNARK friendly proof', false) .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') .option('-o, --output-path ', 'Specify the proof output path', './proofs/proof') - .action(async ({ bytecodePath, recursive, witnessPath, outputPath }) => { + .action(async ({ bytecodePath, witnessPath, outputPath }) => { const { crsPath } = handleGlobalOptions(); - await proveUltraHonk(bytecodePath, recursive, witnessPath, crsPath, outputPath); + await proveUltraHonk(bytecodePath, witnessPath, crsPath, outputPath); }); program .command('prove_ultra_keccak_honk') .description('Generate a proof and write it to a file.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Create a SNARK friendly proof', false) .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') .option('-o, --output-path ', 'Specify the proof output path', './proofs/proof') - .action(async ({ bytecodePath, recursive, witnessPath, outputPath, crsPath }) => { + .action(async ({ bytecodePath, witnessPath, outputPath, crsPath }) => { handleGlobalOptions(); - await proveUltraHonk(bytecodePath, recursive, witnessPath, crsPath, outputPath, { keccak: true }); + await proveUltraHonk(bytecodePath, witnessPath, crsPath, outputPath, { keccak: true }); }); program .command('write_vk_ultra_honk') .description('Output verification key.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Create a SNARK friendly proof', false) .requiredOption('-o, --output-path ', 'Specify the path to write the key') - .action(async ({ bytecodePath, recursive, outputPath }) => { + .action(async ({ bytecodePath, outputPath }) => { const { crsPath } = handleGlobalOptions(); - await writeVkUltraHonk(bytecodePath, recursive, crsPath, outputPath); + await writeVkUltraHonk(bytecodePath, crsPath, outputPath); }); program .command('write_vk_ultra_keccak_honk') .description('Output verification key.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/program.json') - .option('-r, --recursive', 'Create a SNARK friendly proof', false) .requiredOption('-o, --output-path ', 'Specify the path to write the key') - .action(async ({ bytecodePath, recursive, outputPath, crsPath }) => { + .action(async ({ bytecodePath, outputPath, crsPath }) => { handleGlobalOptions(); - await writeVkUltraHonk(bytecodePath, recursive, crsPath, outputPath, { keccak: true }); + await writeVkUltraHonk(bytecodePath, crsPath, outputPath, { keccak: true }); }); program diff --git a/barretenberg/ts/src/proof/index.ts b/barretenberg/ts/src/proof/index.ts index 0cca0706d3a4..5cd9df43c931 100644 --- a/barretenberg/ts/src/proof/index.ts +++ b/barretenberg/ts/src/proof/index.ts @@ -11,16 +11,7 @@ export type ProofData = { proof: Uint8Array; }; -/** - * @description - * The representation of a proof - * */ -export type ProofDataForRecursion = { - /** @description Public inputs of a proof */ - publicInputs: string[]; - /** @description An byte array representing the proof */ - proof: string[]; -}; +export const AGGREGATION_OBJECT_LENGTH = 16; // Fields are 32 bytes const fieldByteSize = 32; diff --git a/noir-projects/scripts/generate_vk_json.js b/noir-projects/scripts/generate_vk_json.js index 64a819a29fe4..3fb3575ca42f 100644 --- a/noir-projects/scripts/generate_vk_json.js +++ b/noir-projects/scripts/generate_vk_json.js @@ -157,9 +157,7 @@ async function generateVKData( honk_recursion = 1; } - const writeVkCommand = `${BB_BIN_PATH} ${write_vk_flow} -h ${honk_recursion} -b "${artifactPath}" -o "${binaryVkPath}" ${ - isRecursive ? "--recursive" : "" - }`; + const writeVkCommand = `${BB_BIN_PATH} ${write_vk_flow} -h ${honk_recursion} -b "${artifactPath}" -o "${binaryVkPath}"`; console.log("WRITE VK CMD: ", writeVkCommand); diff --git a/yarn-project/noir-bb-bench/src/index.ts b/yarn-project/noir-bb-bench/src/index.ts index 108b3899a97d..1c6009a9a563 100644 --- a/yarn-project/noir-bb-bench/src/index.ts +++ b/yarn-project/noir-bb-bench/src/index.ts @@ -67,7 +67,7 @@ export async function proveCircuit1( const backend = new UltraHonkBackend(bytecode, { threads: threads }, { recursive: true }); try { logger(`proving...`); - const proverOutput = await backend.generateProofForRecursiveAggregation(witness); + const proverOutput = await backend.generateProof(witness); logger(`done generating recursive proof artifacts.`); return { proof: proverOutput.proof as FixedLengthArray,