mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge branch 'release/1.0.0-pre.0'
This commit is contained in:
commit
12c5777b23
4 changed files with 32 additions and 51 deletions
15
Cargo.toml
15
Cargo.toml
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ed25519-dalek"
|
name = "ed25519-dalek"
|
||||||
version = "0.8.1"
|
version = "1.0.0-pre.0"
|
||||||
authors = ["Isis Lovecruft <isis@patternsinthevoid.net>"]
|
authors = ["Isis Lovecruft <isis@patternsinthevoid.net>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "BSD-3-Clause"
|
license = "BSD-3-Clause"
|
||||||
|
|
@ -16,7 +16,7 @@ exclude = [ ".gitignore", "TESTVECTORS", "res/*" ]
|
||||||
travis-ci = { repository = "dalek-cryptography/ed25519-dalek", branch = "master"}
|
travis-ci = { repository = "dalek-cryptography/ed25519-dalek", branch = "master"}
|
||||||
|
|
||||||
[dependencies.curve25519-dalek]
|
[dependencies.curve25519-dalek]
|
||||||
version = "0.20"
|
version = "1.0.0-pre.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.rand]
|
[dependencies.rand]
|
||||||
|
|
@ -24,19 +24,12 @@ version = "0.5"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["i128_support"]
|
features = ["i128_support"]
|
||||||
|
|
||||||
[dependencies.digest]
|
|
||||||
version = "^0.7"
|
|
||||||
|
|
||||||
[dependencies.generic-array]
|
|
||||||
# same version that digest depends on
|
|
||||||
version = "0.9"
|
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "^1.0"
|
version = "^1.0"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.sha2]
|
[dependencies.sha2]
|
||||||
version = "^0.7"
|
version = "^0.8"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.failure]
|
[dependencies.failure]
|
||||||
|
|
@ -48,7 +41,7 @@ version = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = "^0.3"
|
hex = "^0.3"
|
||||||
sha2 = "^0.7"
|
sha2 = "^0.8"
|
||||||
bincode = "^0.9"
|
bincode = "^0.9"
|
||||||
criterion = "0.2"
|
criterion = "0.2"
|
||||||
|
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -89,18 +89,6 @@ can read qhasm, making it more readily and more easily auditable. We're of
|
||||||
the opinion that, ultimately, these features—combined with speed—are more
|
the opinion that, ultimately, these features—combined with speed—are more
|
||||||
valuable than simply cycle counts alone.
|
valuable than simply cycle counts alone.
|
||||||
|
|
||||||
# Warnings
|
|
||||||
|
|
||||||
ed25519-dalek and
|
|
||||||
[our elliptic curve library](https://github.com/dalek-cryptography/curve25519-dalek)
|
|
||||||
(which this code uses) have received *one* formal cryptographic and security
|
|
||||||
review. Neither have yet received what we would consider *sufficient* peer
|
|
||||||
review by other qualified cryptographers to be considered in any way, shape,
|
|
||||||
or form, safe.
|
|
||||||
|
|
||||||
**USE AT YOUR OWN RISK.**
|
|
||||||
|
|
||||||
|
|
||||||
### A Note on Signature Malleability
|
### A Note on Signature Malleability
|
||||||
|
|
||||||
The signatures produced by this library are malleable, as discussed in
|
The signatures produced by this library are malleable, as discussed in
|
||||||
|
|
@ -130,7 +118,7 @@ To install, add the following to your project's `Cargo.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies.ed25519-dalek]
|
[dependencies.ed25519-dalek]
|
||||||
version = "^0.8"
|
version = "1"
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, in your library or executable source, add:
|
Then, in your library or executable source, add:
|
||||||
|
|
@ -146,7 +134,7 @@ enabled by default, instead do:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies.ed25519-dalek]
|
[dependencies.ed25519-dalek]
|
||||||
version = "^0.8"
|
version = "1"
|
||||||
features = ["nightly"]
|
features = ["nightly"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -163,7 +151,7 @@ To enable [serde](https://serde.rs) support, build `ed25519-dalek` with:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies.ed25519-dalek]
|
[dependencies.ed25519-dalek]
|
||||||
version = "^0.8"
|
version = "1"
|
||||||
features = ["serde"]
|
features = ["serde"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,8 @@ use sha2::Sha512;
|
||||||
|
|
||||||
use clear_on_drop::clear::Clear;
|
use clear_on_drop::clear::Clear;
|
||||||
|
|
||||||
use digest::Digest;
|
use curve25519_dalek::digest::Digest;
|
||||||
|
use curve25519_dalek::digest::generic_array::typenum::U64;
|
||||||
use generic_array::typenum::U64;
|
|
||||||
|
|
||||||
use curve25519_dalek::constants;
|
use curve25519_dalek::constants;
|
||||||
use curve25519_dalek::edwards::CompressedEdwardsY;
|
use curve25519_dalek::edwards::CompressedEdwardsY;
|
||||||
|
|
@ -186,7 +185,9 @@ impl Drop for SecretKey {
|
||||||
|
|
||||||
impl SecretKey {
|
impl SecretKey {
|
||||||
/// Expand this `SecretKey` into an `ExpandedSecretKey`.
|
/// Expand this `SecretKey` into an `ExpandedSecretKey`.
|
||||||
pub fn expand<D>(&self) -> ExpandedSecretKey where D: Digest<OutputSize = U64> + Default {
|
pub fn expand<D>(&self) -> ExpandedSecretKey
|
||||||
|
where D: Digest<OutputSize = U64> + Default
|
||||||
|
{
|
||||||
ExpandedSecretKey::from_secret_key::<D>(&self)
|
ExpandedSecretKey::from_secret_key::<D>(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -556,7 +557,7 @@ impl ExpandedSecretKey {
|
||||||
let mut upper: [u8; 32] = [0u8; 32];
|
let mut upper: [u8; 32] = [0u8; 32];
|
||||||
|
|
||||||
h.input(secret_key.as_bytes());
|
h.input(secret_key.as_bytes());
|
||||||
hash.copy_from_slice(h.fixed_result().as_slice());
|
hash.copy_from_slice(h.result().as_slice());
|
||||||
|
|
||||||
lower.copy_from_slice(&hash[00..32]);
|
lower.copy_from_slice(&hash[00..32]);
|
||||||
upper.copy_from_slice(&hash[32..64]);
|
upper.copy_from_slice(&hash[32..64]);
|
||||||
|
|
@ -620,7 +621,7 @@ impl ExpandedSecretKey {
|
||||||
context: Option<&'static [u8]>) -> Signature
|
context: Option<&'static [u8]>) -> Signature
|
||||||
where D: Digest<OutputSize = U64> + Default
|
where D: Digest<OutputSize = U64> + Default
|
||||||
{
|
{
|
||||||
let mut h: D = D::default();
|
let mut h: D;
|
||||||
let mut prehash: [u8; 64] = [0u8; 64];
|
let mut prehash: [u8; 64] = [0u8; 64];
|
||||||
let R: CompressedEdwardsY;
|
let R: CompressedEdwardsY;
|
||||||
let r: Scalar;
|
let r: Scalar;
|
||||||
|
|
@ -634,7 +635,7 @@ impl ExpandedSecretKey {
|
||||||
let ctx_len: u8 = ctx.len() as u8;
|
let ctx_len: u8 = ctx.len() as u8;
|
||||||
|
|
||||||
// Get the result of the pre-hashed message.
|
// Get the result of the pre-hashed message.
|
||||||
prehash.copy_from_slice(prehashed_message.fixed_result().as_slice());
|
prehash.copy_from_slice(prehashed_message.result().as_slice());
|
||||||
|
|
||||||
// This is the dumbest, ten-years-late, non-admission of fucking up the
|
// This is the dumbest, ten-years-late, non-admission of fucking up the
|
||||||
// domain separation I have ever seen. Why am I still required to put
|
// domain separation I have ever seen. Why am I still required to put
|
||||||
|
|
@ -648,24 +649,25 @@ impl ExpandedSecretKey {
|
||||||
//
|
//
|
||||||
// This is a really fucking stupid bandaid, and the damned scheme is
|
// This is a really fucking stupid bandaid, and the damned scheme is
|
||||||
// still bleeding from malleability, for fuck's sake.
|
// still bleeding from malleability, for fuck's sake.
|
||||||
h.input(b"SigEd25519 no Ed25519 collisions");
|
h = D::default()
|
||||||
h.input(&[1]); // Ed25519ph
|
.chain(b"SigEd25519 no Ed25519 collisions")
|
||||||
h.input(&[ctx_len]);
|
.chain(&[1]) // Ed25519ph
|
||||||
h.input(ctx);
|
.chain(&[ctx_len])
|
||||||
h.input(&self.nonce);
|
.chain(ctx)
|
||||||
h.input(&prehash);
|
.chain(&self.nonce)
|
||||||
|
.chain(&prehash[..]);
|
||||||
|
|
||||||
r = Scalar::from_hash(h);
|
r = Scalar::from_hash(h);
|
||||||
R = (&r * &constants::ED25519_BASEPOINT_TABLE).compress();
|
R = (&r * &constants::ED25519_BASEPOINT_TABLE).compress();
|
||||||
|
|
||||||
h = D::default();
|
h = D::default()
|
||||||
h.input(b"SigEd25519 no Ed25519 collisions");
|
.chain(b"SigEd25519 no Ed25519 collisions")
|
||||||
h.input(&[1]); // Ed25519ph
|
.chain(&[1]) // Ed25519ph
|
||||||
h.input(&[ctx_len]);
|
.chain(&[ctx_len])
|
||||||
h.input(ctx);
|
.chain(ctx)
|
||||||
h.input(R.as_bytes());
|
.chain(R.as_bytes())
|
||||||
h.input(public_key.as_bytes());
|
.chain(public_key.as_bytes())
|
||||||
h.input(&prehash);
|
.chain(&prehash[..]);
|
||||||
|
|
||||||
k = Scalar::from_hash(h);
|
k = Scalar::from_hash(h);
|
||||||
s = &(&k * &self.key) + &r;
|
s = &(&k * &self.key) + &r;
|
||||||
|
|
@ -784,7 +786,7 @@ impl PublicKey {
|
||||||
let mut digest: [u8; 32] = [0u8; 32];
|
let mut digest: [u8; 32] = [0u8; 32];
|
||||||
|
|
||||||
h.input(secret_key.as_bytes());
|
h.input(secret_key.as_bytes());
|
||||||
hash.copy_from_slice(h.fixed_result().as_slice());
|
hash.copy_from_slice(h.result().as_slice());
|
||||||
|
|
||||||
digest.copy_from_slice(&hash[..32]);
|
digest.copy_from_slice(&hash[..32]);
|
||||||
|
|
||||||
|
|
@ -886,7 +888,7 @@ impl PublicKey {
|
||||||
h.input(ctx);
|
h.input(ctx);
|
||||||
h.input(signature.R.as_bytes());
|
h.input(signature.R.as_bytes());
|
||||||
h.input(self.as_bytes());
|
h.input(self.as_bytes());
|
||||||
h.input(prehashed_message.fixed_result().as_slice());
|
h.input(prehashed_message.result().as_slice());
|
||||||
|
|
||||||
k = Scalar::from_hash(h);
|
k = Scalar::from_hash(h);
|
||||||
R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
|
R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
|
||||||
|
|
|
||||||
|
|
@ -258,8 +258,6 @@
|
||||||
#![deny(missing_docs)] // refuse to compile if documentation is missing
|
#![deny(missing_docs)] // refuse to compile if documentation is missing
|
||||||
|
|
||||||
extern crate curve25519_dalek;
|
extern crate curve25519_dalek;
|
||||||
extern crate generic_array;
|
|
||||||
extern crate digest;
|
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate clear_on_drop;
|
extern crate clear_on_drop;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue