Open SebastienGllmt opened 5 years ago
takes a mnemonic, turns it into an entropy [u8] internally and uses that for paperwallet:unscramble https://github.com/input-output-hk/js-cardano-wasm/blob/e099e7e666805b5efb4eac14103b5dafdb1b73de/js/PaperWallet.js#L62 https://github.com/input-output-hk/js-cardano-wasm/blob/bd40ab0f8d6ae27998c7ef5125c8c5cbd109a285/wallet-wasm/src/lib.rs#L266
[u8]
paperwallet:unscramble
takes the entropy directly as a [u8] https://github.com/input-output-hk/js-cardano-wasm/blob/1ce87da6ebee4f70cee7971eb79900fd83674f50/cardano-wallet/src/lib.rs#L1080
However, we have no way of turning type Entropy to [u8] in Yoroi as Entropy only exposes two methods: from_english_mnemonics and to_english_mnemonics.
Entropy
from_english_mnemonics
to_english_mnemonics
This seems like a strange quirk in the API because of the following:
paper_wallet_scramble input: Entropy paper_wallet_scramble output: [u8] paper_wallet_unscramble input: [u8] paper_wallet_unscramble output: Entropy
paper_wallet_scramble
paper_wallet_unscramble
This allows you to write the following code
let bytes = paper_wallet_scramble(&test.entropy, &test.iv, test.password).unwrap(); let bytes: Vec<u8> = JsValue::into_serde(&bytes).unwrap(); let entropy = paper_wallet_unscramble(&bytes, test.password).unwrap();
However, in Yoroi we don't unscramble right after scrambling. These are done in different sessions. Maybe it makes more sense to have it consistently use Entropy for all these methods? We can also fix it with something like #57 but then we should probably also add a from_array function also which is a bit more complex (which is why it was left as a TODO https://github.com/input-output-hk/js-cardano-wasm/blob/1ce87da6ebee4f70cee7971eb79900fd83674f50/cardano-wallet/src/lib.rs#L89 )
from_array
Old API
takes a mnemonic, turns it into an entropy
[u8]
internally and uses that forpaperwallet:unscramble
https://github.com/input-output-hk/js-cardano-wasm/blob/e099e7e666805b5efb4eac14103b5dafdb1b73de/js/PaperWallet.js#L62 https://github.com/input-output-hk/js-cardano-wasm/blob/bd40ab0f8d6ae27998c7ef5125c8c5cbd109a285/wallet-wasm/src/lib.rs#L266New API
takes the entropy directly as a
[u8]
https://github.com/input-output-hk/js-cardano-wasm/blob/1ce87da6ebee4f70cee7971eb79900fd83674f50/cardano-wallet/src/lib.rs#L1080Problem
However, we have no way of turning type
Entropy
to[u8]
in Yoroi asEntropy
only exposes two methods:from_english_mnemonics
andto_english_mnemonics
.This seems like a strange quirk in the API because of the following:
paper_wallet_scramble
input:Entropy
paper_wallet_scramble
output:[u8]
paper_wallet_unscramble
input:[u8]
paper_wallet_unscramble
output:Entropy
This allows you to write the following code
However, in Yoroi we don't unscramble right after scrambling. These are done in different sessions. Maybe it makes more sense to have it consistently use
Entropy
for all these methods? We can also fix it with something like #57 but then we should probably also add afrom_array
function also which is a bit more complex (which is why it was left as a TODO https://github.com/input-output-hk/js-cardano-wasm/blob/1ce87da6ebee4f70cee7971eb79900fd83674f50/cardano-wallet/src/lib.rs#L89 )