dalek-cryptography / curve25519-dalek

A pure-Rust implementation of group operations on Ristretto and Curve25519
Other
887 stars 452 forks source link

crypto_box compatibility is broken in eddalek@2.0.0 #564

Closed dignifiedquire closed 1 year ago

dignifiedquire commented 1 year ago

When trying to upgrade from the last RC, I ran into this. The following test code should pass, but it will not, breaking the ability to use the crypto_box functionality.

let mut rng = rand::thread_rng();
let key = ed25519_dalek::SigningKey::generate(&mut rng);
let public_key1 = {
    let m = key.verifying_key().to_montgomery();
    crypto_box::PublicKey::from(m)
};

let public_key2 = {
    let s = key.to_scalar();
    let cs = crypto_box::SecretKey::from(s);
    cs.public_key()
};

assert_eq!(public_key1, public_key2); // fails
tarcieri commented 1 year ago

This seems like a bug in crypto_box. Here's a fix: https://github.com/RustCrypto/nacl-compat/pull/137