-
Notifications
You must be signed in to change notification settings - Fork 0
Add function to create a SignedMessage without using types from sp-core version 6 #16
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
For context, this is where this new function is called from the test client i am playing around with, and we could do the same in |
Hmm, that version of
I guess not being tied to |
If we can get sp-core 21 with the features needed to do sr25119 signing to work on wasm, this would definately not be needed and nor would a lot of the extra code and workarounds in But in my understanding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in my understanding subxt-signer was created for exactly this reason - that the newer versions of sp-core no longer have an sr25519 implementation that works on wasm (if i remember rightly the crate itself will compile but not with the needed features).
There is the full-crypto
feature which compiles to no_std
, but it doesn't say anything about necessarily working in a Wasm context. I guess we could try that out and if it doesn't work then we can merge this PR and switch to subxt-signer
later.
src/lib.rs
Outdated
pub fn new_with_keypair_seed( | ||
sr25519_keypair_seed: &[u8; 32], | ||
msg: Vec<u8>, | ||
recip: &PublicKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recip: &PublicKey, | |
recipient: &PublicKey, |
Co-authored-by: Hernando Castano <[email protected]>
You are right, thanks! I am closing this in favor of #19 |
Due to #15 we cannot use the
encrypt_and_sign
function from environments usingsp-core
/subxt-signer
, so we need to useSignedMessage
directly as we do inentropy-core
.This crate depends on
sp-core
version 6, as new versions don't compile to wasm. SinceSignedMessage::new
has two arguments with types fromsp-core
this is inconvenient to use from crates which depend on a newer version of sp-core.This PR adds an extra constructor which takes a 32 byte seed and generates a keypair from it internally, meaning the
Pair
type doesn't need to be given as an argument.This is a hacky fix. In the long term i would like to switch this crate to using
subxt-signer
but that will be a breaking change and until then i would like to do it this way.