Skip to content

Commit

Permalink
refactor!: with_network_config for ShamirGroth16 doesn't need zkey an…
Browse files Browse the repository at this point in the history
…ymore

BREAKING CHANGE: Removes the zkey in the said function signature. We needed
it earlier because we had to know domain size, which we now no longer need.
  • Loading branch information
0xThemis authored and dkales committed Oct 15, 2024
1 parent d0d1376 commit 2052d89
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion co-circom/co-circom/src/bin/co-circom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ where
let public_input = witness_share.public_inputs.clone();

// connect to network
let prover = ShamirCoGroth16::with_network_config(t, config.network, &zkey)
let prover = ShamirCoGroth16::with_network_config(t, config.network)
.context("while building prover")?;

// execute prover in MPC
Expand Down
12 changes: 4 additions & 8 deletions co-circom/co-groth16/src/groth16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,10 @@ where
P::ScalarField: CircomArkworksPrimeFieldBridge,
{
/// Create a new [ShamirCoGroth16] protocol with a given network configuration.
pub fn with_network_config(
threshold: usize,
config: NetworkConfig,
zkey: &ZKey<P>,
) -> Result<Self> {
let domain_size = 2usize.pow(u32::try_from(zkey.pow).expect("pow fits into u32"));
// we need domain_size + 2 + 1 number of corr rand pairs in witness_map_from_matrices (degree_reduce_vec + r and s + 1 for fork)
let num_pairs = domain_size + 2 + 1;
pub fn with_network_config(threshold: usize, config: NetworkConfig) -> Result<Self> {
// we need 2 + 1 number of corr rand pairs. We need the values r/s (1 pair) and 2 muls (2
// pairs)
let num_pairs = 3;
let mpc_net = ShamirMpcNet::new(config)?;
let preprocessing = ShamirPreprocessing::new(threshold, mpc_net, num_pairs)?;
let mut protocol0 = ShamirProtocol::from(preprocessing);
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/circom/e2e_tests/shamir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ macro_rules! add_test_impl {
threads.push(thread::spawn(move || {
let domain_size = 2usize.pow(u32::try_from(zkey.pow).expect("pow fits into u32"));
let num_pairs = match stringify!($proof_system) {
"Groth16" => domain_size + 2 + 1,
"Groth16" => 3,
"Plonk"=> domain_size * 222 + 15,
_ => unreachable!()
};
Expand Down

0 comments on commit 2052d89

Please sign in to comment.