Browse Source

adapt Nova's DeciderEth prepare_calldata & update examples to it

adapt-preparecalldata
arnaucube 3 weeks ago
parent
commit
b2db660ba7
5 changed files with 26 additions and 1 deletions
  1. +2
    -0
      examples/circom_full_flow.rs
  2. +2
    -0
      examples/full_flow.rs
  3. +2
    -0
      examples/noir_full_flow.rs
  4. +2
    -0
      examples/noname_full_flow.rs
  5. +18
    -1
      folding-schemes/src/folding/nova/decider_eth.rs

+ 2
- 0
examples/circom_full_flow.rs

@ -84,6 +84,7 @@ fn main() {
// prepare the Nova prover & verifier params // prepare the Nova prover & verifier params
let nova_preprocess_params = PreprocessorParam::new(poseidon_config, f_circuit.clone()); let nova_preprocess_params = PreprocessorParam::new(poseidon_config, f_circuit.clone());
let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap(); let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap();
let pp_hash = nova_params.1.pp_hash().unwrap();
// initialize the folding scheme engine, in our case we use Nova // initialize the folding scheme engine, in our case we use Nova
let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap(); let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap();
@ -131,6 +132,7 @@ fn main() {
let calldata: Vec<u8> = prepare_calldata( let calldata: Vec<u8> = prepare_calldata(
function_selector, function_selector,
pp_hash,
nova.i, nova.i,
nova.z_0, nova.z_0,
nova.z_i, nova.z_i,

+ 2
- 0
examples/full_flow.rs

@ -101,6 +101,7 @@ fn main() {
// prepare the Nova prover & verifier params // prepare the Nova prover & verifier params
let nova_preprocess_params = PreprocessorParam::new(poseidon_config.clone(), f_circuit); let nova_preprocess_params = PreprocessorParam::new(poseidon_config.clone(), f_circuit);
let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap(); let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap();
let pp_hash = nova_params.1.pp_hash().unwrap();
// initialize the folding scheme engine, in our case we use Nova // initialize the folding scheme engine, in our case we use Nova
let mut nova = N::init(&nova_params, f_circuit, z_0).unwrap(); let mut nova = N::init(&nova_params, f_circuit, z_0).unwrap();
@ -138,6 +139,7 @@ fn main() {
let calldata: Vec<u8> = prepare_calldata( let calldata: Vec<u8> = prepare_calldata(
function_selector, function_selector,
pp_hash,
nova.i, nova.i,
nova.z_0, nova.z_0,
nova.z_i, nova.z_i,

+ 2
- 0
examples/noir_full_flow.rs

@ -74,6 +74,7 @@ fn main() {
// prepare the Nova prover & verifier params // prepare the Nova prover & verifier params
let nova_preprocess_params = PreprocessorParam::new(poseidon_config, f_circuit.clone()); let nova_preprocess_params = PreprocessorParam::new(poseidon_config, f_circuit.clone());
let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap(); let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap();
let pp_hash = nova_params.1.pp_hash().unwrap();
// initialize the folding scheme engine, in our case we use Nova // initialize the folding scheme engine, in our case we use Nova
let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap(); let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap();
@ -119,6 +120,7 @@ fn main() {
let calldata: Vec<u8> = prepare_calldata( let calldata: Vec<u8> = prepare_calldata(
function_selector, function_selector,
pp_hash,
nova.i, nova.i,
nova.z_0, nova.z_0,
nova.z_i, nova.z_i,

+ 2
- 0
examples/noname_full_flow.rs

@ -84,6 +84,7 @@ fn main() {
// prepare the Nova prover & verifier params // prepare the Nova prover & verifier params
let nova_preprocess_params = PreprocessorParam::new(poseidon_config, f_circuit.clone()); let nova_preprocess_params = PreprocessorParam::new(poseidon_config, f_circuit.clone());
let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap(); let nova_params = N::preprocess(&mut rng, &nova_preprocess_params).unwrap();
let pp_hash = nova_params.1.pp_hash().unwrap();
// initialize the folding scheme engine, in our case we use Nova // initialize the folding scheme engine, in our case we use Nova
let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap(); let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap();
@ -131,6 +132,7 @@ fn main() {
let calldata: Vec<u8> = prepare_calldata( let calldata: Vec<u8> = prepare_calldata(
function_selector, function_selector,
pp_hash,
nova.i, nova.i,
nova.z_0, nova.z_0,
nova.z_i, nova.z_i,

+ 18
- 1
folding-schemes/src/folding/nova/decider_eth.rs

@ -25,6 +25,7 @@ use crate::commitment::{
CommitmentScheme, CommitmentScheme,
}; };
use crate::folding::circuits::{nonnative::affine::NonNativeAffineVar, CF2}; use crate::folding::circuits::{nonnative::affine::NonNativeAffineVar, CF2};
use crate::folding::nova::circuits::ChallengeGadget;
use crate::frontend::FCircuit; use crate::frontend::FCircuit;
use crate::transcript::poseidon::poseidon_canonical_config; use crate::transcript::poseidon::poseidon_canonical_config;
use crate::Error; use crate::Error;
@ -277,14 +278,30 @@ where
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub fn prepare_calldata( pub fn prepare_calldata(
function_signature_check: [u8; 4], function_signature_check: [u8; 4],
pp_hash: ark_bn254::Fr,
i: ark_bn254::Fr, i: ark_bn254::Fr,
z_0: Vec<ark_bn254::Fr>, z_0: Vec<ark_bn254::Fr>,
z_i: Vec<ark_bn254::Fr>, z_i: Vec<ark_bn254::Fr>,
r: ark_bn254::Fr,
running_instance: &CommittedInstance<ark_bn254::G1Projective>, running_instance: &CommittedInstance<ark_bn254::G1Projective>,
incoming_instance: &CommittedInstance<ark_bn254::G1Projective>, incoming_instance: &CommittedInstance<ark_bn254::G1Projective>,
proof: Proof<ark_bn254::G1Projective, KZG<'static, Bn254>, Groth16<Bn254>>, proof: Proof<ark_bn254::G1Projective, KZG<'static, Bn254>, Groth16<Bn254>>,
) -> Result<Vec<u8>, Error> { ) -> Result<Vec<u8>, Error> {
// compute the challenge r
let poseidon_config = poseidon_canonical_config::<ark_bn254::Fr>();
let mut transcript = PoseidonSponge::<ark_bn254::Fr>::new(&poseidon_config);
let r_bits = ChallengeGadget::<
ark_bn254::G1Projective,
CommittedInstance<ark_bn254::G1Projective>,
>::get_challenge_native(
&mut transcript,
pp_hash,
running_instance,
incoming_instance,
Some(&proof.cmT),
);
let r =
ark_bn254::Fr::from_bigint(BigInteger::from_bits_le(&r_bits)).ok_or(Error::OutOfBounds)?;
Ok(vec![ Ok(vec![
function_signature_check.to_vec(), function_signature_check.to_vec(),
i.into_bigint().to_bytes_be(), // i i.into_bigint().to_bytes_be(), // i

Loading…
Cancel
Save