The output of wasm-pack on IOHK's cardano wallet
Friday 01 March 2019
It all started with the Icarus project last year. At the time we wrote a first version of the crypto graphic library in rust and provided hand-written bindings from rust to JS. While it worked well to a certain point it was not a great API to utilise.
Before you would have to do this:
const CardanoCrypto = require('OldCardanoCrypto.js'); const SEED = new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,]); const root_xprv = CardanoCrypto.HdWallet.fromSeed(seed); const xpub = CardanoCrypto.HdWallet.toPublic(xprv); const known_address = CardanoCrypto.HdWallet.publicKeyToAddress(xpub);
While very raw it also comes without type script annotations.
Now you can:
const MNEMONICS = "crowd captain hungry tray powder motor coast oppose month shed parent mystery torch resemble index"; const PASSWORD = "Cardano Rust for the winners!"; let settings = Wallet.BlockchainSettings.mainnet(); let entropy = Wallet.Entropy.from_english_mnemonics(MNEMONICS); let wallet = Wallet.Bip44RootPrivateKey.recover(entropy, PASSWORD); let account = wallet.bip44_account(Wallet.AccountIndex.new(0 | 0x80000000)); let account_public = account.public(); let key_prv = account.address_key(false, Wallet.AddressKeyIndex.new(0)); let key_pub = account_public.address_key(false, Wallet.AddressKeyIndex.new(0)); let address = key_pub.bootstrap_era_address(settings);