arnaucube 0dce0668ce | 2 years ago | |
---|---|---|
.github/workflows | 2 years ago | |
src | 2 years ago | |
.gitignore | 2 years ago | |
Cargo.toml | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago |
Inner Product Argument (IPA) version from Halo paper (https://eprint.iacr.org/2019/1021.pdf) implementation done to get familiar with arkworks and the modified IPA scheme.
Warning: do not use this code in production.
let mut ipa = IPA::new(8);
let a = vec![
F::from(1 as u32),
F::from(2 as u32),
F::from(3 as u32),
F::from(4 as u32),
F::from(5 as u32),
F::from(6 as u32),
F::from(7 as u32),
F::from(8 as u32),
];
let r = F::rand(&mut ipa.rng);
// prover commits
let P = ipa.commit(&a, r).unwrap();
// verifier sets challenges
let U = EdwardsProjective::rand(&mut ipa.rng);
let k = (f64::from(ipa.d as u32).log2()) as usize;
let mut u: Vec<F> = vec![F::zero(); k];
for j in 0..k {
u[j] = F::rand(&mut ipa.rng);
}
let x = F::from(3 as u32);
// prover opens at the challenges
let b = powers_of(x, ipa.d);
let v = inner_product_field(&a, &b).unwrap();
let proof = ipa.prove(&a, &b, &u, &U).unwrap();
// verifier
let verif = ipa.verify(&x, &v, &P, &proof, &r, &u, &U).unwrap();
assert!(verif);