diff --git a/src/lib.rs b/src/lib.rs index 435ec0e..9b8be8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,9 @@ mod secret_key; mod signature; pub use error::Error; +pub use public_key::{PublicKey, PublicKeyBytes}; +pub use secret_key::{SecretKey, SecretKeyBytes}; +pub use signature::Signature; #[cfg(test)] mod tests { diff --git a/src/public_key.rs b/src/public_key.rs index e69de29..2267b92 100644 --- a/src/public_key.rs +++ b/src/public_key.rs @@ -0,0 +1,41 @@ +use std::convert::TryFrom; + +use crate::Error; + +/// A refinement type indicating that the inner `[u8; 32]` represents an +/// encoding of a RedJubJub public key. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub struct PublicKeyBytes(pub [u8; 32]); + +impl From<[u8; 32]> for PublicKeyBytes { + fn from(raw: [u8; 32]) -> PublicKeyBytes { + PublicKeyBytes(raw) + } +} + +impl From for [u8; 32] { + fn from(refined: PublicKeyBytes) -> [u8; 32] { + refined.0 + } +} + +/// A RedJubJub public key. +// XXX PartialEq, Eq? +#[derive(Copy, Clone, Debug)] +pub struct PublicKey { + // fields +} + +impl From for PublicKeyBytes { + fn from(pk: PublicKey) -> PublicKeyBytes { + unimplemented!(); + } +} + +impl TryFrom for PublicKey { + type Error = Error; + + fn try_from(bytes: PublicKeyBytes) -> Result { + unimplemented!(); + } +} diff --git a/src/secret_key.rs b/src/secret_key.rs index e69de29..e54b076 100644 --- a/src/secret_key.rs +++ b/src/secret_key.rs @@ -0,0 +1,41 @@ +use std::convert::TryFrom; + +use crate::Error; + +/// A refinement type indicating that the inner `[u8; 32]` represents an +/// encoding of a RedJubJub secret key. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub struct SecretKeyBytes(pub [u8; 32]); + +impl From<[u8; 32]> for SecretKeyBytes { + fn from(raw: [u8; 32]) -> SecretKeyBytes { + SecretKeyBytes(raw) + } +} + +impl From for [u8; 32] { + fn from(refined: SecretKeyBytes) -> [u8; 32] { + refined.0 + } +} + +/// A RedJubJub secret key. +// XXX PartialEq, Eq? +#[derive(Copy, Clone, Debug)] +pub struct SecretKey { + // fields +} + +impl From for SecretKeyBytes { + fn from(pk: SecretKey) -> SecretKeyBytes { + unimplemented!(); + } +} + +impl TryFrom for SecretKey { + type Error = Error; + + fn try_from(bytes: SecretKeyBytes) -> Result { + unimplemented!(); + } +} diff --git a/src/signature.rs b/src/signature.rs index e69de29..3cfa75f 100644 --- a/src/signature.rs +++ b/src/signature.rs @@ -0,0 +1,14 @@ +/// A RedJubJub signature. +pub struct Signature(pub [u8; 64]); + +impl From<[u8; 64]> for Signature { + fn from(bytes: [u8; 64]) -> Signature { + Signature(bytes) + } +} + +impl From for [u8; 64] { + fn from(s: Signature) -> [u8; 64] { + s.0 + } +}