Created
July 20, 2020 23:43
-
-
Save adler99/b72413335a51992d4d732080d88b76ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create note & commitment | |
let note = to | |
.create_note(value, Fs::random(&mut rng), &JUBJUB) | |
.unwrap(); | |
let cm = Node::new(note.cm(&JUBJUB).into_repr()); | |
// create empty commitment tree and add commitment | |
let mut tree = CommitmentTree::new(); | |
tree.append(cm).unwrap(); | |
let witness = IncrementalWitness::from_tree(&tree); | |
let merkle_path = witness.path().unwrap(); | |
let anchor = Fr::from(witness.root()); | |
let mut ctx = SaplingProvingContext::new(); | |
let alpha = Fs::random(&mut rng); | |
let (proof, cv, rk) = SaplingProvingContext::spend_proof( | |
&mut ctx, | |
proof_generation_key, //proof_generation_key: ProofGenerationKey<Bls12>, | |
*to.diversifier(), //diversifier: Diversifier, | |
note.r, // rcm: Fs, | |
alpha, //ar: Fs, | |
note.value, //value: u64, | |
anchor, //anchor, rt: Fr, | |
merkle_path, //merkle_path: MerklePath<Node>, | |
¶ms.spend_params, //proving_key: &Parameters<Bls12>, | |
¶ms.spend_vk, //verifying_key: &PreparedVerifyingKey<Bls12>, | |
&JUBJUB, //params: &JubjubBls12, | |
) | |
.expect("proving should not fail"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment