Skip to content

Commit

Permalink
Update curve25519-dalek dependency to 1.0.0-pre.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
isislovecruft committed Nov 6, 2018
1 parent 9721d1d commit b97fa08
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
13 changes: 3 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,20 @@ exclude = [ ".gitignore", "TESTVECTORS", "res/*" ]
travis-ci = { repository = "dalek-cryptography/ed25519-dalek", branch = "master"}

[dependencies.curve25519-dalek]
version = "0.20"
version = "1.0.0-pre.0"
default-features = false

[dependencies.rand]
version = "0.5"
default-features = false
features = ["i128_support"]

[dependencies.digest]
version = "^0.7"

[dependencies.generic-array]
# same version that digest depends on
version = "0.9"

[dependencies.serde]
version = "^1.0"
optional = true

[dependencies.sha2]
version = "^0.7"
version = "^0.8"
optional = true

[dependencies.failure]
Expand All @@ -48,7 +41,7 @@ version = "0.2"

[dev-dependencies]
hex = "^0.3"
sha2 = "^0.7"
sha2 = "^0.8"
bincode = "^0.9"
criterion = "0.2"

Expand Down
48 changes: 25 additions & 23 deletions src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ use sha2::Sha512;

use clear_on_drop::clear::Clear;

use digest::Digest;

use generic_array::typenum::U64;
use curve25519_dalek::digest::Digest;
use curve25519_dalek::digest::generic_array::typenum::U64;

use curve25519_dalek::constants;
use curve25519_dalek::edwards::CompressedEdwardsY;
Expand Down Expand Up @@ -186,7 +185,9 @@ impl Drop for SecretKey {

impl SecretKey {
/// 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)
}

Expand Down Expand Up @@ -556,7 +557,7 @@ impl ExpandedSecretKey {
let mut upper: [u8; 32] = [0u8; 32];

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]);
upper.copy_from_slice(&hash[32..64]);
Expand Down Expand Up @@ -620,7 +621,7 @@ impl ExpandedSecretKey {
context: Option<&'static [u8]>) -> Signature
where D: Digest<OutputSize = U64> + Default
{
let mut h: D = D::default();
let mut h: D;
let mut prehash: [u8; 64] = [0u8; 64];
let R: CompressedEdwardsY;
let r: Scalar;
Expand All @@ -634,7 +635,7 @@ impl ExpandedSecretKey {
let ctx_len: u8 = ctx.len() as u8;

// 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
// domain separation I have ever seen. Why am I still required to put
Expand All @@ -648,24 +649,25 @@ impl ExpandedSecretKey {
//
// This is a really fucking stupid bandaid, and the damned scheme is
// still bleeding from malleability, for fuck's sake.
h.input(b"SigEd25519 no Ed25519 collisions");
h.input(&[1]); // Ed25519ph
h.input(&[ctx_len]);
h.input(ctx);
h.input(&self.nonce);
h.input(&prehash);
h = D::default()
.chain(b"SigEd25519 no Ed25519 collisions")
.chain(&[1]) // Ed25519ph
.chain(&[ctx_len])
.chain(ctx)
.chain(&self.nonce)
.chain(&prehash[..]);

r = Scalar::from_hash(h);
R = (&r * &constants::ED25519_BASEPOINT_TABLE).compress();

h = D::default();
h.input(b"SigEd25519 no Ed25519 collisions");
h.input(&[1]); // Ed25519ph
h.input(&[ctx_len]);
h.input(ctx);
h.input(R.as_bytes());
h.input(public_key.as_bytes());
h.input(&prehash);
h = D::default()
.chain(b"SigEd25519 no Ed25519 collisions")
.chain(&[1]) // Ed25519ph
.chain(&[ctx_len])
.chain(ctx)
.chain(R.as_bytes())
.chain(public_key.as_bytes())
.chain(&prehash[..]);

k = Scalar::from_hash(h);
s = &(&k * &self.key) + &r;
Expand Down Expand Up @@ -784,7 +786,7 @@ impl PublicKey {
let mut digest: [u8; 32] = [0u8; 32];

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]);

Expand Down Expand Up @@ -886,7 +888,7 @@ impl PublicKey {
h.input(ctx);
h.input(signature.R.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);
R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@
#![deny(missing_docs)] // refuse to compile if documentation is missing

extern crate curve25519_dalek;
extern crate generic_array;
extern crate digest;
extern crate failure;
extern crate rand;
extern crate clear_on_drop;
Expand Down

0 comments on commit b97fa08

Please sign in to comment.