Skip to content

Commit

Permalink
fix: adapt ed25519 public key to 33-byte length
Browse files Browse the repository at this point in the history
  • Loading branch information
aya015757881 committed Dec 10, 2024
1 parent 52d44a7 commit 9912e21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Extended private keys
use crate::bip32::{
ChildNumber, Depth, Error, ExtendedKey, ExtendedKeyAttrs, ExtendedPublicKey, HmacSha512,
KeyFingerprint, Prefix, PrivateKey, PublicKey, Result, KEY_SIZE,
ChildNumber, Depth, Error, ExtendedKey, ExtendedKeyAttrs, ExtendedPublicKey, HmacSha512, KeyFingerprint, Prefix, PrivateKey, PublicKey, Result, XpubEd25519, XpubSecp256k1, KEY_SIZE
};
use core::{
fmt::{self, Debug},
Expand Down Expand Up @@ -250,4 +249,4 @@ where
Err(Error::Crypto)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ where
attrs: self.attrs.clone(),
key_bytes: {
let mut key_bytes = [0u8; KEY_SIZE + 1];
key_bytes.copy_from_slice(&self.to_bytes());
let bytes = self.to_bytes();
let bytes = match bytes.len() {
KEY_SIZE => [vec![0u8], bytes].concat(),
_ => bytes,
};
key_bytes.copy_from_slice(&bytes);
key_bytes
},
}
Expand Down Expand Up @@ -148,4 +153,4 @@ where
Err(Error::Crypto)
}
}
}
}

0 comments on commit 9912e21

Please sign in to comment.