Closed zachyking closed 2 years ago
Changing to_bytes
to as_bytes
for CBORValue
in the verify function fixes it.
This
let address = cml::address::Address::from_bytes(cbor_val_address.to_bytes())
.unwrap() //this is line that panics
.to_bech32(None)
.unwrap();
To
let address = cml::address::Address::from_bytes(cbor_val_address.as_bytes().unwrap())
.unwrap() //doesn't panic now - assuming correct COSESign1 headers
.to_bech32(None)
.unwrap();
I implemented sign function in rust based on Nami's implementation here
Then verify function. It seems to be working fine, beside I can't get address from the ProtectedHeader of COSESign1 - I'll get an error
CBOR(TrailingData)
. After finding I mostly followed this example but couldn't get it work in rust.using
In sign function:
In verify function:
I tried
header_addr_val
tocml::address::Address::from_bytes
without going toms::cbor::CBORValue
first, but neither does work.The len of bytes is the same, so is there some conversion needed for Rust when going from CBORValue?