From 4f139eea4624374f095ef91c612bb8e41e5453e7 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 11 May 2023 13:33:41 -0700 Subject: [PATCH 01/16] chore!: Update to ACVM 0.12.0 --- Cargo.lock | 54 ++++++++++++++---------------------------------------- Cargo.toml | 4 ++++ 2 files changed, 18 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7a30e3adc0..b1dac4bd493 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,8 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084577e67b44c72d1cdfabe286d48adac6f5e0ad441ef134c5c467f4b6eee291" +source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ "acir_field", "flate2", @@ -17,8 +16,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a267ef529f4b132293199ecdf8c232ade817f01d916039f2d34562cab39e75e9" +source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ "ark-bn254", "ark-ff", @@ -31,8 +29,7 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1d6795105b50b13fa0dd1779b5191c4d8e9cd98b357b0b9a0b04a847baacf0" +source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ "acir", "acvm_stdlib", @@ -42,7 +39,7 @@ dependencies = [ "k256", "num-bigint", "num-traits", - "sha2 0.9.9", + "sha2 0.10.6", "sha3", "thiserror", ] @@ -50,12 +47,10 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf493c97da8c528c21353452aa10f7972f4870a3aab90919bcc08ba56a8cd8" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=98d0148c71ef59549bca7082b0180c6cc20fb7e6#98d0148c71ef59549bca7082b0180c6cc20fb7e6" dependencies = [ "acvm", "barretenberg-sys", - "blake2", "dirs 3.0.2", "futures-util", "getrandom", @@ -71,8 +66,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3131af53d17ac12340c0ff50f8555d8e040321f8078b8ee3cd8846560b6a44a9" +source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ "acir", ] @@ -374,13 +368,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.9.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", - "opaque-debug", + "digest 0.10.6", ] [[package]] @@ -389,7 +381,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", "generic-array", ] @@ -402,12 +393,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bstr" version = "1.4.0" @@ -824,16 +809,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "crypto-mac" version = "0.10.1" @@ -965,6 +940,7 @@ checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.4", "crypto-common", + "subtle", ] [[package]] @@ -1448,7 +1424,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.1", + "crypto-mac", "digest 0.9.0", ] @@ -2844,14 +2820,12 @@ dependencies = [ [[package]] name = "sha3" -version = "0.9.1" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", + "digest 0.10.6", "keccak", - "opaque-debug", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4169aa9b6eb..88644da76c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,3 +50,7 @@ toml = "0.7.2" url = "2.2.0" wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" + +[patch.crates-io] +acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "a83333b9e270dfcfd40a36271896840ec0201bc4" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "98d0148c71ef59549bca7082b0180c6cc20fb7e6" } From 133e26102781f073aaf2b9a69bffffd2ee8c7f2f Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 12:01:39 +0000 Subject: [PATCH 02/16] feat: adapted to heterogeneous bb calls --- crates/nargo/src/ops/execute.rs | 5 +- crates/noirc_evaluator/src/lib.rs | 4 +- .../src/ssa/acir_gen/constraints.rs | 24 ++- .../src/ssa/acir_gen/operations/bitwise.rs | 28 ++-- .../src/ssa/acir_gen/operations/intrinsics.rs | 128 +++++++++----- .../src/ssa/acir_gen/operations/sort.rs | 158 +++++++++--------- crates/noirc_frontend/src/node_interner.rs | 11 +- 7 files changed, 202 insertions(+), 156 deletions(-) diff --git a/crates/nargo/src/ops/execute.rs b/crates/nargo/src/ops/execute.rs index e4c8a5afbb5..04f3501d211 100644 --- a/crates/nargo/src/ops/execute.rs +++ b/crates/nargo/src/ops/execute.rs @@ -1,5 +1,6 @@ +use acvm::pwg::{solve, PartialWitnessGeneratorStatus}; +use acvm::PartialWitnessGenerator; use acvm::{acir::circuit::Circuit, pwg::block::Blocks}; -use acvm::{PartialWitnessGenerator, PartialWitnessGeneratorStatus}; use noirc_abi::WitnessMap; use crate::NargoError; @@ -10,7 +11,7 @@ pub fn execute_circuit( mut initial_witness: WitnessMap, ) -> Result { let mut blocks = Blocks::default(); - let solver_status = backend.solve(&mut initial_witness, &mut blocks, circuit.opcodes)?; + let solver_status = solve(backend, &mut initial_witness, &mut blocks, circuit.opcodes)?; if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) { todo!("Add oracle support to nargo execute") } diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 533adce4325..4c70e15bcb4 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -13,7 +13,7 @@ pub mod ssa_refactor; use acvm::{ acir::circuit::{opcodes::Opcode as AcirOpcode, Circuit, PublicInputs}, acir::native_types::{Expression, Witness}, - compiler::transformers::IsOpcodeSupported, + compiler::{optimizers::simplify::CircuitSimplifier, transformers::IsOpcodeSupported}, Language, }; use errors::{RuntimeError, RuntimeErrorKind}; @@ -83,6 +83,7 @@ pub fn create_circuit( opcodes, .. } = evaluator; + let simplifier = CircuitSimplifier::new(current_witness_index); let optimized_circuit = acvm::compiler::compile( Circuit { current_witness_index, @@ -92,6 +93,7 @@ pub fn create_circuit( }, np_language, is_opcode_supported, + &simplifier, ) .map_err(|_| RuntimeErrorKind::Spanless(String::from("produced an acvm compile error")))?; diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs b/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs index 0f8ad42620d..cb3c6e79aa2 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs @@ -6,7 +6,7 @@ use crate::{ use acvm::{ acir::{ circuit::{ - directives::Directive, + directives::{Directive, QuotientDirective}, opcodes::{BlackBoxFuncCall, FunctionInput, Opcode as AcirOpcode}, }, native_types::{Expression, Witness}, @@ -265,13 +265,13 @@ pub(crate) fn range_constraint( let b_witness = evaluator.add_witness_to_cs(); let exp_big = BigUint::from(2_u128).pow(num_bits - 1); let exp = FieldElement::from_be_bytes_reduce(&exp_big.to_bytes_be()); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: Expression::from(witness), b: Expression::from_field(exp), q: b_witness, r: r_witness, predicate: None, - })); + }))); try_range_constraint(r_witness, num_bits - 1, evaluator); try_range_constraint(b_witness, 1, evaluator); @@ -283,10 +283,8 @@ pub(crate) fn range_constraint( let my_constraint = add(&res, -FieldElement::one(), &witness.into()); evaluator.push_opcode(AcirOpcode::Arithmetic(my_constraint)); } else { - let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall { - name: acvm::acir::BlackBoxFunc::RANGE, - inputs: vec![FunctionInput { witness, num_bits }], - outputs: vec![], + let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::RANGE { + input: FunctionInput { witness, num_bits }, }); evaluator.push_opcode(gate); } @@ -311,13 +309,13 @@ pub(crate) fn bound_check( //2^s+a-b=q*2^s +r let expr = add(&r_witness.into(), two_s, &q_witness.into()); evaluator.push_opcode(AcirOpcode::Arithmetic(subtract(&sub, FieldElement::one(), &expr))); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: sub, b: Expression::from_field(two_s), q: q_witness, r: r_witness, predicate: None, - })); + }))); try_range_constraint(r_witness, max_bits, evaluator); evaluator.push_opcode(AcirOpcode::Arithmetic(boolean(q_witness))); q_witness @@ -522,13 +520,13 @@ pub(crate) fn evaluate_truncate( //1. Generate witnesses a,b,c let b_witness = evaluator.add_witness_to_cs(); let c_witness = evaluator.add_witness_to_cs(); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: lhs.clone(), b: Expression::from_field(exp), q: c_witness, r: b_witness, predicate: None, - })); + }))); try_range_constraint(b_witness, rhs, evaluator); //TODO propagate the error using ? try_range_constraint(c_witness, max_bits - rhs, evaluator); @@ -608,13 +606,13 @@ pub(crate) fn evaluate_udiv( let q_witness = evaluator.add_witness_to_cs(); let r_witness = evaluator.add_witness_to_cs(); let pa = mul_with_witness(evaluator, lhs, predicate); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: lhs.clone(), b: rhs.clone(), q: q_witness, r: r_witness, predicate: Some(predicate.clone()), - })); + }))); //r acvm::acir::BlackBoxFunc::AND, - BinaryOp::Xor => acvm::acir::BlackBoxFunc::XOR, + let gate = match opcode { + BinaryOp::And => AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::AND { + lhs: FunctionInput { witness: a_witness, num_bits: bit_size }, + rhs: FunctionInput { witness: b_witness, num_bits: bit_size }, + output: result, + }), + BinaryOp::Xor => AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::XOR { + lhs: FunctionInput { witness: a_witness, num_bits: bit_size }, + rhs: FunctionInput { witness: b_witness, num_bits: bit_size }, + output: result, + }), BinaryOp::Or => { a_witness = evaluator.create_intermediate_variable(constraints::subtract( &Expression::from_field(max), @@ -136,19 +144,15 @@ pub(super) fn evaluate_bitwise( &Expression::from(b_witness), )); // We do not have an OR gate yet, so we use the AND gate - acvm::acir::BlackBoxFunc::AND + AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::AND { + lhs: FunctionInput { witness: a_witness, num_bits: bit_size }, + rhs: FunctionInput { witness: b_witness, num_bits: bit_size }, + output: result, + }) } _ => unreachable!("ICE: expected a bitwise operation"), }; - let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall { - name: bit_gate, - inputs: vec![ - FunctionInput { witness: a_witness, num_bits: bit_size }, - FunctionInput { witness: b_witness, num_bits: bit_size }, - ], - outputs: vec![result], - }); evaluator.opcodes.push(gate); if opcode == BinaryOp::Or { diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs index ea7d3d9c6c0..86b916d8ce3 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs @@ -7,7 +7,7 @@ use crate::{ }, builtin, context::SsaContext, - mem::{ArrayId, Memory}, + mem::Memory, node::{self, Instruction, Node, NodeId, ObjectType}, }, Evaluator, @@ -19,6 +19,7 @@ use acvm::{ opcodes::{BlackBoxFuncCall, FunctionInput, Opcode as AcirOpcode}, }, native_types::{Expression, Witness}, + BlackBoxFunc, }, FieldElement, }; @@ -79,15 +80,70 @@ pub(crate) fn evaluate( } } Opcode::LowLevel(op) => { - let inputs = prepare_inputs(acir_gen, args, ctx, evaluator); - let output_count = op.definition().output_size.0 as u32; - outputs = - prepare_outputs(&mut acir_gen.memory, instruction_id, output_count, ctx, evaluator); - - let func_call = BlackBoxFuncCall { - name: op, - inputs, //witness + bit size - outputs: outputs.clone(), //witness + outputs = match op { + BlackBoxFunc::SHA256 | BlackBoxFunc::Blake2s => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 32, ctx, evaluator) + } + BlackBoxFunc::Keccak256 => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 32, ctx, evaluator) + } + BlackBoxFunc::Pedersen | BlackBoxFunc::FixedBaseScalarMul => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 2, ctx, evaluator) + } + BlackBoxFunc::SchnorrVerify + | BlackBoxFunc::EcdsaSecp256k1 + | BlackBoxFunc::ComputeMerkleRoot + | BlackBoxFunc::HashToField128Security => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 1, ctx, evaluator) + } + _ => panic!("Unsupported low level function {:?}", op), + }; + let func_call = match op { + BlackBoxFunc::SHA256 => BlackBoxFuncCall::SHA256 { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::Blake2s => BlackBoxFuncCall::Blake2s { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::Keccak256 => BlackBoxFuncCall::Keccak256 { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::Pedersen => BlackBoxFuncCall::Pedersen { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::FixedBaseScalarMul => BlackBoxFuncCall::FixedBaseScalarMul { + input: resolve_variable(&args[0], acir_gen, ctx, evaluator).unwrap(), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::SchnorrVerify => BlackBoxFuncCall::SchnorrVerify { + public_key_x: resolve_variable(&args[0], acir_gen, ctx, evaluator).unwrap(), + public_key_y: resolve_variable(&args[1], acir_gen, ctx, evaluator).unwrap(), + signature: resolve_array(&args[2], acir_gen, ctx, evaluator), + message: resolve_array(&args[3], acir_gen, ctx, evaluator), + output: outputs[0], + }, + BlackBoxFunc::EcdsaSecp256k1 => BlackBoxFuncCall::EcdsaSecp256k1 { + public_key_x: resolve_array(&args[0], acir_gen, ctx, evaluator), + public_key_y: resolve_array(&args[1], acir_gen, ctx, evaluator), + signature: resolve_array(&args[2], acir_gen, ctx, evaluator), + hashed_message: resolve_array(&args[3], acir_gen, ctx, evaluator), + output: outputs[0], + }, + BlackBoxFunc::ComputeMerkleRoot => BlackBoxFuncCall::ComputeMerkleRoot { + leaf: resolve_variable(&args[0], acir_gen, ctx, evaluator).unwrap(), + index: resolve_variable(&args[1], acir_gen, ctx, evaluator).unwrap(), + hash_path: resolve_array(&args[2], acir_gen, ctx, evaluator), + output: outputs[0], + }, + BlackBoxFunc::HashToField128Security => BlackBoxFuncCall::HashToField128Security { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + output: outputs[0], + }, + _ => panic!("Unsupported low level function {:?}", op), }; evaluator.opcodes.push(AcirOpcode::BlackBoxFuncCall(func_call)); } @@ -139,27 +195,12 @@ pub(crate) fn evaluate( (outputs.len() == 1).then(|| InternalVar::from(outputs[0])) } -// Transform the arguments of intrinsic functions into witnesses -fn prepare_inputs( - acir_gen: &mut Acir, - arguments: &[NodeId], - cfg: &SsaContext, - evaluator: &mut Evaluator, -) -> Vec { - let mut inputs: Vec = Vec::new(); - - for argument in arguments { - inputs.extend(resolve_node_id(argument, acir_gen, cfg, evaluator)); - } - inputs -} - -fn resolve_node_id( +fn resolve_variable( node_id: &NodeId, acir_gen: &mut Acir, cfg: &SsaContext, evaluator: &mut Evaluator, -) -> Vec { +) -> Option { let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}"); match node_object { node::NodeObject::Variable(v) => { @@ -167,14 +208,12 @@ fn resolve_node_id( match node_obj_type { // If the `Variable` represents a Pointer // Then we know that it is an `Array` - node::ObjectType::ArrayPointer(a) => resolve_array(a, acir_gen, cfg, evaluator), + node::ObjectType::ArrayPointer(_) => None, // If it is not a pointer, we attempt to fetch the witness associated with it - _ => match v.witness { - Some(w) => { - vec![FunctionInput { witness: w, num_bits: v.size_in_bits() }] - } - None => todo!("generate a witness"), - }, + _ => { + let witness = v.witness?; + Some(FunctionInput { witness, num_bits: v.size_in_bits() }) + } } } _ => { @@ -182,21 +221,30 @@ fn resolve_node_id( // we attempt to fetch an associated `InternalVar`. // Otherwise, this is a internal compiler error. let internal_var = acir_gen.var_cache.get(node_id).expect("invalid input").clone(); - let witness = acir_gen - .var_cache - .get_or_compute_witness(internal_var, evaluator) - .expect("unexpected constant expression"); - vec![FunctionInput { witness, num_bits: node_object.size_in_bits() }] + let witness = acir_gen.var_cache.get_or_compute_witness(internal_var, evaluator)?; + Some(FunctionInput { witness, num_bits: node_object.size_in_bits() }) } } } fn resolve_array( - array_id: ArrayId, + node_id: &NodeId, acir_gen: &mut Acir, cfg: &SsaContext, evaluator: &mut Evaluator, ) -> Vec { + let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}"); + let array_id = match node_object { + node::NodeObject::Variable(_) => { + let node_obj_type = node_object.get_type(); + match node_obj_type { + node::ObjectType::ArrayPointer(a) => a, + _ => unreachable!(), + } + } + _ => todo!("generate a witness"), + }; + let mut inputs = Vec::new(); let array = &cfg.mem[array_id]; diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 9566252b2be..02870bf1ef9 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -111,88 +111,88 @@ fn permutation_layer( (conf, out_expr) } -#[cfg(test)] -mod test { - use std::collections::BTreeMap; +// #[cfg(test)] +// mod test { +// use std::collections::BTreeMap; - use acvm::{ - acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness}, - pwg::block::Blocks, - FieldElement, OpcodeResolution, OpcodeResolutionError, PartialWitnessGenerator, - PartialWitnessGeneratorStatus, - }; +// use acvm::{ +// acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness}, +// pwg::block::Blocks, +// FieldElement, OpcodeResolution, OpcodeResolutionError, PartialWitnessGenerator, +// PartialWitnessGeneratorStatus, +// }; - use crate::{ - ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, - Evaluator, - }; - use rand::prelude::*; +// use crate::{ +// ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, +// Evaluator, +// }; +// use rand::prelude::*; - struct MockBackend {} - impl PartialWitnessGenerator for MockBackend { - fn solve_black_box_function_call( - &self, - _initial_witness: &mut BTreeMap, - _func_call: &BlackBoxFuncCall, - ) -> Result { - unreachable!(); - } - } +// struct MockBackend {} +// impl PartialWitnessGenerator for MockBackend { +// fn solve_black_box_function_call( +// &self, +// _initial_witness: &mut BTreeMap, +// _func_call: &BlackBoxFuncCall, +// ) -> Result { +// unreachable!(); +// } +// } - // Check that a random network constrains its output to be a permutation of any random input - #[test] - fn test_permutation() { - let mut rng = rand::thread_rng(); - for n in 2..50 { - let mut eval = Evaluator::default(); +// // Check that a random network constrains its output to be a permutation of any random input +// #[test] +// fn test_permutation() { +// let mut rng = rand::thread_rng(); +// for n in 2..50 { +// let mut eval = Evaluator::default(); - //we generate random inputs - let mut input = Vec::new(); - let mut a_val = Vec::new(); - let mut b_wit = Vec::new(); - let mut solved_witness: BTreeMap = BTreeMap::new(); - for i in 0..n { - let w = eval.add_witness_to_cs(); - input.push(w.into()); - a_val.push(FieldElement::from(rng.next_u32() as i128)); - solved_witness.insert(w, a_val[i]); - } +// //we generate random inputs +// let mut input = Vec::new(); +// let mut a_val = Vec::new(); +// let mut b_wit = Vec::new(); +// let mut solved_witness: BTreeMap = BTreeMap::new(); +// for i in 0..n { +// let w = eval.add_witness_to_cs(); +// input.push(w.into()); +// a_val.push(FieldElement::from(rng.next_u32() as i128)); +// solved_witness.insert(w, a_val[i]); +// } - let mut output = Vec::new(); - for _i in 0..n { - let w = eval.add_witness_to_cs(); - b_wit.push(w); - output.push(w.into()); - } - //generate constraints for the inputs - let w = evaluate_permutation(&input, &output, &mut eval); - //checks that it generate the same witness - let (w1, _) = permutation_layer(&input, &w, false, &mut eval); - assert_eq!(w, w1); - //we generate random network - let mut c = Vec::new(); - for _i in 0..w.len() { - c.push(rng.next_u32() % 2 != 0); - } - // initialize bits - for i in 0..w.len() { - solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); - } - // compute the network output by solving the constraints - let backend = MockBackend {}; - let mut blocks = Blocks::default(); - let solver_status = backend - .solve(&mut solved_witness, &mut blocks, eval.opcodes.clone()) - .expect("Could not solve permutation constraints"); - assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); - let mut b_val = Vec::new(); - for i in 0..output.len() { - b_val.push(solved_witness[&b_wit[i]]); - } - // ensure the outputs are a permutation of the inputs - a_val.sort(); - b_val.sort(); - assert_eq!(a_val, b_val); - } - } -} +// let mut output = Vec::new(); +// for _i in 0..n { +// let w = eval.add_witness_to_cs(); +// b_wit.push(w); +// output.push(w.into()); +// } +// //generate constraints for the inputs +// let w = evaluate_permutation(&input, &output, &mut eval); +// //checks that it generate the same witness +// let (w1, _) = permutation_layer(&input, &w, false, &mut eval); +// assert_eq!(w, w1); +// //we generate random network +// let mut c = Vec::new(); +// for _i in 0..w.len() { +// c.push(rng.next_u32() % 2 != 0); +// } +// // initialize bits +// for i in 0..w.len() { +// solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); +// } +// // compute the network output by solving the constraints +// let backend = MockBackend {}; +// let mut blocks = Blocks::default(); +// let solver_status = backend +// .solve(&mut solved_witness, &mut blocks, eval.opcodes.clone()) +// .expect("Could not solve permutation constraints"); +// assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); +// let mut b_val = Vec::new(); +// for i in 0..output.len() { +// b_val.push(solved_witness[&b_wit[i]]); +// } +// // ensure the outputs are a permutation of the inputs +// a_val.sort(); +// b_val.sort(); +// assert_eq!(a_val, b_val); +// } +// } +// } diff --git a/crates/noirc_frontend/src/node_interner.rs b/crates/noirc_frontend/src/node_interner.rs index d8ea11ae89c..f43071c30b5 100644 --- a/crates/noirc_frontend/src/node_interner.rs +++ b/crates/noirc_frontend/src/node_interner.rs @@ -1,7 +1,5 @@ use std::collections::{BTreeMap, HashMap}; -use acvm::acir::circuit::opcodes::BlackBoxFuncCall; -use acvm::acir::circuit::Opcode; use acvm::Language; use arena::{Arena, Index}; use fm::FileId; @@ -583,18 +581,13 @@ impl NodeInterner { self.language = language.clone(); } - #[allow(deprecated)] pub fn foreign(&self, opcode: &str) -> bool { - let is_supported = acvm::default_is_opcode_supported(self.language.clone()); + let is_supported = acvm::default_is_bb_supported(self.language.clone()); let black_box_func = match acvm::acir::BlackBoxFunc::lookup(opcode) { Some(black_box_func) => black_box_func, None => return false, }; - is_supported(&Opcode::BlackBoxFuncCall(BlackBoxFuncCall { - name: black_box_func, - inputs: Vec::new(), - outputs: Vec::new(), - })) + is_supported(black_box_func) } pub fn push_delayed_type_check(&mut self, f: TypeCheckFn) { From 57d1cbf4c13dd2cd7e9f8af0c6915372cbd48ad5 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 12:23:20 +0000 Subject: [PATCH 03/16] chore: update cargo tomls --- Cargo.lock | 74 +++++++++++++++++++++++++++++++++++++++++++++--------- Cargo.toml | 3 ++- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1dac4bd493..ccfce70cf5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,17 +2,41 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "acir" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +dependencies = [ + "acir_field 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "flate2", + "rmp-serde", + "serde", +] + [[package]] name = "acir" version = "0.11.0" source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ - "acir_field", + "acir_field 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", "flate2", "rmp-serde", "serde", ] +[[package]] +name = "acir_field" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +dependencies = [ + "ark-bn254", + "ark-ff", + "cfg-if 1.0.0", + "hex", + "num-bigint", + "serde", +] + [[package]] name = "acir_field" version = "0.11.0" @@ -26,13 +50,31 @@ dependencies = [ "serde", ] +[[package]] +name = "acvm" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +dependencies = [ + "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm_stdlib 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "blake2", + "crc32fast", + "indexmap", + "k256", + "num-bigint", + "num-traits", + "sha2 0.10.6", + "sha3", + "thiserror", +] + [[package]] name = "acvm" version = "0.11.0" source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ - "acir", - "acvm_stdlib", + "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", + "acvm_stdlib 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", "blake2", "crc32fast", "indexmap", @@ -49,7 +91,7 @@ name = "acvm-backend-barretenberg" version = "0.1.2" source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=98d0148c71ef59549bca7082b0180c6cc20fb7e6#98d0148c71ef59549bca7082b0180c6cc20fb7e6" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", "barretenberg-sys", "dirs 3.0.2", "futures-util", @@ -63,12 +105,20 @@ dependencies = [ "wasmer", ] +[[package]] +name = "acvm_stdlib" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +dependencies = [ + "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", +] + [[package]] name = "acvm_stdlib" version = "0.11.0" source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" dependencies = [ - "acir", + "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", ] [[package]] @@ -1835,7 +1885,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" name = "nargo" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "iter-extended", "noirc_abi", "noirc_driver", @@ -1849,7 +1899,7 @@ dependencies = [ name = "nargo_cli" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "acvm-backend-barretenberg", "assert_cmd", "assert_fs", @@ -1880,7 +1930,7 @@ dependencies = [ name = "noir_wasm" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "build-data", "console_error_panic_hook", "gloo-utils", @@ -1896,7 +1946,7 @@ dependencies = [ name = "noirc_abi" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "iter-extended", "serde", "serde_json", @@ -1910,7 +1960,7 @@ dependencies = [ name = "noirc_driver" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "clap", "fm", "iter-extended", @@ -1936,7 +1986,7 @@ dependencies = [ name = "noirc_evaluator" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "arena", "iter-extended", "noirc_abi", @@ -1952,7 +2002,7 @@ dependencies = [ name = "noirc_frontend" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", "arena", "chumsky", "fm", diff --git a/Cargo.toml b/Cargo.toml index 88644da76c1..42ccbc2ac09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,8 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.11.0" +#acvm = "0.11.0" +acvm = { git = "https://github.com/noir-lang/acvm", rev = "045e18ae13f2228171ce9e37da6e3e9691da2876" } arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } From 9375d3bebf460e4d0c6420b75ec255e55e4092be Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 12:29:42 +0000 Subject: [PATCH 04/16] test: re enabled sort test --- .../src/ssa/acir_gen/operations/sort.rs | 263 ++++++++++++------ 1 file changed, 184 insertions(+), 79 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 02870bf1ef9..d85182f1387 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -111,88 +111,193 @@ fn permutation_layer( (conf, out_expr) } -// #[cfg(test)] -// mod test { -// use std::collections::BTreeMap; +#[cfg(test)] +mod test { + use std::collections::BTreeMap; -// use acvm::{ -// acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness}, -// pwg::block::Blocks, -// FieldElement, OpcodeResolution, OpcodeResolutionError, PartialWitnessGenerator, -// PartialWitnessGeneratorStatus, -// }; + use acvm::{ + acir::{circuit::opcodes::FunctionInput, native_types::Witness}, + pwg::{block::Blocks, solve, OpcodeResolution, PartialWitnessGeneratorStatus}, + FieldElement, OpcodeResolutionError, PartialWitnessGenerator, + }; -// use crate::{ -// ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, -// Evaluator, -// }; -// use rand::prelude::*; + use crate::{ + ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, + Evaluator, + }; + use rand::prelude::*; -// struct MockBackend {} -// impl PartialWitnessGenerator for MockBackend { -// fn solve_black_box_function_call( -// &self, -// _initial_witness: &mut BTreeMap, -// _func_call: &BlackBoxFuncCall, -// ) -> Result { -// unreachable!(); -// } -// } + struct MockBackend {} + impl PartialWitnessGenerator for MockBackend { + fn aes( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn and( + &self, + _initial_witness: &mut BTreeMap, + _lhs: &FunctionInput, + _rhs: &FunctionInput, + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn xor( + &self, + _initial_witness: &mut BTreeMap, + _lhs: &FunctionInput, + _rhs: &FunctionInput, + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn range( + &self, + _initial_witness: &mut BTreeMap, + _input: &FunctionInput, + ) -> Result { + panic!("Path not trodden by this test") + } + fn sha256( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn blake2s( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn compute_merkle_root( + &self, + _initial_witness: &mut BTreeMap, + _leaf: &FunctionInput, + _index: &FunctionInput, + _hash_path: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn schnorr_verify( + &self, + _initial_witness: &mut BTreeMap, + _public_key_x: &FunctionInput, + _public_key_y: &FunctionInput, + _signature: &[FunctionInput], + _message: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn pedersen( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn hash_to_field_128_security( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn ecdsa_secp256k1( + &self, + _initial_witness: &mut BTreeMap, + _public_key_x: &[FunctionInput], + _public_key_y: &[FunctionInput], + _signature: &[FunctionInput], + _message: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn fixed_base_scalar_mul( + &self, + _initial_witness: &mut BTreeMap, + _input: &FunctionInput, + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn keccak256( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + } -// // Check that a random network constrains its output to be a permutation of any random input -// #[test] -// fn test_permutation() { -// let mut rng = rand::thread_rng(); -// for n in 2..50 { -// let mut eval = Evaluator::default(); + // Check that a random network constrains its output to be a permutation of any random input + #[test] + fn test_permutation() { + let mut rng = rand::thread_rng(); + for n in 2..50 { + let mut eval = Evaluator::default(); -// //we generate random inputs -// let mut input = Vec::new(); -// let mut a_val = Vec::new(); -// let mut b_wit = Vec::new(); -// let mut solved_witness: BTreeMap = BTreeMap::new(); -// for i in 0..n { -// let w = eval.add_witness_to_cs(); -// input.push(w.into()); -// a_val.push(FieldElement::from(rng.next_u32() as i128)); -// solved_witness.insert(w, a_val[i]); -// } + //we generate random inputs + let mut input = Vec::new(); + let mut a_val = Vec::new(); + let mut b_wit = Vec::new(); + let mut solved_witness: BTreeMap = BTreeMap::new(); + for i in 0..n { + let w = eval.add_witness_to_cs(); + input.push(w.into()); + a_val.push(FieldElement::from(rng.next_u32() as i128)); + solved_witness.insert(w, a_val[i]); + } -// let mut output = Vec::new(); -// for _i in 0..n { -// let w = eval.add_witness_to_cs(); -// b_wit.push(w); -// output.push(w.into()); -// } -// //generate constraints for the inputs -// let w = evaluate_permutation(&input, &output, &mut eval); -// //checks that it generate the same witness -// let (w1, _) = permutation_layer(&input, &w, false, &mut eval); -// assert_eq!(w, w1); -// //we generate random network -// let mut c = Vec::new(); -// for _i in 0..w.len() { -// c.push(rng.next_u32() % 2 != 0); -// } -// // initialize bits -// for i in 0..w.len() { -// solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); -// } -// // compute the network output by solving the constraints -// let backend = MockBackend {}; -// let mut blocks = Blocks::default(); -// let solver_status = backend -// .solve(&mut solved_witness, &mut blocks, eval.opcodes.clone()) -// .expect("Could not solve permutation constraints"); -// assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); -// let mut b_val = Vec::new(); -// for i in 0..output.len() { -// b_val.push(solved_witness[&b_wit[i]]); -// } -// // ensure the outputs are a permutation of the inputs -// a_val.sort(); -// b_val.sort(); -// assert_eq!(a_val, b_val); -// } -// } -// } + let mut output = Vec::new(); + for _i in 0..n { + let w = eval.add_witness_to_cs(); + b_wit.push(w); + output.push(w.into()); + } + //generate constraints for the inputs + let w = evaluate_permutation(&input, &output, &mut eval); + //checks that it generate the same witness + let (w1, _) = permutation_layer(&input, &w, false, &mut eval); + assert_eq!(w, w1); + //we generate random network + let mut c = Vec::new(); + for _i in 0..w.len() { + c.push(rng.next_u32() % 2 != 0); + } + // initialize bits + for i in 0..w.len() { + solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); + } + // compute the network output by solving the constraints + let backend = MockBackend {}; + let mut blocks = Blocks::default(); + let solver_status = + solve(&backend, &mut solved_witness, &mut blocks, eval.opcodes.clone()) + .expect("Could not solve permutation constraints"); + assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); + let mut b_val = Vec::new(); + for i in 0..output.len() { + b_val.push(solved_witness[&b_wit[i]]); + } + // ensure the outputs are a permutation of the inputs + a_val.sort(); + b_val.sort(); + assert_eq!(a_val, b_val); + } + } +} From 2132c0a80ccb896cc8d8fad45646be6977ca8e19 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 13:31:24 +0000 Subject: [PATCH 05/16] fix: improve variable resolution --- .../src/ssa/acir_gen/operations/intrinsics.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs index 86b916d8ce3..01d5fecc897 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs @@ -204,17 +204,7 @@ fn resolve_variable( let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}"); match node_object { node::NodeObject::Variable(v) => { - let node_obj_type = node_object.get_type(); - match node_obj_type { - // If the `Variable` represents a Pointer - // Then we know that it is an `Array` - node::ObjectType::ArrayPointer(_) => None, - // If it is not a pointer, we attempt to fetch the witness associated with it - _ => { - let witness = v.witness?; - Some(FunctionInput { witness, num_bits: v.size_in_bits() }) - } - } + Some(FunctionInput { witness: v.witness?, num_bits: v.size_in_bits() }) } _ => { // Upon the case that the `NodeObject` is not a `Variable`, @@ -244,7 +234,6 @@ fn resolve_array( } _ => todo!("generate a witness"), }; - let mut inputs = Vec::new(); let array = &cfg.mem[array_id]; From d22be54c3ee6209302cc5a89c3f191e39713a2d6 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Thu, 11 May 2023 08:52:21 +0000 Subject: [PATCH 06/16] feat: use dummy constructor for bb call --- Cargo.lock | 30 +++++++++++----------- Cargo.toml | 2 +- crates/noirc_frontend/src/node_interner.rs | 11 +++++--- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ccfce70cf5b..ddacd9f8139 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,9 +5,9 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ - "acir_field 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acir_field 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "flate2", "rmp-serde", "serde", @@ -27,7 +27,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ "ark-bn254", "ark-ff", @@ -53,10 +53,10 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ - "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", - "acvm_stdlib 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm_stdlib 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "blake2", "crc32fast", "indexmap", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ - "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", ] [[package]] @@ -1885,7 +1885,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" name = "nargo" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "iter-extended", "noirc_abi", "noirc_driver", @@ -1899,7 +1899,7 @@ dependencies = [ name = "nargo_cli" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "acvm-backend-barretenberg", "assert_cmd", "assert_fs", @@ -1930,7 +1930,7 @@ dependencies = [ name = "noir_wasm" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "build-data", "console_error_panic_hook", "gloo-utils", @@ -1946,7 +1946,7 @@ dependencies = [ name = "noirc_abi" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "iter-extended", "serde", "serde_json", @@ -1960,7 +1960,7 @@ dependencies = [ name = "noirc_driver" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "clap", "fm", "iter-extended", @@ -1986,7 +1986,7 @@ dependencies = [ name = "noirc_evaluator" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "arena", "iter-extended", "noirc_abi", @@ -2002,7 +2002,7 @@ dependencies = [ name = "noirc_frontend" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876)", + "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", "arena", "chumsky", "fm", diff --git a/Cargo.toml b/Cargo.toml index 42ccbc2ac09..2202ce128fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ rust-version = "1.66" [workspace.dependencies] #acvm = "0.11.0" -acvm = { git = "https://github.com/noir-lang/acvm", rev = "045e18ae13f2228171ce9e37da6e3e9691da2876" } +acvm = { git = "https://github.com/noir-lang/acvm", rev = "018d6865e03ddd09ed409b383f38971ec9ec3310" } arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } diff --git a/crates/noirc_frontend/src/node_interner.rs b/crates/noirc_frontend/src/node_interner.rs index f43071c30b5..f3cb00ae9ca 100644 --- a/crates/noirc_frontend/src/node_interner.rs +++ b/crates/noirc_frontend/src/node_interner.rs @@ -1,5 +1,7 @@ use std::collections::{BTreeMap, HashMap}; +use acvm::acir::circuit::opcodes::BlackBoxFuncCall; +use acvm::acir::circuit::Opcode; use acvm::Language; use arena::{Arena, Index}; use fm::FileId; @@ -581,13 +583,14 @@ impl NodeInterner { self.language = language.clone(); } + #[allow(deprecated)] pub fn foreign(&self, opcode: &str) -> bool { - let is_supported = acvm::default_is_bb_supported(self.language.clone()); - let black_box_func = match acvm::acir::BlackBoxFunc::lookup(opcode) { - Some(black_box_func) => black_box_func, + let is_supported = acvm::default_is_opcode_supported(self.language.clone()); + let black_box_func_call = match acvm::acir::BlackBoxFunc::lookup(opcode) { + Some(black_box_func) => BlackBoxFuncCall::dummy(black_box_func), None => return false, }; - is_supported(black_box_func) + is_supported(&Opcode::BlackBoxFuncCall(black_box_func_call)) } pub fn push_delayed_type_check(&mut self, f: TypeCheckFn) { From b71f69022a4f68b70ce5f6bfa9d4b4ab99fb728c Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 15 May 2023 12:34:16 -0700 Subject: [PATCH 07/16] updates for latest --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs | 4 ++-- flake.lock | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ddacd9f8139..9df51775bda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=98d0148c71ef59549bca7082b0180c6cc20fb7e6#98d0148c71ef59549bca7082b0180c6cc20fb7e6" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=a97dc35affc33db015a0f84f7e0e22dd143ac558#a97dc35affc33db015a0f84f7e0e22dd143ac558" dependencies = [ "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", "barretenberg-sys", diff --git a/Cargo.toml b/Cargo.toml index 2202ce128fb..408edb3b715 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,4 +54,4 @@ wasm-bindgen-test = "0.3.33" [patch.crates-io] acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "a83333b9e270dfcfd40a36271896840ec0201bc4" } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "98d0148c71ef59549bca7082b0180c6cc20fb7e6" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "a97dc35affc33db015a0f84f7e0e22dd143ac558" } diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs b/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs index cb3c6e79aa2..0900c34ce36 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs @@ -565,13 +565,13 @@ pub(crate) fn evaluate_constant_modulo( //1. Generate witnesses b,c let b_witness = evaluator.add_witness_to_cs(); let c_witness = evaluator.add_witness_to_cs(); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: lhs.clone(), b: modulus_exp.clone(), q: c_witness, r: b_witness, predicate: None, - })); + }))); bound_constraint_with_offset( &Expression::from(b_witness), &modulus_exp, diff --git a/flake.lock b/flake.lock index 62abdb4a42e..53b65eb4b4f 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1683839119, - "narHash": "sha256-pVoW3C5Ek9/878PBzvXqnt51KpIDrxPt5HVtNwdErnE=", + "lastModified": 1683909802, + "narHash": "sha256-2CL8NYKLYwwy6n0RyldvH86ULgrSvfzHrgq2Qf0ZUkE=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "223b9dee2542145d67126cc8a5aa0e9b9d82c244", + "rev": "97c9bc72aebab850b4a647d6e6cc50085226eafb", "type": "github" }, "original": { From e1f5b61baffe6e8310e61f081764b8677401352c Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 1 May 2023 15:07:57 -0700 Subject: [PATCH 08/16] feat!: Move WitnessMap type into ACVM to avoid leaking BTreeMap type --- Cargo.lock | 85 ++++--------------- Cargo.toml | 7 +- crates/nargo/src/ops/execute.rs | 3 +- crates/nargo/src/ops/prove.rs | 3 +- crates/nargo/src/ops/verify.rs | 3 +- crates/nargo_cli/src/cli/execute_cmd.rs | 4 +- crates/nargo_cli/src/cli/fs/witness.rs | 5 +- crates/nargo_cli/src/cli/test_cmd.rs | 6 +- crates/nargo_cli/src/errors.rs | 6 +- crates/noirc_abi/src/lib.rs | 12 +-- .../src/ssa/acir_gen/operations/sort.rs | 32 ++++--- 11 files changed, 57 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9df51775bda..88237d6b6d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,42 +5,19 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" +source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" dependencies = [ - "acir_field 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acir_field", "flate2", "rmp-serde", "serde", -] - -[[package]] -name = "acir" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" -dependencies = [ - "acir_field 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", - "flate2", - "rmp-serde", - "serde", -] - -[[package]] -name = "acir_field" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" -dependencies = [ - "ark-bn254", - "ark-ff", - "cfg-if 1.0.0", - "hex", - "num-bigint", - "serde", + "thiserror", ] [[package]] name = "acir_field" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" +source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" dependencies = [ "ark-bn254", "ark-ff", @@ -53,28 +30,10 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" +source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" dependencies = [ - "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", - "acvm_stdlib 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", - "blake2", - "crc32fast", - "indexmap", - "k256", - "num-bigint", - "num-traits", - "sha2 0.10.6", - "sha3", - "thiserror", -] - -[[package]] -name = "acvm" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" -dependencies = [ - "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", - "acvm_stdlib 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", + "acir", + "acvm_stdlib", "blake2", "crc32fast", "indexmap", @@ -89,9 +48,9 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=a97dc35affc33db015a0f84f7e0e22dd143ac558#a97dc35affc33db015a0f84f7e0e22dd143ac558" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=4f622b58144330ebc53d8458bd9e456a8efb147c#4f622b58144330ebc53d8458bd9e456a8efb147c" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", + "acvm", "barretenberg-sys", "dirs 3.0.2", "futures-util", @@ -108,17 +67,9 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" -dependencies = [ - "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", -] - -[[package]] -name = "acvm_stdlib" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4#a83333b9e270dfcfd40a36271896840ec0201bc4" +source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" dependencies = [ - "acir 0.11.0 (git+https://github.com/noir-lang/acvm?rev=a83333b9e270dfcfd40a36271896840ec0201bc4)", + "acir", ] [[package]] @@ -1885,7 +1836,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" name = "nargo" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "iter-extended", "noirc_abi", "noirc_driver", @@ -1899,7 +1850,7 @@ dependencies = [ name = "nargo_cli" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "acvm-backend-barretenberg", "assert_cmd", "assert_fs", @@ -1930,7 +1881,7 @@ dependencies = [ name = "noir_wasm" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "build-data", "console_error_panic_hook", "gloo-utils", @@ -1946,7 +1897,7 @@ dependencies = [ name = "noirc_abi" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "iter-extended", "serde", "serde_json", @@ -1960,7 +1911,7 @@ dependencies = [ name = "noirc_driver" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "clap", "fm", "iter-extended", @@ -1986,7 +1937,7 @@ dependencies = [ name = "noirc_evaluator" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "arena", "iter-extended", "noirc_abi", @@ -2002,7 +1953,7 @@ dependencies = [ name = "noirc_frontend" version = "0.5.1" dependencies = [ - "acvm 0.11.0 (git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310)", + "acvm", "arena", "chumsky", "fm", diff --git a/Cargo.toml b/Cargo.toml index 408edb3b715..4563a629043 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,7 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -#acvm = "0.11.0" -acvm = { git = "https://github.com/noir-lang/acvm", rev = "018d6865e03ddd09ed409b383f38971ec9ec3310" } +acvm = "0.11.0" arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } @@ -53,5 +52,5 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "a83333b9e270dfcfd40a36271896840ec0201bc4" } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "a97dc35affc33db015a0f84f7e0e22dd143ac558" } +acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "bbd9ab7ca5be3fb31f3e141fee2522704852f5de" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "4f622b58144330ebc53d8458bd9e456a8efb147c" } diff --git a/crates/nargo/src/ops/execute.rs b/crates/nargo/src/ops/execute.rs index 04f3501d211..a46c440c76c 100644 --- a/crates/nargo/src/ops/execute.rs +++ b/crates/nargo/src/ops/execute.rs @@ -1,7 +1,6 @@ use acvm::pwg::{solve, PartialWitnessGeneratorStatus}; use acvm::PartialWitnessGenerator; -use acvm::{acir::circuit::Circuit, pwg::block::Blocks}; -use noirc_abi::WitnessMap; +use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap, pwg::block::Blocks}; use crate::NargoError; diff --git a/crates/nargo/src/ops/prove.rs b/crates/nargo/src/ops/prove.rs index 80771bc9cb7..523b2ed5ed4 100644 --- a/crates/nargo/src/ops/prove.rs +++ b/crates/nargo/src/ops/prove.rs @@ -1,6 +1,5 @@ -use acvm::acir::circuit::Circuit; +use acvm::acir::{circuit::Circuit, native_types::WitnessMap}; use acvm::ProofSystemCompiler; -use noirc_abi::WitnessMap; pub fn prove_execution( backend: &B, diff --git a/crates/nargo/src/ops/verify.rs b/crates/nargo/src/ops/verify.rs index cd76fbd430e..f2145e3cf87 100644 --- a/crates/nargo/src/ops/verify.rs +++ b/crates/nargo/src/ops/verify.rs @@ -1,6 +1,5 @@ -use acvm::acir::circuit::Circuit; +use acvm::acir::{circuit::Circuit, native_types::WitnessMap}; use acvm::ProofSystemCompiler; -use noirc_abi::WitnessMap; pub fn verify_proof( backend: &B, diff --git a/crates/nargo_cli/src/cli/execute_cmd.rs b/crates/nargo_cli/src/cli/execute_cmd.rs index 855fea04cb3..61e709ce500 100644 --- a/crates/nargo_cli/src/cli/execute_cmd.rs +++ b/crates/nargo_cli/src/cli/execute_cmd.rs @@ -1,10 +1,10 @@ use std::path::Path; -use acvm::acir::circuit::Circuit; +use acvm::acir::{circuit::Circuit, native_types::WitnessMap}; use acvm::Backend; use clap::Args; use noirc_abi::input_parser::{Format, InputValue}; -use noirc_abi::{Abi, InputMap, WitnessMap}; +use noirc_abi::{Abi, InputMap}; use noirc_driver::{CompileOptions, CompiledProgram}; use super::fs::{inputs::read_inputs_from_file, witness::save_witness_to_dir}; diff --git a/crates/nargo_cli/src/cli/fs/witness.rs b/crates/nargo_cli/src/cli/fs/witness.rs index d41123e74fa..3b2ca2aab9f 100644 --- a/crates/nargo_cli/src/cli/fs/witness.rs +++ b/crates/nargo_cli/src/cli/fs/witness.rs @@ -1,7 +1,6 @@ use std::path::{Path, PathBuf}; -use acvm::acir::native_types::Witness; -use noirc_abi::WitnessMap; +use acvm::acir::native_types::WitnessMap; use super::{create_named_dir, write_to_file}; use crate::{constants::WITNESS_EXT, errors::FilesystemError}; @@ -14,7 +13,7 @@ pub(crate) fn save_witness_to_dir>( create_named_dir(witness_dir.as_ref(), "witness"); let witness_path = witness_dir.as_ref().join(witness_name).with_extension(WITNESS_EXT); - let buf = Witness::to_bytes(&witness); + let buf: Vec = witness.try_into()?; write_to_file(buf.as_slice(), &witness_path); diff --git a/crates/nargo_cli/src/cli/test_cmd.rs b/crates/nargo_cli/src/cli/test_cmd.rs index 139d33b6c3d..16857f4b3a1 100644 --- a/crates/nargo_cli/src/cli/test_cmd.rs +++ b/crates/nargo_cli/src/cli/test_cmd.rs @@ -1,6 +1,6 @@ -use std::{collections::BTreeMap, io::Write, path::Path}; +use std::{io::Write, path::Path}; -use acvm::Backend; +use acvm::{acir::native_types::WitnessMap, Backend}; use clap::Args; use nargo::ops::execute_circuit; use noirc_driver::{CompileOptions, Driver}; @@ -89,7 +89,7 @@ fn run_test( // Run the backend to ensure the PWG evaluates functions like std::hash::pedersen, // otherwise constraints involving these expressions will not error. - match execute_circuit(backend, program.circuit, BTreeMap::new()) { + match execute_circuit(backend, program.circuit, WitnessMap::new()) { Ok(_) => Ok(()), Err(error) => { let writer = StandardStream::stderr(ColorChoice::Always); diff --git a/crates/nargo_cli/src/errors.rs b/crates/nargo_cli/src/errors.rs index 15d1917a5d6..94772b578b4 100644 --- a/crates/nargo_cli/src/errors.rs +++ b/crates/nargo_cli/src/errors.rs @@ -1,4 +1,4 @@ -use acvm::{Backend, ProofSystemCompiler, SmartContract}; +use acvm::{acir::native_types::WitnessMapError, Backend, ProofSystemCompiler, SmartContract}; use hex::FromHexError; use nargo::NargoError; use noirc_abi::errors::{AbiError, InputParserError}; @@ -21,6 +21,10 @@ pub(crate) enum FilesystemError { /// Input parsing error #[error(transparent)] InputParserError(#[from] InputParserError), + + /// WitnessMap serialization error + #[error(transparent)] + WitnessMapSerialization(#[from] WitnessMapError), } #[derive(Debug, Error)] diff --git a/crates/noirc_abi/src/lib.rs b/crates/noirc_abi/src/lib.rs index 191128b9407..56ed3728527 100644 --- a/crates/noirc_abi/src/lib.rs +++ b/crates/noirc_abi/src/lib.rs @@ -5,7 +5,10 @@ use std::{collections::BTreeMap, str}; -use acvm::{acir::native_types::Witness, FieldElement}; +use acvm::{ + acir::native_types::{Witness, WitnessMap}, + FieldElement, +}; use errors::AbiError; use input_parser::InputValue; use iter_extended::{try_btree_map, try_vecmap, vecmap}; @@ -22,9 +25,6 @@ mod serialization; /// A map from the fields in an TOML/JSON file which correspond to some ABI to their values pub type InputMap = BTreeMap; -/// A map from the witnesses in a constraint system to the field element values -pub type WitnessMap = BTreeMap; - /// A tuple of the arguments to a function along with its return value. pub type FunctionSignature = (Vec, Option); @@ -254,7 +254,7 @@ impl Abi { .collect::>()?; // Write input field elements into witness indices specified in `self.param_witnesses`. - let mut witness_map: WitnessMap = encoded_input_map + let mut witness_map: BTreeMap = encoded_input_map .iter() .flat_map(|(param_name, encoded_param_fields)| { let param_witness_indices = &self.param_witnesses[param_name]; @@ -297,7 +297,7 @@ impl Abi { (_, None) => {} } - Ok(witness_map) + Ok(witness_map.into()) } fn encode_value(value: InputValue) -> Result, AbiError> { diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index d85182f1387..ccea9caac4c 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -113,10 +113,8 @@ fn permutation_layer( #[cfg(test)] mod test { - use std::collections::BTreeMap; - use acvm::{ - acir::{circuit::opcodes::FunctionInput, native_types::Witness}, + acir::{circuit::opcodes::FunctionInput, native_types::Witness, native_types::WitnessMap}, pwg::{block::Blocks, solve, OpcodeResolution, PartialWitnessGeneratorStatus}, FieldElement, OpcodeResolutionError, PartialWitnessGenerator, }; @@ -131,7 +129,7 @@ mod test { impl PartialWitnessGenerator for MockBackend { fn aes( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _inputs: &[FunctionInput], _outputs: &[Witness], ) -> Result { @@ -139,7 +137,7 @@ mod test { } fn and( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _lhs: &FunctionInput, _rhs: &FunctionInput, _output: &Witness, @@ -148,7 +146,7 @@ mod test { } fn xor( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _lhs: &FunctionInput, _rhs: &FunctionInput, _output: &Witness, @@ -157,14 +155,14 @@ mod test { } fn range( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _input: &FunctionInput, ) -> Result { panic!("Path not trodden by this test") } fn sha256( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _inputs: &[FunctionInput], _outputs: &[Witness], ) -> Result { @@ -172,7 +170,7 @@ mod test { } fn blake2s( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _inputs: &[FunctionInput], _outputs: &[Witness], ) -> Result { @@ -180,7 +178,7 @@ mod test { } fn compute_merkle_root( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _leaf: &FunctionInput, _index: &FunctionInput, _hash_path: &[FunctionInput], @@ -190,7 +188,7 @@ mod test { } fn schnorr_verify( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _public_key_x: &FunctionInput, _public_key_y: &FunctionInput, _signature: &[FunctionInput], @@ -201,7 +199,7 @@ mod test { } fn pedersen( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _inputs: &[FunctionInput], _outputs: &[Witness], ) -> Result { @@ -209,7 +207,7 @@ mod test { } fn hash_to_field_128_security( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _inputs: &[FunctionInput], _output: &Witness, ) -> Result { @@ -217,7 +215,7 @@ mod test { } fn ecdsa_secp256k1( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _public_key_x: &[FunctionInput], _public_key_y: &[FunctionInput], _signature: &[FunctionInput], @@ -228,7 +226,7 @@ mod test { } fn fixed_base_scalar_mul( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _input: &FunctionInput, _outputs: &[Witness], ) -> Result { @@ -236,7 +234,7 @@ mod test { } fn keccak256( &self, - _initial_witness: &mut BTreeMap, + _initial_witness: &mut WitnessMap, _inputs: &[FunctionInput], _outputs: &[Witness], ) -> Result { @@ -255,7 +253,7 @@ mod test { let mut input = Vec::new(); let mut a_val = Vec::new(); let mut b_wit = Vec::new(); - let mut solved_witness: BTreeMap = BTreeMap::new(); + let mut solved_witness = WitnessMap::new(); for i in 0..n { let w = eval.add_witness_to_cs(); input.push(w.into()); From da2525d740c7170fd5213867c6a590e03cd4e590 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 11 May 2023 17:04:40 -0700 Subject: [PATCH 09/16] feat(nargo): Only download as much CRS as you need --- Cargo.lock | 118 +++++++++++------- Cargo.toml | 4 +- crates/nargo/Cargo.toml | 1 - crates/nargo/src/ops/codegen_verifier.rs | 3 +- crates/nargo/src/ops/mod.rs | 2 +- crates/nargo/src/ops/preprocess.rs | 50 ++++---- crates/nargo/src/ops/prove.rs | 3 +- crates/nargo/src/ops/verify.rs | 3 +- crates/nargo_cli/Cargo.toml | 1 + .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 28 +++-- crates/nargo_cli/src/cli/compile_cmd.rs | 42 +++++-- .../src/cli/fs/common_reference_string.rs | 42 +++++++ crates/nargo_cli/src/cli/fs/mod.rs | 1 + crates/nargo_cli/src/cli/prove_cmd.rs | 36 ++++-- crates/nargo_cli/src/cli/verify_cmd.rs | 42 +++++-- crates/nargo_cli/src/errors.rs | 9 +- crates/noirc_driver/src/lib.rs | 3 +- flake.nix | 34 +++-- 18 files changed, 290 insertions(+), 132 deletions(-) create mode 100644 crates/nargo_cli/src/cli/fs/common_reference_string.rs diff --git a/Cargo.lock b/Cargo.lock index 88237d6b6d0..aeaa9e45f96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" +source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" dependencies = [ "acir_field", "flate2", @@ -17,7 +17,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" +source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" dependencies = [ "ark-bn254", "ark-ff", @@ -30,10 +30,11 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" +source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" dependencies = [ "acir", "acvm_stdlib", + "async-trait", "blake2", "crc32fast", "indexmap", @@ -48,26 +49,27 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=4f622b58144330ebc53d8458bd9e456a8efb147c#4f622b58144330ebc53d8458bd9e456a8efb147c" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=5647a7f329865ec4c12e468f40d6cdb38fb921a2#5647a7f329865ec4c12e468f40d6cdb38fb921a2" dependencies = [ "acvm", "barretenberg-sys", - "dirs 3.0.2", + "bincode", + "bytes", "futures-util", "getrandom", "indicatif", "pkg-config", "reqwest", "rust-embed", + "serde", "thiserror", - "tokio", "wasmer", ] [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=bbd9ab7ca5be3fb31f3e141fee2522704852f5de#bbd9ab7ca5be3fb31f3e141fee2522704852f5de" +source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" dependencies = [ "acir", ] @@ -195,7 +197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d6873aaba7959593d89babed381d33e2329453368f1bf3c67e07686a1c1056f" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -208,7 +210,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -244,7 +246,7 @@ checksum = "fd34f0920d995d2c932f38861c416f70de89a6de9875876b012557079603e6cc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -287,6 +289,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "async-trait" +version = "0.1.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -328,6 +341,15 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bindgen" version = "0.64.0" @@ -346,7 +368,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", "which", ] @@ -442,7 +464,7 @@ checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -544,7 +566,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -844,7 +866,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.109", ] [[package]] @@ -861,7 +883,7 @@ checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -884,7 +906,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -895,7 +917,7 @@ checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -915,7 +937,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -944,15 +966,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs" version = "4.0.0" @@ -1046,7 +1059,7 @@ checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1067,7 +1080,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1213,7 +1226,7 @@ checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1748,7 +1761,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1837,7 +1850,6 @@ name = "nargo" version = "0.5.1" dependencies = [ "acvm", - "iter-extended", "noirc_abi", "noirc_driver", "rustc_version", @@ -1859,7 +1871,7 @@ dependencies = [ "clap", "color-eyre", "const_format", - "dirs 4.0.0", + "dirs", "hex", "iter-extended", "nargo", @@ -1873,6 +1885,7 @@ dependencies = [ "tempdir", "termcolor", "thiserror", + "tokio", "toml", "url", ] @@ -2184,7 +2197,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -2234,7 +2247,7 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2509,7 +2522,7 @@ checksum = "ff26ed6c7c4dfc2aa9480b86a60e3c7233543a270a680e10758a507c5a4ce476" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2555,7 +2568,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn", + "syn 1.0.109", "walkdir", ] @@ -2760,7 +2773,7 @@ checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2844,7 +2857,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" dependencies = [ - "dirs 4.0.0", + "dirs", ] [[package]] @@ -2959,7 +2972,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -2979,6 +2992,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -2987,7 +3011,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -3052,7 +3076,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3193,7 +3217,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3366,7 +3390,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -3400,7 +3424,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3531,7 +3555,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3938,6 +3962,6 @@ checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 4563a629043..4f56b550cae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,5 +52,5 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "bbd9ab7ca5be3fb31f3e141fee2522704852f5de" } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "4f622b58144330ebc53d8458bd9e456a8efb147c" } +acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "44604f872126602787e38794026d86345380f2bb" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "5647a7f329865ec4c12e468f40d6cdb38fb921a2" } diff --git a/crates/nargo/Cargo.toml b/crates/nargo/Cargo.toml index 8d3c9fbd3cd..77c881835dc 100644 --- a/crates/nargo/Cargo.toml +++ b/crates/nargo/Cargo.toml @@ -14,7 +14,6 @@ rustc_version = "0.4.0" acvm.workspace = true noirc_abi.workspace = true noirc_driver.workspace = true -iter-extended.workspace = true toml.workspace = true serde.workspace = true thiserror.workspace = true diff --git a/crates/nargo/src/ops/codegen_verifier.rs b/crates/nargo/src/ops/codegen_verifier.rs index 2a0b54df865..4db3d53f7aa 100644 --- a/crates/nargo/src/ops/codegen_verifier.rs +++ b/crates/nargo/src/ops/codegen_verifier.rs @@ -2,7 +2,8 @@ use acvm::SmartContract; pub fn codegen_verifier( backend: &B, + common_reference_string: &[u8], verification_key: &[u8], ) -> Result { - backend.eth_contract_from_vk(verification_key) + backend.eth_contract_from_vk(common_reference_string, verification_key) } diff --git a/crates/nargo/src/ops/mod.rs b/crates/nargo/src/ops/mod.rs index 5d1f096ecf4..8a0cce4b8c5 100644 --- a/crates/nargo/src/ops/mod.rs +++ b/crates/nargo/src/ops/mod.rs @@ -1,6 +1,6 @@ pub use self::codegen_verifier::codegen_verifier; pub use self::execute::execute_circuit; -pub use self::preprocess::{preprocess_contract, preprocess_program}; +pub use self::preprocess::{preprocess_contract_function, preprocess_program}; pub use self::prove::prove_execution; pub use self::verify::verify_proof; diff --git a/crates/nargo/src/ops/preprocess.rs b/crates/nargo/src/ops/preprocess.rs index 3be8151f9c9..f2c3629e701 100644 --- a/crates/nargo/src/ops/preprocess.rs +++ b/crates/nargo/src/ops/preprocess.rs @@ -1,23 +1,21 @@ use acvm::ProofSystemCompiler; -use iter_extended::try_vecmap; -use noirc_driver::{CompiledContract, CompiledProgram}; +use noirc_driver::{CompiledProgram, ContractFunction}; -use crate::artifacts::{ - contract::{PreprocessedContract, PreprocessedContractFunction}, - program::PreprocessedProgram, -}; +use crate::artifacts::{contract::PreprocessedContractFunction, program::PreprocessedProgram}; // TODO: pull this from backend. const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg"; pub fn preprocess_program( backend: &B, + common_reference_string: &[u8], compiled_program: CompiledProgram, ) -> Result { // TODO: currently `compiled_program`'s bytecode is already optimized for the backend. // In future we'll need to apply those optimizations here. let optimized_bytecode = compiled_program.circuit; - let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?; + let (proving_key, verification_key) = + backend.preprocess(common_reference_string, &optimized_bytecode)?; Ok(PreprocessedProgram { backend: String::from(BACKEND_IDENTIFIER), @@ -28,30 +26,24 @@ pub fn preprocess_program( }) } -pub fn preprocess_contract( +pub fn preprocess_contract_function( backend: &B, - compiled_contract: CompiledContract, -) -> Result { - let preprocessed_contract_functions = try_vecmap(compiled_contract.functions, |func| { - // TODO: currently `func`'s bytecode is already optimized for the backend. - // In future we'll need to apply those optimizations here. - let optimized_bytecode = func.bytecode; - let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?; - - Ok(PreprocessedContractFunction { - name: func.name, - function_type: func.function_type, - abi: func.abi, + common_reference_string: &[u8], + func: ContractFunction, +) -> Result { + // TODO: currently `func`'s bytecode is already optimized for the backend. + // In future we'll need to apply those optimizations here. + let optimized_bytecode = func.bytecode; + let (proving_key, verification_key) = + backend.preprocess(common_reference_string, &optimized_bytecode)?; - bytecode: optimized_bytecode, - proving_key, - verification_key, - }) - })?; + Ok(PreprocessedContractFunction { + name: func.name, + function_type: func.function_type, + abi: func.abi, - Ok(PreprocessedContract { - name: compiled_contract.name, - backend: String::from(BACKEND_IDENTIFIER), - functions: preprocessed_contract_functions, + bytecode: optimized_bytecode, + proving_key, + verification_key, }) } diff --git a/crates/nargo/src/ops/prove.rs b/crates/nargo/src/ops/prove.rs index 523b2ed5ed4..e2c70739a35 100644 --- a/crates/nargo/src/ops/prove.rs +++ b/crates/nargo/src/ops/prove.rs @@ -3,9 +3,10 @@ use acvm::ProofSystemCompiler; pub fn prove_execution( backend: &B, + common_reference_string: &[u8], circuit: &Circuit, solved_witness: WitnessMap, proving_key: &[u8], ) -> Result, B::Error> { - backend.prove_with_pk(circuit, solved_witness, proving_key) + backend.prove_with_pk(common_reference_string, circuit, solved_witness, proving_key) } diff --git a/crates/nargo/src/ops/verify.rs b/crates/nargo/src/ops/verify.rs index f2145e3cf87..1d2d3bbbd6f 100644 --- a/crates/nargo/src/ops/verify.rs +++ b/crates/nargo/src/ops/verify.rs @@ -3,10 +3,11 @@ use acvm::ProofSystemCompiler; pub fn verify_proof( backend: &B, + common_reference_string: &[u8], circuit: &Circuit, proof: &[u8], public_inputs: WitnessMap, verification_key: &[u8], ) -> Result { - backend.verify_with_vk(proof, public_inputs, circuit, verification_key) + backend.verify_with_vk(common_reference_string, proof, public_inputs, circuit, verification_key) } diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 74db54c8ef7..4b0c96e0eb9 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -35,6 +35,7 @@ hex = "0.4.2" serde_json = "1.0" termcolor = "1.1.2" color-eyre = "0.6.2" +tokio = "1.0" # Backends acvm-backend-barretenberg = { version = "0.1.2", default-features = false } diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index d38433e2d1c..5f7358d6c2c 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -1,4 +1,7 @@ -use super::fs::{create_named_dir, program::read_program_from_file, write_to_file}; +use super::fs::{ + common_reference_string::get_common_reference_string, create_named_dir, + program::read_program_from_file, write_to_file, +}; use super::NargoConfig; use crate::{ cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, constants::TARGET_DIR, @@ -29,18 +32,27 @@ pub(crate) fn run( .circuit_name .map(|circuit_name| config.program_dir.join(TARGET_DIR).join(circuit_name)); - let preprocessed_program = match circuit_build_path { - Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, + let (common_reference_string, preprocessed_program) = match circuit_build_path { + Some(circuit_build_path) => { + let program = read_program_from_file(circuit_build_path)?; + let common_reference_string = get_common_reference_string(backend, &program.bytecode) + .map_err(CliError::CommonReferenceStringError)?; + (common_reference_string, program) + } None => { - let compiled_program = + let program = compile_circuit(backend, config.program_dir.as_ref(), &args.compile_options)?; - preprocess_program(backend, compiled_program) - .map_err(CliError::ProofSystemCompilerError)? + let common_reference_string = get_common_reference_string(backend, &program.circuit) + .map_err(CliError::CommonReferenceStringError)?; + let program = preprocess_program(backend, &common_reference_string, program) + .map_err(CliError::ProofSystemCompilerError)?; + (common_reference_string, program) } }; - let smart_contract_string = codegen_verifier(backend, &preprocessed_program.verification_key) - .map_err(CliError::SmartContractError)?; + let smart_contract_string = + codegen_verifier(backend, &common_reference_string, &preprocessed_program.verification_key) + .map_err(CliError::SmartContractError)?; let contract_dir = config.program_dir.join(CONTRACT_DIR); create_named_dir(&contract_dir, "contract"); diff --git a/crates/nargo_cli/src/cli/compile_cmd.rs b/crates/nargo_cli/src/cli/compile_cmd.rs index 531560b87db..04d44057ee4 100644 --- a/crates/nargo_cli/src/cli/compile_cmd.rs +++ b/crates/nargo_cli/src/cli/compile_cmd.rs @@ -1,18 +1,25 @@ use acvm::Backend; use iter_extended::try_vecmap; +use nargo::artifacts::contract::PreprocessedContract; use noirc_driver::{CompileOptions, CompiledProgram, Driver}; use std::path::Path; use clap::Args; -use nargo::ops::{preprocess_contract, preprocess_program}; +use nargo::ops::{preprocess_contract_function, preprocess_program}; use crate::resolver::DependencyResolutionError; use crate::{constants::TARGET_DIR, errors::CliError, resolver::Resolver}; -use super::fs::program::{save_contract_to_file, save_program_to_file}; +use super::fs::{ + common_reference_string::get_common_reference_string, + program::{save_contract_to_file, save_program_to_file}, +}; use super::NargoConfig; +// TODO: pull this from backend. +const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg"; + /// Compile the program and its secret execution trace into ACIR format #[derive(Debug, Clone, Args)] pub(crate) struct CompileCommand { @@ -40,10 +47,27 @@ pub(crate) fn run( let compiled_contracts = driver .compile_contracts(&args.compile_options) .map_err(|_| CliError::CompilationError)?; - let preprocessed_contracts = try_vecmap(compiled_contracts, |contract| { - preprocess_contract(backend, contract).map_err(CliError::ProofSystemCompilerError) - })?; - for contract in preprocessed_contracts { + // TODO: I wonder if it is incorrect for nargo-core to know anything about contracts. + // As can be seen here, It seems like a leaky abstraction where ContractFunctions (essentially CompiledPrograms) + // are compiled via nargo-core and then the PreprocessedContract is constructed here. + // This is due to EACH function needing it's own CRS, PKey, and VKey from the backend. + let preprocessed_contracts: Result, CliError> = + try_vecmap(compiled_contracts, |contract| { + let preprocessed_contract_functions = try_vecmap(contract.functions, |func| { + let common_reference_string = + get_common_reference_string(backend, &func.bytecode) + .map_err(CliError::CommonReferenceStringError)?; + preprocess_contract_function(backend, &common_reference_string, func) + .map_err(CliError::ProofSystemCompilerError) + })?; + + Ok(PreprocessedContract { + name: contract.name, + backend: String::from(BACKEND_IDENTIFIER), + functions: preprocessed_contract_functions, + }) + }); + for contract in preprocessed_contracts? { save_contract_to_file( &contract, &format!("{}-{}", &args.circuit_name, contract.name), @@ -52,8 +76,10 @@ pub(crate) fn run( } } else { let program = compile_circuit(backend, &config.program_dir, &args.compile_options)?; - let preprocessed_program = - preprocess_program(backend, program).map_err(CliError::ProofSystemCompilerError)?; + let common_reference_string = get_common_reference_string(backend, &program.circuit) + .map_err(CliError::CommonReferenceStringError)?; + let preprocessed_program = preprocess_program(backend, &common_reference_string, program) + .map_err(CliError::ProofSystemCompilerError)?; save_program_to_file(&preprocessed_program, &args.circuit_name, circuit_dir); } Ok(()) diff --git a/crates/nargo_cli/src/cli/fs/common_reference_string.rs b/crates/nargo_cli/src/cli/fs/common_reference_string.rs new file mode 100644 index 00000000000..b6fa1a28349 --- /dev/null +++ b/crates/nargo_cli/src/cli/fs/common_reference_string.rs @@ -0,0 +1,42 @@ +use std::{env, path::PathBuf}; + +use acvm::{acir::circuit::Circuit, CommonReferenceString}; + +use super::{create_named_dir, write_to_file}; + +// TODO: pull this from backend. +const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg"; +const TRANSCRIPT_NAME: &str = "common-reference-string.bin"; + +fn common_reference_string_location() -> PathBuf { + let cache_dir = match env::var("BACKEND_CACHE_DIR") { + Ok(cache_dir) => PathBuf::from(cache_dir), + Err(_) => dirs::home_dir().unwrap().join(".nargo").join("backends"), + }; + cache_dir.join(BACKEND_IDENTIFIER).join(TRANSCRIPT_NAME) +} + +pub(crate) fn get_common_reference_string( + backend: &Backend, + circuit: &Circuit, +) -> Result, Backend::Error> { + use tokio::runtime::Builder; + + let crs_path = common_reference_string_location(); + + let runtime = Builder::new_current_thread().enable_all().build().unwrap(); + + // TODO: Implement retries + let crs = match std::fs::read(&crs_path) { + // If the read data is empty, we don't have a CRS and need to generate one + Ok(common_reference_string) if !common_reference_string.is_empty() => runtime + .block_on(backend.update_common_reference_string(common_reference_string, circuit))?, + Ok(_) | Err(_) => runtime.block_on(backend.generate_common_reference_string(circuit))?, + }; + + create_named_dir(crs_path.parent().unwrap(), "crs"); + + write_to_file(crs.as_slice(), &crs_path); + + Ok(crs) +} diff --git a/crates/nargo_cli/src/cli/fs/mod.rs b/crates/nargo_cli/src/cli/fs/mod.rs index 4ebce3b3325..73229e0476c 100644 --- a/crates/nargo_cli/src/cli/fs/mod.rs +++ b/crates/nargo_cli/src/cli/fs/mod.rs @@ -6,6 +6,7 @@ use std::{ use crate::errors::FilesystemError; +pub(super) mod common_reference_string; pub(super) mod inputs; pub(super) mod program; pub(super) mod proof; diff --git a/crates/nargo_cli/src/cli/prove_cmd.rs b/crates/nargo_cli/src/cli/prove_cmd.rs index d2adc8d4af1..7589dd4bba3 100644 --- a/crates/nargo_cli/src/cli/prove_cmd.rs +++ b/crates/nargo_cli/src/cli/prove_cmd.rs @@ -11,6 +11,7 @@ use super::NargoConfig; use super::{ compile_cmd::compile_circuit, fs::{ + common_reference_string::get_common_reference_string, inputs::{read_inputs_from_file, write_inputs_to_file}, program::read_program_from_file, proof::save_proof_to_dir, @@ -72,12 +73,20 @@ pub(crate) fn prove_with_path>( check_proof: bool, compile_options: &CompileOptions, ) -> Result, CliError> { - let preprocessed_program = match circuit_build_path { - Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, + let (common_reference_string, preprocessed_program) = match circuit_build_path { + Some(circuit_build_path) => { + let program = read_program_from_file(circuit_build_path)?; + let common_reference_string = get_common_reference_string(backend, &program.bytecode) + .map_err(CliError::CommonReferenceStringError)?; + (common_reference_string, program) + } None => { - let compiled_program = compile_circuit(backend, program_dir.as_ref(), compile_options)?; - preprocess_program(backend, compiled_program) - .map_err(CliError::ProofSystemCompilerError)? + let program = compile_circuit(backend, program_dir.as_ref(), compile_options)?; + let common_reference_string = get_common_reference_string(backend, &program.circuit) + .map_err(CliError::CommonReferenceStringError)?; + let program = preprocess_program(backend, &common_reference_string, program) + .map_err(CliError::ProofSystemCompilerError)?; + (common_reference_string, program) } }; @@ -102,14 +111,21 @@ pub(crate) fn prove_with_path>( Format::Toml, )?; - let proof = prove_execution(backend, &bytecode, solved_witness, &proving_key) - .map_err(CliError::ProofSystemCompilerError)?; + let proof = + prove_execution(backend, &common_reference_string, &bytecode, solved_witness, &proving_key) + .map_err(CliError::ProofSystemCompilerError)?; if check_proof { let public_inputs = public_abi.encode(&public_inputs, return_value)?; - let valid_proof = - verify_proof(backend, &bytecode, &proof, public_inputs, &verification_key) - .map_err(CliError::ProofSystemCompilerError)?; + let valid_proof = verify_proof( + backend, + &common_reference_string, + &bytecode, + &proof, + public_inputs, + &verification_key, + ) + .map_err(CliError::ProofSystemCompilerError)?; if !valid_proof { return Err(CliError::InvalidProof("".into())); diff --git a/crates/nargo_cli/src/cli/verify_cmd.rs b/crates/nargo_cli/src/cli/verify_cmd.rs index 07ba12d3899..62333ff0bdf 100644 --- a/crates/nargo_cli/src/cli/verify_cmd.rs +++ b/crates/nargo_cli/src/cli/verify_cmd.rs @@ -1,5 +1,8 @@ use super::compile_cmd::compile_circuit; -use super::fs::{inputs::read_inputs_from_file, load_hex_data, program::read_program_from_file}; +use super::fs::{ + common_reference_string::get_common_reference_string, inputs::read_inputs_from_file, + load_hex_data, program::read_program_from_file, +}; use super::NargoConfig; use crate::{ constants::{PROOFS_DIR, PROOF_EXT, TARGET_DIR, VERIFIER_INPUT_FILE}, @@ -9,7 +12,7 @@ use crate::{ use acvm::Backend; use clap::Args; use nargo::artifacts::program::PreprocessedProgram; -use nargo::ops::preprocess_program; +use nargo::ops::{preprocess_program, verify_proof}; use noirc_abi::input_parser::Format; use noirc_driver::CompileOptions; use std::path::{Path, PathBuf}; @@ -44,7 +47,7 @@ pub(crate) fn run( &config.program_dir, proof_path, circuit_build_path.as_ref(), - args.compile_options, + &args.compile_options, ) } @@ -53,15 +56,22 @@ fn verify_with_path>( program_dir: P, proof_path: PathBuf, circuit_build_path: Option

