Skip to content
Snippets Groups Projects

[fix] crypto:ed25519: must support pubkey of 31 bytes

Merged Éloïs requested to merge elois/pub31 into dev
6 files
+ 93
63
Compare changes
  • Side-by-side
  • Inline

Files

+ 9
2
@@ -24,7 +24,8 @@ pub trait ToBase58 {
}
/// Create an array of 32 bytes from a Base58 string.
pub fn str_base58_to_32bytes(base58_data: &str) -> Result<[u8; 32], BaseConvertionError> {
pub fn str_base58_to_32bytes(base58_data: &str) -> Result<([u8; 32], usize), BaseConvertionError> {
debug!("str_base58_to_32bytes({});", base58_data);
match bs58::decode(base58_data).into_vec() {
Ok(result) => {
if result.len() == 32 {
@@ -32,7 +33,13 @@ pub fn str_base58_to_32bytes(base58_data: &str) -> Result<[u8; 32], BaseConverti
u8_array[..32].clone_from_slice(&result[..32]);
Ok(u8_array)
Ok((u8_array, 32))
} else if result.len() == 31 {
let mut u8_array = [0; 32];
u8_array[..31].clone_from_slice(&result[..31]);
Ok((u8_array, 31))
} else {
Err(BaseConvertionError::InvalidLength {
expected: 32,
Loading