Skip to content

Bump ed25519-dalek to 2.1.1, ed25519-dalek-bip32 to 0.3.0 #26

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kevinheavey
Copy link
Contributor

Ported from anza-xyz/agave#3088

Summary of Changes

  • Bump the two crate versions as in title and fix what breaks
  • This involves one breaking change: Keypair::generate now relies on traits from a newer version of the rand crate - it no longer works with rand 0.7.

@seanyoung
Copy link
Contributor

How does this affect performance (the bench should tell us that, I think).

@kevinheavey
Copy link
Contributor Author

Looks like the new version is faster. Found this in the CI bench output https://github.com/anza-xyz/solana-sdk/actions/runs/13304474459/job/37152326064?pr=26:

test bench_ed25519_len_032 ... bench:      48,795.52 ns/iter (+/- 238.09)
test bench_ed25519_len_128 ... bench:      49,085.67 ns/iter (+/- 368.34)
test bench_ed25519_len_32k ... bench:     110,201.12 ns/iter (+/- 1,078.12)
test bench_ed25519_len_max ... bench:     171,307.76 ns/iter (+/- 1,212.43)

Meanwhile in another unrelated PR: https://github.com/anza-xyz/solana-sdk/actions/runs/13344518453/job/37273344074?pr=40

test bench_ed25519_len_032 ... bench:      62,532.14 ns/iter (+/- 1,077.31)
test bench_ed25519_len_128 ... bench:      62,774.78 ns/iter (+/- 597.11)
test bench_ed25519_len_32k ... bench:     123,763.83 ns/iter (+/- 1,565.07)
test bench_ed25519_len_max ... bench:     184,640.96 ns/iter (+/- 1,562.99)

@@ -76,12 +71,12 @@ impl Keypair {

/// Returns this `Keypair` as a base58-encoded string
pub fn to_base58_string(&self) -> String {
bs58::encode(&self.0.to_bytes()).into_string()
bs58::encode(&self.to_bytes()).into_string()
}

/// Gets this `Keypair`'s SecretKey
pub fn secret(&self) -> &ed25519_dalek::SecretKey {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should just return [u8; 32] directly, skip the type alias of ed25519-dalek.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would have security implications but I'm not the right person to comment on it

@@ -271,11 +262,9 @@ pub fn keypair_from_seed(seed: &[u8]) -> Result<Keypair, Box<dyn error::Error>>
if seed.len() < ed25519_dalek::SECRET_KEY_LENGTH {
return Err("Seed is too short".into());
}
let secret = ed25519_dalek::SecretKey::from_bytes(&seed[..ed25519_dalek::SECRET_KEY_LENGTH])
let secret_key = ed25519_dalek::SecretKey::try_from(&seed[..ed25519_dalek::SECRET_KEY_LENGTH])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function never fail, should call unwrap here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking PR contains breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants