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

Master #42

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1166d66
feat: replace ark-groth16 from 0.3.0 to 0.4.0 to make buildable and t…
mariobenissimo Oct 19, 2023
246591f
feat: start writing circuit for pst-mipp and create new struct for po…
mariobenissimo Nov 4, 2023
5c2b0d1
feat: add parse poseidon config from ScalarField to BaseField
mariobenissimo Nov 9, 2023
4020529
feat: add absorb and challange
mariobenissimo Nov 9, 2023
8f4f91e
feat: added part of the circuit (delete reduce and par_iter)
mariobenissimo Nov 10, 2023
f170f2a
feat: start write check2 verify pst as circuit
mariobenissimo Nov 10, 2023
2978f80
feat: finish write circuit for check2
mariobenissimo Nov 10, 2023
ea4987d
feat: finish circuit and write groth16 verifier
mariobenissimo Nov 13, 2023
bacfc10
feat: add new file and create function for mipp
mariobenissimo Nov 15, 2023
8f860f0
feat: try to test poseidon
mariobenissimo Nov 17, 2023
8e6e986
feat: add print vec byte
mariobenissimo Nov 17, 2023
2a969c5
feat: add absorb made with bytes
mariobenissimo Nov 19, 2023
8b586f5
feat: add groth16 verifier inside the circuit
mariobenissimo Nov 27, 2023
1062c3c
feat: check poseidon function from native to circuit
mariobenissimo Nov 28, 2023
4bcda28
feat: hash non native inside the circuit
mariobenissimo Nov 29, 2023
c08674f
feat: allocated naive scalar as NonNative inside the circuit and fini…
rosariocannavo Nov 29, 2023
286794e
feat: start to translate the r1csproof poseidon from scalarfield to b…
rosariocannavo Dec 4, 2023
8eed040
feat: clean code and make benchmarks for testudo_comm
mariobenissimo Dec 13, 2023
ba0e9fc
fix: changed number of params in benchmark
rosariocannavo Dec 13, 2023
e289942
fix: Error AssignmentMissing in circuit variable
mariobenissimo Dec 14, 2023
bcd3c8b
feat: added groth16 proof generation time bench
rosariocannavo Dec 14, 2023
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
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ ark-bls12-377 = { version = "0.4.0", features = ["r1cs","curve"] }
ark-bls12-381 = { version = "0.4.0", features = ["curve"] }
ark-blst = { git = "https://github.com/nikkolasg/ark-blst" }
ark-serialize = { version = "0.4.0", features = ["derive"] }
ark-crypto-primitives = {version = "0.4.0", features = ["sponge","r1cs","snark"] }
ark-crypto-primitives = {version = "^0.4.0", features = ["sponge","r1cs","snark"] }
ark-r1cs-std = { version = "0.4.0", default-features = false }
ark-relations = { version = "0.4.0", default-features = false, optional = true }
ark-snark = { version = "0.4.0", default-features = false }
ark-groth16 = { version = "0.3.0" }
ark-groth16 = { version = "0.4.0", features = ["r1cs"] }
ark-bw6-761 = { version = "0.4.0" }
ark-poly-commit = { version = "0.4.0" }
ark-poly = {version = "0.4.0"}
Expand All @@ -47,6 +47,7 @@ tracing-subscriber = { version = "0.2" }


[dev-dependencies]
rand_chacha = { version = "0.3.0", default-features = false }
serde = { version = "1.0", features = ["derive"] }
csv = "1.1.5"
criterion = "0.3.6"
Expand All @@ -67,6 +68,10 @@ harness = false
name = "pst"
harness = false

[[bench]]
name = "testudo_comm"
harness = false

[features]
multicore = ["rayon"]
profile = []
Expand Down
197 changes: 99 additions & 98 deletions benches/pst.rs
Original file line number Diff line number Diff line change
@@ -1,98 +1,99 @@
use std::time::Instant;

use ark_poly_commit::multilinear_pc::MultilinearPC;
use ark_serialize::CanonicalSerialize;
use libtestudo::{
parameters::PoseidonConfiguration, poseidon_transcript::PoseidonTranscript, sqrt_pst::Polynomial,
};
use serde::Serialize;
type F = ark_bls12_377::Fr;
type E = ark_bls12_377::Bls12_377;
use ark_std::UniformRand;

