Relocate structs for cleanliness.
This commit is contained in:
@@ -35,7 +35,6 @@ use primitives::{
|
|||||||
PaymentAddress
|
PaymentAddress
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO: This should probably be removed and we
|
// TODO: This should probably be removed and we
|
||||||
// should use existing helper methods on `Option`
|
// should use existing helper methods on `Option`
|
||||||
// for mapping with an error.
|
// for mapping with an error.
|
||||||
@@ -55,6 +54,47 @@ impl<T> Assignment<T> for Option<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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<ValueCommitment<E>>,
|
||||||
|
|
||||||
|
/// Key required to construct proofs for spending notes
|
||||||
|
/// for a particular spending key
|
||||||
|
pub proof_generation_key: Option<ProofGenerationKey<E>>,
|
||||||
|
|
||||||
|
/// The payment address associated with the note
|
||||||
|
pub payment_address: Option<PaymentAddress<E>>,
|
||||||
|
|
||||||
|
/// The randomness of the note commitment
|
||||||
|
pub commitment_randomness: Option<E::Fs>,
|
||||||
|
|
||||||
|
/// The authentication path of the commitment in the tree
|
||||||
|
pub auth_path: Vec<Option<(E::Fr, bool)>>
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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<ValueCommitment<E>>,
|
||||||
|
|
||||||
|
/// The diversified base, computed by GH(d)
|
||||||
|
pub g_d: Option<edwards::Point<E, PrimeOrder>>,
|
||||||
|
|
||||||
|
/// The diversified address point, computed by GH(d)^ivk
|
||||||
|
pub pk_d: Option<edwards::Point<E, PrimeOrder>>,
|
||||||
|
|
||||||
|
/// The randomness used to hide the note commitment data
|
||||||
|
pub commitment_randomness: Option<E::Fs>,
|
||||||
|
|
||||||
|
/// The ephemeral secret key for DH with recipient
|
||||||
|
pub esk: Option<E::Fs>
|
||||||
|
}
|
||||||
|
|
||||||
/// Exposes a Pedersen commitment to the value as an
|
/// Exposes a Pedersen commitment to the value as an
|
||||||
/// input to the circuit
|
/// input to the circuit
|
||||||
fn expose_value_commitment<E, CS>(
|
fn expose_value_commitment<E, CS>(
|
||||||
@@ -108,27 +148,6 @@ fn expose_value_commitment<E, CS>(
|
|||||||
Ok(value_bits)
|
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<ValueCommitment<E>>,
|
|
||||||
|
|
||||||
/// Key required to construct proofs for spending notes
|
|
||||||
/// for a particular spending key
|
|
||||||
pub proof_generation_key: Option<ProofGenerationKey<E>>,
|
|
||||||
|
|
||||||
/// The payment address associated with the note
|
|
||||||
pub payment_address: Option<PaymentAddress<E>>,
|
|
||||||
|
|
||||||
/// The randomness of the note commitment
|
|
||||||
pub commitment_randomness: Option<E::Fs>,
|
|
||||||
|
|
||||||
/// The authentication path of the commitment in the tree
|
|
||||||
pub auth_path: Vec<Option<(E::Fr, bool)>>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, E: JubjubEngine> Circuit<E> for Spend<'a, E> {
|
impl<'a, E: JubjubEngine> Circuit<E> for Spend<'a, E> {
|
||||||
fn synthesize<CS: ConstraintSystem<E>>(self, cs: &mut CS) -> Result<(), SynthesisError>
|
fn synthesize<CS: ConstraintSystem<E>>(self, cs: &mut CS) -> Result<(), SynthesisError>
|
||||||
{
|
{
|
||||||
@@ -411,26 +430,6 @@ impl<'a, E: JubjubEngine> Circuit<E> 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<ValueCommitment<E>>,
|
|
||||||
|
|
||||||
/// The diversified base, computed by GH(d)
|
|
||||||
pub g_d: Option<edwards::Point<E, PrimeOrder>>,
|
|
||||||
|
|
||||||
/// The diversified address point, computed by GH(d)^ivk
|
|
||||||
pub pk_d: Option<edwards::Point<E, PrimeOrder>>,
|
|
||||||
|
|
||||||
/// The randomness used to hide the note commitment data
|
|
||||||
pub commitment_randomness: Option<E::Fs>,
|
|
||||||
|
|
||||||
/// The ephemeral secret key for DH with recipient
|
|
||||||
pub esk: Option<E::Fs>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, E: JubjubEngine> Circuit<E> for Output<'a, E> {
|
impl<'a, E: JubjubEngine> Circuit<E> for Output<'a, E> {
|
||||||
fn synthesize<CS: ConstraintSystem<E>>(self, cs: &mut CS) -> Result<(), SynthesisError>
|
fn synthesize<CS: ConstraintSystem<E>>(self, cs: &mut CS) -> Result<(), SynthesisError>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user