From 993cc526d118ea2539d5818f421109e83612084e Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 18:21:16 +0000 Subject: [PATCH 01/28] move recursive flag onto the circuit itself rather than having it be a tooling flag, serde needs to be fixed still --- noir/acvm-repo/acir/codegen/acir.cpp | 4 ++++ noir/acvm-repo/acir/src/circuit/mod.rs | 7 +++++++ noir/acvm-repo/acir/src/lib.rs | 8 ++++---- noir/compiler/noirc_evaluator/src/ssa.rs | 2 ++ noir/compiler/noirc_frontend/src/ast/function.rs | 2 ++ .../noirc_frontend/src/hir/resolution/errors.rs | 14 ++++++++++++++ .../noirc_frontend/src/hir/resolution/resolver.rs | 6 +++++- .../noirc_frontend/src/hir_def/function.rs | 2 +- noir/compiler/noirc_frontend/src/lexer/token.rs | 4 ++++ .../noirc_frontend/src/monomorphization/ast.rs | 4 ++++ .../noirc_frontend/src/monomorphization/mod.rs | 4 ++++ .../execution_success/assert_statement/src/main.nr | 1 + 12 files changed, 52 insertions(+), 6 deletions(-) diff --git a/noir/acvm-repo/acir/codegen/acir.cpp b/noir/acvm-repo/acir/codegen/acir.cpp index 07bcd5f9f97..33cd3084c04 100644 --- a/noir/acvm-repo/acir/codegen/acir.cpp +++ b/noir/acvm-repo/acir/codegen/acir.cpp @@ -1024,6 +1024,7 @@ namespace Circuit { Circuit::PublicInputs public_parameters; Circuit::PublicInputs return_values; std::vector> assert_messages; + bool recursive; friend bool operator==(const Circuit&, const Circuit&); std::vector bincodeSerialize() const; @@ -4718,6 +4719,7 @@ namespace Circuit { if (!(lhs.public_parameters == rhs.public_parameters)) { return false; } if (!(lhs.return_values == rhs.return_values)) { return false; } if (!(lhs.assert_messages == rhs.assert_messages)) { return false; } + if (!(lhs.recursive == rhs.recursive)) { return false; } return true; } @@ -4748,6 +4750,7 @@ void serde::Serializable::serialize(const Circuit::Circuit &ob serde::Serializable::serialize(obj.public_parameters, serializer); serde::Serializable::serialize(obj.return_values, serializer); serde::Serializable::serialize(obj.assert_messages, serializer); + serde::Serializable::serialize(obj.recursive, serializer); serializer.decrease_container_depth(); } @@ -4762,6 +4765,7 @@ Circuit::Circuit serde::Deserializable::deserialize(Deserializ obj.public_parameters = serde::Deserializable::deserialize(deserializer); obj.return_values = serde::Deserializable::deserialize(deserializer); obj.assert_messages = serde::Deserializable::deserialize(deserializer); + obj.recursive = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } diff --git a/noir/acvm-repo/acir/src/circuit/mod.rs b/noir/acvm-repo/acir/src/circuit/mod.rs index b248b30b1d9..0fedf0ae26a 100644 --- a/noir/acvm-repo/acir/src/circuit/mod.rs +++ b/noir/acvm-repo/acir/src/circuit/mod.rs @@ -39,6 +39,11 @@ pub struct Circuit { // c++ code at the moment when it is, due to OpcodeLocation needing a comparison // implementation which is never generated. pub assert_messages: Vec<(OpcodeLocation, String)>, + + /// States whether the backend should use a SNARK recursion friendly prover. + /// If implemented by a backend, this means that proofs generated with this circuit + /// will be friendly for recursively verifying inside of another SNARK. + pub recursive: bool, } impl Circuit { @@ -318,6 +323,7 @@ mod tests { public_parameters: PublicInputs(BTreeSet::from_iter(vec![Witness(2), Witness(12)])), return_values: PublicInputs(BTreeSet::from_iter(vec![Witness(4), Witness(12)])), assert_messages: Default::default(), + recursive: false, }; fn read_write(circuit: Circuit) -> (Circuit, Circuit) { @@ -348,6 +354,7 @@ mod tests { public_parameters: PublicInputs(BTreeSet::from_iter(vec![Witness(2)])), return_values: PublicInputs(BTreeSet::from_iter(vec![Witness(2)])), assert_messages: Default::default(), + recursive: false, }; let json = serde_json::to_string_pretty(&circuit).unwrap(); diff --git a/noir/acvm-repo/acir/src/lib.rs b/noir/acvm-repo/acir/src/lib.rs index b7bcaa0c5c0..6604ec29bd7 100644 --- a/noir/acvm-repo/acir/src/lib.rs +++ b/noir/acvm-repo/acir/src/lib.rs @@ -81,10 +81,10 @@ mod reflection { generator.output(&mut source, ®istry).unwrap(); // Comment this out to write updated C++ code to file. - if let Some(old_hash) = old_hash { - let new_hash = fxhash::hash64(&source); - assert_eq!(new_hash, old_hash, "Serialization format has changed"); - } + // if let Some(old_hash) = old_hash { + // let new_hash = fxhash::hash64(&source); + // assert_eq!(new_hash, old_hash, "Serialization format has changed"); + // } write_to_file(&source, &path); } diff --git a/noir/compiler/noirc_evaluator/src/ssa.rs b/noir/compiler/noirc_evaluator/src/ssa.rs index e2da5652faf..63739146114 100644 --- a/noir/compiler/noirc_evaluator/src/ssa.rs +++ b/noir/compiler/noirc_evaluator/src/ssa.rs @@ -86,6 +86,7 @@ pub fn create_circuit( enable_brillig_logging: bool, ) -> Result<(Circuit, DebugInfo, Vec, Vec, Vec), RuntimeError> { let func_sig = program.main_function_signature.clone(); + let recursive = program.recursive; let mut generated_acir = optimize_into_acir(program, enable_ssa_logging, enable_brillig_logging)?; let opcodes = generated_acir.take_opcodes(); @@ -112,6 +113,7 @@ pub fn create_circuit( public_parameters, return_values, assert_messages: assert_messages.into_iter().collect(), + recursive, }; // This converts each im::Vector in the BTreeMap to a Vec diff --git a/noir/compiler/noirc_frontend/src/ast/function.rs b/noir/compiler/noirc_frontend/src/ast/function.rs index b8f385f52d3..01e97e15af1 100644 --- a/noir/compiler/noirc_frontend/src/ast/function.rs +++ b/noir/compiler/noirc_frontend/src/ast/function.rs @@ -29,6 +29,7 @@ pub enum FunctionKind { Builtin, Normal, Oracle, + Recursive, } impl NoirFunction { @@ -106,6 +107,7 @@ impl From for NoirFunction { Some(FunctionAttribute::Foreign(_)) => FunctionKind::LowLevel, Some(FunctionAttribute::Test { .. }) => FunctionKind::Normal, Some(FunctionAttribute::Oracle(_)) => FunctionKind::Oracle, + Some(FunctionAttribute::Recursive) => FunctionKind::Recursive, None => FunctionKind::Normal, }; diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/errors.rs b/noir/compiler/noirc_frontend/src/hir/resolution/errors.rs index 390807afd17..2fa81bbbe1f 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -84,6 +84,8 @@ pub enum ResolverError { InvalidTypeForEntryPoint { span: Span }, #[error("Nested slices are not supported")] NestedSlices { span: Span }, + #[error("#[recursive] attribute is only allowed on entry points to a program")] + MisplacedRecursiveAttribute { ident: Ident }, } impl ResolverError { @@ -311,6 +313,18 @@ impl From for Diagnostic { "Try to use a constant sized array instead".into(), span, ), + ResolverError::MisplacedRecursiveAttribute { ident } => { + let name = &ident.0.contents; + + let mut diag = Diagnostic::simple_error( + format!("misplaced #[recursive] attribute on function {name} rather than the main function"), + "misplaced #[recursive] attribute".to_string(), + ident.0.span(), + ); + + diag.add_note("The `#[recursive]` attribute specifies to the backend whether it should use a prover which generates proofs that are friendly for recursive verification in another circuit".to_owned()); + diag + } } } } diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 1d4f60ffd51..0c491730d04 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -406,7 +406,7 @@ impl<'a> Resolver<'a> { FunctionKind::Builtin | FunctionKind::LowLevel | FunctionKind::Oracle => { HirFunction::empty() } - FunctionKind::Normal => { + FunctionKind::Normal | FunctionKind::Recursive => { let expr_id = self.intern_block(func.def.body); self.interner.push_expr_location(expr_id, func.def.span, self.file); HirFunction::unchecked_from_expr(expr_id) @@ -896,6 +896,10 @@ impl<'a> Resolver<'a> { { self.push_err(ResolverError::NecessaryPub { ident: func.name_ident().clone() }); } + // '#[recursive]' attribute is only allowed for entry point functions + if !self.is_entry_point_function(func) && func.kind == FunctionKind::Recursive { + self.push_err(ResolverError::MisplacedRecursiveAttribute { ident: func.name_ident().clone() }); + } if !self.distinct_allowed(func) && func.def.return_distinctness != Distinctness::DuplicationAllowed diff --git a/noir/compiler/noirc_frontend/src/hir_def/function.rs b/noir/compiler/noirc_frontend/src/hir_def/function.rs index 9fff301f5f7..78f44696b72 100644 --- a/noir/compiler/noirc_frontend/src/hir_def/function.rs +++ b/noir/compiler/noirc_frontend/src/hir_def/function.rs @@ -127,7 +127,7 @@ impl FuncMeta { pub fn can_ignore_return_type(&self) -> bool { match self.kind { FunctionKind::LowLevel | FunctionKind::Builtin | FunctionKind::Oracle => true, - FunctionKind::Normal => false, + FunctionKind::Normal | FunctionKind::Recursive => false, } } diff --git a/noir/compiler/noirc_frontend/src/lexer/token.rs b/noir/compiler/noirc_frontend/src/lexer/token.rs index ab131ccd880..6071057d72a 100644 --- a/noir/compiler/noirc_frontend/src/lexer/token.rs +++ b/noir/compiler/noirc_frontend/src/lexer/token.rs @@ -491,6 +491,7 @@ impl Attribute { Attribute::Function(FunctionAttribute::Oracle(name.to_string())) } ["test"] => Attribute::Function(FunctionAttribute::Test(TestScope::None)), + ["recursive"] => Attribute::Function(FunctionAttribute::Recursive), ["test", name] => { validate(name)?; let malformed_scope = @@ -541,6 +542,7 @@ pub enum FunctionAttribute { Builtin(String), Oracle(String), Test(TestScope), + Recursive, } impl FunctionAttribute { @@ -574,6 +576,7 @@ impl fmt::Display for FunctionAttribute { FunctionAttribute::Foreign(ref k) => write!(f, "#[foreign({k})]"), FunctionAttribute::Builtin(ref k) => write!(f, "#[builtin({k})]"), FunctionAttribute::Oracle(ref k) => write!(f, "#[oracle({k})]"), + FunctionAttribute::Recursive => write!(f, "#[recursive]"), } } } @@ -617,6 +620,7 @@ impl AsRef for FunctionAttribute { FunctionAttribute::Builtin(string) => string, FunctionAttribute::Oracle(string) => string, FunctionAttribute::Test { .. } => "", + FunctionAttribute::Recursive => "", } } } diff --git a/noir/compiler/noirc_frontend/src/monomorphization/ast.rs b/noir/compiler/noirc_frontend/src/monomorphization/ast.rs index 42a618e7d77..515d9710882 100644 --- a/noir/compiler/noirc_frontend/src/monomorphization/ast.rs +++ b/noir/compiler/noirc_frontend/src/monomorphization/ast.rs @@ -246,6 +246,8 @@ pub struct Program { pub return_distinctness: Distinctness, pub return_location: Option, pub return_visibility: Visibility, + /// Indicates to a backend whether a SNARK-friendly prover should be used. + pub recursive: bool, } impl Program { @@ -255,6 +257,7 @@ impl Program { return_distinctness: Distinctness, return_location: Option, return_visibility: Visibility, + recursive: bool, ) -> Program { Program { functions, @@ -262,6 +265,7 @@ impl Program { return_distinctness, return_location, return_visibility, + recursive, } } diff --git a/noir/compiler/noirc_frontend/src/monomorphization/mod.rs b/noir/compiler/noirc_frontend/src/monomorphization/mod.rs index 67b246a02ce..0334e01af5d 100644 --- a/noir/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/noir/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -117,6 +117,7 @@ pub fn monomorphize(main: node_interner::FuncId, interner: &NodeInterner) -> Pro meta.return_distinctness, monomorphizer.return_location, meta.return_visibility, + meta.kind == FunctionKind::Recursive, ) } @@ -195,6 +196,9 @@ impl<'interner> Monomorphizer<'interner> { _ => unreachable!("Oracle function must have an oracle attribute"), } } + FunctionKind::Recursive => { + unreachable!("Only main can be specified as recursive, which should already be checked"); + } } } } diff --git a/noir/test_programs/execution_success/assert_statement/src/main.nr b/noir/test_programs/execution_success/assert_statement/src/main.nr index 2646a0b85c2..16d5917fb59 100644 --- a/noir/test_programs/execution_success/assert_statement/src/main.nr +++ b/noir/test_programs/execution_success/assert_statement/src/main.nr @@ -1,6 +1,7 @@ // Tests a very simple program. // // The features being tested is assertion +#[recursive] fn main(x: Field, y: pub Field) { assert(x == y, "x and y are not equal"); assert_eq(x, y, "x and y are not equal"); From 51709d892cf3681a40d1444343f2ef998bcb3a28 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 18:21:37 +0000 Subject: [PATCH 02/28] missed bberg files --- .../acir_format/acir_to_constraint_buf.hpp | 2 +- .../dsl/acir_format/serde/acir.hpp | 248 +++++++++--------- 2 files changed, 128 insertions(+), 122 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index 5d6cf0063b8..ff83755e312 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -327,7 +327,7 @@ void handle_memory_op(Circuit::Opcode::MemoryOp const& mem_op, BlockConstraint& AcirFormat circuit_buf_to_acir_format(std::vector const& buf) { auto circuit = Circuit::Circuit::bincodeDeserialize(buf); - + info("is recursive: ", circuit.recursive); AcirFormat af; // `varnum` is the true number of variables, thus we add one to the index which starts at zero af.varnum = circuit.current_witness_index + 1; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 8e18e5bc043..77718aca8ca 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -1077,11 +1077,12 @@ struct PublicInputs { struct Circuit { uint32_t current_witness_index; - std::vector opcodes; - std::vector private_parameters; - PublicInputs public_parameters; - PublicInputs return_values; - std::vector> assert_messages; + std::vector opcodes; + std::vector private_parameters; + Circuit::PublicInputs public_parameters; + Circuit::PublicInputs return_values; + std::vector> assert_messages; + bool recursive; friend bool operator==(const Circuit&, const Circuit&); std::vector bincodeSerialize() const; @@ -1112,7 +1113,7 @@ inline BinaryFieldOp BinaryFieldOp::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1158,7 +1159,7 @@ inline BinaryFieldOp::Add BinaryFieldOp::Add::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1198,7 +1199,7 @@ inline BinaryFieldOp::Sub BinaryFieldOp::Sub::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1238,7 +1239,7 @@ inline BinaryFieldOp::Mul BinaryFieldOp::Mul::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1278,7 +1279,7 @@ inline BinaryFieldOp::Div BinaryFieldOp::Div::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1318,7 +1319,7 @@ inline BinaryFieldOp::Equals BinaryFieldOp::Equals::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1362,7 +1363,7 @@ inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1408,7 +1409,7 @@ inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1448,7 +1449,7 @@ inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1488,7 +1489,7 @@ inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1528,7 +1529,7 @@ inline BinaryIntOp::SignedDiv BinaryIntOp::SignedDiv::bincodeDeserialize(std::ve auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1569,7 +1570,7 @@ inline BinaryIntOp::UnsignedDiv BinaryIntOp::UnsignedDiv::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1610,7 +1611,7 @@ inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1651,7 +1652,7 @@ inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1692,7 +1693,7 @@ inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1733,7 +1734,7 @@ inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1773,7 +1774,7 @@ inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1813,7 +1814,7 @@ inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1853,7 +1854,7 @@ inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1893,7 +1894,7 @@ inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1936,7 +1937,7 @@ inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -1992,7 +1993,7 @@ inline BlackBoxFuncCall::AND BlackBoxFuncCall::AND::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2049,7 +2050,7 @@ inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2100,7 +2101,7 @@ inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2150,7 +2151,7 @@ inline BlackBoxFuncCall::SHA256 BlackBoxFuncCall::SHA256::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2202,7 +2203,7 @@ inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(s auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2254,7 +2255,7 @@ inline BlackBoxFuncCall::Blake3 BlackBoxFuncCall::Blake3::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2315,7 +2316,7 @@ inline BlackBoxFuncCall::SchnorrVerify BlackBoxFuncCall::SchnorrVerify::bincodeD auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2377,7 +2378,7 @@ inline BlackBoxFuncCall::PedersenCommitment BlackBoxFuncCall::PedersenCommitment auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2434,7 +2435,7 @@ inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDes auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2497,7 +2498,7 @@ inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincod auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2564,7 +2565,7 @@ inline BlackBoxFuncCall::EcdsaSecp256r1 BlackBoxFuncCall::EcdsaSecp256r1::bincod auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2626,7 +2627,7 @@ inline BlackBoxFuncCall::FixedBaseScalarMul BlackBoxFuncCall::FixedBaseScalarMul auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2690,7 +2691,7 @@ inline BlackBoxFuncCall::EmbeddedCurveAdd BlackBoxFuncCall::EmbeddedCurveAdd::bi auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2753,7 +2754,7 @@ inline BlackBoxFuncCall::EmbeddedCurveDouble BlackBoxFuncCall::EmbeddedCurveDoub auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2807,7 +2808,7 @@ inline BlackBoxFuncCall::Keccak256 BlackBoxFuncCall::Keccak256::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2864,7 +2865,7 @@ inline BlackBoxFuncCall::Keccak256VariableLength BlackBoxFuncCall::Keccak256Vari auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2918,7 +2919,7 @@ inline BlackBoxFuncCall::Keccakf1600 BlackBoxFuncCall::Keccakf1600::bincodeDeser auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -2978,7 +2979,7 @@ inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggrega auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3037,7 +3038,7 @@ inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3094,7 +3095,7 @@ inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3151,7 +3152,7 @@ inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3208,7 +3209,7 @@ inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3266,7 +3267,7 @@ inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3321,7 +3322,7 @@ inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::binc auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3370,7 +3371,7 @@ inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3422,7 +3423,7 @@ inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3473,7 +3474,7 @@ inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3525,7 +3526,7 @@ inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3576,7 +3577,7 @@ inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3628,7 +3629,7 @@ inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3689,7 +3690,7 @@ inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3756,7 +3757,7 @@ inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3823,7 +3824,7 @@ inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(s auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3884,7 +3885,7 @@ inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDes auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3941,7 +3942,7 @@ inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -3998,7 +3999,7 @@ inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDes auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4061,7 +4062,7 @@ inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeseria auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4122,7 +4123,7 @@ inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeD auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4179,7 +4180,7 @@ inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4236,7 +4237,7 @@ inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4293,7 +4294,7 @@ inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4350,7 +4351,7 @@ inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4407,7 +4408,7 @@ inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeser auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4461,7 +4462,7 @@ inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4510,7 +4511,7 @@ inline BlockId BlockId::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4568,7 +4569,7 @@ inline Brillig Brillig::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4623,7 +4624,7 @@ inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4672,7 +4673,7 @@ inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4719,7 +4720,7 @@ inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4766,7 +4767,7 @@ inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4824,7 +4825,7 @@ inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeseria auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4889,7 +4890,7 @@ inline BrilligOpcode::BinaryIntOp BrilligOpcode::BinaryIntOp::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4947,7 +4948,7 @@ inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -4999,7 +5000,7 @@ inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5048,7 +5049,7 @@ inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5095,7 +5096,7 @@ inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5145,7 +5146,7 @@ inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5191,7 +5192,7 @@ inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5241,7 +5242,7 @@ inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5295,7 +5296,7 @@ inline BrilligOpcode::Mov BrilligOpcode::Mov::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5346,7 +5347,7 @@ inline BrilligOpcode::Load BrilligOpcode::Load::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5398,7 +5399,7 @@ inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5447,7 +5448,7 @@ inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5491,7 +5492,7 @@ inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5532,7 +5533,7 @@ inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5576,7 +5577,7 @@ inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector in auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5625,7 +5626,7 @@ inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::ve auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5672,7 +5673,7 @@ inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5719,6 +5720,9 @@ inline bool operator==(const Circuit& lhs, const Circuit& rhs) if (!(lhs.assert_messages == rhs.assert_messages)) { return false; } + if (!(lhs.recursive == rhs.recursive)) { + return false; + } return true; } @@ -5734,7 +5738,7 @@ inline Circuit Circuit::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5752,6 +5756,7 @@ void serde::Serializable::serialize(const Circuit::Circuit& ob serde::Serializable::serialize(obj.public_parameters, serializer); serde::Serializable::serialize(obj.return_values, serializer); serde::Serializable::serialize(obj.assert_messages, serializer); + serde::Serializable::serialize(obj.recursive, serializer); serializer.decrease_container_depth(); } @@ -5767,6 +5772,7 @@ Circuit::Circuit serde::Deserializable::deserialize(Deserializ obj.public_parameters = serde::Deserializable::deserialize(deserializer); obj.return_values = serde::Deserializable::deserialize(deserializer); obj.assert_messages = serde::Deserializable::deserialize(deserializer); + obj.recursive = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } @@ -5793,7 +5799,7 @@ inline Directive Directive::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5848,7 +5854,7 @@ inline Directive::ToLeRadix Directive::ToLeRadix::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5908,7 +5914,7 @@ inline Directive::PermutationSort Directive::PermutationSort::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -5967,7 +5973,7 @@ inline Expression Expression::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6023,7 +6029,7 @@ inline FunctionInput FunctionInput::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6077,7 +6083,7 @@ inline HeapArray HeapArray::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6131,7 +6137,7 @@ inline HeapVector HeapVector::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6188,7 +6194,7 @@ inline MemOp MemOp::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6241,7 +6247,7 @@ inline Opcode Opcode::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6290,7 +6296,7 @@ inline Opcode::AssertZero Opcode::AssertZero::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6336,7 +6342,7 @@ inline Opcode::BlackBoxFuncCall Opcode::BlackBoxFuncCall::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6383,7 +6389,7 @@ inline Opcode::Directive Opcode::Directive::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6429,7 +6435,7 @@ inline Opcode::Brillig Opcode::Brillig::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6481,7 +6487,7 @@ inline Opcode::MemoryOp Opcode::MemoryOp::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6534,7 +6540,7 @@ inline Opcode::MemoryInit Opcode::MemoryInit::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6582,7 +6588,7 @@ inline OpcodeLocation OpcodeLocation::bincodeDeserialize(std::vector in auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6631,7 +6637,7 @@ inline OpcodeLocation::Acir OpcodeLocation::Acir::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6681,7 +6687,7 @@ inline OpcodeLocation::Brillig OpcodeLocation::Brillig::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6730,7 +6736,7 @@ inline PublicInputs PublicInputs::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6779,7 +6785,7 @@ inline RegisterIndex RegisterIndex::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6828,7 +6834,7 @@ inline RegisterOrMemory RegisterOrMemory::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6878,7 +6884,7 @@ inline RegisterOrMemory::RegisterIndex RegisterOrMemory::RegisterIndex::bincodeD auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6925,7 +6931,7 @@ inline RegisterOrMemory::HeapArray RegisterOrMemory::HeapArray::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -6972,7 +6978,7 @@ inline RegisterOrMemory::HeapVector RegisterOrMemory::HeapVector::bincodeDeseria auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -7019,7 +7025,7 @@ inline Value Value::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } @@ -7068,7 +7074,7 @@ inline Witness Witness::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); + throw serde::deserialization_error("Some input bytes were not read"); } return value; } From a746985a6b4def2b364fec01a6b17b6336557239 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 19:23:37 +0000 Subject: [PATCH 03/28] remove is_recursive flag and add recursive flag to AcirComposer --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 30 ++++++++----------- .../dsl/acir_format/acir_format.hpp | 6 ++++ .../acir_format/acir_to_constraint_buf.hpp | 3 +- .../dsl/acir_format/serde/acir.hpp | 10 +++---- .../dsl/acir_proofs/acir_composer.cpp | 20 ++++--------- .../dsl/acir_proofs/acir_composer.hpp | 5 ++-- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 10 ++----- .../barretenberg/dsl/acir_proofs/c_bind.hpp | 6 +--- noir/acvm-repo/acir/src/circuit/mod.rs | 2 +- .../src/hir/resolution/resolver.rs | 4 ++- .../backend_interface/src/cli/prove.rs | 7 +---- .../backend_interface/src/cli/verify.rs | 15 ++-------- .../backend_interface/src/proof_system.rs | 15 +++------- .../backend_interface/src/smart_contract.rs | 1 + noir/tooling/nargo_cli/src/cli/prove_cmd.rs | 5 ++-- 15 files changed, 52 insertions(+), 87 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 6c567b00bcd..b49d6f95908 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -91,7 +91,7 @@ acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path) * @return true if the proof is valid * @return false if the proof is invalid */ -bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessPath, bool recursive) +bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessPath) { auto constraint_system = get_constraint_system(bytecodePath); auto witness = get_witness(witnessPath); @@ -109,14 +109,14 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP write_benchmark("subgroup_size", acir_composer.get_dyadic_circuit_size(), "acir_test", current_dir); Timer proof_timer; - auto proof = acir_composer.create_proof(recursive); + auto proof = acir_composer.create_proof(); write_benchmark("proof_construction_time", proof_timer.milliseconds(), "acir_test", current_dir); Timer vk_timer; acir_composer.init_verification_key(); write_benchmark("vk_construction_time", vk_timer.milliseconds(), "acir_test", current_dir); - auto verified = acir_composer.verify_proof(proof, recursive); + auto verified = acir_composer.verify_proof(proof); vinfo("verified: ", verified); return verified; @@ -172,9 +172,7 @@ bool accumulateAndVerifyGoblin(const std::string& bytecodePath, const std::strin * @return true if the proof is valid * @return false if the proof is invalid */ -bool proveAndVerifyGoblin(const std::string& bytecodePath, - const std::string& witnessPath, - [[maybe_unused]] bool recursive) +bool proveAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath) { // Populate the acir constraint system and witness from gzipped data auto constraint_system = get_constraint_system(bytecodePath); @@ -212,10 +210,7 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, * @param recursive Whether to use recursive proof generation of non-recursive * @param outputPath Path to write the proof to */ -void prove(const std::string& bytecodePath, - const std::string& witnessPath, - bool recursive, - const std::string& outputPath) +void prove(const std::string& bytecodePath, const std::string& witnessPath, const std::string& outputPath) { auto constraint_system = get_constraint_system(bytecodePath); auto witness = get_witness(witnessPath); @@ -224,7 +219,7 @@ void prove(const std::string& bytecodePath, acir_composer.create_circuit(constraint_system, witness); init_bn254_crs(acir_composer.get_dyadic_circuit_size()); acir_composer.init_proving_key(); - auto proof = acir_composer.create_proof(recursive); + auto proof = acir_composer.create_proof(); if (outputPath == "-") { writeRawBytesToStdout(proof); @@ -270,12 +265,12 @@ void gateCount(const std::string& bytecodePath) * @return true If the proof is valid * @return false If the proof is invalid */ -bool verify(const std::string& proof_path, bool recursive, const std::string& vk_path) +bool verify(const std::string& proof_path, const std::string& vk_path) { auto acir_composer = verifier_init(); auto vk_data = from_buffer(read_file(vk_path)); acir_composer.load_verification_key(std::move(vk_data)); - auto verified = acir_composer.verify_proof(read_file(proof_path), recursive); + auto verified = acir_composer.verify_proof(read_file(proof_path)); vinfo("verified: ", verified); return verified; @@ -491,7 +486,6 @@ int main(int argc, char* argv[]) std::string vk_path = get_option(args, "-k", "./target/vk"); std::string pk_path = get_option(args, "-r", "./target/pk"); CRS_PATH = get_option(args, "-c", CRS_PATH); - bool recursive = flag_present(args, "-r") || flag_present(args, "--recursive"); // Skip CRS initialization for any command which doesn't require the CRS. if (command == "--version") { @@ -504,21 +498,21 @@ int main(int argc, char* argv[]) return 0; } if (command == "prove_and_verify") { - return proveAndVerify(bytecode_path, witness_path, recursive) ? 0 : 1; + return proveAndVerify(bytecode_path, witness_path) ? 0 : 1; } if (command == "accumulate_and_verify_goblin") { return accumulateAndVerifyGoblin(bytecode_path, witness_path) ? 0 : 1; } if (command == "prove_and_verify_goblin") { - return proveAndVerifyGoblin(bytecode_path, witness_path, recursive) ? 0 : 1; + return proveAndVerifyGoblin(bytecode_path, witness_path) ? 0 : 1; } if (command == "prove") { std::string output_path = get_option(args, "-o", "./proofs/proof"); - prove(bytecode_path, witness_path, recursive, output_path); + prove(bytecode_path, witness_path, output_path); } else if (command == "gates") { gateCount(bytecode_path); } else if (command == "verify") { - return verify(proof_path, recursive, vk_path) ? 0 : 1; + return verify(proof_path, vk_path) ? 0 : 1; } else if (command == "contract") { std::string output_path = get_option(args, "-o", "./target/contract.sol"); contract(output_path, vk_path); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp index 82cf7eccad3..e7a06c93402 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp @@ -22,6 +22,12 @@ namespace acir_format { struct AcirFormat { // The number of witnesses in the circuit uint32_t varnum; + // Specifies whether a prover that produces SNARK recursion friendly proofs should be used. + // The proof produced when this flag is true should be friendly for recursive verification inside + // of another SNARK. For example, a recursive friendly proof may use Blake3Pedersen for + // hashing in its transcript, while we still want a prove that uses Keccak for its transcript in order + // to be able to verify SNARKs on Ethereum. + bool recursive; std::vector public_inputs; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index ff83755e312..3a84a723f83 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -327,10 +327,11 @@ void handle_memory_op(Circuit::Opcode::MemoryOp const& mem_op, BlockConstraint& AcirFormat circuit_buf_to_acir_format(std::vector const& buf) { auto circuit = Circuit::Circuit::bincodeDeserialize(buf); - info("is recursive: ", circuit.recursive); + AcirFormat af; // `varnum` is the true number of variables, thus we add one to the index which starts at zero af.varnum = circuit.current_witness_index + 1; + af.recursive = circuit.recursive; af.public_inputs = join({ map(circuit.public_parameters.value, [](auto e) { return e.value; }), map(circuit.return_values.value, [](auto e) { return e.value; }) }); std::map block_id_to_block_constraint; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 77718aca8ca..6eac38c4bc2 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -1077,11 +1077,11 @@ struct PublicInputs { struct Circuit { uint32_t current_witness_index; - std::vector opcodes; - std::vector private_parameters; - Circuit::PublicInputs public_parameters; - Circuit::PublicInputs return_values; - std::vector> assert_messages; + std::vector opcodes; + std::vector private_parameters; + PublicInputs public_parameters; + PublicInputs return_values; + std::vector> assert_messages; bool recursive; friend bool operator==(const Circuit&, const Circuit&); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index 072540db80f..b62d3f43f5c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -29,6 +29,8 @@ void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, Wi vinfo("building circuit..."); builder_ = acir_format::create_circuit(constraint_system, size_hint_, witness); vinfo("gates: ", builder_.get_total_circuit_size()); + recursive_ = constraint_system.recursive; + vinfo("circuit is recursive friendly: ", recursive_); } std::shared_ptr AcirComposer::init_proving_key() @@ -39,7 +41,7 @@ std::shared_ptr AcirComposer::init_proving_key() return proving_key_; } -std::vector AcirComposer::create_proof(bool is_recursive) +std::vector AcirComposer::create_proof() { if (!proving_key_) { throw_or_abort("Must compute proving key before constructing proof."); @@ -49,7 +51,7 @@ std::vector AcirComposer::create_proof(bool is_recursive) vinfo("creating proof..."); std::vector proof; - if (is_recursive) { + if (recursive_) { auto prover = composer.create_prover(builder_); proof = prover.construct_proof().proof_data; } else { @@ -78,7 +80,7 @@ void AcirComposer::load_verification_key(bb::plonk::verification_key_data&& data std::make_shared(std::move(data), srs::get_crs_factory()->get_verifier_crs()); } -bool AcirComposer::verify_proof(std::vector const& proof, bool is_recursive) +bool AcirComposer::verify_proof(std::vector const& proof) { acir_format::Composer composer(proving_key_, verification_key_); @@ -91,17 +93,7 @@ bool AcirComposer::verify_proof(std::vector const& proof, bool is_recur // Hack. Shouldn't need to do this. 2144 is size with no public inputs. builder_.public_inputs.resize((proof.size() - 2144) / 32); - // TODO: We could get rid of this, if we made the Noir program specify whether something should be - // TODO: created with the recursive setting or not. ie: - // - // #[recursive_friendly] - // fn main() {} - // would put in the ACIR that we want this to be recursion friendly with a flag maybe and the backend - // would set the is_recursive flag to be true. - // This would eliminate the need for nargo to have a --recursive flag - // - // End result is that we may just be able to get it off of builder_, like builder_.is_recursive_friendly - if (is_recursive) { + if (recursive_) { auto verifier = composer.create_verifier(builder_); return verifier.verify_proof({ proof }); } else { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp index a83d7f85c95..d421994dd5a 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp @@ -21,13 +21,13 @@ class AcirComposer { std::shared_ptr init_proving_key(); - std::vector create_proof(bool is_recursive); + std::vector create_proof(); void load_verification_key(bb::plonk::verification_key_data&& data); std::shared_ptr init_verification_key(); - bool verify_proof(std::vector const& proof, bool is_recursive); + bool verify_proof(std::vector const& proof); std::string get_solidity_verifier(); size_t get_total_circuit_size() { return builder_.get_total_circuit_size(); }; @@ -43,6 +43,7 @@ class AcirComposer { std::shared_ptr proving_key_; std::shared_ptr verification_key_; bool verbose_ = true; + bool recursive_ = false; template inline void vinfo(Args... args) { 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 18d44941e56..02518ba8977 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -49,7 +49,6 @@ WASM_EXPORT void acir_init_proving_key(in_ptr acir_composer_ptr, uint8_t const* WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, uint8_t const* acir_vec, uint8_t const* witness_vec, - bool const* is_recursive, uint8_t** out) { auto acir_composer = reinterpret_cast(*acir_composer_ptr); @@ -59,7 +58,7 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, acir_composer->create_circuit(constraint_system, witness); acir_composer->init_proving_key(); - auto proof_data = acir_composer->create_proof(*is_recursive); + auto proof_data = acir_composer->create_proof(); *out = to_heap_buffer(proof_data); } @@ -136,14 +135,11 @@ WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* pro *result = acir_composer->verify(proof); } -WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, - uint8_t const* proof_buf, - bool const* is_recursive, - bool* result) +WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) { auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto proof = from_buffer>(proof_buf); - *result = acir_composer->verify_proof(proof, *is_recursive); + *result = acir_composer->verify_proof(proof); } WASM_EXPORT void acir_get_solidity_verifier(in_ptr acir_composer_ptr, out_str_buf out) 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 76b24886b1d..4dfc3259947 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -31,7 +31,6 @@ WASM_EXPORT void acir_init_proving_key(in_ptr acir_composer_ptr, uint8_t const* WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, uint8_t const* constraint_system_buf, uint8_t const* witness_buf, - bool const* is_recursive, uint8_t** out); /** @@ -62,10 +61,7 @@ WASM_EXPORT void acir_get_verification_key(in_ptr acir_composer_ptr, uint8_t** o WASM_EXPORT void acir_get_proving_key(in_ptr acir_composer_ptr, uint8_t const* acir_vec, uint8_t** out); -WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, - uint8_t const* proof_buf, - bool const* is_recursive, - bool* result); +WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); /** * @brief Verifies a GUH proof produced during goblin accumulation diff --git a/noir/acvm-repo/acir/src/circuit/mod.rs b/noir/acvm-repo/acir/src/circuit/mod.rs index 0fedf0ae26a..ccfb19bbf05 100644 --- a/noir/acvm-repo/acir/src/circuit/mod.rs +++ b/noir/acvm-repo/acir/src/circuit/mod.rs @@ -41,7 +41,7 @@ pub struct Circuit { pub assert_messages: Vec<(OpcodeLocation, String)>, /// States whether the backend should use a SNARK recursion friendly prover. - /// If implemented by a backend, this means that proofs generated with this circuit + /// If implemented by a backend, this means that proofs generated with this circuit /// will be friendly for recursively verifying inside of another SNARK. pub recursive: bool, } diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 0c491730d04..3c5cf7c2f4e 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -898,7 +898,9 @@ impl<'a> Resolver<'a> { } // '#[recursive]' attribute is only allowed for entry point functions if !self.is_entry_point_function(func) && func.kind == FunctionKind::Recursive { - self.push_err(ResolverError::MisplacedRecursiveAttribute { ident: func.name_ident().clone() }); + self.push_err(ResolverError::MisplacedRecursiveAttribute { + ident: func.name_ident().clone(), + }); } if !self.distinct_allowed(func) diff --git a/noir/tooling/backend_interface/src/cli/prove.rs b/noir/tooling/backend_interface/src/cli/prove.rs index c12e516db57..c63d8afab54 100644 --- a/noir/tooling/backend_interface/src/cli/prove.rs +++ b/noir/tooling/backend_interface/src/cli/prove.rs @@ -13,7 +13,6 @@ use super::string_from_stderr; /// The proof will be written to the specified output file. pub(crate) struct ProveCommand { pub(crate) crs_path: PathBuf, - pub(crate) is_recursive: bool, pub(crate) bytecode_path: PathBuf, pub(crate) witness_path: PathBuf, } @@ -33,10 +32,6 @@ impl ProveCommand { .arg("-o") .arg("-"); - if self.is_recursive { - command.arg("-r"); - } - let output = command.output()?; if output.status.success() { Ok(output.stdout) @@ -61,7 +56,7 @@ fn prove_command() -> Result<(), BackendError> { std::fs::File::create(&witness_path).expect("file should be created"); let crs_path = backend.backend_directory(); - let prove_command = ProveCommand { crs_path, bytecode_path, witness_path, is_recursive: false }; + let prove_command = ProveCommand { crs_path, bytecode_path, witness_path }; let proof = prove_command.run(backend.binary_path())?; assert_eq!(proof, "proof".as_bytes()); diff --git a/noir/tooling/backend_interface/src/cli/verify.rs b/noir/tooling/backend_interface/src/cli/verify.rs index a31f476d84c..1a4ba50b7de 100644 --- a/noir/tooling/backend_interface/src/cli/verify.rs +++ b/noir/tooling/backend_interface/src/cli/verify.rs @@ -6,7 +6,6 @@ use crate::BackendError; /// to verify a proof pub(crate) struct VerifyCommand { pub(crate) crs_path: PathBuf, - pub(crate) is_recursive: bool, pub(crate) proof_path: PathBuf, pub(crate) vk_path: PathBuf, } @@ -24,10 +23,6 @@ impl VerifyCommand { .arg("-k") .arg(self.vk_path); - if self.is_recursive { - command.arg("-r"); - } - let output = command.output()?; // We currently do not distinguish between an invalid proof and an error inside the backend. @@ -64,18 +59,12 @@ fn verify_command() -> Result<(), BackendError> { write_vk_command.run(backend.binary_path())?; - let prove_command = ProveCommand { - crs_path: crs_path.clone(), - is_recursive: false, - bytecode_path, - witness_path, - }; + let prove_command = ProveCommand { crs_path: crs_path.clone(), bytecode_path, witness_path }; let proof = prove_command.run(backend.binary_path())?; write_to_file(&proof, &proof_path); - let verify_command = - VerifyCommand { crs_path, is_recursive: false, proof_path, vk_path: vk_path_output }; + let verify_command = VerifyCommand { crs_path, proof_path, vk_path: vk_path_output }; let verified = verify_command.run(backend.binary_path())?; assert!(verified); diff --git a/noir/tooling/backend_interface/src/proof_system.rs b/noir/tooling/backend_interface/src/proof_system.rs index 595cd7e2020..9369c91fa94 100644 --- a/noir/tooling/backend_interface/src/proof_system.rs +++ b/noir/tooling/backend_interface/src/proof_system.rs @@ -55,7 +55,6 @@ impl Backend { &self, circuit: &Circuit, witness_values: WitnessMap, - is_recursive: bool, ) -> Result, BackendError> { let binary_path = self.assert_binary_exists()?; self.assert_correct_version()?; @@ -76,13 +75,9 @@ impl Backend { write_to_file(&serialized_circuit, &bytecode_path); // Create proof and store it in the specified path - let proof_with_public_inputs = ProveCommand { - crs_path: self.crs_directory(), - is_recursive, - bytecode_path, - witness_path, - } - .run(binary_path)?; + let proof_with_public_inputs = + ProveCommand { crs_path: self.crs_directory(), bytecode_path, witness_path } + .run(binary_path)?; let proof = bb_abstraction_leaks::remove_public_inputs( circuit.public_inputs().0.len(), @@ -97,7 +92,6 @@ impl Backend { proof: &[u8], public_inputs: WitnessMap, circuit: &Circuit, - is_recursive: bool, ) -> Result { let binary_path = self.assert_binary_exists()?; self.assert_correct_version()?; @@ -127,8 +121,7 @@ impl Backend { .run(binary_path)?; // Verify the proof - VerifyCommand { crs_path: self.crs_directory(), is_recursive, proof_path, vk_path } - .run(binary_path) + VerifyCommand { crs_path: self.crs_directory(), proof_path, vk_path }.run(binary_path) } pub fn get_intermediate_proof_artifacts( diff --git a/noir/tooling/backend_interface/src/smart_contract.rs b/noir/tooling/backend_interface/src/smart_contract.rs index 2548079f8e3..524832c6308 100644 --- a/noir/tooling/backend_interface/src/smart_contract.rs +++ b/noir/tooling/backend_interface/src/smart_contract.rs @@ -56,6 +56,7 @@ mod tests { public_parameters: PublicInputs::default(), return_values: PublicInputs::default(), assert_messages: Default::default(), + recursive: false, }; let contract = get_mock_backend()?.eth_contract(&circuit)?; diff --git a/noir/tooling/nargo_cli/src/cli/prove_cmd.rs b/noir/tooling/nargo_cli/src/cli/prove_cmd.rs index d02464fd6df..64ed5b57f54 100644 --- a/noir/tooling/nargo_cli/src/cli/prove_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/prove_cmd.rs @@ -124,12 +124,11 @@ pub(crate) fn prove_package( Format::Toml, )?; - let proof = backend.prove(&compiled_program.circuit, solved_witness, false)?; + let proof = backend.prove(&compiled_program.circuit, solved_witness)?; if check_proof { let public_inputs = public_abi.encode(&public_inputs, return_value)?; - let valid_proof = - backend.verify(&proof, public_inputs, &compiled_program.circuit, false)?; + let valid_proof = backend.verify(&proof, public_inputs, &compiled_program.circuit)?; if !valid_proof { return Err(CliError::InvalidProof("".into())); From 192beebf2d6c6997da3c0d843b0e68ce5c1141ea Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 19:33:30 +0000 Subject: [PATCH 04/28] use throw_or_abort --- .../dsl/acir_format/serde/acir.hpp | 232 +++++++++--------- 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 6eac38c4bc2..1f640462643 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -1113,7 +1113,7 @@ inline BinaryFieldOp BinaryFieldOp::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1159,7 +1159,7 @@ inline BinaryFieldOp::Add BinaryFieldOp::Add::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1199,7 +1199,7 @@ inline BinaryFieldOp::Sub BinaryFieldOp::Sub::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1239,7 +1239,7 @@ inline BinaryFieldOp::Mul BinaryFieldOp::Mul::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1279,7 +1279,7 @@ inline BinaryFieldOp::Div BinaryFieldOp::Div::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1319,7 +1319,7 @@ inline BinaryFieldOp::Equals BinaryFieldOp::Equals::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1363,7 +1363,7 @@ inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1409,7 +1409,7 @@ inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1449,7 +1449,7 @@ inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1489,7 +1489,7 @@ inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1529,7 +1529,7 @@ inline BinaryIntOp::SignedDiv BinaryIntOp::SignedDiv::bincodeDeserialize(std::ve auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1570,7 +1570,7 @@ inline BinaryIntOp::UnsignedDiv BinaryIntOp::UnsignedDiv::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1611,7 +1611,7 @@ inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1652,7 +1652,7 @@ inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1693,7 +1693,7 @@ inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1734,7 +1734,7 @@ inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1774,7 +1774,7 @@ inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1814,7 +1814,7 @@ inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1854,7 +1854,7 @@ inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1894,7 +1894,7 @@ inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1937,7 +1937,7 @@ inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -1993,7 +1993,7 @@ inline BlackBoxFuncCall::AND BlackBoxFuncCall::AND::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2050,7 +2050,7 @@ inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2101,7 +2101,7 @@ inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2151,7 +2151,7 @@ inline BlackBoxFuncCall::SHA256 BlackBoxFuncCall::SHA256::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2203,7 +2203,7 @@ inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(s auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2255,7 +2255,7 @@ inline BlackBoxFuncCall::Blake3 BlackBoxFuncCall::Blake3::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2316,7 +2316,7 @@ inline BlackBoxFuncCall::SchnorrVerify BlackBoxFuncCall::SchnorrVerify::bincodeD auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2378,7 +2378,7 @@ inline BlackBoxFuncCall::PedersenCommitment BlackBoxFuncCall::PedersenCommitment auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2435,7 +2435,7 @@ inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDes auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2498,7 +2498,7 @@ inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincod auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2565,7 +2565,7 @@ inline BlackBoxFuncCall::EcdsaSecp256r1 BlackBoxFuncCall::EcdsaSecp256r1::bincod auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2627,7 +2627,7 @@ inline BlackBoxFuncCall::FixedBaseScalarMul BlackBoxFuncCall::FixedBaseScalarMul auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2691,7 +2691,7 @@ inline BlackBoxFuncCall::EmbeddedCurveAdd BlackBoxFuncCall::EmbeddedCurveAdd::bi auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2754,7 +2754,7 @@ inline BlackBoxFuncCall::EmbeddedCurveDouble BlackBoxFuncCall::EmbeddedCurveDoub auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2808,7 +2808,7 @@ inline BlackBoxFuncCall::Keccak256 BlackBoxFuncCall::Keccak256::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2865,7 +2865,7 @@ inline BlackBoxFuncCall::Keccak256VariableLength BlackBoxFuncCall::Keccak256Vari auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2919,7 +2919,7 @@ inline BlackBoxFuncCall::Keccakf1600 BlackBoxFuncCall::Keccakf1600::bincodeDeser auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -2979,7 +2979,7 @@ inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggrega auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3038,7 +3038,7 @@ inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3095,7 +3095,7 @@ inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3152,7 +3152,7 @@ inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3209,7 +3209,7 @@ inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3267,7 +3267,7 @@ inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3322,7 +3322,7 @@ inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::binc auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3371,7 +3371,7 @@ inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3423,7 +3423,7 @@ inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3474,7 +3474,7 @@ inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3526,7 +3526,7 @@ inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3577,7 +3577,7 @@ inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3629,7 +3629,7 @@ inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3690,7 +3690,7 @@ inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3757,7 +3757,7 @@ inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3824,7 +3824,7 @@ inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(s auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3885,7 +3885,7 @@ inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDes auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3942,7 +3942,7 @@ inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -3999,7 +3999,7 @@ inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDes auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4062,7 +4062,7 @@ inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeseria auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4123,7 +4123,7 @@ inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeD auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4180,7 +4180,7 @@ inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4237,7 +4237,7 @@ inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4294,7 +4294,7 @@ inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4351,7 +4351,7 @@ inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4408,7 +4408,7 @@ inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeser auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4462,7 +4462,7 @@ inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4511,7 +4511,7 @@ inline BlockId BlockId::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4569,7 +4569,7 @@ inline Brillig Brillig::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4624,7 +4624,7 @@ inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4673,7 +4673,7 @@ inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4720,7 +4720,7 @@ inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4767,7 +4767,7 @@ inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4825,7 +4825,7 @@ inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeseria auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4890,7 +4890,7 @@ inline BrilligOpcode::BinaryIntOp BrilligOpcode::BinaryIntOp::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -4948,7 +4948,7 @@ inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5000,7 +5000,7 @@ inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5049,7 +5049,7 @@ inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5096,7 +5096,7 @@ inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5146,7 +5146,7 @@ inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5192,7 +5192,7 @@ inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5242,7 +5242,7 @@ inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5296,7 +5296,7 @@ inline BrilligOpcode::Mov BrilligOpcode::Mov::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5347,7 +5347,7 @@ inline BrilligOpcode::Load BrilligOpcode::Load::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5399,7 +5399,7 @@ inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5448,7 +5448,7 @@ inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5492,7 +5492,7 @@ inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5533,7 +5533,7 @@ inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5577,7 +5577,7 @@ inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector in auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5626,7 +5626,7 @@ inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::ve auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5673,7 +5673,7 @@ inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vect auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5738,7 +5738,7 @@ inline Circuit Circuit::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5799,7 +5799,7 @@ inline Directive Directive::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5854,7 +5854,7 @@ inline Directive::ToLeRadix Directive::ToLeRadix::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5914,7 +5914,7 @@ inline Directive::PermutationSort Directive::PermutationSort::bincodeDeserialize auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -5973,7 +5973,7 @@ inline Expression Expression::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6029,7 +6029,7 @@ inline FunctionInput FunctionInput::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6083,7 +6083,7 @@ inline HeapArray HeapArray::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6137,7 +6137,7 @@ inline HeapVector HeapVector::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6194,7 +6194,7 @@ inline MemOp MemOp::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6247,7 +6247,7 @@ inline Opcode Opcode::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6296,7 +6296,7 @@ inline Opcode::AssertZero Opcode::AssertZero::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6342,7 +6342,7 @@ inline Opcode::BlackBoxFuncCall Opcode::BlackBoxFuncCall::bincodeDeserialize(std auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6389,7 +6389,7 @@ inline Opcode::Directive Opcode::Directive::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6435,7 +6435,7 @@ inline Opcode::Brillig Opcode::Brillig::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6487,7 +6487,7 @@ inline Opcode::MemoryOp Opcode::MemoryOp::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6540,7 +6540,7 @@ inline Opcode::MemoryInit Opcode::MemoryInit::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6588,7 +6588,7 @@ inline OpcodeLocation OpcodeLocation::bincodeDeserialize(std::vector in auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6637,7 +6637,7 @@ inline OpcodeLocation::Acir OpcodeLocation::Acir::bincodeDeserialize(std::vector auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6687,7 +6687,7 @@ inline OpcodeLocation::Brillig OpcodeLocation::Brillig::bincodeDeserialize(std:: auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6736,7 +6736,7 @@ inline PublicInputs PublicInputs::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6785,7 +6785,7 @@ inline RegisterIndex RegisterIndex::bincodeDeserialize(std::vector inpu auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6834,7 +6834,7 @@ inline RegisterOrMemory RegisterOrMemory::bincodeDeserialize(std::vector::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6884,7 +6884,7 @@ inline RegisterOrMemory::RegisterIndex RegisterOrMemory::RegisterIndex::bincodeD auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6931,7 +6931,7 @@ inline RegisterOrMemory::HeapArray RegisterOrMemory::HeapArray::bincodeDeseriali auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -6978,7 +6978,7 @@ inline RegisterOrMemory::HeapVector RegisterOrMemory::HeapVector::bincodeDeseria auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -7025,7 +7025,7 @@ inline Value Value::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } @@ -7074,7 +7074,7 @@ inline Witness Witness::bincodeDeserialize(std::vector input) auto deserializer = serde::BincodeDeserializer(input); auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); + throw_or_abort("Some input bytes were not read"); } return value; } From a3a7800b95124177e6e7743fd88090310c849546 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 19:38:20 +0000 Subject: [PATCH 05/28] remove is_recursive flag --- noir/tooling/nargo_cli/src/cli/verify_cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir/tooling/nargo_cli/src/cli/verify_cmd.rs b/noir/tooling/nargo_cli/src/cli/verify_cmd.rs index 1701b9e063c..ec87ae60d2a 100644 --- a/noir/tooling/nargo_cli/src/cli/verify_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/verify_cmd.rs @@ -90,7 +90,7 @@ fn verify_package( let proof = load_hex_data(&proof_path)?; - let valid_proof = backend.verify(&proof, public_inputs, &compiled_program.circuit, false)?; + let valid_proof = backend.verify(&proof, public_inputs, &compiled_program.circuit)?; if valid_proof { Ok(()) From bc3843fb00155fdaede6c69884d70437047953c0 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 19:44:51 +0000 Subject: [PATCH 06/28] update dsl bberg tests to use new AcirFormat --- .../src/barretenberg/dsl/acir_format/acir_format.test.cpp | 6 ++++++ .../barretenberg/dsl/acir_format/bigint_constraint.test.cpp | 1 + .../barretenberg/dsl/acir_format/block_constraint.test.cpp | 1 + .../barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp | 3 +++ .../barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp | 4 ++++ .../dsl/acir_format/recursion_constraint.test.cpp | 2 ++ 6 files changed, 17 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp index 8804cd0c573..a305e5c0040 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp @@ -29,6 +29,7 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) AcirFormat constraint_system{ .varnum = 4, + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, @@ -142,6 +143,7 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit) // EXPR [ (-1, _6) 1 ] AcirFormat constraint_system{ .varnum = 6, + .recursive = false, .public_inputs = { 1 }, .logic_constraints = { logic_constraint }, .range_constraints = { range_a, range_b }, @@ -207,6 +209,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass) .signature = signature, }; AcirFormat constraint_system{ .varnum = 81, + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = range_constraints, @@ -300,6 +303,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) }; AcirFormat constraint_system{ .varnum = 81, + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = range_constraints, @@ -412,6 +416,7 @@ TEST_F(AcirFormatTests, TestVarKeccak) AcirFormat constraint_system{ .varnum = 36, + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = { range_a, range_b, range_c, range_d }, @@ -456,6 +461,7 @@ TEST_F(AcirFormatTests, TestKeccakPermutation) }; AcirFormat constraint_system{ .varnum = 51, + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp index 0762bfd783a..2caa0041359 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp @@ -48,6 +48,7 @@ TEST_F(BigIntTests, TestBigIntConstraintDummy) AcirFormat constraint_system{ .varnum = 4, + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp index 7c0444f6191..c4a4f65c59f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp @@ -110,6 +110,7 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) size_t num_variables = generate_block_constraint(block, witness_values); AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp index 2e17b97008d..51c5d6ca811 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp @@ -89,6 +89,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed) size_t num_variables = generate_ecdsa_constraint(ecdsa_k1_constraint, witness_values); AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, @@ -135,6 +136,7 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier) size_t num_variables = generate_ecdsa_constraint(ecdsa_k1_constraint, witness_values); AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, @@ -176,6 +178,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp index c3487e35da0..b652d4ca965 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp @@ -124,6 +124,7 @@ TEST(ECDSASecp256r1, test_hardcoded) AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, @@ -171,6 +172,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed) size_t num_variables = generate_ecdsa_constraint(ecdsa_r1_constraint, witness_values); AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, @@ -216,6 +218,7 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier) size_t num_variables = generate_ecdsa_constraint(ecdsa_r1_constraint, witness_values); AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, @@ -256,6 +259,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) AcirFormat constraint_system{ .varnum = static_cast(num_variables), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp index 20650bf589b..9091d581305 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp @@ -82,6 +82,7 @@ Builder create_inner_circuit() }; AcirFormat constraint_system{ .varnum = 6, + .recursive = true, .public_inputs = { 1, 2 }, .logic_constraints = { logic_constraint }, .range_constraints = { range_a, range_b }, @@ -236,6 +237,7 @@ Builder create_outer_circuit(std::vector& inner_circuits) } AcirFormat constraint_system{ .varnum = static_cast(witness.size()), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, From 3fd6edc065802e18d9e1ee6671c45e3a6899b730 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 19:46:47 +0000 Subject: [PATCH 07/28] uncomment serde_reflection test --- noir/acvm-repo/acir/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/noir/acvm-repo/acir/src/lib.rs b/noir/acvm-repo/acir/src/lib.rs index 6604ec29bd7..b7bcaa0c5c0 100644 --- a/noir/acvm-repo/acir/src/lib.rs +++ b/noir/acvm-repo/acir/src/lib.rs @@ -81,10 +81,10 @@ mod reflection { generator.output(&mut source, ®istry).unwrap(); // Comment this out to write updated C++ code to file. - // if let Some(old_hash) = old_hash { - // let new_hash = fxhash::hash64(&source); - // assert_eq!(new_hash, old_hash, "Serialization format has changed"); - // } + if let Some(old_hash) = old_hash { + let new_hash = fxhash::hash64(&source); + assert_eq!(new_hash, old_hash, "Serialization format has changed"); + } write_to_file(&source, &path); } From 4c074bef0b24b4014a6e44f69c5495f7401c0daf Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 20:18:38 +0000 Subject: [PATCH 08/28] make a separate test for recursive assert_statement --- noir/acvm-repo/acir/src/lib.rs | 8 ++++---- .../execution_success/assert_statement/src/main.nr | 1 - .../assert_statement_recursive/Nargo.toml | 7 +++++++ .../assert_statement_recursive/Prover.toml | 2 ++ .../assert_statement_recursive/src/main.nr | 11 +++++++++++ 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 noir/test_programs/execution_success/assert_statement_recursive/Nargo.toml create mode 100644 noir/test_programs/execution_success/assert_statement_recursive/Prover.toml create mode 100644 noir/test_programs/execution_success/assert_statement_recursive/src/main.nr diff --git a/noir/acvm-repo/acir/src/lib.rs b/noir/acvm-repo/acir/src/lib.rs index b7bcaa0c5c0..6604ec29bd7 100644 --- a/noir/acvm-repo/acir/src/lib.rs +++ b/noir/acvm-repo/acir/src/lib.rs @@ -81,10 +81,10 @@ mod reflection { generator.output(&mut source, ®istry).unwrap(); // Comment this out to write updated C++ code to file. - if let Some(old_hash) = old_hash { - let new_hash = fxhash::hash64(&source); - assert_eq!(new_hash, old_hash, "Serialization format has changed"); - } + // if let Some(old_hash) = old_hash { + // let new_hash = fxhash::hash64(&source); + // assert_eq!(new_hash, old_hash, "Serialization format has changed"); + // } write_to_file(&source, &path); } diff --git a/noir/test_programs/execution_success/assert_statement/src/main.nr b/noir/test_programs/execution_success/assert_statement/src/main.nr index 16d5917fb59..2646a0b85c2 100644 --- a/noir/test_programs/execution_success/assert_statement/src/main.nr +++ b/noir/test_programs/execution_success/assert_statement/src/main.nr @@ -1,7 +1,6 @@ // Tests a very simple program. // // The features being tested is assertion -#[recursive] fn main(x: Field, y: pub Field) { assert(x == y, "x and y are not equal"); assert_eq(x, y, "x and y are not equal"); diff --git a/noir/test_programs/execution_success/assert_statement_recursive/Nargo.toml b/noir/test_programs/execution_success/assert_statement_recursive/Nargo.toml new file mode 100644 index 00000000000..2a5b02cad00 --- /dev/null +++ b/noir/test_programs/execution_success/assert_statement_recursive/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "assert_statement_recursive" +type = "bin" +authors = [""] +compiler_version = ">=0.23.0" + +[dependencies] \ No newline at end of file diff --git a/noir/test_programs/execution_success/assert_statement_recursive/Prover.toml b/noir/test_programs/execution_success/assert_statement_recursive/Prover.toml new file mode 100644 index 00000000000..5d1dc99124f --- /dev/null +++ b/noir/test_programs/execution_success/assert_statement_recursive/Prover.toml @@ -0,0 +1,2 @@ +x = "3" +y = "3" diff --git a/noir/test_programs/execution_success/assert_statement_recursive/src/main.nr b/noir/test_programs/execution_success/assert_statement_recursive/src/main.nr new file mode 100644 index 00000000000..687a0d324ba --- /dev/null +++ b/noir/test_programs/execution_success/assert_statement_recursive/src/main.nr @@ -0,0 +1,11 @@ +// Tests a very simple program. +// +// The features being tested is assertion +// This is the same as the `assert_statement` test except we specify +// that the backend should use a prover which will construct proofs +// friendly to recursive verification in another SNARK. +#[recursive] +fn main(x: Field, y: pub Field) { + assert(x == y, "x and y are not equal"); + assert_eq(x, y, "x and y are not equal"); +} \ No newline at end of file From 018f25fbb338fdccafb33376a6859b9ac1f5a609 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 20:39:48 +0000 Subject: [PATCH 09/28] update noir js to not distinguish between intermediate and final proofs --- .../acir_tests/gen_inner_proof_inputs.sh | 2 +- barretenberg/ts/src/barretenberg_api/index.ts | 14 ++-- barretenberg/ts/src/main.ts | 22 +++---- .../test/browser/compile_prove_verify.test.ts | 4 +- .../test/browser/recursion.test.ts | 14 ++-- .../onchain_recursive_verification.test.ts | 14 ++-- .../test/node/smart_contract_verifier.test.ts | 4 +- noir/tooling/noir_js/src/program.ts | 8 +-- noir/tooling/noir_js/test/node/e2e.test.ts | 25 ++++---- .../noir_js_backend_barretenberg/src/index.ts | 64 ++----------------- noir/tooling/noir_js_types/src/types.ts | 17 ++--- 11 files changed, 61 insertions(+), 127 deletions(-) diff --git a/barretenberg/acir_tests/gen_inner_proof_inputs.sh b/barretenberg/acir_tests/gen_inner_proof_inputs.sh index 36137bde82e..ade57bcea4f 100755 --- a/barretenberg/acir_tests/gen_inner_proof_inputs.sh +++ b/barretenberg/acir_tests/gen_inner_proof_inputs.sh @@ -20,7 +20,7 @@ export BRANCH ./clone_test_vectors.sh -cd acir_tests/assert_statement +cd acir_tests/assert_statement_recursive PROOF_DIR=$PWD/proofs PROOF_PATH=$PROOF_DIR/$PROOF_NAME diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index d6280851562..ca3ac3febcf 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -356,9 +356,8 @@ export class BarretenbergApi { acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array, - isRecursive: boolean, ): Promise { - const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf, isRecursive].map(serializeBufferable); + const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_create_proof', @@ -449,8 +448,8 @@ export class BarretenbergApi { return out[0]; } - async acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array, isRecursive: boolean): Promise { - const inArgs = [acirComposerPtr, proofBuf, isRecursive].map(serializeBufferable); + async acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { + const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_verify_proof', @@ -869,9 +868,8 @@ export class BarretenbergApiSync { acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array, - isRecursive: boolean, ): Uint8Array { - const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf, isRecursive].map(serializeBufferable); + const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = this.wasm.callWasmExport( 'acir_create_proof', @@ -954,8 +952,8 @@ export class BarretenbergApiSync { return out[0]; } - acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array, isRecursive: boolean): boolean { - const inArgs = [acirComposerPtr, proofBuf, isRecursive].map(serializeBufferable); + acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { + const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = this.wasm.callWasmExport( 'acir_verify_proof', diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index d06de96431d..b8d38773751 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -99,7 +99,7 @@ async function initLite() { return { api, acirComposer }; } -export async function proveAndVerify(bytecodePath: string, witnessPath: string, crsPath: string, isRecursive: boolean) { +export async function proveAndVerify(bytecodePath: string, witnessPath: string, crsPath: string) { /* eslint-disable camelcase */ const acir_test = path.basename(process.cwd()); @@ -116,11 +116,11 @@ export async function proveAndVerify(bytecodePath: string, witnessPath: string, writeBenchmark('subgroup_size', subgroupSize, { acir_test, threads }); const proofTimer = new Timer(); - const proof = await api.acirCreateProof(acirComposer, bytecode, witness, isRecursive); + const proof = await api.acirCreateProof(acirComposer, bytecode, witness); writeBenchmark('proof_construction_time', proofTimer.ms(), { acir_test, threads }); debug(`verifying...`); - const verified = await api.acirVerifyProof(acirComposer, proof, isRecursive); + const verified = await api.acirVerifyProof(acirComposer, proof); debug(`verified: ${verified}`); return verified; } finally { @@ -190,7 +190,6 @@ export async function prove( bytecodePath: string, witnessPath: string, crsPath: string, - isRecursive: boolean, outputPath: string, ) { const { api, acirComposer } = await init(bytecodePath, crsPath); @@ -198,7 +197,7 @@ export async function prove( debug(`creating proof...`); const bytecode = getBytecode(bytecodePath); const witness = getWitness(witnessPath); - const proof = await api.acirCreateProof(acirComposer, bytecode, witness, isRecursive); + const proof = await api.acirCreateProof(acirComposer, bytecode, witness); debug(`done.`); if (outputPath === '-') { @@ -241,11 +240,11 @@ export function acvmInfo(outputPath: string) { } } -export async function verify(proofPath: string, isRecursive: boolean, vkPath: string) { +export async function verify(proofPath: string, vkPath: string) { const { api, acirComposer } = await initLite(); try { await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath))); - const verified = await api.acirVerifyProof(acirComposer, readFileSync(proofPath), isRecursive); + const verified = await api.acirVerifyProof(acirComposer, readFileSync(proofPath)); debug(`verified: ${verified}`); return verified; } finally { @@ -379,10 +378,9 @@ program .description('Generate a proof and verify it. Process exits with success or failure code.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .option('-r, --recursive', 'prove and verify using recursive prover and verifier', false) .action(async ({ bytecodePath, witnessPath, recursive, crsPath }) => { handleGlobalOptions(); - const result = await proveAndVerify(bytecodePath, witnessPath, crsPath, recursive); + const result = await proveAndVerify(bytecodePath, witnessPath, crsPath); process.exit(result ? 0 : 1); }); @@ -413,11 +411,10 @@ program .description('Generate a proof and write it to a file.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .option('-r, --recursive', 'prove using recursive prover', false) .option('-o, --output-path ', 'Specify the proof output path', './proofs/proof') .action(async ({ bytecodePath, witnessPath, recursive, outputPath, crsPath }) => { handleGlobalOptions(); - await prove(bytecodePath, witnessPath, crsPath, recursive, outputPath); + await prove(bytecodePath, witnessPath, crsPath, recursive); }); program @@ -433,11 +430,10 @@ program .command('verify') .description('Verify a proof. Process exists with success or failure code.') .requiredOption('-p, --proof-path ', 'Specify the path to the proof') - .option('-r, --recursive', 'prove using recursive prover', false) .requiredOption('-k, --vk ', 'path to a verification key. avoids recomputation.') .action(async ({ proofPath, recursive, vk }) => { handleGlobalOptions(); - const result = await verify(proofPath, recursive, vk); + const result = await verify(proofPath, vk); process.exit(result ? 0 : 1); }); diff --git a/noir/compiler/integration-tests/test/browser/compile_prove_verify.test.ts b/noir/compiler/integration-tests/test/browser/compile_prove_verify.test.ts index 0a829def09e..dba51895bb8 100644 --- a/noir/compiler/integration-tests/test/browser/compile_prove_verify.test.ts +++ b/noir/compiler/integration-tests/test/browser/compile_prove_verify.test.ts @@ -59,11 +59,11 @@ test_cases.forEach((testInfo) => { // JS Proving - const proofWithPublicInputs = await program.generateFinalProof(inputs); + const proofWithPublicInputs = await program.generateProof(inputs); // JS verification - const verified = await program.verifyFinalProof(proofWithPublicInputs); + const verified = await program.verifyProof(proofWithPublicInputs); expect(verified, 'Proof fails verification in JS').to.be.true; }); diff --git a/noir/compiler/integration-tests/test/browser/recursion.test.ts b/noir/compiler/integration-tests/test/browser/recursion.test.ts index 80199de5701..a8927aa6a75 100644 --- a/noir/compiler/integration-tests/test/browser/recursion.test.ts +++ b/noir/compiler/integration-tests/test/browser/recursion.test.ts @@ -19,7 +19,7 @@ await newABICoder(); await initACVM(); const base_relative_path = '../../../../..'; -const circuit_main = 'test_programs/execution_success/assert_statement'; +const circuit_main = 'test_programs/execution_success/assert_statement_recursive'; const circuit_recursion = 'compiler/integration-tests/circuits/recursion'; async function getCircuit(projectPath: string) { @@ -48,15 +48,15 @@ describe('It compiles noir program code, receiving circuit bytes and abi object. const { witness: main_witnessUint8Array } = await new Noir(main_program).execute(main_inputs); - const main_proof = await main_backend.generateIntermediateProof(main_witnessUint8Array); - const main_verification = await main_backend.verifyIntermediateProof(main_proof); + const main_proof = await main_backend.generateProof(main_witnessUint8Array); + const main_verification = await main_backend.verifyProof(main_proof); logger.debug('main_verification', main_verification); expect(main_verification).to.be.true; const numPublicInputs = 1; - const { proofAsFields, vkAsFields, vkHash } = await main_backend.generateIntermediateProofArtifacts( + const { proofAsFields, vkAsFields, vkHash } = await main_backend.generateRecursiveProofArtifacts( main_proof, numPublicInputs, ); @@ -76,20 +76,20 @@ describe('It compiles noir program code, receiving circuit bytes and abi object. const { witness: recursion_witnessUint8Array } = await new Noir(recursion_program).execute(recursion_inputs); - const recursion_proof = await recursion_backend.generateFinalProof(recursion_witnessUint8Array); + const recursion_proof = await recursion_backend.generateProof(recursion_witnessUint8Array); // Causes an "unreachable" error. // Due to the fact that it's a non-recursive proof? // // const recursion_numPublicInputs = 1; - // const { proofAsFields: recursion_proofAsFields } = await recursion_backend.generateIntermediateProofArtifacts( + // const { proofAsFields: recursion_proofAsFields } = await recursion_backend.generateRecursiveProofArtifacts( // recursion_proof, // recursion_numPublicInputs, // ); // // logger.debug('recursion_proofAsFields', recursion_proofAsFields); - const recursion_verification = await recursion_backend.verifyFinalProof(recursion_proof); + const recursion_verification = await recursion_backend.verifyProof(recursion_proof); logger.debug('recursion_verification', recursion_verification); diff --git a/noir/compiler/integration-tests/test/node/onchain_recursive_verification.test.ts b/noir/compiler/integration-tests/test/node/onchain_recursive_verification.test.ts index 9cdd80edc15..6147f770f16 100644 --- a/noir/compiler/integration-tests/test/node/onchain_recursive_verification.test.ts +++ b/noir/compiler/integration-tests/test/node/onchain_recursive_verification.test.ts @@ -16,7 +16,7 @@ it(`smart contract can verify a recursive proof`, async () => { const fm = createFileManager(basePath); const innerCompilationResult = await compile( fm, - join(basePath, './test_programs/execution_success/assert_statement'), + join(basePath, './test_programs/execution_success/assert_statement_recursive'), ); if (!('program' in innerCompilationResult)) { throw new Error('Compilation failed'); @@ -38,17 +38,17 @@ it(`smart contract can verify a recursive proof`, async () => { const inner = new Noir(innerProgram); const inner_prover_toml = readFileSync( - join(basePath, `./test_programs/execution_success/assert_statement/Prover.toml`), + join(basePath, `./test_programs/execution_success/assert_statement_recursive/Prover.toml`), ).toString(); const inner_inputs = toml.parse(inner_prover_toml); const { witness: main_witness } = await inner.execute(inner_inputs); - const intermediate_proof = await inner_backend.generateIntermediateProof(main_witness); + const intermediate_proof = await inner_backend.generateProof(main_witness); - expect(await inner_backend.verifyIntermediateProof(intermediate_proof)).to.be.true; + expect(await inner_backend.verifyProof(intermediate_proof)).to.be.true; - const { proofAsFields, vkAsFields, vkHash } = await inner_backend.generateIntermediateProofArtifacts( + const { proofAsFields, vkAsFields, vkHash } = await inner_backend.generateRecursiveProofArtifacts( intermediate_proof, 1, // 1 public input ); @@ -65,8 +65,8 @@ it(`smart contract can verify a recursive proof`, async () => { key_hash: vkHash, }; - const recursion_proof = await recursion.generateFinalProof(recursion_inputs); - expect(await recursion.verifyFinalProof(recursion_proof)).to.be.true; + const recursion_proof = await recursion.generateProof(recursion_inputs); + expect(await recursion.verifyProof(recursion_proof)).to.be.true; // Smart contract verification diff --git a/noir/compiler/integration-tests/test/node/smart_contract_verifier.test.ts b/noir/compiler/integration-tests/test/node/smart_contract_verifier.test.ts index d870956ea7a..79a0520da32 100644 --- a/noir/compiler/integration-tests/test/node/smart_contract_verifier.test.ts +++ b/noir/compiler/integration-tests/test/node/smart_contract_verifier.test.ts @@ -46,11 +46,11 @@ test_cases.forEach((testInfo) => { const prover_toml = readFileSync(resolve(`${base_relative_path}/${test_case}/Prover.toml`)).toString(); const inputs = toml.parse(prover_toml); - const proofData = await program.generateFinalProof(inputs); + const proofData = await program.generateProof(inputs); // JS verification - const verified = await program.verifyFinalProof(proofData); + const verified = await program.verifyProof(proofData); expect(verified, 'Proof fails verification in JS').to.be.true; // Smart contract verification diff --git a/noir/tooling/noir_js/src/program.ts b/noir/tooling/noir_js/src/program.ts index 809943727eb..9dbb8013f81 100644 --- a/noir/tooling/noir_js/src/program.ts +++ b/noir/tooling/noir_js/src/program.ts @@ -71,9 +71,9 @@ export class Noir { * ``` * */ - async generateFinalProof(inputs: InputMap, foreignCallHandler?: ForeignCallHandler): Promise { + async generateProof(inputs: InputMap, foreignCallHandler?: ForeignCallHandler): Promise { const { witness } = await this.execute(inputs, foreignCallHandler); - return this.getBackend().generateFinalProof(witness); + return this.getBackend().generateProof(witness); } /** @@ -88,7 +88,7 @@ export class Noir { * ``` * */ - async verifyFinalProof(proofData: ProofData): Promise { - return this.getBackend().verifyFinalProof(proofData); + async verifyProof(proofData: ProofData): Promise { + return this.getBackend().verifyProof(proofData); } } diff --git a/noir/tooling/noir_js/test/node/e2e.test.ts b/noir/tooling/noir_js/test/node/e2e.test.ts index 33d64377b06..8921314e8ea 100644 --- a/noir/tooling/noir_js/test/node/e2e.test.ts +++ b/noir/tooling/noir_js/test/node/e2e.test.ts @@ -21,10 +21,10 @@ it('end-to-end proof creation and verification (outer)', async () => { // // Proof creation const prover = new Backend(assert_lt_program); - const proof = await prover.generateFinalProof(witness); + const proof = await prover.generateProof(witness); // Proof verification - const isValid = await prover.verifyFinalProof(proof); + const isValid = await prover.verifyProof(proof); expect(isValid).to.be.true; }); @@ -40,13 +40,14 @@ it('end-to-end proof creation and verification (outer) -- Program API', async () // Initialize program const program = new Noir(assert_lt_program, backend); // Generate proof - const proof = await program.generateFinalProof(inputs); + const proof = await program.generateProof(inputs); // Proof verification - const isValid = await program.verifyFinalProof(proof); + const isValid = await program.verifyProof(proof); expect(isValid).to.be.true; }); +// TODO: maybe switch to using assert_statement_recursive here to test both options it('end-to-end proof creation and verification (inner)', async () => { // Noir.Js part const inputs = { @@ -62,10 +63,10 @@ it('end-to-end proof creation and verification (inner)', async () => { // // Proof creation const prover = new Backend(assert_lt_program); - const proof = await prover.generateIntermediateProof(witness); + const proof = await prover.generateProof(witness); // Proof verification - const isValid = await prover.verifyIntermediateProof(proof); + const isValid = await prover.verifyProof(proof); expect(isValid).to.be.true; }); @@ -83,10 +84,10 @@ it('end-to-end proving and verification with different instances', async () => { // bb.js part const prover = new Backend(assert_lt_program); - const proof = await prover.generateFinalProof(witness); + const proof = await prover.generateProof(witness); const verifier = new Backend(assert_lt_program); - const proof_is_valid = await verifier.verifyFinalProof(proof); + const proof_is_valid = await verifier.verifyProof(proof); expect(proof_is_valid).to.be.true; }); @@ -115,14 +116,14 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', const prover = new Backend(assert_lt_program); // Create a proof using both proving systems, the majority of the time // one would only use outer proofs. - const proofOuter = await prover.generateFinalProof(witness); - const _proofInner = await prover.generateIntermediateProof(witness); + const proofOuter = await prover.generateProof(witness); + const _proofInner = await prover.generateProof(witness); // Proof verification // - const isValidOuter = await prover.verifyFinalProof(proofOuter); + const isValidOuter = await prover.verifyProof(proofOuter); expect(isValidOuter).to.be.true; // We can also try verifying an inner proof and it will fail. - const isValidInner = await prover.verifyIntermediateProof(_proofInner); + const isValidInner = await prover.verifyProof(_proofInner); expect(isValidInner).to.be.true; }); diff --git a/noir/tooling/noir_js_backend_barretenberg/src/index.ts b/noir/tooling/noir_js_backend_barretenberg/src/index.ts index 6e619fd59cf..c84d4237047 100644 --- a/noir/tooling/noir_js_backend_barretenberg/src/index.ts +++ b/noir/tooling/noir_js_backend_barretenberg/src/index.ts @@ -46,48 +46,13 @@ export class BarretenbergBackend implements Backend { } } - // Generate an outer proof. This is the proof for the circuit which will verify - // inner proofs and or can be seen as the proof created for regular circuits. - // - // The settings for this proof are the same as the settings for a "normal" proof - // ie one that is not in the recursive setting. - async generateFinalProof(decompressedWitness: Uint8Array): Promise { - const makeEasyToVerifyInCircuit = false; - return this.generateProof(decompressedWitness, makeEasyToVerifyInCircuit); - } - - // Generates an inner proof. This is the proof that will be verified - // in another circuit. - // - // This is sometimes referred to as a recursive proof. - // We avoid this terminology as the only property of this proof - // that matters, is the fact that it is easy to verify in another - // circuit. We _could_ choose to verify this proof in the CLI. - // - // We set `makeEasyToVerifyInCircuit` to true, which will tell the backend to - // generate the proof using components that will make the proof - // easier to verify in a circuit. - - /** - * - * @example - * ```typescript - * const intermediateProof = await backend.generateIntermediateProof(witness); - * ``` - */ - async generateIntermediateProof(witness: Uint8Array): Promise { - const makeEasyToVerifyInCircuit = true; - return this.generateProof(witness, makeEasyToVerifyInCircuit); - } - /** @ignore */ - async generateProof(compressedWitness: Uint8Array, makeEasyToVerifyInCircuit: boolean): Promise { + async generateProof(compressedWitness: Uint8Array): Promise { await this.instantiate(); const proofWithPublicInputs = await this.api.acirCreateProof( this.acirComposer, this.acirUncompressedBytecode, gunzip(compressedWitness), - makeEasyToVerifyInCircuit, ); const splitIndex = proofWithPublicInputs.length - numBytesInProofWithoutPublicInputs; @@ -116,7 +81,7 @@ export class BarretenbergBackend implements Backend { * const artifacts = await backend.generateIntermediateProofArtifacts(proof, numOfPublicInputs); * ``` */ - async generateIntermediateProofArtifacts( + async generateRecursiveProofArtifacts( proofData: ProofData, numOfPublicInputs = 0, ): Promise<{ @@ -144,31 +109,12 @@ export class BarretenbergBackend implements Backend { }; } - async verifyFinalProof(proofData: ProofData): Promise { - const proof = reconstructProofWithPublicInputs(proofData); - const makeEasyToVerifyInCircuit = false; - const verified = await this.verifyProof(proof, makeEasyToVerifyInCircuit); - return verified; - } - - /** - * - * @example - * ```typescript - * const isValidIntermediate = await backend.verifyIntermediateProof(proof); - * ``` - */ - async verifyIntermediateProof(proofData: ProofData): Promise { - const proof = reconstructProofWithPublicInputs(proofData); - const makeEasyToVerifyInCircuit = true; - return this.verifyProof(proof, makeEasyToVerifyInCircuit); - } - /** @ignore */ - async verifyProof(proof: Uint8Array, makeEasyToVerifyInCircuit: boolean): Promise { + async verifyProof(proofData: ProofData): Promise { + const proof = reconstructProofWithPublicInputs(proofData); await this.instantiate(); await this.api.acirInitVerificationKey(this.acirComposer); - return await this.api.acirVerifyProof(this.acirComposer, proof, makeEasyToVerifyInCircuit); + return await this.api.acirVerifyProof(this.acirComposer, proof); } async destroy(): Promise { diff --git a/noir/tooling/noir_js_types/src/types.ts b/noir/tooling/noir_js_types/src/types.ts index ee4921bd606..84148c5d855 100644 --- a/noir/tooling/noir_js_types/src/types.ts +++ b/noir/tooling/noir_js_types/src/types.ts @@ -4,18 +4,14 @@ export { Abi, WitnessMap } from '@noir-lang/noirc_abi'; export interface Backend { /** - * @description Generates a final proof (not meant to be verified in another circuit) */ - generateFinalProof(decompressedWitness: Uint8Array): Promise; - - /** - * @description Generates an intermediate proof (meant to be verified in another circuit) */ - generateIntermediateProof(decompressedWitness: Uint8Array): Promise; + * @description Generates a proof */ + generateProof(decompressedWitness: Uint8Array): Promise; /** * * @description Retrieves the artifacts from a proof in the Field format */ - generateIntermediateProofArtifacts( + generateRecursiveProofArtifacts( proofData: ProofData, numOfPublicInputs: number, ): Promise<{ @@ -28,11 +24,8 @@ export interface Backend { }>; /** - * @description Verifies a final proof */ - verifyFinalProof(proofData: ProofData): Promise; - - /** @description Verifies an intermediate proof */ - verifyIntermediateProof(proofData: ProofData): Promise; + * @description Verifies a proof */ + verifyProof(proofData: ProofData): Promise; /** * @description Destroys the backend */ From 73975d1658dc0d8104823ea86e24a887fb33b64e Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 20:41:10 +0000 Subject: [PATCH 10/28] update comment --- noir/tooling/noir_js/src/program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noir/tooling/noir_js/src/program.ts b/noir/tooling/noir_js/src/program.ts index 9dbb8013f81..8d80ec3a247 100644 --- a/noir/tooling/noir_js/src/program.ts +++ b/noir/tooling/noir_js/src/program.ts @@ -67,7 +67,7 @@ export class Noir { * * @example * ```typescript - * async generateFinalProof(input) + * async generateProof(input) * ``` * */ @@ -84,7 +84,7 @@ export class Noir { * * @example * ```typescript - * async verifyFinalProof(proof) + * async verifyProof(proof) * ``` * */ From 3c67a552c0af90d963cd70b375057f8d9b29185e Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 20:45:34 +0000 Subject: [PATCH 11/28] bb js foramt --- barretenberg/ts/src/barretenberg_api/index.ts | 6 +----- barretenberg/ts/src/main.ts | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index ca3ac3febcf..1a337c33e2a 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -864,11 +864,7 @@ export class BarretenbergApiSync { return; } - acirCreateProof( - acirComposerPtr: Ptr, - constraintSystemBuf: Uint8Array, - witnessBuf: Uint8Array, - ): Uint8Array { + acirCreateProof(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = this.wasm.callWasmExport( diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index b8d38773751..8616a139327 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -186,12 +186,7 @@ export async function proveAndVerifyGoblin(bytecodePath: string, witnessPath: st /* eslint-enable camelcase */ } -export async function prove( - bytecodePath: string, - witnessPath: string, - crsPath: string, - outputPath: string, -) { +export async function prove(bytecodePath: string, witnessPath: string, crsPath: string, outputPath: string) { const { api, acirComposer } = await init(bytecodePath, crsPath); try { debug(`creating proof...`); From 545e6f00e258198f19d97f582f665a886af8d867 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 20:49:32 +0000 Subject: [PATCH 12/28] missed recursive flag in acir format test --- .../cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp index 11ea6a77b9d..d64110d938d 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp @@ -49,6 +49,7 @@ TEST_F(EcOperations, TestECOperations) AcirFormat constraint_system{ .varnum = static_cast(num_variables + 1), + .recursive = false, .public_inputs = {}, .logic_constraints = {}, .range_constraints = {}, From b37e972a6e2bf5cc4393cc2eed9f6ce8be3864e9 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 20:52:03 +0000 Subject: [PATCH 13/28] remove unused flags --- barretenberg/ts/src/main.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index 8616a139327..ec974fd1c35 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -373,7 +373,7 @@ program .description('Generate a proof and verify it. Process exits with success or failure code.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .action(async ({ bytecodePath, witnessPath, recursive, crsPath }) => { + .action(async ({ bytecodePath, witnessPath, crsPath }) => { handleGlobalOptions(); const result = await proveAndVerify(bytecodePath, witnessPath, crsPath); process.exit(result ? 0 : 1); @@ -407,9 +407,9 @@ program .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') .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, witnessPath, recursive, outputPath, crsPath }) => { + .action(async ({ bytecodePath, witnessPath, outputPath, crsPath }) => { handleGlobalOptions(); - await prove(bytecodePath, witnessPath, crsPath, recursive); + await prove(bytecodePath, witnessPath, crsPath, outputPath); }); program @@ -426,7 +426,7 @@ program .description('Verify a proof. Process exists with success or failure code.') .requiredOption('-p, --proof-path ', 'Specify the path to the proof') .requiredOption('-k, --vk ', 'path to a verification key. avoids recomputation.') - .action(async ({ proofPath, recursive, vk }) => { + .action(async ({ proofPath, vk }) => { handleGlobalOptions(); const result = await verify(proofPath, vk); process.exit(result ? 0 : 1); From 2eba28f7b6efa743ee544b436576cc3a0002bea1 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 25 Jan 2024 23:40:28 +0000 Subject: [PATCH 14/28] browser-test-app in acir_tests --- barretenberg/acir_tests/browser-test-app/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/barretenberg/acir_tests/browser-test-app/src/index.ts b/barretenberg/acir_tests/browser-test-app/src/index.ts index 56708214eeb..45b39346ddf 100644 --- a/barretenberg/acir_tests/browser-test-app/src/index.ts +++ b/barretenberg/acir_tests/browser-test-app/src/index.ts @@ -31,10 +31,9 @@ async function runTest( acirComposer, bytecode, witness, - true ); debug(`verifying...`); - const verified = await api.acirVerifyProof(acirComposer, proof, true); + const verified = await api.acirVerifyProof(acirComposer, proof); debug(`verified: ${verified}`); await api.destroy(); From 0b5931c7a58ac122980a1506219d0a51b981b609 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 26 Jan 2024 21:33:56 +0000 Subject: [PATCH 15/28] move is_recursive_circuit to vkey --- .../dsl/acir_format/acir_format.cpp | 4 ++- .../dsl/acir_proofs/acir_composer.cpp | 7 ++--- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 1 + .../plonk/composer/ultra_composer.cpp | 2 ++ .../proof_system/proving_key/proving_key.hpp | 7 +++++ .../verification_key/verification_key.cpp | 1 + .../verification_key/verification_key.hpp | 26 +++++++++++++------ .../circuit_builder/circuit_builder_base.hpp | 9 ++++++- .../goblin_ultra_circuit_builder.hpp | 3 ++- .../circuit_builder/ultra_circuit_builder.hpp | 5 +++- .../noir_js_backend_barretenberg/src/index.ts | 6 ++--- 11 files changed, 53 insertions(+), 18 deletions(-) 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 360d43324e9..dfe00b03703 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -193,7 +193,9 @@ void build_constraints(Builder& builder, AcirFormat const& constraint_system, bo template Builder create_circuit(const AcirFormat& constraint_system, size_t size_hint, WitnessVector const& witness) { - Builder builder{ size_hint, witness, constraint_system.public_inputs, constraint_system.varnum }; + Builder builder{ + size_hint, witness, constraint_system.public_inputs, constraint_system.varnum, constraint_system.recursive + }; bool has_valid_witness_assignments = !witness.empty(); build_constraints(builder, constraint_system, has_valid_witness_assignments); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index b62d3f43f5c..4eae7e07f99 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -8,6 +8,7 @@ #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp" #include "contract.hpp" +#include namespace acir_proofs { @@ -29,7 +30,6 @@ void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, Wi vinfo("building circuit..."); builder_ = acir_format::create_circuit(constraint_system, size_hint_, witness); vinfo("gates: ", builder_.get_total_circuit_size()); - recursive_ = constraint_system.recursive; vinfo("circuit is recursive friendly: ", recursive_); } @@ -51,7 +51,7 @@ std::vector AcirComposer::create_proof() vinfo("creating proof..."); std::vector proof; - if (recursive_) { + if (builder_.is_recursive_circuit) { auto prover = composer.create_prover(builder_); proof = prover.construct_proof().proof_data; } else { @@ -70,6 +70,7 @@ std::shared_ptr AcirComposer::init_verification_key vinfo("computing verification key..."); acir_format::Composer composer(proving_key_, nullptr); verification_key_ = composer.compute_verification_key(builder_); + vinfo("done."); return verification_key_; } @@ -93,7 +94,7 @@ bool AcirComposer::verify_proof(std::vector const& proof) // Hack. Shouldn't need to do this. 2144 is size with no public inputs. builder_.public_inputs.resize((proof.size() - 2144) / 32); - if (recursive_) { + if (verification_key_->is_recursive_circuit) { auto verifier = composer.create_verifier(builder_); return verifier.verify_proof({ proof }); } else { 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 02518ba8977..3ef438175ce 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -41,6 +41,7 @@ WASM_EXPORT void acir_init_proving_key(in_ptr acir_composer_ptr, uint8_t const* { auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto constraint_system = acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec)); + info("in init_proving_key"); acir_composer->create_circuit(constraint_system); acir_composer->init_proving_key(); diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp index d293f509d4f..ad3aa5fd260 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.cpp @@ -497,6 +497,8 @@ std::shared_ptr UltraComposer::compute_verification_key circuit_verification_key->contains_recursive_proof = circuit_constructor.contains_recursive_proof; + circuit_verification_key->is_recursive_circuit = circuit_constructor.is_recursive_circuit; + return circuit_verification_key; } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp index 13d8c80b3c5..66b07fba4c5 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp @@ -63,6 +63,13 @@ struct proving_key { std::vector memory_read_records; // Used by UltraPlonkComposer only; for ROM, RAM reads. std::vector memory_write_records; // Used by UltraPlonkComposer only, for RAM writes. + // We only know from the circuit description whether a circuit should use a prover which produces + // proofs that are friendly to verify in a circuit themselves. However, a verifier does not need a full circuit + // description and should be able to verify a proof with just the verification key and the proof. + // This field exists to later set the same field in the verification key, and make sure + // that we are using the correct prover/verifier. + // bool generate_recursive_proof = false; + #ifdef __wasm__ PolynomialStoreCache polynomial_store; // PolynomialStoreWasm polynomial_store; diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp index 2b7ee9fa75e..0022b3de741 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp @@ -92,6 +92,7 @@ verification_key::verification_key(verification_key_data&& data, , polynomial_manifest(static_cast(data.circuit_type)) , contains_recursive_proof(data.contains_recursive_proof) , recursive_proof_public_input_indices(std::move(data.recursive_proof_public_input_indices)) + , is_recursive_circuit(data.is_recursive_circuit) {} verification_key::verification_key(const verification_key& other) diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp index 5bf59acd4d2..c09c8d32558 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.hpp @@ -18,6 +18,7 @@ struct verification_key_data { std::map commitments; bool contains_recursive_proof = false; std::vector recursive_proof_public_input_indices; + bool is_recursive_circuit = false; // for serialization: update with any new fields MSGPACK_FIELDS(circuit_type, @@ -25,7 +26,8 @@ struct verification_key_data { num_public_inputs, commitments, contains_recursive_proof, - recursive_proof_public_input_indices); + recursive_proof_public_input_indices, + is_recursive_circuit); [[nodiscard]] bb::fr hash_native(size_t hash_index = 0) const; }; @@ -36,7 +38,8 @@ inline std::ostream& operator<<(std::ostream& os, verification_key_data const& k << "key.num_public_inputs: " << static_cast(key.num_public_inputs) << "\n" << "key.commitments: " << key.commitments << "\n" << "key.contains_recursive_proof: " << key.contains_recursive_proof << "\n" - << "key.recursive_proof_public_input_indices: " << key.recursive_proof_public_input_indices << "\n"; + << "key.recursive_proof_public_input_indices: " << key.recursive_proof_public_input_indices << "\n" + << "key.is_recursive_circuit: " << key.is_recursive_circuit << "\n"; }; inline bool operator==(verification_key_data const& lhs, verification_key_data const& rhs) @@ -72,6 +75,7 @@ struct verification_key { .commitments = commitments, .contains_recursive_proof = contains_recursive_proof, .recursive_proof_public_input_indices = recursive_proof_public_input_indices, + .is_recursive_circuit = is_recursive_circuit, }; } @@ -94,17 +98,23 @@ struct verification_key { bool contains_recursive_proof = false; std::vector recursive_proof_public_input_indices; + + bool is_recursive_circuit = false; + size_t program_width = 3; // for serialization: update with new fields void msgpack_pack(auto& packer) const { - verification_key_data data = { static_cast(circuit_type), - static_cast(circuit_size), - static_cast(num_public_inputs), - commitments, - contains_recursive_proof, - recursive_proof_public_input_indices }; + verification_key_data data = { + static_cast(circuit_type), + static_cast(circuit_size), + static_cast(num_public_inputs), + commitments, + contains_recursive_proof, + recursive_proof_public_input_indices, + is_recursive_circuit, + }; packer.pack(data); } void msgpack_unpack(auto obj) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp index ffc8e1dce5d..5231f1cad23 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp @@ -35,10 +35,17 @@ template class CircuitBuilderBase { // DOCTODO(#231): replace with the relevant wiki link. std::map tau; - // Publicin put indices which contain recursive proof information + // Public input indices which contain recursive proof information std::vector recursive_proof_public_input_indices; bool contains_recursive_proof = false; + // We only know from the circuit description whether a circuit should use a prover which produces + // proofs that are friendly to verify in a circuit themselves. However, a verifier does not need a full circuit + // description and should be able to verify a proof with just the verification key and the proof. + // This field exists to later set the same field in the verification key, and make sure + // that we are using the correct prover/verifier. + bool is_recursive_circuit = false; + bool _failed = false; std::string _err; static constexpr uint32_t REAL_VARIABLE = UINT32_MAX - 1; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp index 072a7d10357..41826c7a4fb 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp @@ -95,7 +95,8 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui auto& witness_values, std::vector& public_inputs, size_t varnum) - : UltraCircuitBuilder_>(/*size_hint=*/0, witness_values, public_inputs, varnum) + : UltraCircuitBuilder_>( + /*size_hint=*/0, witness_values, public_inputs, varnum, false) , op_queue(op_queue_in) { // Set indices to constants corresponding to Goblin ECC op codes diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp index 2ef60b71cc3..2d5e98ce84a 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp @@ -673,7 +673,8 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase& public_inputs, - size_t varnum) + size_t varnum, + bool recursive) : CircuitBuilderBase(size_hint) { selectors.reserve(size_hint); @@ -696,6 +697,8 @@ class UltraCircuitBuilder_ : public CircuitBuilderBasezero_idx = put_constant_variable(FF::zero()); this->tau.insert({ DUMMY_TAG, DUMMY_TAG }); // TODO(luke): explain this + + this->is_recursive_circuit = recursive; }; UltraCircuitBuilder_(const UltraCircuitBuilder_& other) = default; UltraCircuitBuilder_(UltraCircuitBuilder_&& other) diff --git a/noir/tooling/noir_js_backend_barretenberg/src/index.ts b/noir/tooling/noir_js_backend_barretenberg/src/index.ts index c84d4237047..e8df0017476 100644 --- a/noir/tooling/noir_js_backend_barretenberg/src/index.ts +++ b/noir/tooling/noir_js_backend_barretenberg/src/index.ts @@ -69,8 +69,8 @@ export class BarretenbergBackend implements Backend { // Instead of passing the proof and verification key as a byte array, we pass them // as fields which makes it cheaper to verify in a circuit. // - // The proof that is passed here will have been created using the `generateInnerProof` - // method. + // The proof that is passed here will have been created using a circuit + // that has the #[recursive] attribute on its `main` method. // // The number of public inputs denotes how many public inputs are in the inner proof. @@ -78,7 +78,7 @@ export class BarretenbergBackend implements Backend { * * @example * ```typescript - * const artifacts = await backend.generateIntermediateProofArtifacts(proof, numOfPublicInputs); + * const artifacts = await backend.generateRecursiveProofArtifacts(proof, numOfPublicInputs); * ``` */ async generateRecursiveProofArtifacts( From c9d162929485e6b1f5d8572e6ca48495294d1502 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 26 Jan 2024 21:39:34 +0000 Subject: [PATCH 16/28] remove old comment --- .../plonk/proof_system/proving_key/proving_key.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp index 66b07fba4c5..13d8c80b3c5 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.hpp @@ -63,13 +63,6 @@ struct proving_key { std::vector memory_read_records; // Used by UltraPlonkComposer only; for ROM, RAM reads. std::vector memory_write_records; // Used by UltraPlonkComposer only, for RAM writes. - // We only know from the circuit description whether a circuit should use a prover which produces - // proofs that are friendly to verify in a circuit themselves. However, a verifier does not need a full circuit - // description and should be able to verify a proof with just the verification key and the proof. - // This field exists to later set the same field in the verification key, and make sure - // that we are using the correct prover/verifier. - // bool generate_recursive_proof = false; - #ifdef __wasm__ PolynomialStoreCache polynomial_store; // PolynomialStoreWasm polynomial_store; From 847fa250ae8f35bc63bd37378b437abbc0cb346c Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 26 Jan 2024 21:40:33 +0000 Subject: [PATCH 17/28] bring back test comment --- noir/acvm-repo/acir/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/noir/acvm-repo/acir/src/lib.rs b/noir/acvm-repo/acir/src/lib.rs index 6604ec29bd7..b7bcaa0c5c0 100644 --- a/noir/acvm-repo/acir/src/lib.rs +++ b/noir/acvm-repo/acir/src/lib.rs @@ -81,10 +81,10 @@ mod reflection { generator.output(&mut source, ®istry).unwrap(); // Comment this out to write updated C++ code to file. - // if let Some(old_hash) = old_hash { - // let new_hash = fxhash::hash64(&source); - // assert_eq!(new_hash, old_hash, "Serialization format has changed"); - // } + if let Some(old_hash) = old_hash { + let new_hash = fxhash::hash64(&source); + assert_eq!(new_hash, old_hash, "Serialization format has changed"); + } write_to_file(&source, &path); } From 91b2a16ba457290d7b7bb4b4e2def5db0159393c Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 26 Jan 2024 21:41:46 +0000 Subject: [PATCH 18/28] remove old recursive_ field on acir composer --- .../cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp | 2 +- .../cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index 4eae7e07f99..c7fae9f8c19 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -30,7 +30,7 @@ void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, Wi vinfo("building circuit..."); builder_ = acir_format::create_circuit(constraint_system, size_hint_, witness); vinfo("gates: ", builder_.get_total_circuit_size()); - vinfo("circuit is recursive friendly: ", recursive_); + vinfo("circuit is recursive friendly: ", builder_.is_recursive_circuit); } std::shared_ptr AcirComposer::init_proving_key() diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp index d421994dd5a..9ff9b51ace3 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp @@ -43,7 +43,6 @@ class AcirComposer { std::shared_ptr proving_key_; std::shared_ptr verification_key_; bool verbose_ = true; - bool recursive_ = false; template inline void vinfo(Args... args) { From d2a7e98dc212a3fff2906cf09fc3d0fc7a1570df Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 26 Jan 2024 21:42:43 +0000 Subject: [PATCH 19/28] cleanup info --- barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp | 1 - 1 file changed, 1 deletion(-) 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 3ef438175ce..02518ba8977 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -41,7 +41,6 @@ WASM_EXPORT void acir_init_proving_key(in_ptr acir_composer_ptr, uint8_t const* { auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto constraint_system = acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec)); - info("in init_proving_key"); acir_composer->create_circuit(constraint_system); acir_composer->init_proving_key(); From 4a994579e063614601e841f8fb7be56b51b34108 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Mon, 29 Jan 2024 19:04:56 +0000 Subject: [PATCH 20/28] update dep for noir_js_backend_barretenberg --- .../noir_js_backend_barretenberg/package.json | 2 +- noir/yarn.lock | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/noir/tooling/noir_js_backend_barretenberg/package.json b/noir/tooling/noir_js_backend_barretenberg/package.json index cd2a6354ac4..f87dafd33ae 100644 --- a/noir/tooling/noir_js_backend_barretenberg/package.json +++ b/noir/tooling/noir_js_backend_barretenberg/package.json @@ -42,7 +42,7 @@ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "dependencies": { - "@aztec/bb.js": "0.19.0", + "@aztec/bb.js": "portal:../../../barretenberg/ts", "@noir-lang/types": "workspace:*", "fflate": "^0.8.0" }, diff --git a/noir/yarn.lock b/noir/yarn.lock index db3f493bc62..862616be54e 100644 --- a/noir/yarn.lock +++ b/noir/yarn.lock @@ -235,19 +235,18 @@ __metadata: languageName: node linkType: hard -"@aztec/bb.js@npm:0.19.0": - version: 0.19.0 - resolution: "@aztec/bb.js@npm:0.19.0" +"@aztec/bb.js@portal:../../../barretenberg/ts::locator=%40noir-lang%2Fbackend_barretenberg%40workspace%3Atooling%2Fnoir_js_backend_barretenberg": + version: 0.0.0-use.local + resolution: "@aztec/bb.js@portal:../../../barretenberg/ts::locator=%40noir-lang%2Fbackend_barretenberg%40workspace%3Atooling%2Fnoir_js_backend_barretenberg" dependencies: comlink: ^4.4.1 commander: ^10.0.1 debug: ^4.3.4 tslib: ^2.4.0 bin: - bb.js: dest/node/main.js - checksum: c78c22c3b8c43e0010a43145f973489aa7da9fcf0b8527884107f1f34ac3ca5f5d4ab087d74ce50cb75d6dbaef88bfc693e23745282faa30b81dc78481c65874 + bb.js: ./dest/node/main.js languageName: node - linkType: hard + linkType: soft "@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.12.11, @babel/code-frame@npm:^7.16.0, @babel/code-frame@npm:^7.22.13, @babel/code-frame@npm:^7.23.5, @babel/code-frame@npm:^7.8.3": version: 7.23.5 @@ -4435,7 +4434,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg" dependencies: - "@aztec/bb.js": 0.19.0 + "@aztec/bb.js": "portal:../../../barretenberg/ts" "@noir-lang/types": "workspace:*" "@types/node": ^20.6.2 "@types/prettier": ^3 From 87459cff91a548c31f1a02853bfba8805fc32def Mon Sep 17 00:00:00 2001 From: vezenovm Date: Mon, 29 Jan 2024 19:37:57 +0000 Subject: [PATCH 21/28] docs updates after bootstrapping --- .../classes/BarretenbergBackend.md | 84 +++++-------------- .../interfaces/Backend.md | 60 ++----------- .../reference/NoirJS/noir_js/classes/Noir.md | 12 +-- 3 files changed, 33 insertions(+), 123 deletions(-) diff --git a/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md b/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md index 5cbe9421b92..5428e615d9a 100644 --- a/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md +++ b/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md @@ -45,17 +45,17 @@ Destroys the backend *** -### generateFinalProof() +### generateProof() ```ts -generateFinalProof(decompressedWitness): Promise +generateProof(compressedWitness): Promise ``` #### Parameters | Parameter | Type | | :------ | :------ | -| `decompressedWitness` | `Uint8Array` | +| `compressedWitness` | `Uint8Array` | #### Returns @@ -63,47 +63,29 @@ generateFinalProof(decompressedWitness): Promise #### Implementation of -[`Backend`](../interfaces/Backend.md).[`generateFinalProof`](../interfaces/Backend.md#generatefinalproof) +[`Backend`](../interfaces/Backend.md).[`generateProof`](../interfaces/Backend.md#generateproof) #### Description -Generates a final proof (not meant to be verified in another circuit) +Generates a proof *** -### generateIntermediateProof() +### generateRecursiveProofArtifacts() ```ts -generateIntermediateProof(witness): Promise +generateRecursiveProofArtifacts(proofData, numOfPublicInputs): Promise ``` -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `witness` | `Uint8Array` | - -#### Returns - -`Promise`\<[`ProofData`](../type-aliases/ProofData.md)\> - -#### Implementation of - -[`Backend`](../interfaces/Backend.md).[`generateIntermediateProof`](../interfaces/Backend.md#generateintermediateproof) +Generates artifacts that will be passed to a circuit that will verify this proof. -#### Example - -```typescript -const intermediateProof = await backend.generateIntermediateProof(witness); -``` +Instead of passing the proof and verification key as a byte array, we pass them +as fields which makes it cheaper to verify in a circuit. -*** +The proof that is passed here will have been created using a circuit +that has the #[recursive] attribute on its `main` method. -### generateIntermediateProofArtifacts() - -```ts -generateIntermediateProofArtifacts(proofData, numOfPublicInputs): Promise -``` +The number of public inputs denotes how many public inputs are in the inner proof. #### Parameters @@ -118,20 +100,20 @@ generateIntermediateProofArtifacts(proofData, numOfPublicInputs): Promise +verifyProof(proofData): Promise ``` #### Parameters @@ -146,39 +128,11 @@ verifyFinalProof(proofData): Promise #### Implementation of -[`Backend`](../interfaces/Backend.md).[`verifyFinalProof`](../interfaces/Backend.md#verifyfinalproof) +[`Backend`](../interfaces/Backend.md).[`verifyProof`](../interfaces/Backend.md#verifyproof) #### Description -Verifies a final proof - -*** - -### verifyIntermediateProof() - -```ts -verifyIntermediateProof(proofData): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | - -#### Returns - -`Promise`\<`boolean`\> - -#### Implementation of - -[`Backend`](../interfaces/Backend.md).[`verifyIntermediateProof`](../interfaces/Backend.md#verifyintermediateproof) - -#### Example - -```typescript -const isValidIntermediate = await backend.verifyIntermediateProof(proof); -``` +Verifies a proof *** diff --git a/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md b/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md index 3eb9645c8d2..c02c6968f45 100644 --- a/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md +++ b/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md @@ -18,10 +18,10 @@ Destroys the backend *** -### generateFinalProof() +### generateProof() ```ts -generateFinalProof(decompressedWitness): Promise +generateProof(decompressedWitness): Promise ``` #### Parameters @@ -36,36 +36,14 @@ generateFinalProof(decompressedWitness): Promise #### Description -Generates a final proof (not meant to be verified in another circuit) +Generates a proof *** -### generateIntermediateProof() +### generateRecursiveProofArtifacts() ```ts -generateIntermediateProof(decompressedWitness): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `decompressedWitness` | `Uint8Array` | - -#### Returns - -`Promise`\<[`ProofData`](../type-aliases/ProofData.md)\> - -#### Description - -Generates an intermediate proof (meant to be verified in another circuit) - -*** - -### generateIntermediateProofArtifacts() - -```ts -generateIntermediateProofArtifacts(proofData, numOfPublicInputs): Promise +generateRecursiveProofArtifacts(proofData, numOfPublicInputs): Promise ``` #### Parameters @@ -85,32 +63,10 @@ Retrieves the artifacts from a proof in the Field format *** -### verifyFinalProof() - -```ts -verifyFinalProof(proofData): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | - -#### Returns - -`Promise`\<`boolean`\> - -#### Description - -Verifies a final proof - -*** - -### verifyIntermediateProof() +### verifyProof() ```ts -verifyIntermediateProof(proofData): Promise +verifyProof(proofData): Promise ``` #### Parameters @@ -125,7 +81,7 @@ verifyIntermediateProof(proofData): Promise #### Description -Verifies an intermediate proof +Verifies a proof *** diff --git a/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md b/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md index 34e20d99684..421d274fff8 100644 --- a/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md +++ b/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md @@ -72,10 +72,10 @@ async execute(inputs) *** -### generateFinalProof() +### generateProof() ```ts -generateFinalProof(inputs, foreignCallHandler?): Promise +generateProof(inputs, foreignCallHandler?): Promise ``` #### Parameters @@ -96,15 +96,15 @@ Generates a witness and a proof given an object as input. #### Example ```typescript -async generateFinalProof(input) +async generateProof(input) ``` *** -### verifyFinalProof() +### verifyProof() ```ts -verifyFinalProof(proofData): Promise +verifyProof(proofData): Promise ``` #### Parameters @@ -124,7 +124,7 @@ Instantiates the verification key and verifies a proof. #### Example ```typescript -async verifyFinalProof(proof) +async verifyProof(proof) ``` *** From 07436edb6edf85382d4d974cd708475cf73a50a1 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Mon, 29 Jan 2024 20:00:36 +0000 Subject: [PATCH 22/28] move back to 0.19.0 --- .../noir_js_backend_barretenberg/package.json | 2 +- .../noir_js_backend_barretenberg/src/index.ts | 5 ++++- noir/yarn.lock | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/noir/tooling/noir_js_backend_barretenberg/package.json b/noir/tooling/noir_js_backend_barretenberg/package.json index f87dafd33ae..cd2a6354ac4 100644 --- a/noir/tooling/noir_js_backend_barretenberg/package.json +++ b/noir/tooling/noir_js_backend_barretenberg/package.json @@ -42,7 +42,7 @@ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "dependencies": { - "@aztec/bb.js": "portal:../../../barretenberg/ts", + "@aztec/bb.js": "0.19.0", "@noir-lang/types": "workspace:*", "fflate": "^0.8.0" }, diff --git a/noir/tooling/noir_js_backend_barretenberg/src/index.ts b/noir/tooling/noir_js_backend_barretenberg/src/index.ts index 753b8bb222c..4d5b6389404 100644 --- a/noir/tooling/noir_js_backend_barretenberg/src/index.ts +++ b/noir/tooling/noir_js_backend_barretenberg/src/index.ts @@ -50,10 +50,12 @@ export class BarretenbergBackend implements Backend { /** @description Generates a proof */ async generateProof(compressedWitness: Uint8Array): Promise { await this.instantiate(); + // TODO: Change once `@aztec/bb.js` version is updated to use methods without isRecursive flag const proofWithPublicInputs = await this.api.acirCreateProof( this.acirComposer, this.acirUncompressedBytecode, gunzip(compressedWitness), + false, ); const splitIndex = proofWithPublicInputs.length - numBytesInProofWithoutPublicInputs; @@ -114,7 +116,8 @@ export class BarretenbergBackend implements Backend { const proof = reconstructProofWithPublicInputs(proofData); await this.instantiate(); await this.api.acirInitVerificationKey(this.acirComposer); - return await this.api.acirVerifyProof(this.acirComposer, proof); + // TODO: Change once `@aztec/bb.js` version is updated to use methods without isRecursive flag + return await this.api.acirVerifyProof(this.acirComposer, proof, false); } async destroy(): Promise { diff --git a/noir/yarn.lock b/noir/yarn.lock index 862616be54e..db3f493bc62 100644 --- a/noir/yarn.lock +++ b/noir/yarn.lock @@ -235,18 +235,19 @@ __metadata: languageName: node linkType: hard -"@aztec/bb.js@portal:../../../barretenberg/ts::locator=%40noir-lang%2Fbackend_barretenberg%40workspace%3Atooling%2Fnoir_js_backend_barretenberg": - version: 0.0.0-use.local - resolution: "@aztec/bb.js@portal:../../../barretenberg/ts::locator=%40noir-lang%2Fbackend_barretenberg%40workspace%3Atooling%2Fnoir_js_backend_barretenberg" +"@aztec/bb.js@npm:0.19.0": + version: 0.19.0 + resolution: "@aztec/bb.js@npm:0.19.0" dependencies: comlink: ^4.4.1 commander: ^10.0.1 debug: ^4.3.4 tslib: ^2.4.0 bin: - bb.js: ./dest/node/main.js + bb.js: dest/node/main.js + checksum: c78c22c3b8c43e0010a43145f973489aa7da9fcf0b8527884107f1f34ac3ca5f5d4ab087d74ce50cb75d6dbaef88bfc693e23745282faa30b81dc78481c65874 languageName: node - linkType: soft + linkType: hard "@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.12.11, @babel/code-frame@npm:^7.16.0, @babel/code-frame@npm:^7.22.13, @babel/code-frame@npm:^7.23.5, @babel/code-frame@npm:^7.8.3": version: 7.23.5 @@ -4434,7 +4435,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg" dependencies: - "@aztec/bb.js": "portal:../../../barretenberg/ts" + "@aztec/bb.js": 0.19.0 "@noir-lang/types": "workspace:*" "@types/node": ^20.6.2 "@types/prettier": ^3 From a706c477273e852757b71ed57582fb378b799b9d Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Tue, 30 Jan 2024 18:17:31 +0000 Subject: [PATCH 23/28] Update barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp Co-authored-by: ledwards2225 <98505400+ledwards2225@users.noreply.github.com> --- .../proof_system/circuit_builder/ultra_circuit_builder.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp index 2d5e98ce84a..4ee4751b403 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp @@ -674,7 +674,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase& public_inputs, size_t varnum, - bool recursive) + bool recursive = false) : CircuitBuilderBase(size_hint) { selectors.reserve(size_hint); From c2abde7a25557c2ed03c3c27530259bae9d06a6a Mon Sep 17 00:00:00 2001 From: vezenovm Date: Tue, 30 Jan 2024 18:18:18 +0000 Subject: [PATCH 24/28] remove floating false on GoblinUltraCircuitBuilder_ --- .../circuit_builder/goblin_ultra_circuit_builder.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp index 41826c7a4fb..b21abc87325 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp @@ -96,7 +96,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui std::vector& public_inputs, size_t varnum) : UltraCircuitBuilder_>( - /*size_hint=*/0, witness_values, public_inputs, varnum, false) + /*size_hint=*/0, witness_values, public_inputs, varnum) , op_queue(op_queue_in) { // Set indices to constants corresponding to Goblin ECC op codes From 64375f4e5585b40f0fc64a502b584c8f7881e745 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Tue, 30 Jan 2024 18:19:31 +0000 Subject: [PATCH 25/28] slight format update --- .../circuit_builder/goblin_ultra_circuit_builder.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp index b21abc87325..072a7d10357 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp @@ -95,8 +95,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui auto& witness_values, std::vector& public_inputs, size_t varnum) - : UltraCircuitBuilder_>( - /*size_hint=*/0, witness_values, public_inputs, varnum) + : UltraCircuitBuilder_>(/*size_hint=*/0, witness_values, public_inputs, varnum) , op_queue(op_queue_in) { // Set indices to constants corresponding to Goblin ECC op codes From 6a70ef09514a53b324985731919613c45579511f Mon Sep 17 00:00:00 2001 From: vezenovm Date: Wed, 31 Jan 2024 15:03:01 +0000 Subject: [PATCH 26/28] don't commit codegen'd docs --- .../classes/BarretenbergBackend.md | 142 ------------------ .../interfaces/Backend.md | 88 ----------- .../reference/NoirJS/noir_js/classes/Noir.md | 132 ---------------- 3 files changed, 362 deletions(-) delete mode 100644 noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md delete mode 100644 noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md delete mode 100644 noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md diff --git a/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md b/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md deleted file mode 100644 index 109ed884df1..00000000000 --- a/noir/docs/docs/reference/NoirJS/backend_barretenberg/classes/BarretenbergBackend.md +++ /dev/null @@ -1,142 +0,0 @@ -# BarretenbergBackend - -## Implements - -- [`Backend`](../interfaces/Backend.md) - -## Constructors - -### new BarretenbergBackend(acirCircuit, options) - -```ts -new BarretenbergBackend(acirCircuit, options): BarretenbergBackend -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `acirCircuit` | [`CompiledCircuit`](../type-aliases/CompiledCircuit.md) | -| `options` | [`BackendOptions`](../type-aliases/BackendOptions.md) | - -#### Returns - -[`BarretenbergBackend`](BarretenbergBackend.md) - -## Methods - -### destroy() - -```ts -destroy(): Promise -``` - -#### Returns - -`Promise`\<`void`\> - -#### Implementation of - -[`Backend`](../interfaces/Backend.md).[`destroy`](../interfaces/Backend.md#destroy) - -#### Description - -Destroys the backend - -*** - -### generateProof() - -```ts -generateProof(compressedWitness): Promise -``` - -Generate a final proof. This is the proof for the circuit which will verify -intermediate proofs and or can be seen as the proof created for regular circuits. - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `compressedWitness` | `Uint8Array` | - -#### Returns - -`Promise`\<[`ProofData`](../type-aliases/ProofData.md)\> - -#### Implementation of - -[`Backend`](../interfaces/Backend.md).[`generateProof`](../interfaces/Backend.md#generateproof) - -#### Description - -Generates a proof - -*** - -### generateRecursiveProofArtifacts() - -```ts -generateRecursiveProofArtifacts(proofData, numOfPublicInputs): Promise -``` - -Generates artifacts that will be passed to a circuit that will verify this proof. - -Instead of passing the proof and verification key as a byte array, we pass them -as fields which makes it cheaper to verify in a circuit. - -The proof that is passed here will have been created using a circuit -that has the #[recursive] attribute on its `main` method. - -The number of public inputs denotes how many public inputs are in the inner proof. - -#### Parameters - -| Parameter | Type | Default value | -| :------ | :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | `undefined` | -| `numOfPublicInputs` | `number` | `0` | - -#### Returns - -`Promise`\<`object`\> - -#### Implementation of - -[`Backend`](../interfaces/Backend.md).[`generateRecursiveProofArtifacts`](../interfaces/Backend.md#generaterecursiveproofartifacts) - -#### Example - -```typescript -const artifacts = await backend.generateRecursiveProofArtifacts(proof, numOfPublicInputs); -``` - -*** - -### verifyProof() - -```ts -verifyProof(proofData): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | - -#### Returns - -`Promise`\<`boolean`\> - -#### Implementation of - -[`Backend`](../interfaces/Backend.md).[`verifyProof`](../interfaces/Backend.md#verifyproof) - -#### Description - -Verifies a proof - -*** - -Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md b/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md deleted file mode 100644 index c02c6968f45..00000000000 --- a/noir/docs/docs/reference/NoirJS/backend_barretenberg/interfaces/Backend.md +++ /dev/null @@ -1,88 +0,0 @@ -# Backend - -## Methods - -### destroy() - -```ts -destroy(): Promise -``` - -#### Returns - -`Promise`\<`void`\> - -#### Description - -Destroys the backend - -*** - -### generateProof() - -```ts -generateProof(decompressedWitness): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `decompressedWitness` | `Uint8Array` | - -#### Returns - -`Promise`\<[`ProofData`](../type-aliases/ProofData.md)\> - -#### Description - -Generates a proof - -*** - -### generateRecursiveProofArtifacts() - -```ts -generateRecursiveProofArtifacts(proofData, numOfPublicInputs): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | -| `numOfPublicInputs` | `number` | - -#### Returns - -`Promise`\<`object`\> - -#### Description - -Retrieves the artifacts from a proof in the Field format - -*** - -### verifyProof() - -```ts -verifyProof(proofData): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | - -#### Returns - -`Promise`\<`boolean`\> - -#### Description - -Verifies a proof - -*** - -Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md b/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md deleted file mode 100644 index 421d274fff8..00000000000 --- a/noir/docs/docs/reference/NoirJS/noir_js/classes/Noir.md +++ /dev/null @@ -1,132 +0,0 @@ -# Noir - -## Constructors - -### new Noir(circuit, backend) - -```ts -new Noir(circuit, backend?): Noir -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `circuit` | [`CompiledCircuit`](../type-aliases/CompiledCircuit.md) | -| `backend`? | `Backend` | - -#### Returns - -[`Noir`](Noir.md) - -## Methods - -### destroy() - -```ts -destroy(): Promise -``` - -#### Returns - -`Promise`\<`void`\> - -#### Description - -Destroys the underlying backend instance. - -#### Example - -```typescript -await noir.destroy(); -``` - -*** - -### execute() - -```ts -execute(inputs, foreignCallHandler?): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `inputs` | [`InputMap`](../type-aliases/InputMap.md) | -| `foreignCallHandler`? | [`ForeignCallHandler`](../type-aliases/ForeignCallHandler.md) | - -#### Returns - -`Promise`\<`object`\> - -#### Description - -Allows to execute a circuit to get its witness and return value. - -#### Example - -```typescript -async execute(inputs) -``` - -*** - -### generateProof() - -```ts -generateProof(inputs, foreignCallHandler?): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `inputs` | [`InputMap`](../type-aliases/InputMap.md) | -| `foreignCallHandler`? | [`ForeignCallHandler`](../type-aliases/ForeignCallHandler.md) | - -#### Returns - -`Promise`\<[`ProofData`](../type-aliases/ProofData.md)\> - -#### Description - -Generates a witness and a proof given an object as input. - -#### Example - -```typescript -async generateProof(input) -``` - -*** - -### verifyProof() - -```ts -verifyProof(proofData): Promise -``` - -#### Parameters - -| Parameter | Type | -| :------ | :------ | -| `proofData` | [`ProofData`](../type-aliases/ProofData.md) | - -#### Returns - -`Promise`\<`boolean`\> - -#### Description - -Instantiates the verification key and verifies a proof. - -#### Example - -```typescript -async verifyProof(proof) -``` - -*** - -Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) From 2a1b16b1fb25c07c8cfc96b46368e54908b8eb7c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 1 Feb 2024 14:22:07 +0000 Subject: [PATCH 27/28] regenerate bindings Signed-off-by: kevaundray --- barretenberg/exports.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/barretenberg/exports.json b/barretenberg/exports.json index 3925ff1fa54..f04b2871163 100644 --- a/barretenberg/exports.json +++ b/barretenberg/exports.json @@ -536,10 +536,6 @@ { "name": "witness_buf", "type": "const uint8_t *" - }, - { - "name": "is_recursive", - "type": "const bool *" } ], "outArgs": [ @@ -670,10 +666,6 @@ { "name": "proof_buf", "type": "const uint8_t *" - }, - { - "name": "is_recursive", - "type": "const bool *" } ], "outArgs": [ From 11e757185d03d0cf55fc93440130ce9cfbb5b65e Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 1 Feb 2024 15:01:42 +0000 Subject: [PATCH 28/28] Empty-Commit