-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add no_std support * Update CHANGELOG * Remove unused alloc feature flag * Remove a forgotten comment Co-authored-by: str4d <[email protected]> * Make zeroize dependency optional * Add alloc feature flag * Clean the code by outer attributes * use 2021 edition Co-authored-by: str4d <[email protected]> Co-authored-by: Conrado Gouvea <[email protected]>
- Loading branch information
1 parent
0e912de
commit ed11f44
Showing
19 changed files
with
88 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,18 +8,28 @@ | |
// - Deirdre Connolly <[email protected]> | ||
// - Henry de Valence <[email protected]> | ||
|
||
use thiserror::Error; | ||
use core::fmt; | ||
|
||
/// An error related to RedDSA signatures. | ||
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)] | ||
#[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
pub enum Error { | ||
/// The encoding of a signing key was malformed. | ||
#[error("Malformed signing key encoding.")] | ||
MalformedSigningKey, | ||
/// The encoding of a verification key was malformed. | ||
#[error("Malformed verification key encoding.")] | ||
MalformedVerificationKey, | ||
/// Signature verification failed. | ||
#[error("Invalid signature.")] | ||
InvalidSignature, | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl std::error::Error for Error {} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Self::MalformedSigningKey => write!(f, "Malformed signing key encoding."), | ||
Self::MalformedVerificationKey => write!(f, "Malformed verification key encoding."), | ||
Self::InvalidSignature => write!(f, "Invalid signature."), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
// - Deirdre Connolly <[email protected]> | ||
// - Henry de Valence <[email protected]> | ||
|
||
use std::marker::PhantomData; | ||
use core::marker::PhantomData; | ||
|
||
use blake2b_simd::{Params, State}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,19 +8,30 @@ | |
// - Deirdre Connolly <[email protected]> | ||
// - Henry de Valence <[email protected]> | ||
|
||
#![no_std] | ||
#![deny(missing_docs)] | ||
#![doc = include_str!("../README.md")] | ||
|
||
//! Docs require the `nightly` feature until RFC 1990 lands. | ||
#[cfg(feature = "alloc")] | ||
#[macro_use] | ||
extern crate alloc; | ||
#[cfg(feature = "std")] | ||
extern crate std; | ||
|
||
#[cfg(feature = "alloc")] | ||
pub mod batch; | ||
mod constants; | ||
mod error; | ||
#[cfg(feature = "std")] | ||
pub mod frost; | ||
mod hash; | ||
#[cfg(feature = "std")] | ||
mod messages; | ||
pub mod orchard; | ||
pub mod sapling; | ||
#[cfg(feature = "alloc")] | ||
mod scalar_mul; | ||
pub(crate) mod signature; | ||
mod signing_key; | ||
|
@@ -74,12 +85,18 @@ pub(crate) mod private { | |
} | ||
|
||
pub trait Sealed<T: SigType>: | ||
Copy + Clone + Default + Eq + PartialEq + std::fmt::Debug | ||
Copy + Clone + Default + Eq + PartialEq + core::fmt::Debug | ||
{ | ||
const H_STAR_PERSONALIZATION: &'static [u8; 16]; | ||
type Scalar: group::ff::PrimeField + SealedScalar; | ||
|
||
// `Point: VartimeMultiscalarMul` is conditioned by `alloc` feature flag | ||
// This is fine because `Sealed` is an internal trait. | ||
#[cfg(feature = "alloc")] | ||
type Point: group::cofactor::CofactorCurve<Scalar = Self::Scalar> | ||
+ scalar_mul::VartimeMultiscalarMul<Scalar = Self::Scalar, Point = Self::Point>; | ||
#[cfg(not(feature = "alloc"))] | ||
type Point: group::cofactor::CofactorCurve<Scalar = Self::Scalar>; | ||
|
||
fn basepoint() -> T::Point; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ | |
// - Henry de Valence <[email protected]> | ||
// - Deirdre Connolly <[email protected]> | ||
|
||
use std::{borrow::Borrow, fmt::Debug}; | ||
use alloc::vec::Vec; | ||
use core::{borrow::Borrow, fmt::Debug}; | ||
|
||
use jubjub::{ExtendedNielsPoint, ExtendedPoint}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
// - Henry de Valence <[email protected]> | ||
|
||
//! RedDSA Signatures | ||
use std::marker::PhantomData; | ||
use core::marker::PhantomData; | ||
|
||
use crate::SigType; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
// - Deirdre Connolly <[email protected]> | ||
// - Henry de Valence <[email protected]> | ||
|
||
use std::{ | ||
use core::{ | ||
convert::{TryFrom, TryInto}, | ||
marker::PhantomData, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
// - Deirdre Connolly <[email protected]> | ||
// - Henry de Valence <[email protected]> | ||
|
||
use std::{ | ||
use core::{ | ||
convert::{TryFrom, TryInto}, | ||
hash::{Hash, Hasher}, | ||
marker::PhantomData, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![cfg(feature = "alloc")] | ||
|
||
use rand::thread_rng; | ||
|
||
use reddsa::*; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![cfg(all(feature = "std", feature = "serde"))] | ||
|
||
use rand::thread_rng; | ||
use std::collections::HashMap; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use std::convert::TryFrom; | ||
use core::convert::TryFrom; | ||
|
||
#[macro_use] | ||
extern crate lazy_static; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use std::convert::TryFrom; | ||
use core::convert::TryFrom; | ||
|
||
use jubjub::{AffinePoint, Fq}; | ||
|
||
|