2

Hey I have some call data which is similar to this.

I am signing it using schnorrkel libaray function function. as secret.sign_simple(&[], msg) where secret is a Keypair and msg is in bytes.

Then I create a multisignature using

let sig_slice: &[u8] = &sig_bytes;
let sig = Signature::try_from(sig_slice).unwrap();
let multisig = MultiSignature::Sr25519(sig);

where &sig_bytes in bytes returned by signing and if I add that signature to make a extrinsic bytes e.g. here

I get error Transaction has a bad signature.

And if I send the same extrinsic using subxt and pass the signer as PairSigner<SubstrateConfig, sr25519::Pair> it works fine. But I can't use this pair sign function when signing a msg because of nature of architecture. I have to use an independent lib something more generic.

How can I solve this error?

1 Answer 1

3

Actually we need a context string for substrate signatures

let context = schnorrkel::signing_context(b"substrate");
Signature::Sr25519(secret.sign(context.bytes(msg)))

and then we can use the sign function which gives us a valid signature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.