From cb38360311d61e3ab6170102270b9f516a3f5054 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Fri, 18 Mar 2022 15:01:37 +0800 Subject: [PATCH] docs(rln): comments and notes --- rln/src/protocol.rs | 14 ++++++++++++++ rln/src/public.rs | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/rln/src/protocol.rs b/rln/src/protocol.rs index ea3167a..a06dc8e 100644 --- a/rln/src/protocol.rs +++ b/rln/src/protocol.rs @@ -77,6 +77,11 @@ fn ark_to_bigint(n: Field) -> BigInt { n.to_bigint().expect("conversion always succeeds for uint") } +// XXX This is different from zk-kit API: +// const witness = RLN.genWitness(secretHash, merkleProof, epoch, signal, rlnIdentifier) +// const fullProof = await RLN.genProof(witness, wasmFilePath, finalZkeyPath) +// + /// Generates a semaphore proof /// /// # Errors @@ -90,6 +95,15 @@ pub fn generate_proof( ) -> Result>, ProofError> { let external_nullifier = hash_external_nullifier(external_nullifier); let signal = hash_signal(signal); + // TODO Fix inputs + // Semaphore genWitness corresponds to these + // RLN different, should be: + // identity_secret + // path_elements (merkleProof.siblings)) + // identity_path_index (merkleProof.pathIndices) + // x (RLN.genSignalHash(signal), assuming shouldHash is true) + // epoch + // rln_identifier let inputs = [ ("identityNullifier", vec![identity.nullifier]), ("identityTrapdoor", vec![identity.trapdoor]), diff --git a/rln/src/public.rs b/rln/src/public.rs index 238a99c..7551706 100644 --- a/rln/src/public.rs +++ b/rln/src/public.rs @@ -25,17 +25,17 @@ use num_bigint::BigInt; use serde::Deserialize; use serde_json; -// XXX -use bellman::pairing::ff::{Field, PrimeField, PrimeFieldRepr, ScalarEngine}; -use sapling_crypto::bellman::pairing::bn256::Bn256; +// For RLN Rust version +//use bellman::pairing::ff::{Field, PrimeField, PrimeFieldRepr, ScalarEngine}; +//use sapling_crypto::bellman::pairing::bn256::Bn256; // TODO Add Engine here? i.e. not -// NOTE Bn254 vs Bn256 mismatch! Tree is originally Bn256 -// TODO Figure out Bn254 vs Bn256 mismatch +// TODO Assuming we want to use IncrementalMerkleTree, figure out type/trait conversions +// TODO Adopt to new protocol structure pub struct RLN { circom: CircomCircuit, params: ProvingKey, - // TODO Replace Bn256 with Bn254 here + // RLN Rust version //tree: IncrementalMerkleTree, tree: PoseidonTree, }