From 999840011707b5dfe6323c079c79f4085bff68c5 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Thu, 8 Mar 2018 01:37:55 -0700 Subject: [PATCH] Relocate structs for cleanliness. --- src/circuit/mod.rs | 83 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/src/circuit/mod.rs b/src/circuit/mod.rs index 30a84c0..19d0940 100644 --- a/src/circuit/mod.rs +++ b/src/circuit/mod.rs @@ -35,7 +35,6 @@ use primitives::{ PaymentAddress }; - // TODO: This should probably be removed and we // should use existing helper methods on `Option` // for mapping with an error. @@ -55,6 +54,47 @@ impl Assignment for Option { } } +/// This is an instance of the `Spend` circuit. +pub struct Spend<'a, E: JubjubEngine> { + pub params: &'a E::Params, + + /// Pedersen commitment to the value being spent + pub value_commitment: Option>, + + /// Key required to construct proofs for spending notes + /// for a particular spending key + pub proof_generation_key: Option>, + + /// The payment address associated with the note + pub payment_address: Option>, + + /// The randomness of the note commitment + pub commitment_randomness: Option, + + /// The authentication path of the commitment in the tree + pub auth_path: Vec> +} + +/// This is an output circuit instance. +pub struct Output<'a, E: JubjubEngine> { + pub params: &'a E::Params, + + /// Pedersen commitment to the value being spent + pub value_commitment: Option>, + + /// The diversified base, computed by GH(d) + pub g_d: Option>, + + /// The diversified address point, computed by GH(d)^ivk + pub pk_d: Option>, + + /// The randomness used to hide the note commitment data + pub commitment_randomness: Option, + + /// The ephemeral secret key for DH with recipient + pub esk: Option +} + /// Exposes a Pedersen commitment to the value as an /// input to the circuit fn expose_value_commitment( @@ -108,27 +148,6 @@ fn expose_value_commitment( Ok(value_bits) } -/// This is an instance of the `Spend` circuit. -pub struct Spend<'a, E: JubjubEngine> { - pub params: &'a E::Params, - - /// Pedersen commitment to the value being spent - pub value_commitment: Option>, - - /// Key required to construct proofs for spending notes - /// for a particular spending key - pub proof_generation_key: Option>, - - /// The payment address associated with the note - pub payment_address: Option>, - - /// The randomness of the note commitment - pub commitment_randomness: Option, - - /// The authentication path of the commitment in the tree - pub auth_path: Vec> -} - impl<'a, E: JubjubEngine> Circuit for Spend<'a, E> { fn synthesize>(self, cs: &mut CS) -> Result<(), SynthesisError> { @@ -411,26 +430,6 @@ impl<'a, E: JubjubEngine> Circuit for Spend<'a, E> { } } -/// This is an output circuit instance. -pub struct Output<'a, E: JubjubEngine> { - pub params: &'a E::Params, - - /// Pedersen commitment to the value being spent - pub value_commitment: Option>, - - /// The diversified base, computed by GH(d) - pub g_d: Option>, - - /// The diversified address point, computed by GH(d)^ivk - pub pk_d: Option>, - - /// The randomness used to hide the note commitment data - pub commitment_randomness: Option, - - /// The ephemeral secret key for DH with recipient - pub esk: Option -} - impl<'a, E: JubjubEngine> Circuit for Output<'a, E> { fn synthesize>(self, cs: &mut CS) -> Result<(), SynthesisError> {