Skip to content

Commit

Permalink
Make helium-crypto-rs compilable with the latest ed25519-compact version
Browse files Browse the repository at this point in the history
  • Loading branch information
kurotych committed Feb 5, 2024
1 parent 8776106 commit afa6de0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 7 additions & 4 deletions src/ed25519/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ impl Keypair {

impl signature::Signature for Signature {
fn from_bytes(input: &[u8]) -> std::result::Result<Self, signature::Error> {
Ok(Signature(signature::Signature::from_bytes(input)?))
let signature = ed25519_compact::Signature::try_from(input)
.map_err(|e| signature::Error::from_source(e))?;
Ok(Signature(signature))
}

fn as_bytes(&self) -> &[u8] {
self.0.as_bytes()
self.0.as_ref()
}
}

Expand Down Expand Up @@ -138,7 +140,8 @@ impl signature::Signer<Signature> for Keypair {

impl Signature {
pub fn from_bytes(bytes: &[u8]) -> Result<Self> {
Ok(Signature(signature::Signature::from_bytes(bytes)?))
let signature = ed25519_compact::Signature::try_from(bytes)?;
Ok(Signature(signature))
}

pub fn to_vec(&self) -> Vec<u8> {
Expand All @@ -150,7 +153,7 @@ impl TryFrom<&[u8]> for Signature {
type Error = Error;

fn try_from(input: &[u8]) -> Result<Self> {
signature::Signature::from_bytes(input)
ed25519_compact::Signature::try_from(input)
.map(Signature)
.map_err(Error::from)
}
Expand Down

0 comments on commit afa6de0

Please sign in to comment.