Open jacogr opened 5 years ago
I assume this is not the only function that you will need, right?
Only one actually - all the Junction etc. stuff is implemented to do the derivation, however in the JS derive function, cannot call anything to adjust the key (as per the Rust sample).
Not sure how that will work, have not looked - so there are possibly additional functions required around it to make thing work.
Ok then it looks fairly minimal to do. Hopefully within the next day should be delivered for you and the js team to test.
yes, it looks like a single function, just not 100% sure how to jump through all the hoops since it operates on an actual pair - but basically, in the ed25519 the derivation just is a hash function, in the sr25519 need to call into the lib.
Just fyi, I added a hard derivation path which previously I'd ignored.
@burdges Gav did this - https://github.com/paritytech/substrate/blob/master/core/primitives/src/sr25519.rs#L368 which is used further on by https://github.com/paritytech/substrate/blob/master/core/primitives/src/sr25519.rs#L450 (i.e. here the soft derivation goes via w3f/schnorrkel
and hard derivation via the first linked function)
So for the meantime the polkadot-js keyring stuff will follow suit until that is adjusted in Substrate.
Specifically
derived_key_simple
enabling us to do this logic from the JS side -