From 8776106f77241bc7bd3143d1bce5f4fb43ba751d Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 5 Feb 2024 15:01:20 +0200 Subject: [PATCH 1/4] Fix compiling issue. Use ed25519-compact 2.0.6 version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b8211c9..583cd8b 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", features = ["std", "traits"] } +ed25519-compact = { version = "=2.0.6", features = ["std", "traits"] } p256 = { version = "0.10", default-features = false, features = [ "arithmetic", "ecdsa", From 02de724383e15a57d44bca389e12ab0a74f04b91 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 5 Feb 2024 17:55:42 +0200 Subject: [PATCH 2/4] Make helium-crypto-rs compilable with the latest ed25519-compact version --- Cargo.toml | 2 +- src/ed25519/mod.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 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..613aab1 100644 --- a/src/ed25519/mod.rs +++ b/src/ed25519/mod.rs @@ -100,11 +100,13 @@ impl Keypair { impl signature::Signature for Signature { fn from_bytes(input: &[u8]) -> std::result::Result { - Ok(Signature(signature::Signature::from_bytes(input)?)) + let signature = + ed25519_compact::Signature::try_from(input).map_err(signature::Error::from_source)?; + Ok(Signature(signature)) } fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() + self.0.as_ref() } } @@ -138,7 +140,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,9 +153,7 @@ impl TryFrom<&[u8]> for Signature { type Error = Error; fn try_from(input: &[u8]) -> Result { - signature::Signature::from_bytes(input) - .map(Signature) - .map_err(Error::from) + Signature::from_bytes(input).map_err(Error::from) } } From 0bb742a4d2c23a6bf413a384ca15ce55d162fb15 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 5 Feb 2024 18:13:32 +0200 Subject: [PATCH 3/4] Remove useless map_err --- src/ed25519/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ed25519/mod.rs b/src/ed25519/mod.rs index 613aab1..0734666 100644 --- a/src/ed25519/mod.rs +++ b/src/ed25519/mod.rs @@ -153,7 +153,7 @@ impl TryFrom<&[u8]> for Signature { type Error = Error; fn try_from(input: &[u8]) -> Result { - Signature::from_bytes(input).map_err(Error::from) + Signature::from_bytes(input) } } From 0be3c410fdebe2527b29c930ce828984b1488427 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 5 Feb 2024 18:23:24 +0200 Subject: [PATCH 4/4] Use ed25519_compact::Signature::try_from for all implemented traits --- src/ed25519/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ed25519/mod.rs b/src/ed25519/mod.rs index 0734666..6ec6b9b 100644 --- a/src/ed25519/mod.rs +++ b/src/ed25519/mod.rs @@ -153,7 +153,8 @@ impl TryFrom<&[u8]> for Signature { type Error = Error; fn try_from(input: &[u8]) -> Result { - Signature::from_bytes(input) + let signature = ed25519_compact::Signature::try_from(input)?; + Ok(Signature(signature)) } }