The js code uses polkadot api, util-crypto and extension-dap
const { signature } = await signRaw({
address: account.address,
data: payload,
type: 'bytes'
});
// isValid is true
const isValid = await signatureVerify(payload, signature, account.address);
The rust code crates the payload and passed it has hex_encoded into the js code. I make sure that hex encoding and decoding was all correct, but I couldn't understand why the signature is valid in js code, but verifying it in the rust code against the payload returns invalid.
let is_valid1 = signature.verify(payload.as_slice(), &signer_address);
// invalid
let message = format!("rust signature is valid1: {}", is_valid1);
Bytes
, I don't hope so since that would be a security issue. Why can you not wrap the message inBytes
before verifying?