, - compile_options: CompileOptions, + compile_options: &CompileOptions, ) -> Result<(), CliError> { - let preprocessed_program = match circuit_build_path { - Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, + let (common_reference_string, preprocessed_program) = match circuit_build_path { + Some(circuit_build_path) => { + let program = read_program_from_file(circuit_build_path)?; + let common_reference_string = get_common_reference_string(backend, &program.bytecode) + .map_err(CliError::CommonReferenceStringError)?; + (common_reference_string, program) + } None => { - let compiled_program = - compile_circuit(backend, program_dir.as_ref(), &compile_options)?; - preprocess_program(backend, compiled_program) - .map_err(CliError::ProofSystemCompilerError)? + let program = compile_circuit(backend, program_dir.as_ref(), compile_options)?; + let common_reference_string = get_common_reference_string(backend, &program.circuit) + .map_err(CliError::CommonReferenceStringError)?; + let program = preprocess_program(backend, &common_reference_string, program) + .map_err(CliError::ProofSystemCompilerError)?; + (common_reference_string, program) } }; @@ -75,9 +85,15 @@ fn verify_with_path>( let public_inputs = public_abi.encode(&public_inputs_map, return_value)?; let proof = load_hex_data(&proof_path)?; - let valid_proof = - nargo::ops::verify_proof(backend, &bytecode, &proof, public_inputs, &verification_key) - .map_err(CliError::ProofSystemCompilerError)?; + let valid_proof = verify_proof( + backend, + &common_reference_string, + &bytecode, + &proof, + public_inputs, + &verification_key, + ) + .map_err(CliError::ProofSystemCompilerError)?; if valid_proof { Ok(()) diff --git a/crates/nargo_cli/src/errors.rs b/crates/nargo_cli/src/errors.rs index 94772b578b4..02bc5b031a9 100644 --- a/crates/nargo_cli/src/errors.rs +++ b/crates/nargo_cli/src/errors.rs @@ -1,4 +1,7 @@ -use acvm::{acir::native_types::WitnessMapError, Backend, ProofSystemCompiler, SmartContract}; +use acvm::{ + acir::native_types::WitnessMapError, Backend, CommonReferenceString, ProofSystemCompiler, + SmartContract, +}; use hex::FromHexError; use nargo::NargoError; use noirc_abi::errors::{AbiError, InputParserError}; @@ -63,4 +66,8 @@ pub(crate) enum CliError { /// Backend error caused by a function on the ProofSystemCompiler trait #[error(transparent)] ProofSystemCompilerError(::Error), // Unfortunately, Rust won't let us `impl From` over an Associated Type on a generic + + /// Backend error caused by a function on the CommonReferenceString trait + #[error(transparent)] + CommonReferenceStringError(::Error), // Unfortunately, Rust won't let us `impl From` over an Associated Type on a generic } diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index a2fbed21885..bff5a7d6943 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -5,7 +5,6 @@ use acvm::Language; use clap::Args; -use contract::ContractFunction; use fm::FileType; use iter_extended::try_vecmap; use noirc_abi::FunctionSignature; @@ -22,7 +21,7 @@ use std::path::{Path, PathBuf}; mod contract; mod program; -pub use contract::{CompiledContract, ContractFunctionType}; +pub use contract::{CompiledContract, ContractFunction, ContractFunctionType}; pub use program::CompiledProgram; pub struct Driver { diff --git a/flake.nix b/flake.nix index 7109e266e0f..d5df9c4b122 100644 --- a/flake.nix +++ b/flake.nix @@ -84,10 +84,6 @@ # We set the environment variable because barretenberg must be compiled in a special way for wasm BARRETENBERG_BIN_DIR = "${pkgs.barretenberg-wasm}/bin"; - - # We provide `barretenberg-transcript00` from the overlay to the build. - # This is necessary because the Nix sandbox disables the $HOME so downloading during tests would fail - BARRETENBERG_TRANSCRIPT = pkgs.barretenberg-transcript00; }; # The `self.rev` property is only available when the working tree is not dirty @@ -138,6 +134,31 @@ inherit GIT_DIRTY; }; + # The `port` is parameterized to support parallel test runs without colliding static servers + testArgs = port: { + # We provide `barretenberg-transcript00` from the overlay to the tests as a URL hosted via a static server + # This is necessary because the Nix sandbox has no network access and downloading during tests would fail + TRANSCRIPT_URL = "http://0.0.0.0:${toString port}/${builtins.baseNameOf pkgs.barretenberg-transcript00}"; + + # This copies the `barretenberg-transcript00` from the Nix store into this sandbox + # which avoids exposing the entire Nix store to the static server it starts + # The static server is moved to the background and killed after checks are completed + # + # We also set the BACKEND_CACHE_DIR environment variable to the $TMP directory so we can successfully cache + # the transcript; which isn't possible with the default path because the Nix sandbox disabled $HOME + preCheck = '' + export BACKEND_CACHE_DIR=$TMP + cp ${pkgs.barretenberg-transcript00} . + echo "Starting simple static server" + ${pkgs.simple-http-server}/bin/simple-http-server --port ${toString port} --silent & + HTTP_SERVER_PID=$! + ''; + + postCheck = '' + kill $HTTP_SERVER_PID + ''; + }; + # Build *just* the cargo dependencies, so we can reuse all of that work between runs cargoArtifacts = craneLib.buildDepsOnly commonArgs; @@ -152,16 +173,15 @@ # TODO(#1198): It'd be nice to include these flags when running `cargo clippy` in a devShell. cargoClippyExtraArgs = "--all-targets -- -D warnings"; - - doCheck = true; }); - cargo-test = craneLib.cargoTest (commonArgs // { + cargo-test = craneLib.cargoTest (commonArgs // (testArgs 8000) // { inherit cargoArtifacts; # TODO(#1198): It'd be nice to include this flag when running `cargo test` in a devShell. cargoTestExtraArgs = "--workspace"; + # It's unclear why doCheck needs to be enabled for tests to run but not clippy doCheck = true; }); }; From b6b2c6c89c29d59b6a29c6ad470b450d73589110 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 16 May 2023 08:55:38 -0700 Subject: [PATCH 10/16] update references --- Cargo.lock | 10 +++++----- Cargo.toml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aeaa9e45f96..3ce02ca2667 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" +source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" dependencies = [ "acir_field", "flate2", @@ -17,7 +17,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" +source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" dependencies = [ "ark-bn254", "ark-ff", @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" +source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" dependencies = [ "acir", "acvm_stdlib", @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=5647a7f329865ec4c12e468f40d6cdb38fb921a2#5647a7f329865ec4c12e468f40d6cdb38fb921a2" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=04c9d0f6b5e0f3625fd7d1e2bb5bacb020ae279d#04c9d0f6b5e0f3625fd7d1e2bb5bacb020ae279d" dependencies = [ "acvm", "barretenberg-sys", @@ -69,7 +69,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=44604f872126602787e38794026d86345380f2bb#44604f872126602787e38794026d86345380f2bb" +source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" dependencies = [ "acir", ] diff --git a/Cargo.toml b/Cargo.toml index 4f56b550cae..94754c65b8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,5 +52,5 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "44604f872126602787e38794026d86345380f2bb" } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "5647a7f329865ec4c12e468f40d6cdb38fb921a2" } +acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "eeddcf179880f246383f7f67a11e589269c4e3ff" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "04c9d0f6b5e0f3625fd7d1e2bb5bacb020ae279d" } From 7439e399778dea719d6d8c975fd3f3327166412a Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 17 May 2023 08:34:50 -0700 Subject: [PATCH 11/16] code review --- crates/nargo_cli/src/cli/fs/common_reference_string.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/nargo_cli/src/cli/fs/common_reference_string.rs b/crates/nargo_cli/src/cli/fs/common_reference_string.rs index b6fa1a28349..a8bfdb50ec1 100644 --- a/crates/nargo_cli/src/cli/fs/common_reference_string.rs +++ b/crates/nargo_cli/src/cli/fs/common_reference_string.rs @@ -16,10 +16,10 @@ fn common_reference_string_location() -> PathBuf { cache_dir.join(BACKEND_IDENTIFIER).join(TRANSCRIPT_NAME) } -pub(crate) fn get_common_reference_string( - backend: &Backend, +pub(crate) fn get_common_reference_string( + backend: &B, circuit: &Circuit, -) -> Result, Backend::Error> { +) -> Result, B::Error> { use tokio::runtime::Builder; let crs_path = common_reference_string_location(); From cb05ac222eb220cc95e4ac7e86bea8014832b1ba Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 17 May 2023 20:34:15 -0400 Subject: [PATCH 12/16] remove usage of IsOpcodeSupported --- Cargo.lock | 876 +++++++++++---------- Cargo.toml | 5 +- crates/noirc_evaluator/src/lib.rs | 4 +- crates/noirc_evaluator/src/ssa_refactor.rs | 4 +- 4 files changed, 469 insertions(+), 420 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ce02ca2667..08feebcb777 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,8 +4,9 @@ version = 3 [[package]] name = "acir" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c831802bad8d6810bfdb57cd00913157dfe710a185dc360c9a94eecd043bbf12" dependencies = [ "acir_field", "flate2", @@ -16,8 +17,9 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d455746f51b4421548e42d34e2ce46b6db637cb048095d78766612d26bf526db" dependencies = [ "ark-bn254", "ark-ff", @@ -29,14 +31,14 @@ dependencies = [ [[package]] name = "acvm" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd8e75cf737b52195a8c109e0ee776e468e1c2ec42f0f88aa4465cd76a09b4ed" dependencies = [ "acir", "acvm_stdlib", "async-trait", "blake2", - "crc32fast", "indexmap", "k256", "num-bigint", @@ -49,15 +51,13 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=04c9d0f6b5e0f3625fd7d1e2bb5bacb020ae279d#04c9d0f6b5e0f3625fd7d1e2bb5bacb020ae279d" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=4358d3b9e8cd98d88a78dda3337e80e90668378e#4358d3b9e8cd98d88a78dda3337e80e90668378e" dependencies = [ "acvm", "barretenberg-sys", "bincode", - "bytes", - "futures-util", + "bytesize", "getrandom", - "indicatif", "pkg-config", "reqwest", "rust-embed", @@ -68,8 +68,9 @@ dependencies = [ [[package]] name = "acvm_stdlib" -version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=eeddcf179880f246383f7f67a11e589269c4e3ff#eeddcf179880f246383f7f67a11e589269c4e3ff" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2e87549b987593eeb1902990006443f2fe5817db927035f081008e4b8a46a49" dependencies = [ "acir", ] @@ -120,6 +121,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -129,11 +139,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] [[package]] name = "arena" @@ -155,9 +208,9 @@ dependencies = [ [[package]] name = "ark-ec" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c60370a92f8e1a5f053cad73a862e1b99bc642333cd676fa11c0c39f80f4ac2" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ "ark-ff", "ark-poly", @@ -172,9 +225,9 @@ dependencies = [ [[package]] name = "ark-ff" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2d42532524bee1da5a4f6f733eb4907301baa480829557adcff5dfaeee1d9a" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" dependencies = [ "ark-ff-asm", "ark-ff-macros", @@ -192,9 +245,9 @@ dependencies = [ [[package]] name = "ark-ff-asm" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6873aaba7959593d89babed381d33e2329453368f1bf3c67e07686a1c1056f" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ "quote", "syn 1.0.109", @@ -202,9 +255,9 @@ dependencies = [ [[package]] name = "ark-ff-macros" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c2e7d0f2d67cc7fc925355c74d36e7eda19073639be4a0a233d4611b8c959d" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", "num-traits", @@ -215,9 +268,9 @@ dependencies = [ [[package]] name = "ark-poly" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6ec811462cabe265cfe1b102fcfe3df79d7d2929c2425673648ee9abfd0272" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" dependencies = [ "ark-ff", "ark-serialize", @@ -228,9 +281,9 @@ dependencies = [ [[package]] name = "ark-serialize" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e735959bc173ea4baf13327b19c22d452b8e9e8e8f7b7fc34e6bf0e316c33e" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-serialize-derive", "ark-std", @@ -240,9 +293,9 @@ dependencies = [ [[package]] name = "ark-serialize-derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd34f0920d995d2c932f38861c416f70de89a6de9875876b012557079603e6cc" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ "proc-macro2", "quote", @@ -261,14 +314,14 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b2340f55d9661d76793b2bfc2eb0e62689bd79d067a95707ea762afd5e9dd" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ "anstyle", "bstr", "doc-comment", - "predicates 3.0.2", + "predicates 3.0.3", "predicates-core", "predicates-tree", "wait-timeout", @@ -276,14 +329,14 @@ dependencies = [ [[package]] name = "assert_fs" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d5bf7e5441c6393b5a9670a5036abe6b4847612f594b870f7332dbf10cf6fa" +checksum = "f070617a68e5c2ed5d06ee8dd620ee18fb72b99f6c094bed34cf8ab07c875b48" dependencies = [ "anstyle", "doc-comment", "globwalk", - "predicates 3.0.2", + "predicates 3.0.3", "predicates-core", "predicates-tree", "tempfile", @@ -297,7 +350,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.12", + "syn 2.0.16", ] [[package]] @@ -316,16 +369,16 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide", + "miniz_oxide 0.6.2", "object 0.30.3", "rustc-demangle", ] [[package]] name = "barretenberg-sys" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc96e40cc45e7d5622cbc57a140aee926a7fb6e4f7d07dda758daa9256f3317" +checksum = "8083873c06ad0d80fa3a3fe72e465da0d89cd5ed92c8a0e75d765dc5eeafe8e0" dependencies = [ "bindgen", "cc", @@ -384,9 +437,21 @@ version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "funty", - "radium", - "wyz", + "funty 1.1.0", + "radium 0.3.0", + "wyz 0.2.0", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty 2.0.0", + "radium 0.7.0", + "tap", + "wyz 0.5.1", ] [[package]] @@ -430,9 +495,9 @@ dependencies = [ [[package]] name = "build-data" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a94f9f7aab679acac7ce29ba5581c00d3971a861c3b501c5bb74c3ba0026d90" +checksum = "4ac83c47416b2db78a5a8a45d7d229a730b62806fa41ac6b4dbde6d016798776" dependencies = [ "chrono", "safe-lock", @@ -441,15 +506,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "bytecheck" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -458,9 +523,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" dependencies = [ "proc-macro2", "quote", @@ -479,6 +544,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[package]] +name = "bytesize" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" + [[package]] name = "cc" version = "1.0.79" @@ -532,9 +603,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -543,40 +614,45 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.8" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ - "bitflags", + "clap_builder", "clap_derive", - "clap_lex", - "is-terminal", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", "strsim", - "termcolor", ] [[package]] name = "clap_derive" -version = "4.1.8" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] name = "clap_lex" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "codespan" @@ -584,7 +660,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ebaf6bb6a863ad6aa3a18729e9710c53d75df03306714d9cc1f7357a00cd789" dependencies = [ - "codespan-reporting 0.9.5", + "codespan-reporting", ] [[package]] @@ -597,16 +673,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "color-eyre" version = "0.6.2" @@ -635,17 +701,10 @@ dependencies = [ ] [[package]] -name = "console" -version = "0.15.5" +name = "colorchoice" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "unicode-width", - "windows-sys 0.42.0", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "console_error_panic_hook" @@ -685,9 +744,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "corosensei" @@ -704,9 +763,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -781,9 +840,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -842,55 +901,11 @@ dependencies = [ "subtle", ] -[[package]] -name = "cxx" -version = "1.0.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" -dependencies = [ - "cc", - "codespan-reporting 0.11.1", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 1.0.109", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", @@ -898,26 +913,26 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] name = "darling_macro" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] @@ -1015,10 +1030,10 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "bitvec", + "bitvec 0.18.5", "digest 0.9.0", "ff", - "funty", + "funty 1.1.0", "generic-array", "group", "pkcs8", @@ -1027,12 +1042,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "encoding_rs" version = "0.8.32" @@ -1064,34 +1073,34 @@ dependencies = [ [[package]] name = "enumset" -version = "1.0.12" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" +checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" +checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ "darling", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1135,19 +1144,19 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "bitvec", + "bitvec 0.18.5", "rand_core 0.5.1", "subtle", ] [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -1164,7 +1173,7 @@ name = "fm" version = "0.5.1" dependencies = [ "cfg-if 1.0.0", - "codespan-reporting 0.9.5", + "codespan-reporting", "rust-embed", "tempfile", "wasm-bindgen", @@ -1197,65 +1206,49 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" - -[[package]] -name = "futures-io" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" - -[[package]] -name = "futures-macro" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", - "futures-io", - "futures-macro", - "futures-sink", "futures-task", - "memchr", "pin-project-lite", "pin-utils", - "slab", ] [[package]] @@ -1269,9 +1262,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1279,9 +1272,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1317,7 +1310,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -1361,9 +1354,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -1478,9 +1471,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.25" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1502,9 +1495,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ "http", "hyper", @@ -1515,26 +1508,25 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -1578,27 +1570,15 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", "serde", ] -[[package]] -name = "indicatif" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729" -dependencies = [ - "console", - "number_prefix", - "portable-atomic", - "unicode-width", -] - [[package]] name = "instant" version = "0.1.12" @@ -1610,30 +1590,31 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1657,9 +1638,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -1705,9 +1686,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libloading" @@ -1730,9 +1711,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "log" @@ -1808,9 +1789,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minimal-lexical" @@ -1827,6 +1808,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.6" @@ -1941,7 +1931,7 @@ version = "0.5.1" dependencies = [ "chumsky", "codespan", - "codespan-reporting 0.9.5", + "codespan-reporting", "fm", "serde", ] @@ -2038,12 +2028,6 @@ dependencies = [ "libc", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "object" version = "0.28.4" @@ -2077,12 +2061,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "owo-colors" version = "3.5.0" @@ -2130,15 +2108,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - -[[package]] -name = "portable-atomic" -version = "0.3.19" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "ppv-lite86" @@ -2162,9 +2134,9 @@ dependencies = [ [[package]] name = "predicates" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c575290b64d24745b6c57a12a31465f0a66f3a4799686a6921526a33b0797965" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" dependencies = [ "anstyle", "difflib", @@ -2214,9 +2186,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" dependencies = [ "unicode-ident", ] @@ -2252,9 +2224,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -2265,6 +2237,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.4.6" @@ -2369,6 +2347,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -2376,7 +2363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] @@ -2393,11 +2380,11 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", "regex-syntax", ] @@ -2410,9 +2397,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "region" @@ -2446,9 +2433,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.16" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "base64", "bytes", @@ -2474,12 +2461,10 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-rustls", - "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", "web-sys", "webpki-roots", "winreg", @@ -2502,23 +2487,26 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.40" +version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c30f1d45d9aa61cbc8cd1eb87705470892289bb2d01943e7803b873a57404dc3" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" dependencies = [ + "bitvec 1.0.1", "bytecheck", "hashbrown 0.12.3", "ptr_meta", "rend", "rkyv_derive", "seahash", + "tinyvec", + "uuid", ] [[package]] name = "rkyv_derive" -version = "0.7.40" +version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff26ed6c7c4dfc2aa9480b86a60e3c7233543a270a680e10758a507c5a4ce476" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" dependencies = [ "proc-macro2", "quote", @@ -2549,9 +2537,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "6.6.0" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb133b9a38b5543fad3807fb2028ea47c5f2b566f4f5e28a11902f1a358348b6" +checksum = "1b68543d5527e158213414a92832d2aab11a84d2571a5eb021ebe22c43aab066" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -2585,9 +2573,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -2606,28 +2594,28 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.9" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" dependencies = [ "log", "ring", + "rustls-webpki", "sct", - "webpki", ] [[package]] @@ -2639,6 +2627,16 @@ dependencies = [ "base64", ] +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -2719,12 +2717,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - [[package]] name = "sct" version = "0.7.0" @@ -2749,9 +2741,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.155" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] @@ -2767,20 +2759,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.155" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -2994,9 +2986,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.12" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ "proc-macro2", "quote", @@ -3004,22 +2996,16 @@ dependencies = [ ] [[package]] -name = "synstructure" -version = "0.12.6" +name = "tap" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempdir" @@ -3033,15 +3019,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if 1.0.0", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -3061,22 +3047,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] @@ -3117,36 +3103,34 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.26.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "pin-project-lite", "socket2", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" dependencies = [ "rustls", "tokio", - "webpki", ] [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -3179,9 +3163,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.6" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08de71aa0d6e348f070457f85af8bd566e2bc452156a423ddf22861b3a953fae" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", "serde", @@ -3211,20 +3195,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -3242,9 +3226,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" dependencies = [ "sharded-slab", "thread_local", @@ -3265,9 +3249,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-bidi" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -3313,6 +3297,18 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" + [[package]] name = "valuable" version = "0.1.0" @@ -3336,12 +3332,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -3369,9 +3364,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3381,24 +3376,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3408,9 +3403,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3418,28 +3413,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-encoder" -version = "0.25.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +checksum = "e77053dc709db790691d3732cfc458adc5acc881dec524965c608effdcd9c581" dependencies = [ "leb128", ] @@ -3455,19 +3450,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasm-streams" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wasmer" version = "2.3.0" @@ -3707,9 +3689,9 @@ checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wast" -version = "55.0.0" +version = "58.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4984d3e1406571f4930ba5cf79bd70f75f41d0e87e17506e0bd19b0e5d085f05" +checksum = "372eecae2d10a5091c2005b32377d7ecd6feecdf2c05838056d02d8b4f07c429" dependencies = [ "leb128", "memchr", @@ -3719,18 +3701,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2b53f4da14db05d32e70e9c617abdf6620c575bd5dd972b7400037b4df2091" +checksum = "6d47446190e112ab1579ab40b3ad7e319d859d74e5134683f04e9f0747bf4173" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -3797,6 +3779,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.33.0" @@ -3812,26 +3803,20 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.42.2", ] [[package]] name = "windows-sys" -version = "0.45.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", ] [[package]] @@ -3840,21 +3825,42 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.2", "windows_aarch64_msvc 0.42.2", "windows_i686_gnu 0.42.2", "windows_i686_msvc 0.42.2", "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.2", "windows_x86_64_msvc 0.42.2", ] +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" @@ -3867,6 +3873,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.33.0" @@ -3879,6 +3891,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.33.0" @@ -3891,6 +3909,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.33.0" @@ -3903,12 +3927,24 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.33.0" @@ -3921,11 +3957,17 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winnow" -version = "0.3.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee7b2c67f962bf5042bfd8b6a916178df33a26eec343ae064cb8e069f638fa6f" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] @@ -3945,23 +3987,31 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", - "synstructure", + "syn 2.0.16", ] diff --git a/Cargo.toml b/Cargo.toml index 94754c65b8e..b022df63dd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.11.0" +acvm = "0.12.0" arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } @@ -52,5 +52,4 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "eeddcf179880f246383f7f67a11e589269c4e3ff" } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "04c9d0f6b5e0f3625fd7d1e2bb5bacb020ae279d" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "4358d3b9e8cd98d88a78dda3337e80e90668378e" } diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 4c70e15bcb4..1cedca3ad7f 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -13,7 +13,7 @@ pub mod ssa_refactor; use acvm::{ acir::circuit::{opcodes::Opcode as AcirOpcode, Circuit, PublicInputs}, acir::native_types::{Expression, Witness}, - compiler::{optimizers::simplify::CircuitSimplifier, transformers::IsOpcodeSupported}, + compiler::{optimizers::simplify::CircuitSimplifier}, Language, }; use errors::{RuntimeError, RuntimeErrorKind}; @@ -66,7 +66,7 @@ pub struct Evaluator { pub fn create_circuit( program: Program, np_language: Language, - is_opcode_supported: IsOpcodeSupported, + is_opcode_supported: impl Fn(&AcirOpcode) -> bool, enable_logging: bool, show_output: bool, ) -> Result<(Circuit, Abi), RuntimeError> { diff --git a/crates/noirc_evaluator/src/ssa_refactor.rs b/crates/noirc_evaluator/src/ssa_refactor.rs index 34061227336..f0e466cdfde 100644 --- a/crates/noirc_evaluator/src/ssa_refactor.rs +++ b/crates/noirc_evaluator/src/ssa_refactor.rs @@ -8,7 +8,7 @@ #![allow(dead_code)] use crate::errors::RuntimeError; -use acvm::{acir::circuit::Circuit, compiler::transformers::IsOpcodeSupported, Language}; +use acvm::{acir::circuit::{Circuit, Opcode as AcirOpcode}, Language}; use noirc_abi::Abi; use noirc_frontend::monomorphization::ast::Program; @@ -33,7 +33,7 @@ pub fn optimize_into_acir(program: Program) -> Acir { pub fn experimental_create_circuit( _program: Program, _np_language: Language, - _is_opcode_supported: IsOpcodeSupported, + _is_opcode_supported: impl Fn(&AcirOpcode) -> bool, _enable_logging: bool, _show_output: bool, ) -> Result<(Circuit, Abi), RuntimeError> { From 6822b47c1d72931268c5b7b9654011e0d719b35d Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 17 May 2023 20:42:10 -0400 Subject: [PATCH 13/16] switch to using dyn --- crates/noirc_evaluator/src/lib.rs | 2 +- crates/noirc_evaluator/src/ssa_refactor.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 1cedca3ad7f..62775d9be9d 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -66,7 +66,7 @@ pub struct Evaluator { pub fn create_circuit( program: Program, np_language: Language, - is_opcode_supported: impl Fn(&AcirOpcode) -> bool, + is_opcode_supported: Box bool>, enable_logging: bool, show_output: bool, ) -> Result<(Circuit, Abi), RuntimeError> { diff --git a/crates/noirc_evaluator/src/ssa_refactor.rs b/crates/noirc_evaluator/src/ssa_refactor.rs index f0e466cdfde..911a5ae6837 100644 --- a/crates/noirc_evaluator/src/ssa_refactor.rs +++ b/crates/noirc_evaluator/src/ssa_refactor.rs @@ -33,7 +33,7 @@ pub fn optimize_into_acir(program: Program) -> Acir { pub fn experimental_create_circuit( _program: Program, _np_language: Language, - _is_opcode_supported: impl Fn(&AcirOpcode) -> bool, + _is_opcode_supported: Box bool>, _enable_logging: bool, _show_output: bool, ) -> Result<(Circuit, Abi), RuntimeError> { From 7e07bf9a0115e0adfeac73486ee610939afa57e0 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 17 May 2023 20:58:45 -0400 Subject: [PATCH 14/16] use Box new --- crates/noirc_driver/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index bff5a7d6943..bcf0e014822 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -261,7 +261,7 @@ impl Driver { experimental_create_circuit( program, np_language, - is_opcode_supported, + Box::new(is_opcode_supported), options.show_ssa, options.show_output, ) @@ -269,7 +269,7 @@ impl Driver { create_circuit( program, np_language, - is_opcode_supported, + Box::new(is_opcode_supported), options.show_ssa, options.show_output, ) From b5834c552ec685c8c6b478e830691a1ea362c4c8 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Thu, 18 May 2023 10:03:12 -0400 Subject: [PATCH 15/16] add verify_proof for PWG due to new acvm where necessary --- Cargo.lock | 140 +++++++++++++++--- Cargo.toml | 8 +- .../src/ssa/acir_gen/operations/sort.rs | 13 ++ crates/noirc_evaluator/src/ssa/builtin.rs | 4 +- noir_stdlib/src/lib.nr | 4 + 5 files changed, 144 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08feebcb777..ba03b234475 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,8 @@ version = 3 [[package]] name = "acir" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c831802bad8d6810bfdb57cd00913157dfe710a185dc360c9a94eecd043bbf12" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" dependencies = [ "acir_field", "flate2", @@ -17,9 +16,8 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d455746f51b4421548e42d34e2ce46b6db637cb048095d78766612d26bf526db" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" dependencies = [ "ark-bn254", "ark-ff", @@ -31,14 +29,14 @@ dependencies = [ [[package]] name = "acvm" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd8e75cf737b52195a8c109e0ee776e468e1c2ec42f0f88aa4465cd76a09b4ed" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" dependencies = [ "acir", "acvm_stdlib", "async-trait", "blake2", + "crc32fast", "indexmap", "k256", "num-bigint", @@ -51,13 +49,15 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=4358d3b9e8cd98d88a78dda3337e80e90668378e#4358d3b9e8cd98d88a78dda3337e80e90668378e" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=748cb0aa3d276c1b526cc9d04df50c4d51f64806#748cb0aa3d276c1b526cc9d04df50c4d51f64806" dependencies = [ "acvm", "barretenberg-sys", "bincode", - "bytesize", + "bytes", + "futures-util", "getrandom", + "indicatif", "pkg-config", "reqwest", "rust-embed", @@ -68,9 +68,8 @@ dependencies = [ [[package]] name = "acvm_stdlib" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e87549b987593eeb1902990006443f2fe5817db927035f081008e4b8a46a49" +version = "0.11.0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" dependencies = [ "acir", ] @@ -377,8 +376,7 @@ dependencies = [ [[package]] name = "barretenberg-sys" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8083873c06ad0d80fa3a3fe72e465da0d89cd5ed92c8a0e75d765dc5eeafe8e0" +source = "git+https://github.com/noir-lang/barretenberg-sys.git?branch=mv/recursion-bindings#49907db86cfe1268b88116297d6dcd249851c3ce" dependencies = [ "bindgen", "cc", @@ -544,12 +542,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -[[package]] -name = "bytesize" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" - [[package]] name = "cc" version = "1.0.79" @@ -706,6 +698,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "console" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.42.0", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -1042,6 +1047,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.32" @@ -1227,6 +1238,23 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.16", +] + [[package]] name = "futures-sink" version = "0.3.28" @@ -1246,9 +1274,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -1579,6 +1612,18 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729" +dependencies = [ + "console", + "number_prefix", + "portable-atomic 0.3.20", + "unicode-width", +] + [[package]] name = "instant" version = "0.1.12" @@ -2028,6 +2073,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.28.4" @@ -2112,6 +2163,21 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "portable-atomic" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e30165d31df606f5726b090ec7592c308a0eaf61721ff64c9a3018e344a8753e" +dependencies = [ + "portable-atomic 1.3.2", +] + +[[package]] +name = "portable-atomic" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc59d1bcc64fc5d021d67521f818db868368028108d37f0e98d74e33f68297b5" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2461,10 +2527,12 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-rustls", + "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots", "winreg", @@ -3450,6 +3518,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm-streams" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmer" version = "2.3.0" @@ -3801,6 +3882,21 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-sys" version = "0.45.0" diff --git a/Cargo.toml b/Cargo.toml index b022df63dd5..fc6bdf9d2f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,9 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.12.0" +# acvm = "0.12.0" +acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", branch = "mv/verify-proof-2" } + arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } @@ -52,4 +54,6 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "4358d3b9e8cd98d88a78dda3337e80e90668378e" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "748cb0aa3d276c1b526cc9d04df50c4d51f64806" } + +# acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "4358d3b9e8cd98d88a78dda3337e80e90668378e" } diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index ccea9caac4c..96cdb2f99cb 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -240,6 +240,19 @@ mod test { ) -> Result { panic!("Path not trodden by this test") } + fn verify_proof( + &self, + _initial_witness: &mut WitnessMap, + _key: &[FunctionInput], + _proof: &[FunctionInput], + _public_inputs: &[FunctionInput], + _key_hash: &FunctionInput, + _input_aggregation_object: &[FunctionInput], + _nested_aggregation_object: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } } // Check that a random network constrains its output to be a permutation of any random input diff --git a/crates/noirc_evaluator/src/ssa/builtin.rs b/crates/noirc_evaluator/src/ssa/builtin.rs index 4f3741583d8..97279317749 100644 --- a/crates/noirc_evaluator/src/ssa/builtin.rs +++ b/crates/noirc_evaluator/src/ssa/builtin.rs @@ -76,7 +76,8 @@ impl Opcode { | BlackBoxFunc::Keccak256 | BlackBoxFunc::Blake2s | BlackBoxFunc::Pedersen - | BlackBoxFunc::FixedBaseScalarMul => BigUint::zero(), + | BlackBoxFunc::FixedBaseScalarMul + | BlackBoxFunc::VerifyProof => BigUint::zero(), // Verify returns zero or one BlackBoxFunc::SchnorrVerify | BlackBoxFunc::EcdsaSecp256k1 => BigUint::one(), BlackBoxFunc::ComputeMerkleRoot | BlackBoxFunc::HashToField128Security => { @@ -115,6 +116,7 @@ impl Opcode { } BlackBoxFunc::Pedersen => (2, ObjectType::native_field()), BlackBoxFunc::FixedBaseScalarMul => (2, ObjectType::native_field()), + BlackBoxFunc::VerifyProof => (16, ObjectType::native_field()), BlackBoxFunc::RANGE | BlackBoxFunc::AND | BlackBoxFunc::XOR => { unreachable!("ICE: these opcodes do not have Noir builtin functions") } diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index f0af06b97ba..e3b4351610a 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -13,3 +13,7 @@ mod collections; #[builtin(println)] fn println(_input : T) {} + +// TODO: have the compiler insert the key_hash and remove as param +#[foreign(verify_proof)] +fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : Field, _key_hash : Field, _input_aggregation_object : [Field]) -> [Field] {} \ No newline at end of file From ab401372bfc50d906a334a12447ada4da4d80505 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Fri, 19 May 2023 13:55:13 -0400 Subject: [PATCH 16/16] add verify_proof builtin and double recursion test --- .gitignore | 1 + Cargo.lock | 47 +++---- Cargo.toml | 5 +- crates/nargo/src/ops/mod.rs | 2 + crates/nargo/src/ops/prove.rs | 9 +- crates/nargo/src/ops/recursion.rs | 22 ++++ crates/nargo/src/ops/verify.rs | 10 +- crates/nargo_cli/src/cli/mod.rs | 4 + crates/nargo_cli/src/cli/prove_cmd.rs | 19 ++- crates/nargo_cli/src/cli/recursion_cmd.rs | 115 ++++++++++++++++++ crates/nargo_cli/src/cli/verify_cmd.rs | 7 ++ crates/nargo_cli/tests/hello_world.rs | 97 ++++++++++++++- crates/nargo_cli/tests/prove_and_verify.rs | 37 +++--- .../tests/test_data/recursion/Nargo.toml | 5 + .../tests/test_data/recursion/Prover.toml | 6 + .../tests/test_data/recursion/src/main.nr | 32 +++++ crates/noirc_evaluator/src/lib.rs | 2 +- .../src/ssa/acir_gen/operations/intrinsics.rs | 59 +++++++++ .../src/ssa/acir_gen/operations/sort.rs | 2 - crates/noirc_evaluator/src/ssa/builtin.rs | 2 +- crates/noirc_evaluator/src/ssa_refactor.rs | 5 +- .../src/monomorphization/mod.rs | 15 +++ flake.lock | 6 +- noir_stdlib/src/lib.nr | 2 +- 24 files changed, 444 insertions(+), 67 deletions(-) create mode 100644 crates/nargo/src/ops/recursion.rs create mode 100644 crates/nargo_cli/src/cli/recursion_cmd.rs create mode 100644 crates/nargo_cli/tests/test_data/recursion/Nargo.toml create mode 100644 crates/nargo_cli/tests/test_data/recursion/Prover.toml create mode 100644 crates/nargo_cli/tests/test_data/recursion/src/main.nr diff --git a/.gitignore b/.gitignore index 351f5e16a7f..352ff479e0e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ result *.pk *.vk **/Verifier.toml +**/target/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index ba03b234475..c393d925b8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#cfbd0ec2c566c7abe35b7f7d92fc9691eb81c691" dependencies = [ "acir_field", "flate2", @@ -17,7 +17,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#cfbd0ec2c566c7abe35b7f7d92fc9691eb81c691" dependencies = [ "ark-bn254", "ark-ff", @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#cfbd0ec2c566c7abe35b7f7d92fc9691eb81c691" dependencies = [ "acir", "acvm_stdlib", @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.1.2" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=748cb0aa3d276c1b526cc9d04df50c4d51f64806#748cb0aa3d276c1b526cc9d04df50c4d51f64806" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=ea05a50e96ec2e36586be446f326290526943e24#ea05a50e96ec2e36586be446f326290526943e24" dependencies = [ "acvm", "barretenberg-sys", @@ -69,7 +69,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#4934dd30877ebb16b9f7d73f78c30b829d62cce0" +source = "git+https://github.com/noir-lang/acvm?branch=mv/verify-proof-2#cfbd0ec2c566c7abe35b7f7d92fc9691eb81c691" dependencies = [ "acir", ] @@ -700,15 +700,15 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "console" -version = "0.15.5" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" +checksum = "d0525278dce688103060006713371cedbad27186c7d913f33d866b498da0f595" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2849,9 +2849,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" dependencies = [ "serde", ] @@ -3210,9 +3210,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" dependencies = [ "serde", "serde_spanned", @@ -3222,18 +3222,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "92d964908cec0d030b812013af25a0e57fddfadb1e066ecc6681d86253129d4f" dependencies = [ "indexmap", "serde", @@ -3882,21 +3882,6 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/Cargo.toml b/Cargo.toml index fc6bdf9d2f2..a59779d696a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ rust-version = "1.66" [workspace.dependencies] # acvm = "0.12.0" acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", branch = "mv/verify-proof-2" } +# acvm = { features = ["bn254"], path = "/Users/maximvezenov/Documents/dev/noir-lang/acvm/acvm" } arena = { path = "crates/arena" } fm = { path = "crates/fm" } @@ -54,6 +55,4 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "748cb0aa3d276c1b526cc9d04df50c4d51f64806" } - -# acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "4358d3b9e8cd98d88a78dda3337e80e90668378e" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "ea05a50e96ec2e36586be446f326290526943e24" } diff --git a/crates/nargo/src/ops/mod.rs b/crates/nargo/src/ops/mod.rs index 8a0cce4b8c5..7b00fbe61c2 100644 --- a/crates/nargo/src/ops/mod.rs +++ b/crates/nargo/src/ops/mod.rs @@ -2,10 +2,12 @@ pub use self::codegen_verifier::codegen_verifier; pub use self::execute::execute_circuit; pub use self::preprocess::{preprocess_contract_function, preprocess_program}; pub use self::prove::prove_execution; +pub use self::recursion::{proof_as_fields, vk_as_fields}; pub use self::verify::verify_proof; mod codegen_verifier; mod execute; mod preprocess; mod prove; +mod recursion; mod verify; diff --git a/crates/nargo/src/ops/prove.rs b/crates/nargo/src/ops/prove.rs index e2c70739a35..d6e1ad84012 100644 --- a/crates/nargo/src/ops/prove.rs +++ b/crates/nargo/src/ops/prove.rs @@ -7,6 +7,13 @@ pub fn prove_execution( circuit: &Circuit, solved_witness: WitnessMap, proving_key: &[u8], + is_recursive: bool, ) -> Result, B::Error> { - backend.prove_with_pk(common_reference_string, circuit, solved_witness, proving_key) + backend.prove_with_pk( + common_reference_string, + circuit, + solved_witness, + proving_key, + is_recursive, + ) } diff --git a/crates/nargo/src/ops/recursion.rs b/crates/nargo/src/ops/recursion.rs new file mode 100644 index 00000000000..f98019770fd --- /dev/null +++ b/crates/nargo/src/ops/recursion.rs @@ -0,0 +1,22 @@ +use acvm::{acir::native_types::WitnessMap, FieldElement, ProofSystemCompiler}; + +pub fn proof_as_fields( + backend: &B, + proof: &[u8], + public_inputs: WitnessMap, +) -> Result, B::Error> { + let proof_as_fields = backend.proof_as_fields(proof, public_inputs)?; + + Ok(proof_as_fields) +} + +pub fn vk_as_fields( + backend: &B, + common_reference_string: &[u8], + verification_key: &[u8], +) -> Result<(Vec, FieldElement), B::Error> { + let (vk_as_fields, vk_hash) = + backend.vk_as_fields(common_reference_string, verification_key)?; + + Ok((vk_as_fields, vk_hash)) +} diff --git a/crates/nargo/src/ops/verify.rs b/crates/nargo/src/ops/verify.rs index 1d2d3bbbd6f..1275bd2fbd0 100644 --- a/crates/nargo/src/ops/verify.rs +++ b/crates/nargo/src/ops/verify.rs @@ -8,6 +8,14 @@ pub fn verify_proof( proof: &[u8], public_inputs: WitnessMap, verification_key: &[u8], + is_recursive: bool, ) -> Result { - backend.verify_with_vk(common_reference_string, proof, public_inputs, circuit, verification_key) + backend.verify_with_vk( + common_reference_string, + proof, + public_inputs, + circuit, + verification_key, + is_recursive, + ) } diff --git a/crates/nargo_cli/src/cli/mod.rs b/crates/nargo_cli/src/cli/mod.rs index d41dc1a815a..91043092ba4 100644 --- a/crates/nargo_cli/src/cli/mod.rs +++ b/crates/nargo_cli/src/cli/mod.rs @@ -17,6 +17,7 @@ mod gates_cmd; mod new_cmd; mod print_acir_cmd; mod prove_cmd; +mod recursion_cmd; mod test_cmd; mod verify_cmd; @@ -57,6 +58,7 @@ enum NargoCommand { Test(test_cmd::TestCommand), Gates(gates_cmd::GatesCommand), PrintAcir(print_acir_cmd::PrintAcirCommand), + Recursion(recursion_cmd::RecursionCommand), } pub fn start_cli() -> eyre::Result<()> { @@ -80,6 +82,7 @@ pub fn start_cli() -> eyre::Result<()> { NargoCommand::Gates(args) => gates_cmd::run(&backend, args, config), NargoCommand::CodegenVerifier(args) => codegen_verifier_cmd::run(&backend, args, config), NargoCommand::PrintAcir(args) => print_acir_cmd::run(&backend, args, config), + NargoCommand::Recursion(args) => recursion_cmd::run(&backend, args, config), }?; Ok(()) @@ -104,6 +107,7 @@ pub fn prove_and_verify(proof_name: &str, program_dir: &Path, show_ssa: bool) -> &proof_dir, None, true, + false, &compile_options, ) { Ok(_) => true, diff --git a/crates/nargo_cli/src/cli/prove_cmd.rs b/crates/nargo_cli/src/cli/prove_cmd.rs index 7589dd4bba3..9f342f94854 100644 --- a/crates/nargo_cli/src/cli/prove_cmd.rs +++ b/crates/nargo_cli/src/cli/prove_cmd.rs @@ -36,6 +36,10 @@ pub(crate) struct ProveCommand { #[arg(short, long)] verify: bool, + /// Whether to generate this proof using the recursive prover + #[arg(short, long)] + recursive: bool, + #[clap(flatten)] compile_options: CompileOptions, } @@ -58,6 +62,7 @@ pub(crate) fn run( proof_dir, circuit_build_path, args.verify, + args.recursive, &args.compile_options, )?; @@ -71,6 +76,7 @@ pub(crate) fn prove_with_path>( proof_dir: P, circuit_build_path: Option, check_proof: bool, + is_recursive: bool, compile_options: &CompileOptions, ) -> Result, CliError> { let (common_reference_string, preprocessed_program) = match circuit_build_path { @@ -111,9 +117,15 @@ pub(crate) fn prove_with_path>( Format::Toml, )?; - let proof = - prove_execution(backend, &common_reference_string, &bytecode, solved_witness, &proving_key) - .map_err(CliError::ProofSystemCompilerError)?; + let proof = prove_execution( + backend, + &common_reference_string, + &bytecode, + solved_witness, + &proving_key, + is_recursive, + ) + .map_err(CliError::ProofSystemCompilerError)?; if check_proof { let public_inputs = public_abi.encode(&public_inputs, return_value)?; @@ -124,6 +136,7 @@ pub(crate) fn prove_with_path>( &proof, public_inputs, &verification_key, + is_recursive, ) .map_err(CliError::ProofSystemCompilerError)?; diff --git a/crates/nargo_cli/src/cli/recursion_cmd.rs b/crates/nargo_cli/src/cli/recursion_cmd.rs new file mode 100644 index 00000000000..8ac6bdddd2c --- /dev/null +++ b/crates/nargo_cli/src/cli/recursion_cmd.rs @@ -0,0 +1,115 @@ +use std::{ + collections::BTreeMap, + path::{Path, PathBuf}, +}; + +use crate::{ + constants::{PROOFS_DIR, PROOF_EXT, TARGET_DIR, VERIFIER_INPUT_FILE}, + errors::CliError, +}; + +use super::{ + compile_cmd::compile_circuit, + fs::{ + common_reference_string::get_common_reference_string, + create_named_dir, + inputs::{read_inputs_from_file, write_inputs_to_file}, + load_hex_data, + program::read_program_from_file, + }, + NargoConfig, +}; +use acvm::Backend; +use clap::Args; +use nargo::ops::{proof_as_fields, vk_as_fields}; +use noirc_abi::input_parser::{Format, InputValue}; + +/// Generates artifacts for recursive verification of circuits +#[derive(Debug, Clone, Args)] +pub(crate) struct RecursionCommand { + /// The name of the proof + proof_name: String, + + /// The name of the circuit build fiels (ACIR, proving and verification key) + circuit_name: String, +} + +pub(crate) fn run( + backend: &B, + args: RecursionCommand, + config: NargoConfig, +) -> Result<(), CliError> { + let proof_path = + config.program_dir.join(PROOFS_DIR).join(&args.proof_name).with_extension(PROOF_EXT); + + let target_dir = config.program_dir.join(TARGET_DIR); + + let circuit_build_path = target_dir.join(&args.circuit_name); + + let recursion_artifacts_path = target_dir.join("recursion"); + create_named_dir(recursion_artifacts_path.as_ref(), "recursion"); + + gen_recursion_artifacts_with_path( + backend, + config.program_dir, + proof_path, + circuit_build_path, + recursion_artifacts_path, + args.circuit_name, + )?; + + Ok(()) +} + +pub(crate) fn gen_recursion_artifacts_with_path>( + backend: &B, + program_dir: P, + proof_path: PathBuf, + circuit_build_path: P, + recursion_artifacts_path: P, + circuit_name: String, +) -> Result<(), CliError> { + // TODO: do we want circuit's to be optional? If the circuit has not changed + // the verification key will be the same, but the proof generated could potentially be generated by a different circuit + // let preprocessed_program = match circuit_build_path { + // Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, + // None => { + // let compiled_program = + // compile_circuit(&backend, program_dir.as_ref(), compile_options)?; + // preprocess_program(&backend, compiled_program)? + // } + // }; + let preprocessed_program = read_program_from_file(&circuit_build_path)?; + let common_reference_string = + get_common_reference_string(backend, &preprocessed_program.bytecode) + .map_err(CliError::CommonReferenceStringError)?; + + let public_abi = preprocessed_program.abi.clone().public_abi(); + let (public_inputs_map, return_value) = + read_inputs_from_file(program_dir, VERIFIER_INPUT_FILE, Format::Toml, &public_abi)?; + let public_inputs = public_abi.encode(&public_inputs_map, return_value)?; + + let proof = &load_hex_data(&proof_path)?; + + let proof_fields = proof_as_fields(backend, proof, public_inputs) + .map_err(CliError::ProofSystemCompilerError)?; + + let mut recursion_artifacts_map = BTreeMap::new(); + recursion_artifacts_map.insert("proof".to_owned(), InputValue::Vec(proof_fields)); + + let (vk_fields, vk_hash) = + vk_as_fields(backend, &common_reference_string, &preprocessed_program.verification_key) + .map_err(CliError::ProofSystemCompilerError)?; + recursion_artifacts_map.insert("verification_key".to_owned(), InputValue::Vec(vk_fields)); + recursion_artifacts_map.insert("key_hash".to_owned(), InputValue::Field(vk_hash)); + + write_inputs_to_file( + &recursion_artifacts_map, + &None, + recursion_artifacts_path, + &circuit_name, + Format::Toml, + )?; + + Ok(()) +} diff --git a/crates/nargo_cli/src/cli/verify_cmd.rs b/crates/nargo_cli/src/cli/verify_cmd.rs index 62333ff0bdf..1057dfbf1de 100644 --- a/crates/nargo_cli/src/cli/verify_cmd.rs +++ b/crates/nargo_cli/src/cli/verify_cmd.rs @@ -26,6 +26,10 @@ pub(crate) struct VerifyCommand { /// The name of the circuit build files (ACIR, proving and verification keys) circuit_name: Option, + /// Whether to generate this proof using the recursive prover + #[arg(short, long)] + recursive: bool, + #[clap(flatten)] compile_options: CompileOptions, } @@ -47,6 +51,7 @@ pub(crate) fn run( &config.program_dir, proof_path, circuit_build_path.as_ref(), + args.recursive, &args.compile_options, ) } @@ -56,6 +61,7 @@ fn verify_with_path>( program_dir: P, proof_path: PathBuf, circuit_build_path: Option

, + is_recursive: bool, compile_options: &CompileOptions, ) -> Result<(), CliError> { let (common_reference_string, preprocessed_program) = match circuit_build_path { @@ -92,6 +98,7 @@ fn verify_with_path>( &proof, public_inputs, &verification_key, + is_recursive, ) .map_err(CliError::ProofSystemCompilerError)?; diff --git a/crates/nargo_cli/tests/hello_world.rs b/crates/nargo_cli/tests/hello_world.rs index 121f09f0ece..9603190244e 100644 --- a/crates/nargo_cli/tests/hello_world.rs +++ b/crates/nargo_cli/tests/hello_world.rs @@ -2,9 +2,15 @@ //! It then follows the steps published at https://noir-lang.org/getting_started/hello_world.html //! Any modifications to the commands run here MUST be documented in the noir-lang book. +mod prove_and_verify; + +use acvm::FieldElement; +use noirc_abi::input_parser::{InputValue, Format}; +use prove_and_verify::copy_recursively; use assert_cmd::prelude::*; use predicates::prelude::*; -use std::process::Command; +use tempdir::TempDir; +use std::{process::Command, collections::BTreeMap, fs::File, io::Write}; use assert_fs::prelude::{FileWriteStr, PathAssert, PathChild}; @@ -54,3 +60,92 @@ fn hello_world_example() { cmd.arg("verify").arg(proof_name); cmd.assert().success(); } + + +#[test] +fn recursive_proof_composition() { + let current_dir = std::env::current_dir().unwrap(); + + let xor_dir = current_dir.join("tests/test_data/xor"); + let recursion_dir = current_dir.join("tests/test_data/recursion"); + + let tmp_dir = TempDir::new("recursion_tests").unwrap(); + let tmp_xor_dir = tmp_dir.as_ref().join("xor"); + let tmp_recursion_dir = tmp_dir.as_ref().join("recursion"); + + copy_recursively(xor_dir, &tmp_xor_dir) + .expect("failed to copy test cases to temp directory"); + + copy_recursively(recursion_dir, &tmp_recursion_dir) + .expect("failed to copy test cases to temp directory"); + + std::env::set_current_dir(&tmp_xor_dir).unwrap(); + + // `nargo check` + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("check"); + cmd.assert() + .success() + .stdout(predicate::str::contains("Constraint system successfully built!")); + + let circuit_name = "c"; + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("compile").arg(circuit_name); + cmd.assert().success(); + + let proof_name = "p"; + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("prove").arg(proof_name).arg(circuit_name).arg("--recursive"); + cmd.assert().success(); + + // `nargo verify p` + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("verify").arg(proof_name).arg("--recursive"); + cmd.assert().success(); + + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("recursion").arg(proof_name).arg(circuit_name); + cmd.assert().success(); + + let recursion_artifacts_path = tmp_xor_dir.join("target/recursion").join(format!("{circuit_name}.toml")); + let recursion_artifacts_string = std::fs::read_to_string(recursion_artifacts_path).unwrap(); + + let mut recursion_circuit_inputs_map = BTreeMap::new(); + recursion_circuit_inputs_map.insert("public_inputs".to_owned(), InputValue::Vec(vec![FieldElement::from_hex("0x0a").unwrap()])); + + let input_aggregation_object = [FieldElement::zero(); 16].to_vec(); + recursion_circuit_inputs_map.insert("input_aggregation_object".to_owned(), InputValue::Vec(input_aggregation_object)); + + let additional_inputs = Format::Toml.serialize(&recursion_circuit_inputs_map).unwrap(); + let full_recursion_prover_inputs = recursion_artifacts_string + "\n" + &additional_inputs; + + let recursion_prover_file_path = tmp_recursion_dir.join("Prover").with_extension("toml"); + let mut recursion_prover_file = match File::create(recursion_prover_file_path) { + Err(why) => panic!("couldn't create recursion Prover.toml: {why}"), + Ok(file) => file, + }; + match recursion_prover_file.write_all(full_recursion_prover_inputs.as_bytes()) { + Err(why) => panic!("couldn't write to recursion Prover.toml: {why}"), + Ok(_) => (), + } + + std::env::set_current_dir(&tmp_recursion_dir).unwrap(); + + // `nargo check` + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("check"); + cmd.assert() + .success() + .stdout(predicate::str::contains("Constraint system successfully built!")); + + // `nargo prove p` + let proof_name = "p"; + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("prove").arg(proof_name); + cmd.assert().success(); + + // `nargo verify p` + let mut cmd = Command::cargo_bin("nargo").unwrap(); + cmd.arg("verify").arg(proof_name); + cmd.assert().success(); +} \ No newline at end of file diff --git a/crates/nargo_cli/tests/prove_and_verify.rs b/crates/nargo_cli/tests/prove_and_verify.rs index 070db6d8ce8..4b2c33d7edf 100644 --- a/crates/nargo_cli/tests/prove_and_verify.rs +++ b/crates/nargo_cli/tests/prove_and_verify.rs @@ -2,6 +2,25 @@ use tempdir::TempDir; use std::collections::BTreeMap; use std::fs; +use std::path::Path; + +/// Copy files from source to destination recursively. +pub fn copy_recursively( + source: impl AsRef, + destination: impl AsRef, +) -> std::io::Result<()> { + fs::create_dir_all(&destination)?; + for entry in fs::read_dir(source)? { + let entry = entry?; + let filetype = entry.file_type()?; + if filetype.is_dir() { + copy_recursively(entry.path(), destination.as_ref().join(entry.file_name()))?; + } else { + fs::copy(entry.path(), destination.as_ref().join(entry.file_name()))?; + } + } + Ok(()) +} mod tests { use std::path::{Path, PathBuf}; @@ -27,24 +46,6 @@ mod tests { conf_data } - /// Copy files from source to destination recursively. - pub fn copy_recursively( - source: impl AsRef, - destination: impl AsRef, - ) -> std::io::Result<()> { - fs::create_dir_all(&destination)?; - for entry in fs::read_dir(source)? { - let entry = entry?; - let filetype = entry.file_type()?; - if filetype.is_dir() { - copy_recursively(entry.path(), destination.as_ref().join(entry.file_name()))?; - } else { - fs::copy(entry.path(), destination.as_ref().join(entry.file_name()))?; - } - } - Ok(()) - } - #[test] fn noir_integration() { // Try to find the directory that Cargo sets when it is running; otherwise fallback to assuming the CWD diff --git a/crates/nargo_cli/tests/test_data/recursion/Nargo.toml b/crates/nargo_cli/tests/test_data/recursion/Nargo.toml new file mode 100644 index 00000000000..09a8dd8e8c8 --- /dev/null +++ b/crates/nargo_cli/tests/test_data/recursion/Nargo.toml @@ -0,0 +1,5 @@ +[package] +authors = [""] +compiler_version = "0.5.1" + +[dependencies] \ No newline at end of file diff --git a/crates/nargo_cli/tests/test_data/recursion/Prover.toml b/crates/nargo_cli/tests/test_data/recursion/Prover.toml new file mode 100644 index 00000000000..d7d48130a05 --- /dev/null +++ b/crates/nargo_cli/tests/test_data/recursion/Prover.toml @@ -0,0 +1,6 @@ +input_aggregation_object = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"] +key_hash = "0x1787a6433118fde0ec6fb43af3b1c3b11185dc073d72cf6bc8a9a0463a84b438" +proof = ["0x000000000000000000000000000000000000000000000000000000000000000a", "0x00000000000000000000000000000013a30214593311b75c43da9f0c9d5c6cba", "0x00000000000000000000000000000000000a3db62682186628f57e133fc87563", "0x000000000000000000000000000000b88ee316a5e037553d829983981c42cb50", "0x0000000000000000000000000000000000199dd309b8e8e9632238e88730cb9d", "0x000000000000000000000000000000868200625596c56e219a39455fa74c4d73", "0x000000000000000000000000000000000001ddb4769bb8ceda35bfcea9c9959a", "0x00000000000000000000000000000068fb11f67980f65b91091d4756bec93877", "0x000000000000000000000000000000000025f5e1dfb7cbf93d505fafd769af28", "0x00000000000000000000000000000091ab7159fc7ac9857ce7ed9a53f503ed07", "0x0000000000000000000000000000000000220bf3af74524312f2c2a9197f2cc9", "0x000000000000000000000000000000a0fa88a2ec88b78c802e276e240f1ce892", "0x00000000000000000000000000000000002a6c433ecc297f3628f7c95c598163", "0x000000000000000000000000000000e9a291e1c8beaf86b3d69d8e981f055e3d", "0x000000000000000000000000000000000015ed27240b40dd222829693e5999de", "0x0000000000000000000000000000000abd1f92224426d1ff8c21b94c8e1b309b", "0x000000000000000000000000000000000014ff2f3ac97606a3a37f49ce31cf95", "0x0000000000000000000000000000004c5fe2de60acd90ebcbb1e68c739938947", "0x0000000000000000000000000000000000206dd1266680cc94d91486292381f3", "0x0000000000000000000000000000006d46eb3e3cc4caf121942846afb2dd81dc", "0x00000000000000000000000000000000002a7f5d7727e6dba35726afe3b3af5c", "0x000000000000000000000000000000f6981d3c48cbda763819aa7ab83617bcbb", "0x00000000000000000000000000000000000dccfe699205a867458279232fbbeb", "0x0000000000000000000000000000001b16806546fdc584963de4c95521e0c664", "0x00000000000000000000000000000000001f440491c73b6f1d62434b4b1c835f", "0x000000000000000000000000000000c98c0b57e912d72c9f416547e025cc7793", "0x0000000000000000000000000000000000000e6267e275ad28b55bcaa93ccc4e", "0x000000000000000000000000000000dc7f696884ffa3844cabb52fe7ac3ffe45", "0x00000000000000000000000000000000001aaa3fd2ebfbb0040bc7af1e7e0ed5", "0x000000000000000000000000000000cd3170d05b1af2fbd9731e433e85e37eb8", "0x00000000000000000000000000000000000b318b78d1b482b9d544d7e6bc3f07", "0x0000000000000000000000000000000465dcaa7c4fa37f5501aa785f609a963c", "0x0000000000000000000000000000000000275c41b171d04464d97c25cc6a55e9", "0x00000000000000000000000000000072ef627c3c43160c9cfa02c150e7a111c5", "0x00000000000000000000000000000000001382238226dd623e4f803ead595c09", "0x000000000000000000000000000000b3ef51f423932e03d45321ecab42056cf1", "0x0000000000000000000000000000000000252870315cd7a4b5058d2097b7a15a", "0x000000000000000000000000000000fcdea7dd6c625b7c0337204a0abdb85dbf", "0x0000000000000000000000000000000000228d30de3650ddbdd9c2181b503ed8", "0x0000000000000000000000000000001d41c27b247b59675455e725d45beb3da4", "0x00000000000000000000000000000000002a6cb776418192d6ef0327f05b04ac", "0x0000000000000000000000000000003f6befd381140d2a98a221adce02a944a5", "0x00000000000000000000000000000000000ebda1bcbed5bb79965b756b36b9eb", "0x00000000000000000000000000000013c98c044bd6444a20639117b4d3333d18", "0x000000000000000000000000000000000024b6daacaea6024e75b3b1b7e34aa1", "0x19fc6de43907fd712ed7f3b6271af0541e3f20165376574f7e362825d781fabc", "0x1498b4e1dac720d60d2965c630e8fa2a36195f9c8ea111d6696d3acc500e20bd", "0x1e29e00ac7ac29f548cc5d9e537372c5f62b1f9f423b1ce24fff34a4c54dcfce", "0x1f6acb9f5e51d30c42851afe228683e9957e51ef5fa84980fdba724105822d86", "0x22dca45a145cf8d70d625d144be7f6871e9f065c120cecc76b84b20880b16eb3", "0x16aef755d8e13d490ec9335038cf837c53160938bc6ec24ff2ef10f161ad2ac6", "0x0fc0e3e9c5c770fe871c9788d9ea325b9558db4248af75a24bb84b4b8b239de3", "0x1124b6602070b8b73ab7a641db6b6416561abedd68956cc20b8f8386df5301f0", "0x17561f9f0f1bb1c872740d8af51d521b7eed14e453f6c181c56b56910fa36e2a", "0x303dd9113ba1a0a4cb3b0d4238d86aa7a927485428655d38fbe385c1523cce5b", "0x16dc123f9afed3ec68e2e3e6ecd71547796888fccf634af782e64ed27120eb46", "0x14599b3e6997567be7fbfc5fef7e5367f1a8efbe745d1061419b2bb6848c79ee", "0x2b5f3a1c5e6c689a67629a552ea618620ed1bb00318a6084e385f0d51772e64e", "0x08ca7e24a62a42813b2aa0f8d8c9bf003a7282cb6d2d177d5255fd37fb37f35a", "0x2225018576d989ce8c9f031c96e421975e2c4d65c1d74cd3b5904c813c526b20", "0x1372bbe28143e0cc675b74723ca2ee51ff5468b39879468ffcb41aed39f195d4", "0x001a033a646e40d092b3b7bc09d0e18709d4f0a756deffeda5473efeb9455124", "0x1cc001b42e0a6fe79b3beffd6a828fbe1fdfb47b9c8f30fceda349611e2af0f5", "0x246c45bfc21ca76129d2b54bb22bfded9aa5f36438d4c686ccaa70d422a91525", "0x2a0e280a4f3a78c8f8c575928b5c03f38c42f7a1094e5b2c7629c52c52192736", "0x287c7c7510192fc6e965b216a81551f5a3aa35025dc8daea6d140c5cdd393cb2", "0x2d37e0580f021611763d7243ed68774386763d4bd9c70df40373f5fa9eb86734", "0x29fd826b57d0337901645b611e8359646cbbb5a96532e4451eb25e72338b8ca2", "0x1a7d8fdf54cd956dd9693ac9032a8bfdf735fda3e313b8fc6854ab0958f05926", "0x002704d796a56138dc0d939a0eb9524a8ebf68fb024e7fe477eade7e15e7f9b6", "0x038885dc8fbcd76e7c658d8f74a10f74fa07b67aa814e6d37450c6503f605d31", "0x19c11a7155aa4b59e3f5add166f5de8d25a36f6683dc941f050109c37ffd9d36", "0x2ca1bc50b9aaf91e6f5b2342c035f1cee8f0471efbabda67da15707715428117", "0x070f312c6705fced5f7a96b524caf3b70b5951f2743e01954e3be56b2a6eacaf", "0x2caa8ff78a6c999392bf49266ace226ef5e9399f4892870d840b1b48e0168b34", "0x09dcde228e2e6d79108bf470e82c32582e2a3d56a79d778f98fb698621aa1f2b", "0x1a7a9324d51008e7a5879f1878da5e960e229788eba765d6402da9154c0f7717", "0x2ef583bc311f563dc8c63b153ef8fb359baee5cc572373d9e38c047a470030fa", "0x1b280593e9b841b251f0802ae489de65745294da325115b783bdd2d7d7842a3b", "0x230215973717fbe2b53008382ca10398534b484eb26f94ff923a0f53af3062ff", "0x21a3aa9c335a456eef3ee4c1f4894146caf8670b1b6005b3c752dafe784516fc", "0x287d5fa50f46493fa36fdc191d4e520721e08b436ac776533fea57b53d4f8ca2", "0x081b6f8c8864a7279553f326b701f163ef9c110abfccbedf2640fb7a808dab0b", "0x02ede698982a8903295d72dea8205237c3e34ae3a0e2a136cbd192f18650eeca", "0x2a1d2af198ea13053225e34eb91454170b47e4086ed0a740493a8a257ec46893", "0x195110eb89597e71fefb5892dc7ce41ebf2992d6e1ab671a46591bc71f2e0811", "0x000000000000000000000000000000f50928a2ab61869ff029f350280b8baca3", "0x00000000000000000000000000000000002cba468768fe5ebc05e00d658e3cfc", "0x0000000000000000000000000000006a211854b975984c1d983125c72261c5b5", "0x0000000000000000000000000000000000226e236d5238e26ec4f21c232a7d2e", "0x0000000000000000000000000000008bf47353b424ee29c9d16747cda839b52c", "0x00000000000000000000000000000000002531e8d17a7a8d8ec931c6d9eb992f", "0x000000000000000000000000000000e3f21262fa9fc4136ecc2334746648ec54", "0x0000000000000000000000000000000000234c26e976b384030e63613388946d"] +verification_key = ["0x006fab49b869ae62001deac878b2667bd31bf3e28e3a2d764aa49b8d9bbdd310", "0x0000000000000000000000000000000000000000000000000000000000002000", "0x0000000000000000000000000000000000000000000000000000000000000005", "0x0000000000000000000000000000000000000000000000000000000000002000", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000009cf52db235ea335d941f4eeb4326f8c497", "0x0000000000000000000000000000000000301a3926b6fa19dffbd75b660df6b2", "0x0000000000000000000000000000002050f8cc24645dc27dc2d25f8e2dc8fd08", "0x0000000000000000000000000000000000058905afd4fc60289fc0656a0065a9", "0x0000000000000000000000000000002f60152775671437b19a6605a23ab2450d", "0x0000000000000000000000000000000000094f46605db7eaebc318a1d6eb0a13", "0x000000000000000000000000000000576808b58acd54b5177b3c99d034bb9dba", "0x000000000000000000000000000000000026b9a55104cb174c15dcbf67fc20a0", "0x0000000000000000000000000000006d57241f0c0bfbbad56c140d2b0e4cbd78", "0x00000000000000000000000000000000001f818cbaa94e816f6f692b2cb46fe7", "0x000000000000000000000000000000d34ec1d978d3626ee86f71d774493bca43", "0x000000000000000000000000000000000021c7e974d3680eedfcd9aa257bd557", "0x00000000000000000000000000000085da19557d2c1954f8e4b50c8f9f416cb8", "0x000000000000000000000000000000000028f437ec8d2a42df2a711764ce675a", "0x00000000000000000000000000000053eebb686a574202f7a6e7056dac4e6a04", "0x00000000000000000000000000000000000a30a2af6d9faaf84d75107090fbb8", "0x000000000000000000000000000000a5c526253b5d7fe5bc03090f882512cf51", "0x00000000000000000000000000000000001264282b9bdf8043ad67c553d11486", "0x000000000000000000000000000000892d49bcae8a30f909f5e27198818422ef", "0x0000000000000000000000000000000000044c1cf862883cc720de3bf1a65158", "0x00000000000000000000000000000063bb9b6be191ad0333a01860021474652e", "0x000000000000000000000000000000000021d4a4fbf4255ec22363c0e67fddcd", "0x00000000000000000000000000000031df120c8c2cdaa1deced300e262a41a59", "0x0000000000000000000000000000000000127f2963c9cc3e46c9b2a81f010566", "0x00000000000000000000000000000055b3eb94ad7db1cebf2493787119372bf2", "0x0000000000000000000000000000000000125ef4e2acb74a4d7e1746b1cb3556", "0x000000000000000000000000000000b6e69abc23cbd3ea2b7e0ac8e44f500473", "0x000000000000000000000000000000000012a37dea2c03430ee09cfaf0dab3b7", "0x00000000000000000000000000000091c4b58c9466db7519e549de29653f7e08", "0x000000000000000000000000000000000005da324c9f8c5928b073bd5d3d4b0f", "0x000000000000000000000000000000b6cc35b21df59fb4e2a36cefe98fe936c4", "0x0000000000000000000000000000000000135878d2105778eaba1a0023a84035", "0x000000000000000000000000000000e648cd91b86f4b17f30e4e62110f41f410", "0x00000000000000000000000000000000001c354c314e59ad314b5388a1feb73d", "0x000000000000000000000000000000b06b91150e48b16fa9a3d52188b430447f", "0x000000000000000000000000000000000018b19ba5b1ef0342f198ff0ef41bab", "0x000000000000000000000000000000cc6b57ed37a72741fd60d4a9c9de019013", "0x000000000000000000000000000000000012343e6875fb97c8dd7ba0515caa0b", "0x000000000000000000000000000000a7e527a7eb6b1ae11fe00e4c5277f9a685", "0x0000000000000000000000000000000000029ff8300c511064acecd1f509280e", "0x00000000000000000000000000000044c870bdabcabafb34d6821b3a307598a7", "0x000000000000000000000000000000000028d3380e84b7cfb8516f4bc3fcf4ac", "0x0000000000000000000000000000009c5604bfc1906a6fc0ee8933eef46f3f53", "0x00000000000000000000000000000000002d18dd12b7c86f57287aab1ed5d155", "0x00000000000000000000000000000084f5b77a5b58efd058ba2665c6b6b1ac34", "0x00000000000000000000000000000000000eca3879d07d56b03547f5918dbbcf", "0x000000000000000000000000000000c284df7c18c6ae5283b6f8129f92ed472d", "0x000000000000000000000000000000000015f16fd4eb9aa6666014196d6702fd", "0x00000000000000000000000000000034e0797db1c80eaca433d3b35bef2c3c59", "0x00000000000000000000000000000000001828a6526c92896f42a6ccf662e86c", "0x000000000000000000000000000000f09d512a079b0c4560e519c4e5e2f47b90", "0x000000000000000000000000000000000014be4e9486a3d105915f5d955d8bc8", "0x000000000000000000000000000000e1b957d7f9214efe05969c2bfd752464f7", "0x00000000000000000000000000000000002c79cc4973201607749f98a9d4a965", "0x00000000000000000000000000000077db4361efaa15cb873474f9e9f9234079", "0x0000000000000000000000000000000000280f196ec4411501aa2256f3393313", "0x000000000000000000000000000000031738dc11c806fc626e06f3c528f261d1", "0x000000000000000000000000000000000004058b5c321f1d0de7302f994ef5b0", "0x000000000000000000000000000000e6e99bd35fbcabda70289996fea3a93011", "0x00000000000000000000000000000000000db7c40d801d2e7eac001a5673c3cd", "0x0000000000000000000000000000004994438a00d1ab228927f908ccfcf2ed3d", "0x0000000000000000000000000000000000237c83789d39d8459848d87929a49e", "0x0000000000000000000000000000008725eb45c8e1888226f2bcc036e0d6a698", "0x000000000000000000000000000000000009d3b1fef691b49a440d6a0ad2be80", "0x0000000000000000000000000000004ad874e52a05928aa2b170cc2b63c274ef", "0x000000000000000000000000000000000010c9d5ae2475ab1b23571f638477ca", "0x000000000000000000000000000000c690acbf94666d3cdb1700cf7aad52ad26", "0x00000000000000000000000000000000000eb136ae272592f98cc23b90dd9b9e", "0x0000000000000000000000000000006dfe9ae4650c42e2d748c4a41f31ef3f79", "0x00000000000000000000000000000000002cc60738774946a2165785da782965", "0x000000000000000000000000000000b372175007e1d700a6c6dccf7725a68cf4", "0x0000000000000000000000000000000000055b0ef271f117387a3e661982046e", "0x00000000000000000000000000000030c29017ffa425c6869ff399db0e9adb6d", "0x000000000000000000000000000000000029379efcf5b36e94fa459fcf11803e", "0x000000000000000000000000000000bed1592b719b28e44dc87b6ad1884f642c", "0x00000000000000000000000000000000000d0037fb7889608353203ef391d7a1", "0x00000000000000000000000000000021a91fa2bd116913d763836e62dbb9957f", "0x000000000000000000000000000000000029cc2825f5f92281f1c7a3df846304", "0x000000000000000000000000000000e4a765d9dccfd5af2cc8d69af2ece343a3", "0x00000000000000000000000000000000001242a3f2f4fec5433e22394c4541b1", "0x000000000000000000000000000000f9992678a973b8fb38c824d0c9a6d14010", "0x00000000000000000000000000000000001a146c1b754ee0eb69e6895b7dd9bf", "0x000000000000000000000000000000c2fc1876673fbae3031dc825559b61f6dc", "0x00000000000000000000000000000000002d45c6df9b1a2d830fb34f1519341e", "0x0000000000000000000000000000007a72745061f1f059046fd03f84564e5d7a", "0x000000000000000000000000000000000012592c8f38051aaf92a955aa17ae75", "0x000000000000000000000000000000081c6ba09203e3e0d874f8bc31e6a0ec40", "0x00000000000000000000000000000000000cdbf1a771f6eb78964a939acddeb9", "0x000000000000000000000000000000b66e472a0cfd42cc6313ec34ff6882e4dc", "0x00000000000000000000000000000000000ebaed1a9a0773ce3a62637ea9d53a", "0x000000000000000000000000000000d2a2bfd3e7ac5860e62f2495a5e792d513", "0x000000000000000000000000000000000022ab28abcec226916d0c7258ba9d2d"] +public_inputs = ["0x0a"] +proof_b = ["0x000000000000000000000000000000000000000000000000000000000000000a", "0x00000000000000000000000000000042097263eedea3f77cde099282594bafce", "0x00000000000000000000000000000000001cfa5f6b9e193cff608cdc25069a4c", "0x000000000000000000000000000000d4c3c3ba8be7997e2943d23214ff9b5453", "0x0000000000000000000000000000000000199a51697a9993f672fac2993be6a8", "0x0000000000000000000000000000008c3909f89e9641cdd7e7e11e0ae6edfa69", "0x000000000000000000000000000000000021190b9e6d77a56c08ab5d262e286c", "0x00000000000000000000000000000028f23d7257efd1e8e5e397826b1bea14cc", "0x000000000000000000000000000000000005c384db97db7ecf9a4de916d346b6", "0x000000000000000000000000000000b011a20fb65a4de317bc504481a075ed69", "0x0000000000000000000000000000000000257012b0bc845846f0a55454979ab3", "0x000000000000000000000000000000aa6a04c8d6dfc45f8ab5b4f77eb9278fdf", "0x00000000000000000000000000000000002178b74119c55b3089c203b83dbd67", "0x00000000000000000000000000000024a4c23dff50e4b3b1da37dd7543326b2e", "0x00000000000000000000000000000000002eec9f0dc364a8670858789d0054e3", "0x0000000000000000000000000000006660bfa39b5ac1cf58208ab9e854dd4dd7", "0x00000000000000000000000000000000001c37b770bd6b7ccdd0f0af304b3548", "0x000000000000000000000000000000720b9cd9c889f66b629ddc7734aad9a5b1", "0x00000000000000000000000000000000001823f7b7f52fd0ecfd1f29b8496d57", "0x000000000000000000000000000000875589f7622b83fcccaea5e1dfbf65ecc9", "0x000000000000000000000000000000000007bda522d6395e0510ece9d3c11213", "0x000000000000000000000000000000df9c55e360057a07a6727d9c2080a802ec", "0x00000000000000000000000000000000000c629ff4a12794c8b76dc53e111729", "0x000000000000000000000000000000712234d7b1ed3872fe2966a380732f9926", "0x00000000000000000000000000000000000f77b649ef799ebdf166c02332a8e1", "0x000000000000000000000000000000396656953e0a28ef2d3a8505521f302878", "0x00000000000000000000000000000000002e0dafceab986615f62ed87a0cbef8", "0x0000000000000000000000000000001f83a0a3e359e986140c6d7276c2e8c791", "0x00000000000000000000000000000000001c574bc78e13ff8e092e6c79d04eab", "0x000000000000000000000000000000d46e1bfb262f549b3cbf0ad8e5bccf0f18", "0x0000000000000000000000000000000000021f7372480e990155673aca421d3c", "0x000000000000000000000000000000af317a779fff9a9bd5e39fe4e2082098eb", "0x000000000000000000000000000000000026cafbbf9081ffdd9562474eccbc92", "0x000000000000000000000000000000d384226fd724a5619aa79f5e910712808d", "0x000000000000000000000000000000000012b900f76f9a76b05779ecf575f206", "0x0000000000000000000000000000007477e13ab0d15810aac1056f4d994736f5", "0x00000000000000000000000000000000000bff804ea396adabfbf3b36fc3dd10", "0x00000000000000000000000000000059d4e381ff3a66896e79255cdc98da6dec", "0x0000000000000000000000000000000000045756075364de3e66c808f5d1668b", "0x000000000000000000000000000000fd260732f28fabed03578d110a5706d4e1", "0x000000000000000000000000000000000026f58a2dc0a1dd101ad3d253e9620c", "0x00000000000000000000000000000004f8e98ea4539a8d8d0d9f82404d22157d", "0x000000000000000000000000000000000014c12a6c51e79d2db43e8f5116dd6c", "0x000000000000000000000000000000f4d8ba20147544503965e7bb2981d3951f", "0x0000000000000000000000000000000000220b86c478bfd57b30325667899110", "0x1d82a0aef7a797360673dafff29630b7e3c632e1497225cb596ab143c07b1046", "0x0d1c1171eee7f110a4c50ec6e4fc94c24279d9ec7809d8af89c41aae43e51d80", "0x151e80a34adcdb0188d18dd8b3beab9649e782aba28ac1717b8169f6a93bde21", "0x21237c71806ba651bf3d509be4cd03437cc3f706db4d31d1880b8067c72345d1", "0x141b68f76caec0aeda9536f8755b7c17c1db850892488dce0ec8f0f70d67f015", "0x0c094de3569764fff36c2f4e66226bbca4ee84e6563de3f6b277ce420bf37d7b", "0x02a2b35069ee7f659f933c5e283124aed9ece8a44fa8bc67c5fc6f168da9a5b5", "0x04ba7afa439625c5ff77a234551c36b9342135779ae8391fe2e174f210a619e6", "0x115af34e0d52166961b80e97aa58fe3c6cb6e12df70c2082a1cc207eb5fa0040", "0x22bd41511568be86ff90aef60675405a292b8ad003c800f2b5949b74b7c8e54e", "0x302274973792e9711f24c48f4c98b85b4dc00443666d3573fa3ca6de0e973585", "0x24add600302aa51ce6f74a70a6bcfe55540c6d2ad0da41a222156f99efed18d6", "0x0468d677436ad62604da21dde448b0bca5b6c0cf9c528cd5408a7447e4dfb904", "0x22ef667a8d9e0b9467b790e775cc596e3de73499edbc9577b4e91d7a268f01f0", "0x29c1df3e3380571753ef6016241de5c7cb71ccd246c263b6df9bec7e7a286dc7", "0x14bbe3b53ff9058ec0889a94f4f5d79d337f649324242c90e8b29d7cb952e456", "0x0187bdb2c68cdb6fa0741aff0f82568543cbcf9fb92b1beeab7e7aba9c233698", "0x1cabe0892910ab442a4c44dd68c40ff41a4c69b3313f2f251be86fbff9572944", "0x22b03d84a9fe7814207fa7ca07bf342853f0164b0be41a1da67e1d52f6b0a3e9", "0x1d993a30933b7dc7de220bed415422601b65c4013d49fdfd93f36972ca34b09c", "0x083c5b19c438e80ec31f4466c4963806eeaf5f93f2e4a861fe40a4e98df15e9c", "0x13cb05728a42b34c89ae7f18ab697489b163f9d84d1817106351f9c6c8ff3284", "0x22755bf4bff4d347931fa8fffaf87872a80fe33090d707ac796e4839038f5734", "0x1f61282a43c11532ce4d1a34df03a39f6141f468c22c9bdcf8557bfebac63d0c", "0x024b9c8c29d3492770ae287e974381c7e5b1b76f95c0a9e6013db817ea34d1e4", "0x2f3970428242c5766cf71b959d6e176f86698c1c0b959bfcd4d975708fc5edd2", "0x104227c490fe811756ca788522d9f6d0578976cc66f0deeddb21d9b576ead3b4", "0x29109f273d91504339d6d5c5284ccb124076e1c4568f811e76dd0c1d06de018c", "0x0a9b1b4145b54d8ed6d1811a1838c8031d1e3377bb710c6b142d24fdc208f4b9", "0x0b84999ab82126ec29595d0dd188f58c854fc3d9d1f64e435ff10689190a48ec", "0x03d6021cbf4b20e7256f35a34846dfaded4451ee0180927b63cf6d0e553b936d", "0x02255002fb3b02e320aeca179676eba97f7111344dd966349646d8a5f78d7702", "0x289c9b5bad0a19f146c6d925109da49a0a40df314585ff7b9cab1aa938086678", "0x03150af19f6dcda0b100414c492715aa69acc3554d249701f1f42bc739ae7401", "0x0117c43291c4b46fa5039ffa40b0ed09bb0374243ae95ef8248d588b01f920b7", "0x250978a0e7fa5757f935dde6e38aaf3391a66623de5f31c91c24341c5ed61c9f", "0x0e993cc6eeca345c64166a4c15172eecd8405f9c86fbb203f0f1074724ec4b22", "0x14b275447dcfdd1d429535def019e002e3f0f8e748f4e42a0081a1686a5fdd9f", "0x11923ddb926032223921064ee9673b5561354f7fdaef052ff9949540f1f97571", "0x2927cf6894f1d22a5ddf2aafaa719ec36d34d3490982bc35910ae5b75753e4ce", "0x1a5369631bb00ff82a84045178584077628890863d5e1ebbf7c1d71c4c6d46e4", "0x000000000000000000000000000000af1f118bfb38387a97397bf9283bc302cf", "0x00000000000000000000000000000000000ee3a8b3180464d3f7d2ed7caa3d26", "0x00000000000000000000000000000065fa3c3b681df7676440a9b83362f64b3d", "0x00000000000000000000000000000000000a827719a9b0e36d7e5fcdcf7c624e", "0x00000000000000000000000000000091f09bfceb180ab974e82d56f9f0cda7f3", "0x000000000000000000000000000000000022bec2556d3147f68f2c4d6184dbdd", "0x000000000000000000000000000000bb499952dc91a14efe562aaec18aba025f", "0x000000000000000000000000000000000030087cf97624e5e178b66221a26686"] diff --git a/crates/nargo_cli/tests/test_data/recursion/src/main.nr b/crates/nargo_cli/tests/test_data/recursion/src/main.nr new file mode 100644 index 00000000000..d510c869682 --- /dev/null +++ b/crates/nargo_cli/tests/test_data/recursion/src/main.nr @@ -0,0 +1,32 @@ +use dep::std; + +fn main( + verification_key : [Field; 114], + proof : [Field; 94], + public_inputs : [Field; 1], + key_hash : Field, + input_aggregation_object : [Field; 16], + proof_b : [Field; 94], +) -> pub [Field; 16] { + let output_aggregation_object_a = std::verify_proof( + verification_key, + proof, + public_inputs, + key_hash, + input_aggregation_object + ); + + let output_aggregation_object = std::verify_proof( + verification_key, + proof_b, + public_inputs, + key_hash, + output_aggregation_object_a + ); + + let mut output = [0; 16]; + for i in 0..16 { + output[i] = output_aggregation_object[i]; + } + output +} \ No newline at end of file diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 62775d9be9d..1688dc1d1f0 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -13,7 +13,7 @@ pub mod ssa_refactor; use acvm::{ acir::circuit::{opcodes::Opcode as AcirOpcode, Circuit, PublicInputs}, acir::native_types::{Expression, Witness}, - compiler::{optimizers::simplify::CircuitSimplifier}, + compiler::optimizers::simplify::CircuitSimplifier, Language, }; use errors::{RuntimeError, RuntimeErrorKind}; diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs index 01d5fecc897..a2f71e9b360 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs @@ -96,6 +96,11 @@ pub(crate) fn evaluate( | BlackBoxFunc::HashToField128Security => { prepare_outputs(&mut acir_gen.memory, instruction_id, 1, ctx, evaluator) } + // There are some low level functions that have variable outputs and should not have a set output count + // in Noir + BlackBoxFunc::VerifyProof => { + prepare_outputs_no_count(&mut acir_gen.memory, instruction_id, ctx, evaluator) + } _ => panic!("Unsupported low level function {:?}", op), }; let func_call = match op { @@ -143,6 +148,41 @@ pub(crate) fn evaluate( inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), output: outputs[0], }, + BlackBoxFunc::VerifyProof => { + let has_previous_aggregation = evaluator.opcodes.iter().any(|op| match op { + AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::VerifyProof { .. }) => true, + _ => false, + }); + + let node_object = + ctx.try_get_node(args[4]).expect("could not find node for {node_id}"); + let array_id = match node_object { + node::NodeObject::Variable(_) => { + let node_obj_type = node_object.get_type(); + match node_obj_type { + node::ObjectType::ArrayPointer(a) => a, + _ => unreachable!(), + } + } + _ => todo!("generate a witness"), + }; + let array = &ctx.mem[array_id]; + let input_aggregation_object = if !has_previous_aggregation { + vec![FunctionInput { witness: Witness(0), num_bits: 0 }; array.len as usize] + } else { + resolve_array(&args[4], acir_gen, ctx, evaluator) + }; + + BlackBoxFuncCall::VerifyProof { + key: resolve_array(&args[0], acir_gen, ctx, evaluator), + proof: resolve_array(&args[1], acir_gen, ctx, evaluator), + public_inputs: resolve_array(&args[2], acir_gen, ctx, evaluator), + key_hash: resolve_variable(&args[3], acir_gen, ctx, evaluator).unwrap(), + input_aggregation_object, + nested_aggregation_object: vec![], + outputs: outputs.to_vec(), + } + } _ => panic!("Unsupported low level function {:?}", op), }; evaluator.opcodes.push(AcirOpcode::BlackBoxFuncCall(func_call)); @@ -272,6 +312,25 @@ fn prepare_outputs( outputs } +fn prepare_outputs_no_count( + memory_map: &mut AcirMem, + pointer: NodeId, + ctx: &SsaContext, + evaluator: &mut Evaluator, +) -> Vec { + // Create fresh variables that will link to the output + let l_obj = ctx.try_get_node(pointer).unwrap(); + if let node::ObjectType::ArrayPointer(a) = l_obj.get_type() { + let mem_array = &ctx.mem[a]; + let output_nb = mem_array.len; + let outputs = vecmap(0..output_nb, |_| evaluator.add_witness_to_cs()); + memory_map.map_array(a, &outputs, ctx); + outputs + } else { + vec![evaluator.add_witness_to_cs()] + } +} + fn evaluate_println( var_cache: &mut InternalVarCache, memory_map: &mut AcirMem, diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 96cdb2f99cb..051c221619c 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -246,9 +246,7 @@ mod test { _key: &[FunctionInput], _proof: &[FunctionInput], _public_inputs: &[FunctionInput], - _key_hash: &FunctionInput, _input_aggregation_object: &[FunctionInput], - _nested_aggregation_object: &[FunctionInput], _outputs: &[Witness], ) -> Result { panic!("Path not trodden by this test") diff --git a/crates/noirc_evaluator/src/ssa/builtin.rs b/crates/noirc_evaluator/src/ssa/builtin.rs index 97279317749..111dac1f090 100644 --- a/crates/noirc_evaluator/src/ssa/builtin.rs +++ b/crates/noirc_evaluator/src/ssa/builtin.rs @@ -76,7 +76,7 @@ impl Opcode { | BlackBoxFunc::Keccak256 | BlackBoxFunc::Blake2s | BlackBoxFunc::Pedersen - | BlackBoxFunc::FixedBaseScalarMul + | BlackBoxFunc::FixedBaseScalarMul | BlackBoxFunc::VerifyProof => BigUint::zero(), // Verify returns zero or one BlackBoxFunc::SchnorrVerify | BlackBoxFunc::EcdsaSecp256k1 => BigUint::one(), diff --git a/crates/noirc_evaluator/src/ssa_refactor.rs b/crates/noirc_evaluator/src/ssa_refactor.rs index 911a5ae6837..46c7750a12f 100644 --- a/crates/noirc_evaluator/src/ssa_refactor.rs +++ b/crates/noirc_evaluator/src/ssa_refactor.rs @@ -8,7 +8,10 @@ #![allow(dead_code)] use crate::errors::RuntimeError; -use acvm::{acir::circuit::{Circuit, Opcode as AcirOpcode}, Language}; +use acvm::{ + acir::circuit::{Circuit, Opcode as AcirOpcode}, + Language, +}; use noirc_abi::Abi; use noirc_frontend::monomorphization::ast::Program; diff --git a/crates/noirc_frontend/src/monomorphization/mod.rs b/crates/noirc_frontend/src/monomorphization/mod.rs index 3c3c602d132..78195864d96 100644 --- a/crates/noirc_frontend/src/monomorphization/mod.rs +++ b/crates/noirc_frontend/src/monomorphization/mod.rs @@ -722,6 +722,7 @@ impl<'interner> Monomorphizer<'interner> { arguments: &[node_interner::ExprId], result_type: &ast::Type, ) -> Option { + // dbg!(func.clone()); if let ast::Expression::Ident(ident) = func { if let Definition::Builtin(opcode) = &ident.definition { if opcode == "array_len" { @@ -756,6 +757,20 @@ impl<'interner> Monomorphizer<'interner> { return Some(self.modulus_array_literal(bytes, 8)); } } + // if let Definition::LowLevel(opcode) = &ident.definition { + // dbg!(opcode.clone()); + // let array = self.interner.id_type(arguments[4]); + // dbg!(array.clone()); + // let element = Self::convert_type(&array); + // dbg!(element.clone()); + // match array { + // crate::Type::Array(len, t) => { + // dbg!(len); + // dbg!(t); + // } + // _ => panic!("input agg obj must be an array") + // } + // } } None } diff --git a/flake.lock b/flake.lock index 53b65eb4b4f..3fabb08cc4e 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1683909802, - "narHash": "sha256-2CL8NYKLYwwy6n0RyldvH86ULgrSvfzHrgq2Qf0ZUkE=", + "lastModified": 1684257632, + "narHash": "sha256-hTE01ftKdbBJXRRVBeqC4Q+GmpBl3L+YYJwOt32tSrM=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "97c9bc72aebab850b4a647d6e6cc50085226eafb", + "rev": "7ecb574fd52fcc99de862b7ca75d7d0d9e8a5673", "type": "github" }, "original": { diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index e3b4351610a..1a522bdb8fb 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -16,4 +16,4 @@ fn println(_input : T) {} // TODO: have the compiler insert the key_hash and remove as param #[foreign(verify_proof)] -fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : Field, _key_hash : Field, _input_aggregation_object : [Field]) -> [Field] {} \ No newline at end of file +fn verify_proof(_verification_key : [Field], _proof : [Field], _public_inputs : [Field], _key_hash : Field, _input_aggregation_object : [Field]) -> [Field] {} \ No newline at end of file