From 23883ff69bc96db0bbdd53125a58e140e21ed972 Mon Sep 17 00:00:00 2001 From: Franco Nieddu Date: Thu, 28 Nov 2024 16:47:30 +0100 Subject: [PATCH] fix: fixed a bug where the constant for linear terms was ignored --- co-noir/co-acvm/src/mpc/rep3.rs | 3 ++- co-noir/co-noir/examples/run_full_quantized.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 co-noir/co-noir/examples/run_full_quantized.sh diff --git a/co-noir/co-acvm/src/mpc/rep3.rs b/co-noir/co-acvm/src/mpc/rep3.rs index 581e7afbb..3d94a961e 100644 --- a/co-noir/co-acvm/src/mpc/rep3.rs +++ b/co-noir/co-acvm/src/mpc/rep3.rs @@ -340,7 +340,8 @@ impl NoirWitnessExtensionProtocol for Rep3Acvm } (Rep3AcvmType::Public(public), Rep3AcvmType::Shared(shared)) | (Rep3AcvmType::Shared(shared), Rep3AcvmType::Public(public)) => { - Rep3AcvmType::Shared(arithmetic::mul_public(shared, public)) + let mul = arithmetic::mul_public(shared, public); + Rep3AcvmType::Shared(arithmetic::mul_public(mul, c)) } (Rep3AcvmType::Shared(lhs), Rep3AcvmType::Shared(rhs)) => { let shared_mul = arithmetic::mul(lhs, rhs, &mut self.io_context)?; diff --git a/co-noir/co-noir/examples/run_full_quantized.sh b/co-noir/co-noir/examples/run_full_quantized.sh new file mode 100755 index 000000000..ca0aa4082 --- /dev/null +++ b/co-noir/co-noir/examples/run_full_quantized.sh @@ -0,0 +1,16 @@ +# split input into shares +cargo run --release --bin co-noir -- split-input --circuit test_vectors/quantized/quantized.json --input test_vectors/quantized/Prover.toml --protocol REP3 --out-dir test_vectors/quantized +# run witness extension in MPC +cargo run --release --bin co-noir -- generate-witness --input test_vectors/quantized/Prover.toml.0.shared --circuit test_vectors/quantized/quantized.json --protocol REP3 --config configs/party1.toml --out test_vectors/quantized/quantized.gz.0.shared & +cargo run --release --bin co-noir -- generate-witness --input test_vectors/quantized/Prover.toml.1.shared --circuit test_vectors/quantized/quantized.json --protocol REP3 --config configs/party2.toml --out test_vectors/quantized/quantized.gz.1.shared & +cargo run --release --bin co-noir -- generate-witness --input test_vectors/quantized/Prover.toml.2.shared --circuit test_vectors/quantized/quantized.json --protocol REP3 --config configs/party3.toml --out test_vectors/quantized/quantized.gz.2.shared +wait $(jobs -p) +# run proving in MPC +cargo run --release --bin co-noir -- build-and-generate-proof --witness test_vectors/quantized/quantized.gz.0.shared --circuit test_vectors/quantized/quantized.json --crs test_vectors/bn254_g1.dat --protocol REP3 --hasher KECCAK --config configs/party1.toml --out proof.0.proof --public-input public_input.json & +cargo run --release --bin co-noir -- build-and-generate-proof --witness test_vectors/quantized/quantized.gz.1.shared --circuit test_vectors/quantized/quantized.json --crs test_vectors/bn254_g1.dat --protocol REP3 --hasher KECCAK --config configs/party2.toml --out proof.1.proof & +cargo run --release --bin co-noir -- build-and-generate-proof --witness test_vectors/quantized/quantized.gz.2.shared --circuit test_vectors/quantized/quantized.json --crs test_vectors/bn254_g1.dat --protocol REP3 --hasher KECCAK --config configs/party3.toml --out proof.2.proof +wait $(jobs -p) +# Create verification key +cargo run --release --bin co-noir -- create-vk --circuit test_vectors/quantized/quantized.json --crs test_vectors/bn254_g1.dat --hasher KECCAK --vk test_vectors/quantized/verification_key +# verify proof +cargo run --release --bin co-noir -- verify --proof proof.0.proof --vk test_vectors/quantized/verification_key --hasher KECCAK --crs test_vectors/bn254_g2.dat