-
Notifications
You must be signed in to change notification settings - Fork 7
Add no-std
support
#11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5142374
Add no_std support
krnak 1afb5c5
Update CHANGELOG
krnak 03f6789
Remove unused alloc feature flag
krnak 2839de1
Remove a forgotten comment
krnak 275a60b
Merge branch 'main' into alloc
krnak 7238718
Make zeroize dependency optional
krnak c383274
Add alloc feature flag
krnak cb3090a
Clean the code by outer attributes
krnak 3caf57b
Merge branch 'main' of https://github.com/ZcashFoundation/reddsa into…
conradoplg cb95e98
use 2021 edition
conradoplg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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."), | ||
} | ||
} | ||
} | ||
conradoplg marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.