-
Notifications
You must be signed in to change notification settings - Fork 4
Keyring
Gung De Surya edited this page Jul 7, 2020
·
1 revision
Use Keyring to create HD Wallet using BIP32. We implementing ed25519 elliptic-curve to create the derivation
Use this function to create securely random passphrase using bip39 libraryimport { ZooKeyring } from "zoobc-wallet-sdk";
const passphrase = ZooKeyring.generateRandomPhrase();
Return
string
of passphrase
Example Result
bread raise token empower antique canyon risk trap artwork grunt trial gown awesome sword glare level faith minor regret prize deal extra achieve fever
import { ZooKeyring } from "zoobc-wallet-sdk";
const passphrase = "bread raise token empower antique canyon risk trap artwork grunt trial gown awesome sword glare level faith minor regret prize deal extra achieve fever"
console.log(ZooKeyring.isPassphraseValid(passphrase));
Return
boolean
import { ZooKeyring } from "zoobc-wallet-sdk";
const keyring = new ZooKeyring(passphrase, password);
Parameters
-
passphrase
: passphrase to open the wallet -
password
: (optional) password to salt the passphrase to make root key more unpredictable
Return
object
of ZooKeyring
Example
const passphrase =
"bread raise token empower antique canyon risk trap artwork grunt trial gown awesome sword glare level faith minor regret prize deal extra achieve fever";
const pass = "p4ssphr4se";
const keyring = new ZooKeyring(passphrase, pass);
// generate bip32 root key first in keyring variable
const childSeed = keyring.calcDerivationPath(accountPath);
Parameters
-
accountPath
: is the 3rd section of derivation path format (m / purpose' / coin_type' / account' / change / address_index
). For example ifaccountPath = 3
it meanm/44'/148'/3'
Return
BIP32Interface
Example
const passphrase = "bread raise token empower antique canyon risk trap artwork grunt trial gown awesome sword glare level faith minor regret prize deal extra achieve fever";
const pass = "p4ssphr4se";
const keyring = new ZooKeyring(passphrase, pass);
const childSeed = keyring.calcDerivationPath(3);
After get the child seed, you can do all function that BIP32Interface
can do, like signing the transaction using childSeed.sign(buffer)
function