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:
|
|
|
|
// - Deirdre Connolly <deirdre@zfnd.org>
|
|
|
|
// - Henry de Valence <hdevalence@hdevalence.ca>
|
|
|
|
|
2020-07-15 12:42:14 -07:00
|
|
|
#![doc(html_root_url = "https://docs.rs/redjubjub/0.2.2")]
|
2019-12-02 21:32:38 -08:00
|
|
|
#![cfg_attr(feature = "nightly", feature(external_doc))]
|
|
|
|
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
|
2019-12-02 21:36:47 -08:00
|
|
|
#![deny(missing_docs)]
|
2019-12-02 21:32:38 -08:00
|
|
|
|
|
|
|
//! Docs require the `nightly` feature until RFC 1990 lands.
|
|
|
|
|
2020-07-03 15:23:28 -07:00
|
|
|
pub mod batch;
|
2019-12-03 13:37:12 -08:00
|
|
|
mod constants;
|
2019-12-02 21:36:47 -08:00
|
|
|
mod error;
|
2021-02-25 08:06:54 -08:00
|
|
|
pub mod frost;
|
2019-12-03 19:54:31 -08:00
|
|
|
mod hash;
|
2020-07-03 15:23:28 -07:00
|
|
|
mod scalar_mul;
|
2019-12-02 21:32:38 -08:00
|
|
|
mod signature;
|
2020-06-25 11:56:29 -07:00
|
|
|
mod signing_key;
|
|
|
|
mod verification_key;
|
2019-12-02 21:32:38 -08:00
|
|
|
|
2019-12-02 22:32:55 -08:00
|
|
|
/// An element of the JubJub scalar field used for randomization of public and secret keys.
|
2021-03-01 06:54:52 -08:00
|
|
|
pub type Randomizer = jubjub::Scalar;
|
2019-12-02 22:32:55 -08:00
|
|
|
|
2019-12-03 19:54:31 -08:00
|
|
|
use hash::HStar;
|
|
|
|
|
2019-12-02 21:36:47 -08:00
|
|
|
pub use error::Error;
|
2019-12-02 21:58:19 -08:00
|
|
|
pub use signature::Signature;
|
2020-06-25 11:56:29 -07:00
|
|
|
pub use signing_key::SigningKey;
|
|
|
|
pub use verification_key::{VerificationKey, VerificationKeyBytes};
|
2019-12-02 21:32:38 -08:00
|
|
|
|
2019-12-04 16:41:16 -08:00
|
|
|
/// Abstracts over different RedJubJub parameter choices, [`Binding`]
|
|
|
|
/// and [`SpendAuth`].
|
2019-12-03 12:22:35 -08:00
|
|
|
///
|
|
|
|
/// As described [at the end of §5.4.6][concretereddsa] of the Zcash
|
|
|
|
/// protocol specification, the generator used in RedJubjub is left as
|
|
|
|
/// an unspecified parameter, chosen differently for each of
|
|
|
|
/// `BindingSig` and `SpendAuthSig`.
|
|
|
|
///
|
|
|
|
/// To handle this, we encode the parameter choice as a genuine type
|
|
|
|
/// parameter.
|
|
|
|
///
|
|
|
|
/// [concretereddsa]: https://zips.z.cash/protocol/protocol.pdf#concretereddsa
|
|
|
|
pub trait SigType: private::Sealed {}
|
|
|
|
|
|
|
|
/// A type variable corresponding to Zcash's `BindingSig`.
|
2019-12-09 11:07:24 -08:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
2019-12-04 16:41:16 -08:00
|
|
|
pub enum Binding {}
|
2019-12-03 12:22:35 -08:00
|
|
|
impl SigType for Binding {}
|
|
|
|
|
|
|
|
/// A type variable corresponding to Zcash's `SpendAuthSig`.
|
2019-12-09 11:07:24 -08:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
2019-12-04 16:41:16 -08:00
|
|
|
pub enum SpendAuth {}
|
2019-12-03 12:22:35 -08:00
|
|
|
impl SigType for SpendAuth {}
|
|
|
|
|
2019-12-03 18:20:45 -08:00
|
|
|
pub(crate) mod private {
|
2019-12-03 12:22:35 -08:00
|
|
|
use super::*;
|
2019-12-09 11:07:24 -08:00
|
|
|
pub trait Sealed: Copy + Clone + Eq + PartialEq + std::fmt::Debug {
|
2019-12-03 18:20:45 -08:00
|
|
|
fn basepoint() -> jubjub::ExtendedPoint;
|
|
|
|
}
|
|
|
|
impl Sealed for Binding {
|
|
|
|
fn basepoint() -> jubjub::ExtendedPoint {
|
|
|
|
jubjub::AffinePoint::from_bytes(constants::BINDINGSIG_BASEPOINT_BYTES)
|
|
|
|
.unwrap()
|
|
|
|
.into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Sealed for SpendAuth {
|
|
|
|
fn basepoint() -> jubjub::ExtendedPoint {
|
|
|
|
jubjub::AffinePoint::from_bytes(constants::SPENDAUTHSIG_BASEPOINT_BYTES)
|
|
|
|
.unwrap()
|
|
|
|
.into()
|
|
|
|
}
|
|
|
|
}
|
2019-12-03 12:22:35 -08:00
|
|
|
}
|