diff --git a/CHANGELOG.md b/CHANGELOG.md index 967da3f6b2..41d1f760ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ parameterized by the lifetime of the input byte slice. - Add explicit prefix check during base58check decoding. - Hash input before signing with `SecretKeyEd25519`, to match octez impl. - Fix `BlsSignature` base58 check encoding/decoding. +- Fix all zeros signature encoding: should be `Unknown` rather than defaulting to `Ed25519`. ### Security diff --git a/crypto/src/hash.rs b/crypto/src/hash.rs index 7680fefcf1..b8c0551c2d 100644 --- a/crypto/src/hash.rs +++ b/crypto/src/hash.rs @@ -465,12 +465,8 @@ impl HashType { Err(FromBytesError::InvalidSize) } else { let mut hash = Vec::with_capacity(self.base58check_prefix().len() + data.len()); - if matches!(self, Self::UnknownSignature) && data == [0; Self::Ed25519Signature.size()] - { - hash.extend(Self::Ed25519Signature.base58check_prefix()); - } else { - hash.extend(self.base58check_prefix()); - } + + hash.extend(self.base58check_prefix()); hash.extend(data); hash.to_base58check() // currently the error is returned if the input lenght exceeds 128 bytes diff --git a/crypto/src/signature.rs b/crypto/src/signature.rs index 4866e662c9..0115723c1d 100644 --- a/crypto/src/signature.rs +++ b/crypto/src/signature.rs @@ -128,3 +128,14 @@ impl ::std::fmt::Display for Signature { write!(f, "{}", self.to_base58_check()) } } + +#[cfg(test)] +mod test { + #[test] + fn test() { + assert_eq!( + &super::Signature::try_from([0; 64].to_vec()).unwrap().to_base58_check(), + "sigMzJ4GVAvXEd2RjsKGfG2H9QvqTSKCZsuB2KiHbZRGFz72XgF6KaKADznh674fQgBatxw3xdHqTtMHUZAGRprxy64wg1aq" + ); + } +}