#[derive(Default, Clone, Serialize)]
struct BenchmarkResults {
power: usize,
commit_time: u128,
opening_time: u128,
verification_time: u128,
proof_size: usize,
commiter_key_size: usize,
}
fn main() {
let params = ark_bls12_377::Fr::poseidon_params();

let mut writer = csv::Writer::from_path("sqrt_pst.csv").expect("unable to open csv writer");
for &s in [4, 5, 20, 27].iter() {
println!("Running for {} inputs", s);
let mut rng = ark_std::test_rng();
let mut br = BenchmarkResults::default();
br.power = s;
let num_vars = s;
let len = 2_usize.pow(num_vars as u32);
let z: Vec<F> = (0..len).into_iter().map(|_| F::rand(&mut rng)).collect();
let r: Vec<F> = (0..num_vars)
.into_iter()
.map(|_| F::rand(&mut rng))
.collect();

let setup_vars = (num_vars as f32 / 2.0).ceil() as usize;
let gens = MultilinearPC::<E>::setup((num_vars as f32 / 2.0).ceil() as usize, &mut rng);
let (ck, vk) = MultilinearPC::<E>::trim(&gens, setup_vars);

let mut cks = Vec::<u8>::new();
ck.serialize_with_mode(&mut cks, ark_serialize::Compress::Yes)
.unwrap();
br.commiter_key_size = cks.len();

let mut pl = Polynomial::from_evaluations(&z.clone());

let v = pl.eval(&r);

let start = Instant::now();
let (comm_list, t) = pl.commit(&ck);
let duration = start.elapsed().as_millis();
br.commit_time = duration;

let mut prover_transcript = PoseidonTranscript::new(&params);

let start = Instant::now();
let (u, pst_proof, mipp_proof) = pl.open(&mut prover_transcript, comm_list, &ck, &r, &t);
let duration = start.elapsed().as_millis();
br.opening_time = duration;

let mut p1 = Vec::<u8>::new();
let mut p2 = Vec::<u8>::new();
pst_proof
.serialize_with_mode(&mut p1, ark_serialize::Compress::Yes)
.unwrap();

mipp_proof
.serialize_with_mode(&mut p2, ark_serialize::Compress::Yes)
.unwrap();

br.proof_size = p1.len() + p2.len();

let mut verifier_transcript = PoseidonTranscript::new(&params);

let start = Instant::now();
let res = Polynomial::verify(
&mut verifier_transcript,
&vk,
&u,
&r,
v,
&pst_proof,
&mipp_proof,
&t,
);
let duration = start.elapsed().as_millis();
br.verification_time = duration;
assert!(res == true);

writer
.serialize(br)
.expect("unable to write results to csv");
writer.flush().expect("wasn't able to flush");
}
}
// use std::time::Instant;

// use ark_poly_commit::multilinear_pc::MultilinearPC;
// use ark_serialize::CanonicalSerialize;
// use libtestudo::{
// parameters::PoseidonConfiguration, poseidon_transcript::PoseidonTranscript, sqrt_pst::Polynomial,
// };
// use serde::Serialize;
// type F = ark_bls12_377::Fr;
// type E = ark_bls12_377::Bls12_377;
// use ark_std::UniformRand;

// #[derive(Default, Clone, Serialize)]
// struct BenchmarkResults {
// power: usize,
// commit_time: u128,
// opening_time: u128,
// verification_time: u128,
// proof_size: usize,
// commiter_key_size: usize,
// }
// fn main() {
// let params = ark_bls12_377::Fr::poseidon_params();

// let mut writer = csv::Writer::from_path("sqrt_pst.csv").expect("unable to open csv writer");
// for &s in [4, 5, 20, 27].iter() {
// println!("Running for {} inputs", s);
// let mut rng = ark_std::test_rng();
// let mut br = BenchmarkResults::default();
// br.power = s;
// let num_vars = s;
// let len = 2_usize.pow(num_vars as u32);
// let z: Vec<F> = (0..len).into_iter().map(|_| F::rand(&mut rng)).collect();
// let r: Vec<F> = (0..num_vars)
// .into_iter()
// .map(|_| F::rand(&mut rng))
// .collect();

// let setup_vars = (num_vars as f32 / 2.0).ceil() as usize;
// let gens = MultilinearPC::<E>::setup((num_vars as f32 / 2.0).ceil() as usize, &mut rng);
// let (ck, vk) = MultilinearPC::<E>::trim(&gens, setup_vars);

// let mut cks = Vec::<u8>::new();
// ck.serialize_with_mode(&mut cks, ark_serialize::Compress::Yes)
// .unwrap();
// br.commiter_key_size = cks.len();

// let mut pl = Polynomial::from_evaluations(&z.clone());

// let v = pl.eval(&r);

// let start = Instant::now();
// let (comm_list, t) = pl.commit(&ck);
// let duration = start.elapsed().as_millis();
// br.commit_time = duration;

// let mut prover_transcript = PoseidonTranscript::new(&params);

// let start = Instant::now();
// let (u, pst_proof, mipp_proof) = pl.open(&mut prover_transcript, comm_list, &ck, &r, &t);
// let duration = start.elapsed().as_millis();
// br.opening_time = duration;

// let mut p1 = Vec::<u8>::new();
// let mut p2 = Vec::<u8>::new();
// pst_proof
// .serialize_with_mode(&mut p1, ark_serialize::Compress::Yes)
// .unwrap();

// mipp_proof
// .serialize_with_mode(&mut p2, ark_serialize::Compress::Yes)
// .unwrap();

// br.proof_size = p1.len() + p2.len();

// let mut verifier_transcript = PoseidonTranscript::new(&params);

// let start = Instant::now();
// let res = Polynomial::verify(
// &mut verifier_transcript,
// &vk,
// &u,
// &r,
// v,
// &pst_proof,
// &mipp_proof,
// &t,
// );
// let duration = start.elapsed().as_millis();
// br.verification_time = duration;
// assert!(res == true);

// writer
// .serialize(br)
// .expect("unable to write results to csv");
// writer.flush().expect("wasn't able to flush");
// }
// }
fn main() {}
Loading