mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-07 20:30:34 +00:00
Update test to pass multiple ConcreteCircuits
This commit is contained in:
parent
def65609b1
commit
de86391f0e
4 changed files with 38 additions and 9 deletions
|
|
@ -20,6 +20,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
|
||||||
// Initialize the polynomial commitment parameters
|
// Initialize the polynomial commitment parameters
|
||||||
let params: Params<EqAffine> = Params::new(k);
|
let params: Params<EqAffine> = Params::new(k);
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
struct PLONKConfig {
|
struct PLONKConfig {
|
||||||
a: Column<Advice>,
|
a: Column<Advice>,
|
||||||
b: Column<Advice>,
|
b: Column<Advice>,
|
||||||
|
|
@ -43,6 +44,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
|
||||||
fn copy(&mut self, a: Variable, b: Variable) -> Result<(), Error>;
|
fn copy(&mut self, a: Variable, b: Variable) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct MyCircuit<F: FieldExt> {
|
struct MyCircuit<F: FieldExt> {
|
||||||
a: Option<F>,
|
a: Option<F>,
|
||||||
k: u32,
|
k: u32,
|
||||||
|
|
@ -241,7 +243,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
|
||||||
|
|
||||||
// Create a proof
|
// Create a proof
|
||||||
let mut transcript = DummyHashWrite::init(vec![], Fq::one());
|
let mut transcript = DummyHashWrite::init(vec![], Fq::one());
|
||||||
create_proof(¶ms, &pk, &circuit, &[], &mut transcript)
|
create_proof(¶ms, &pk, &[circuit], &[], &mut transcript)
|
||||||
.expect("proof generation should not fail")
|
.expect("proof generation should not fail")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -253,7 +255,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
|
||||||
|
|
||||||
// Create a proof
|
// Create a proof
|
||||||
let mut transcript = DummyHashWrite::init(vec![], Fq::one());
|
let mut transcript = DummyHashWrite::init(vec![], Fq::one());
|
||||||
create_proof(¶ms, &pk, &circuit, &[], &mut transcript)
|
create_proof(¶ms, &pk, &[circuit], &[], &mut transcript)
|
||||||
.expect("proof generation should not fail");
|
.expect("proof generation should not fail");
|
||||||
let proof = transcript.finalize();
|
let proof = transcript.finalize();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use std::marker::PhantomData;
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Variable(Column<Advice>, usize);
|
pub struct Variable(Column<Advice>, usize);
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
struct PLONKConfig {
|
struct PLONKConfig {
|
||||||
a: Column<Advice>,
|
a: Column<Advice>,
|
||||||
b: Column<Advice>,
|
b: Column<Advice>,
|
||||||
|
|
@ -43,6 +44,7 @@ trait StandardCS<FF: FieldExt> {
|
||||||
F: FnOnce() -> Result<FF, Error>;
|
F: FnOnce() -> Result<FF, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct MyCircuit<F: FieldExt> {
|
struct MyCircuit<F: FieldExt> {
|
||||||
a: Option<F>,
|
a: Option<F>,
|
||||||
k: u32,
|
k: u32,
|
||||||
|
|
@ -278,7 +280,7 @@ fn main() {
|
||||||
|
|
||||||
// Create a proof
|
// Create a proof
|
||||||
let mut transcript = DummyHashWrite::init(vec![], Fq::one());
|
let mut transcript = DummyHashWrite::init(vec![], Fq::one());
|
||||||
create_proof(¶ms, &pk, &circuit, &[pubinputs], &mut transcript)
|
create_proof(¶ms, &pk, &[circuit], &[&[pubinputs]], &mut transcript)
|
||||||
.expect("proof generation should not fail");
|
.expect("proof generation should not fail");
|
||||||
let proof: Vec<u8> = transcript.finalize();
|
let proof: Vec<u8> = transcript.finalize();
|
||||||
|
|
||||||
|
|
@ -288,7 +290,14 @@ fn main() {
|
||||||
let pubinput_slice = &[pubinput];
|
let pubinput_slice = &[pubinput];
|
||||||
let msm = params.empty_msm();
|
let msm = params.empty_msm();
|
||||||
let mut transcript = DummyHashRead::init(&proof[..], Fq::one());
|
let mut transcript = DummyHashRead::init(&proof[..], Fq::one());
|
||||||
let guard = verify_proof(¶ms, pk.get_vk(), msm, pubinput_slice, &mut transcript).unwrap();
|
let guard = verify_proof(
|
||||||
|
¶ms,
|
||||||
|
pk.get_vk(),
|
||||||
|
msm,
|
||||||
|
&[pubinput_slice],
|
||||||
|
&mut transcript,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
let msm = guard.clone().use_challenges();
|
let msm = guard.clone().use_challenges();
|
||||||
assert!(msm.eval());
|
assert!(msm.eval());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,14 @@ pub enum VerifyFailure {
|
||||||
/// };
|
/// };
|
||||||
/// const K: u32 = 5;
|
/// const K: u32 = 5;
|
||||||
///
|
///
|
||||||
|
/// #[derive(Copy, Clone)]
|
||||||
/// struct MyConfig {
|
/// struct MyConfig {
|
||||||
/// a: Column<Advice>,
|
/// a: Column<Advice>,
|
||||||
/// b: Column<Advice>,
|
/// b: Column<Advice>,
|
||||||
/// c: Column<Advice>,
|
/// c: Column<Advice>,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
/// #[derive(Clone)]
|
||||||
/// struct MyCircuit {
|
/// struct MyCircuit {
|
||||||
/// a: Option<u64>,
|
/// a: Option<u64>,
|
||||||
/// b: Option<u64>,
|
/// b: Option<u64>,
|
||||||
|
|
|
||||||
26
src/plonk.rs
26
src/plonk.rs
|
|
@ -164,6 +164,7 @@ fn test_proving() {
|
||||||
// Initialize the polynomial commitment parameters
|
// Initialize the polynomial commitment parameters
|
||||||
let params: Params<EqAffine> = Params::new(K);
|
let params: Params<EqAffine> = Params::new(K);
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
struct PLONKConfig {
|
struct PLONKConfig {
|
||||||
a: Column<Advice>,
|
a: Column<Advice>,
|
||||||
b: Column<Advice>,
|
b: Column<Advice>,
|
||||||
|
|
@ -197,6 +198,7 @@ fn test_proving() {
|
||||||
fn lookup_table(&mut self, values: &[Vec<FF>]) -> Result<(), Error>;
|
fn lookup_table(&mut self, values: &[Vec<FF>]) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct MyCircuit<F: FieldExt> {
|
struct MyCircuit<F: FieldExt> {
|
||||||
a: Option<F>,
|
a: Option<F>,
|
||||||
lookup_tables: Vec<Vec<F>>,
|
lookup_tables: Vec<Vec<F>>,
|
||||||
|
|
@ -507,18 +509,25 @@ fn test_proving() {
|
||||||
create_proof(
|
create_proof(
|
||||||
¶ms,
|
¶ms,
|
||||||
&pk,
|
&pk,
|
||||||
&circuit,
|
&[circuit.clone(), circuit.clone()],
|
||||||
&[pubinputs.clone()],
|
&[&[pubinputs.clone()], &[pubinputs.clone()]],
|
||||||
&mut transcript,
|
&mut transcript,
|
||||||
)
|
)
|
||||||
.expect("proof generation should not fail");
|
.expect("proof generation should not fail");
|
||||||
let proof: Vec<u8> = transcript.finalize();
|
let proof: Vec<u8> = transcript.finalize();
|
||||||
|
|
||||||
let pubinput_slice = &[pubinput];
|
let pubinput_slice = &[pubinput];
|
||||||
|
let pubinput_slice_copy = &[pubinput];
|
||||||
let msm = params.empty_msm();
|
let msm = params.empty_msm();
|
||||||
let mut transcript = DummyHashRead::init(&proof[..], Fq::one());
|
let mut transcript = DummyHashRead::init(&proof[..], Fq::one());
|
||||||
let guard =
|
let guard = verify_proof(
|
||||||
verify_proof(¶ms, pk.get_vk(), msm, pubinput_slice, &mut transcript).unwrap();
|
¶ms,
|
||||||
|
pk.get_vk(),
|
||||||
|
msm,
|
||||||
|
&[pubinput_slice, pubinput_slice_copy],
|
||||||
|
&mut transcript,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
{
|
{
|
||||||
let msm = guard.clone().use_challenges();
|
let msm = guard.clone().use_challenges();
|
||||||
assert!(msm.eval());
|
assert!(msm.eval());
|
||||||
|
|
@ -535,7 +544,14 @@ fn test_proving() {
|
||||||
pk.get_vk().write(&mut vk_buffer).unwrap();
|
pk.get_vk().write(&mut vk_buffer).unwrap();
|
||||||
let vk = VerifyingKey::<EqAffine>::read::<_, MyCircuit<Fp>>(&mut &vk_buffer[..], ¶ms)
|
let vk = VerifyingKey::<EqAffine>::read::<_, MyCircuit<Fp>>(&mut &vk_buffer[..], ¶ms)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let guard = verify_proof(¶ms, &vk, msm, pubinput_slice, &mut transcript).unwrap();
|
let guard = verify_proof(
|
||||||
|
¶ms,
|
||||||
|
&vk,
|
||||||
|
msm,
|
||||||
|
&[pubinput_slice, pubinput_slice_copy],
|
||||||
|
&mut transcript,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
{
|
{
|
||||||
let msm = guard.clone().use_challenges();
|
let msm = guard.clone().use_challenges();
|
||||||
assert!(msm.eval());
|
assert!(msm.eval());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue