2021-02-25 08:06:54 -08:00
|
|
|
// -*- mode: rust; -*-
|
|
|
|
//
|
|
|
|
// This file is part of redjubjub.
|
|
|
|
// Copyright (c) 2019-2021 Zcash Foundation
|
|
|
|
// See LICENSE for licensing information.
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// - Henry de Valence <hdevalence@hdevalence.ca>
|
|
|
|
|
2021-06-16 12:13:23 -07:00
|
|
|
//! Redjubjub Signatures
|
2019-12-03 12:22:35 -08:00
|
|
|
|
|
|
|
use crate::SigType;
|
2019-12-02 22:10:56 -08:00
|
|
|
|
2019-12-02 21:58:19 -08:00
|
|
|
/// A RedJubJub signature.
|
2019-12-03 20:49:48 -08:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
2019-12-09 11:07:05 -08:00
|
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
2023-02-01 15:22:37 -08:00
|
|
|
pub struct Signature<T: SigType>(pub(crate) reddsa::Signature<T::RedDSASigType>);
|
2019-12-02 21:58:19 -08:00
|
|
|
|
2019-12-03 12:22:35 -08:00
|
|
|
impl<T: SigType> From<[u8; 64]> for Signature<T> {
|
|
|
|
fn from(bytes: [u8; 64]) -> Signature<T> {
|
2023-02-01 15:22:37 -08:00
|
|
|
Signature(reddsa::Signature::<_>::from(bytes))
|
2019-12-02 21:58:19 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-03 12:22:35 -08:00
|
|
|
impl<T: SigType> From<Signature<T>> for [u8; 64] {
|
2019-12-03 20:49:48 -08:00
|
|
|
fn from(sig: Signature<T>) -> [u8; 64] {
|
2023-02-01 15:22:37 -08:00
|
|
|
sig.0.into()
|
2019-12-02 22:10:56 -08:00
|
|
|
}
|
|
|
|
}
|