Fix signature convertion bug
@@ -1422,11 +1422,15 @@ impl TryFrom<RegularEssence> for RustRegularEssence {
impl TryFrom<Ed25519Signature> for RustSignatureUnlock {
type Error = Error;
fn try_from(signature: Ed25519Signature) -> Result<Self> {
- let mut public_key = [0u8; 32];
- hex::decode_to_slice(signature.public_key, &mut public_key)?;
- let mut signature_bytes = [0u8; 64];
- hex::decode_to_slice(signature.signature, &mut signature_bytes)?;
- Ok(RustEd25519Signature::new(public_key, signature_bytes).into())
+ Ok(RustEd25519Signature::new(
+ signature.public_key,
+ signature
+ .signature
+ .clone()
+ .try_into()
+ .unwrap_or_else(|_| panic!("Invalid Signature: {:?}", signature.signature)),
+ )
+ .into())
}
}
