forked from microsoft/Nova
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates our main to be in sync with upstream. Branch was protected so creating PR. I notice there are a lot of changes in upstream and some seem relevant for our purposes. After this is merged, we can update the hypernova branch. --------- Co-authored-by: François Garillot <4142+huitseeker@users.noreply.github.com> Co-authored-by: Chiro Hiro <chiro8x@gmail.com> Co-authored-by: François Garillot <francois@garillot.net> Co-authored-by: Srinath Setty <srinath@microsoft.com> Co-authored-by: Leo Alt <leo@ethereum.org> Co-authored-by: JunheeLee <101318348+Jun-Hee-Lee@users.noreply.github.com> Co-authored-by: 3for <zouyudi@gmail.com>
- Loading branch information
1 parent
7193483
commit 271f554
Showing
30 changed files
with
2,275 additions
and
1,418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
use std::{marker::PhantomData, time::Duration}; | ||
|
||
use bellperson::{gadgets::num::AllocatedNum, ConstraintSystem, SynthesisError}; | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use ff::PrimeField; | ||
use nova_snark::{ | ||
traits::{ | ||
circuit::{StepCircuit, TrivialTestCircuit}, | ||
Group, | ||
}, | ||
PublicParams, | ||
}; | ||
|
||
type G1 = pasta_curves::pallas::Point; | ||
type G2 = pasta_curves::vesta::Point; | ||
type C1 = NonTrivialTestCircuit<<G1 as Group>::Scalar>; | ||
type C2 = TrivialTestCircuit<<G2 as Group>::Scalar>; | ||
|
||
criterion_group! { | ||
name = compute_digest; | ||
config = Criterion::default().warm_up_time(Duration::from_millis(3000)).sample_size(10); | ||
targets = bench_compute_digest | ||
} | ||
|
||
criterion_main!(compute_digest); | ||
|
||
fn bench_compute_digest(c: &mut Criterion) { | ||
c.bench_function("compute_digest", |b| { | ||
b.iter(|| { | ||
PublicParams::<G1, G2, C1, C2>::setup(black_box(C1::new(10)), black_box(C2::default())) | ||
}) | ||
}); | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
struct NonTrivialTestCircuit<F: PrimeField> { | ||
num_cons: usize, | ||
_p: PhantomData<F>, | ||
} | ||
|
||
impl<F> NonTrivialTestCircuit<F> | ||
where | ||
F: PrimeField, | ||
{ | ||
pub fn new(num_cons: usize) -> Self { | ||
Self { | ||
num_cons, | ||
_p: Default::default(), | ||
} | ||
} | ||
} | ||
impl<F> StepCircuit<F> for NonTrivialTestCircuit<F> | ||
where | ||
F: PrimeField, | ||
{ | ||
fn arity(&self) -> usize { | ||
1 | ||
} | ||
|
||
fn synthesize<CS: ConstraintSystem<F>>( | ||
&self, | ||
cs: &mut CS, | ||
z: &[AllocatedNum<F>], | ||
) -> Result<Vec<AllocatedNum<F>>, SynthesisError> { | ||
// Consider a an equation: `x^2 = y`, where `x` and `y` are respectively the input and output. | ||
let mut x = z[0].clone(); | ||
let mut y = x.clone(); | ||
for i in 0..self.num_cons { | ||
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?; | ||
x = y.clone(); | ||
} | ||
Ok(vec![y]) | ||
} | ||
|
||
fn output(&self, z: &[F]) -> Vec<F> { | ||
let mut x = z[0]; | ||
let mut y = x; | ||
for _i in 0..self.num_cons { | ||
y = x * x; | ||
x = y; | ||
} | ||
vec![y] | ||
} | ||
} |
Oops, something went wrong.