From 02eb848b3d367001dee504de4a23b1015bbf0c10 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 5 Feb 2024 17:55:42 +0200 Subject: [PATCH] Make helium-crypto-rs compilable with the latest ed25519-compact version --- Cargo.toml | 2 +- src/ed25519/mod.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 583cd8b..b8211c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ serde = { version = "1", features = ["derive"] } rand_core = "^0.6" getrandom = "0" sha2 = { version = "0.10", default-features = false, features = ["std", "oid"] } -ed25519-compact = { version = "=2.0.6", features = ["std", "traits"] } +ed25519-compact = { version = "2", features = ["std", "traits"] } p256 = { version = "0.10", default-features = false, features = [ "arithmetic", "ecdsa", diff --git a/src/ed25519/mod.rs b/src/ed25519/mod.rs index 5fff594..50f9f50 100644 --- a/src/ed25519/mod.rs +++ b/src/ed25519/mod.rs @@ -100,11 +100,9 @@ impl Keypair { impl signature::Signature for Signature { fn from_bytes(input: &[u8]) -> std::result::Result { - Ok(Signature(signature::Signature::from_bytes(input)?)) - } - - fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() + let signature = ed25519_compact::Signature::try_from(input) + .map_err(|e| signature::Error::from_source(e))?; + Ok(Signature(signature)) } } @@ -138,7 +136,8 @@ impl signature::Signer for Keypair { impl Signature { pub fn from_bytes(bytes: &[u8]) -> Result { - Ok(Signature(signature::Signature::from_bytes(bytes)?)) + let signature = ed25519_compact::Signature::try_from(bytes)?; + Ok(Signature(signature)) } pub fn to_vec(&self) -> Vec { @@ -150,7 +149,7 @@ impl TryFrom<&[u8]> for Signature { type Error = Error; fn try_from(input: &[u8]) -> Result { - signature::Signature::from_bytes(input) + ed25519_compact::Signature::try_from(input) .map(Signature) .map_err(Error::from) }