aptos-core
aptos-core copied to clipboard
ed25519_dalek should be re-exported by the Rust SDK
ISSUE
ed25519_dalek is used for the SecretKey type but is not re-exported, making it impossible to construct a secretKey using the rust SDK alone.
As you can see here:
/// An Ed25519 private key
#[derive(DeserializeKey, SerializeKey, SilentDebug, SilentDisplay)]
pub struct Ed25519PrivateKey(pub(crate) ed25519_dalek::SecretKey);
The Ed25519 Private Key uses the SecretKey from ed25519_dalek crate
In the SecretKey Impl for ed25519_dalek: https://github.com/dalek-cryptography/ed25519-dalek/blob/main/src/secret.rs
///
/// # Returns
///
/// A `Result` whose okay value is an EdDSA `SecretKey` or whose error value
/// is an `SignatureError` wrapping the internal error that occurred.
#[inline]
pub fn from_bytes(bytes: &[u8]) -> Result<SecretKey, SignatureError> {
if bytes.len() != SECRET_KEY_LENGTH {
return Err(InternalError::BytesLengthError {
name: "SecretKey",
length: SECRET_KEY_LENGTH,
}.into());
}
let mut bits: [u8; 32] = [0u8; 32];
bits.copy_from_slice(&bytes[..32]);
Ok(SecretKey(bits))
}
This function is required to create a new SecretKey from bytes since the Ed25519 library in the aptos-crypto crate does not have any constructors
https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos-crypto/src/ed25519/ed25519_keys.rs
Therefore I believe that ed25519_dalek should be exported by aptos_crypto, or at lease relevant functions such as generate or from_bytes
Could you submit a PR?
This issue is stale because it has been open 45 days with no activity. Remove the stale label or comment - otherwise this will be closed in 15 days.