2019-12-02 21:58:19 -08:00
|
|
|
use std::convert::TryFrom;
|
|
|
|
|
2019-12-02 22:20:21 -08:00
|
|
|
use crate::{Error, Signature};
|
2019-12-02 21:58:19 -08:00
|
|
|
|
|
|
|
/// 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<PublicKeyBytes> 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<PublicKey> for PublicKeyBytes {
|
|
|
|
fn from(pk: PublicKey) -> PublicKeyBytes {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<PublicKeyBytes> for PublicKey {
|
|
|
|
type Error = Error;
|
|
|
|
|
|
|
|
fn try_from(bytes: PublicKeyBytes) -> Result<Self, Self::Error> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
2019-12-02 22:20:21 -08:00
|
|
|
|
|
|
|
// This is similar to impl signature::Verifier but without boxed errors
|
|
|
|
impl PublicKey {
|
|
|
|
/// Verify a supposed `signature` over `msg` made by this public key.
|
|
|
|
pub fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|