Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

co-circom and co-noir lib usability refactor #304

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions co-circom/circom-mpc-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ where
fn parse_inner(mut self) -> Result<CoCircomCompilerParsed<P::ScalarField>> {
tracing::debug!("compiler starts parsing..");
let program_archive = self.get_program_archive()?;
let public_inputs = program_archive.public_inputs.clone();
let (circuit, output_mapping) = self.build_circuit(program_archive)?;
tracing::debug!("output mapping: {output_mapping:?}");
let constant_table = circuit
Expand Down Expand Up @@ -740,6 +741,7 @@ where
.map(|x| (x.name, x.start, x.size))
.collect(),
output_mapping,
public_inputs,
))
}
}
Expand Down
1 change: 1 addition & 0 deletions co-circom/circom-mpc-vm/src/mpc/rep3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl<F: PrimeField, N: Rep3Network> CircomRep3VmWitnessExtension<F, N> {
})
}

/// Get the underlying network
pub fn get_network(self) -> N {
self.io_context0.network
}
Expand Down
8 changes: 8 additions & 0 deletions co-circom/circom-mpc-vm/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub struct CoCircomCompilerParsed<F: PrimeField> {
pub(crate) main_outputs: usize,
pub(crate) main_input_list: InputList,
pub(crate) output_mapping: OutputMapping,
pub(crate) public_inputs: Vec<String>,
}

impl<F: PrimeField> CoCircomCompilerParsed<F> {
Expand All @@ -126,6 +127,7 @@ impl<F: PrimeField> CoCircomCompilerParsed<F> {
main_outputs: usize,
main_input_list: InputList,
output_mapping: OutputMapping,
public_inputs: Vec<String>,
) -> Self {
Self {
main,
Expand All @@ -139,6 +141,7 @@ impl<F: PrimeField> CoCircomCompilerParsed<F> {
main_outputs,
main_input_list,
output_mapping,
public_inputs,
}
}
}
Expand Down Expand Up @@ -201,4 +204,9 @@ impl<F: PrimeField> CoCircomCompilerParsed<F> {
vm_config,
)
}

/// Get public input names.
pub fn public_inputs(&self) -> &[String] {
&self.public_inputs
}
}
12 changes: 12 additions & 0 deletions co-circom/circom-types/src/groth16/verification_key.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! This module defines the [`JsonVerificationKey`] struct that implements de/serialization using [`serde`].
use std::io::Read;
use std::marker::PhantomData;

use ark_ec::pairing::Pairing;
Expand Down Expand Up @@ -54,6 +55,17 @@ where
pub ic: Vec<P::G1Affine>,
}

impl<P: Pairing + CircomArkworksPairingBridge> JsonVerificationKey<P>
where
P::BaseField: CircomArkworksPrimeFieldBridge,
P::ScalarField: CircomArkworksPrimeFieldBridge,
{
/// Deserializes a [`JsonVerificationKey`] from a reader.
pub fn from_reader<R: Read>(rdr: R) -> Result<Self, serde_json::Error> {
serde_json::from_reader(rdr)
}
}

fn serialize_g1_sequence<S: Serializer, P: Pairing + CircomArkworksPairingBridge>(
p: &[P::G1Affine],
ser: S,
Expand Down
Loading