diff --git a/Cargo.toml b/Cargo.toml index d5d0dcc..a17c9c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,8 @@ thiserror = "1.0" blake2b_simd = "0.5" jubjub = { git = "https://github.com/zkcrypto/jubjub", rev = "e83f7d2bd136498a27f9d943fea635d8682bf2c6" } +[dev-dependencies] +rand = "0.7" + [features] nightly = [] diff --git a/src/lib.rs b/src/lib.rs index ec359c4..ca9fabd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,16 +39,18 @@ pub use signature::Signature; pub trait SigType: private::Sealed {} /// A type variable corresponding to Zcash's `BindingSig`. +#[derive(Copy, Clone, Debug)] pub struct Binding {} impl SigType for Binding {} /// A type variable corresponding to Zcash's `SpendAuthSig`. +#[derive(Copy, Clone, Debug)] pub struct SpendAuth {} impl SigType for SpendAuth {} pub(crate) mod private { use super::*; - pub trait Sealed { + pub trait Sealed: Copy + Clone + std::fmt::Debug { fn basepoint() -> jubjub::ExtendedPoint; } impl Sealed for Binding { @@ -66,3 +68,18 @@ pub(crate) mod private { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn sign_and_verify() { + let sk = SecretKey::::new(rand::thread_rng()); + let msg = b"test"; + let sig = sk.sign(rand::thread_rng(), msg); + let pk = PublicKey::from(&sk); + + assert_eq!(pk.verify(msg, &sig), Ok(())); + } +}