Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make helium-crypto-rs compilable with the latest ed25519-compact version #69

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 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(signature::Error::from_source)?;
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,9 +153,8 @@ impl TryFrom<&[u8]> for Signature {
type Error = Error;

fn try_from(input: &[u8]) -> Result<Self> {
signature::Signature::from_bytes(input)
.map(Signature)
.map_err(Error::from)
let signature = ed25519_compact::Signature::try_from(input)?;
Ok(Signature(signature))
}
}

Expand Down
Loading