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

[TASK] VAnchor API #173

Closed
1 of 2 tasks
Tracked by #82 ...
lazovicff opened this issue Feb 25, 2022 · 0 comments
Closed
1 of 2 tasks
Tracked by #82 ...

[TASK] VAnchor API #173

lazovicff opened this issue Feb 25, 2022 · 0 comments

Comments

@lazovicff
Copy link
Contributor

lazovicff commented Feb 25, 2022

To make the API more configurable and more stable, I propose the following struct:

struct VAnchorR1CSProver<
    E: PairingEngine,
    H: FieldHasher<E::Fr>,
    const HEIGHT: usize,
    const BRIDGE_SIZE: usize,
    const INS: usize,
    const OUTS: usize,
> {
    engine: PhantomData<E>,
    hasher: PhantomData<H>,
}

Which will be defined as:

type VAnchorR1CSProver_Bn254_Poseidon_30_2_2_2 = VAnchorR1CSProver<Bn254, Poseidon<Bn254Fr>, 30, 2, 2, 2>;

With the name convention: [prover name]_[ec]_[hasher]_[tree height]_[bridge size]_[num inputs]_[num outputs]

With interface:

trait VAnchorProver<
    F: PrimeField,
    H: HasherGadget,
    const HEIGHT: usize,
    const BRIDGE_SIZE: usize,
    const INS: usize,
    const OUTS: usize,
> {
    // For creating fresh utxo, or create a new one by passing values for secret key and blinding
    pub fn create_utxo<R: RngCore>(
        chain_id: u128,
        amount: u128,
        index: Option<u64>,
        secret_key: Option<Vec<u8>>,
        blinding: Option<Vec<u8>>,
        rng: &mut R,
    ) -> Result<Leaf, Error>;
    // For making proofs
    pub fn create_proof<R: RngCore + CryptoRng>(
        curve: Curve,
        // External data
        public_amount: Vec<u8>,
        ext_data_hash: Vec<u8>,
        in_root_set: [Vec<u8>; M],
        in_indices: [u64; INS],
        in_leaves: [Vec<Vec<u8>>; INS],
        // Input transactions
        in_utxos: [Utxo<F>; INS],
        // Output transactions
        out_utxos: [Utxo<F>; OUTS],
        rng: &mut R,
    ) -> Result<VAnchorProof, Error>;
}

NOTE: This interface can be implemented for both R1CS and PLONK systems

  • Update R1CS circuit API
  • Update PLONK circuit API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants