Trial Sapling note decryption

This commit is contained in:
Jack Grigg
2018-11-14 16:39:33 +00:00
parent 757316d355
commit 6996853168
3 changed files with 103 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ pub mod tests;
pub enum Unknown { }
/// Point of prime order.
#[derive(Debug)]
pub enum PrimeOrder { }
/// Fixed generators of the Jubjub curve of unknown

View File

@@ -116,7 +116,7 @@ impl<E: JubjubEngine> ViewingKey<E> {
}
}
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Diversifier(pub [u8; 11]);
impl Diversifier {
@@ -129,12 +129,18 @@ impl Diversifier {
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct PaymentAddress<E: JubjubEngine> {
pub pk_d: edwards::Point<E, PrimeOrder>,
pub diversifier: Diversifier
}
impl<E: JubjubEngine> PartialEq for PaymentAddress<E> {
fn eq(&self, other: &Self) -> bool {
self.pk_d == other.pk_d && self.diversifier == other.diversifier
}
}
impl<E: JubjubEngine> PaymentAddress<E> {
pub fn g_d(
&self,
@@ -162,7 +168,7 @@ impl<E: JubjubEngine> PaymentAddress<E> {
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Note<E: JubjubEngine> {
/// The value of the note
pub value: u64,
@@ -174,6 +180,15 @@ pub struct Note<E: JubjubEngine> {
pub r: E::Fs
}
impl<E: JubjubEngine> PartialEq for Note<E> {
fn eq(&self, other: &Self) -> bool {
self.value == other.value
&& self.g_d == other.g_d
&& self.pk_d == other.pk_d
&& self.r == other.r
}
}
impl<E: JubjubEngine> Note<E> {
pub fn uncommitted() -> E::Fr {
// The smallest u-coordinate that is not on the curve