frost/src/public_key.rs

55 lines
1.3 KiB
Rust
Raw Normal View History

2019-12-02 21:58:19 -08:00
use std::convert::TryFrom;
2019-12-02 22:32:55 -08:00
use crate::{Error, Randomizer, 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
impl PublicKey {
2019-12-02 22:32:55 -08:00
/// Randomize this public key with the given `randomizer`.
pub fn randomize(&self, randomizer: Randomizer) -> PublicKey {
unimplemented!();
}
2019-12-02 22:20:21 -08:00
/// Verify a supposed `signature` over `msg` made by this public key.
2019-12-02 22:32:55 -08:00
// This is similar to impl signature::Verifier but without boxed errors
2019-12-02 22:20:21 -08:00
pub fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> {
unimplemented!();
}
}