Skip to content

Commit

Permalink
udpate ed25519-dalek
Browse files Browse the repository at this point in the history
  • Loading branch information
chcmedeiros committed Jan 13, 2025
1 parent 6436845 commit beac87a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bolos-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ hmac = "0.11.0"

cfg-if = "1.0.0"

ed25519-dalek = "1.0.1"
ed25519-dalek = "2.1.1"
k256 = "0.13.1"
p256 = "0.13.2"

Expand Down
23 changes: 10 additions & 13 deletions bolos-mock/src/crypto/ecfp256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ impl<const B: usize> SecretKey<B> {
*secret.to_bytes().as_ref()
}
Curve::Ed25519 => {
let secret = ed25519_dalek::SecretKey::generate(&mut Self::rng7(path));
use rand_chacha7::rand_core::RngCore;
let mut rng = Self::rng7(path);
let mut bytes = [0u8; 32];
rng.fill_bytes(&mut bytes);
let secret = ed25519_dalek::SigningKey::from_bytes(&bytes);

secret.to_bytes()
}
Expand Down Expand Up @@ -172,12 +176,10 @@ impl<const B: usize> SecretKey<B> {
(bytes, uncompressed_point.len())
}
Curve::Ed25519 => {
let secret = ed25519_dalek::SecretKey::from_bytes(&self.bytes[..]).unwrap();

let public = ed25519_dalek::PublicKey::from(&secret);
let secret = ed25519_dalek::SigningKey::from_bytes(&self.bytes);
let public = secret.verifying_key();
let mut bytes = [0; 65];
bytes[..32].copy_from_slice(&public.as_bytes()[..]);

bytes[..32].copy_from_slice(public.as_bytes());
(bytes, 32)
}
_ => unreachable!(),
Expand Down Expand Up @@ -233,13 +235,8 @@ impl<const B: usize> SecretKey<B> {
}
Curve::Ed25519 => {
use ed25519_dalek::Signer;

let secret = ed25519_dalek::SecretKey::from_bytes(&self.bytes[..]).unwrap();
let public = ed25519_dalek::PublicKey::from(&secret);

let keypair = ed25519_dalek::Keypair { secret, public };
let sig = keypair.sign(data);

let secret = ed25519_dalek::SigningKey::from_bytes(&self.bytes);
let sig = secret.sign(data);
out[..64].copy_from_slice(&sig.to_bytes()[..]);
Ok((Default::default(), 64))
}
Expand Down

0 comments on commit beac87a

Please sign in to comment.