bip39toalgo

bip39toalgo

Methods

(static) _NODE(kL, kR, …args) → {bip39toalgo.DerivationNode}

Returns bip39toalgo.DerivationNode from arguments

Source:
Parameters:
Name Type Attributes Description
kL string | bip39toalgo.WordArray

Leftmost 32 bytes of private key

kR string | bip39toalgo.WordArray

Rightmost 32 bytes of private Key

args Object <repeatable>
Returns:
Type:
bip39toalgo.DerivationNode

Derivation node

(static) algoAddress(key) → {bip39toalgo.AlgoAddressData}

Derives Algorand's public key from private key

Source:
Parameters:
Name Type Description
key string | bip39toalgo.WordArray
Returns:
Type:
bip39toalgo.AlgoAddressData

Algorand's address data

(static) algoAddressFromMnemonic(mnemonic) → {bip39toalgo.AlgoAddressData}

Derives Algorand public key and address

Source:
Parameters:
Name Type Description
mnemonic string

Algorand mnemonic

Returns:
Type:
bip39toalgo.AlgoAddressData

Algorand's address data

(static) algoKeyFromMnemonic(mnemonic) → {bip39toalgo.AlgoParsedMnemonicData}

Translates Algorand mnemonic to private key

Source:
Parameters:
Name Type Description
mnemonic string
Returns:
Type:
bip39toalgo.AlgoParsedMnemonicData

Algorand's parsed mnemonic data

(static) algoMnemonic(key) → {bip39toalgo.AlgoMnemonicData}

Translates Algorand private key to mnemonic words

Source:
Parameters:
Name Type Description
key string

Private key in hexadecimal

Returns:
Type:
bip39toalgo.AlgoMnemonicData

Algorand's mnemonic data

(static) algoSecret(node) → {Promise.<bip39toalgo.DerivationNode>}

Computes Algorand address and mnemonic from bip39toalgo.DerivationNode

Source:
Parameters:
Name Type Description
node bip39toalgo.DerivationNode
Returns:
Type:
Promise.<bip39toalgo.DerivationNode>

Derivation node with Algorand's secret

(static) algoWords(key) → {bip39toalgo.AlgoAddressData}

Computes Algorand address and mnemonic from private key

Source:
Parameters:
Name Type Description
key string

Private key in hexadecimal

Returns:
Type:
bip39toalgo.AlgoAddressData

Algorand's address data

(static) bip39seed(mnemonic, passphrase, prefixopt) → {bip39toalgo.WordArray}

Convert BIP39 mnemonic to seed

Source:
Parameters:
Name Type Attributes Default Description
mnemonic string

Mnemonic (12-24 words delimited by single space)

passphrase string

Passphrase as suffix for the salt

prefix string <optional>
mnemonic

Modifier as prefix for the salt

Returns:
Type:
bip39toalgo.WordArray

Seed

(static) countAddressEnding(nopt) → {void}

Generates N random addresses and counts occurrences of last character

Source:
Parameters:
Name Type Attributes Default Description
n number <optional>
1000

Number of addresses to generate

Returns:
Type:
void

Nothing

(static) curveInfo(curveName) → {bip39toalgo.CurveParams}

Get elliptic curve parameters

Source:
Parameters:
Name Type Description
curveName string

Name of the elliptic curve

Returns:
Type:
bip39toalgo.CurveParams

Curve parameters

(static) deriveBip39Seed(seed, method, pathopt) → {Promise.<bip39toalgo.DerivationNode>}

Derives Algorand's secret from BIP39 seed and using given method and path

Source:
Parameters:
Name Type Attributes Default Description
seed bip39toalgo.WordArray

BIP39 seed bytes

method string

Derivation method

path string <optional>
m/44'/283'/0'/0/0

Derivation path

Returns:
Type:
Promise.<bip39toalgo.DerivationNode>

Derivation node with Algorand's secret

(static) deriveChild(parentKey, parentChaincode, i, curve) → {Promise.<bip39toalgo.DerivationNode>}

Derives child key from parent key data using SLIP10 specs

Source:
Parameters:
Name Type Description
parentKey string | bip39toalgo.WordArray

Parent node private key

parentChaincode bip39toalgo.WordArray

Parent node chain code

i number

Current path index

curve bip39toalgo.CurveParams

Curve params

Returns:
Type:
Promise.<bip39toalgo.DerivationNode>

Child node

(static) deriveChildKhoLaw(node, i) → {Promise.<bip39toalgo.DerivationNode>}

Derive child key by implementing paper from D. Khovratovich and J. Law "BIP32-Ed25519: Hierarchical Deterministic Keys over a Non-linear Keyspace"

Source:
Parameters:
Name Type Description
node bip39toalgo.DerivationNode

Parent node

i number

Current path index

Returns:
Type:
Promise.<bip39toalgo.DerivationNode>

Child node

(static) deriveMnemonic(mnemonic, method, pathopt, passphraseopt) → {Promise.<bip39toalgo.DerivationNode>}

Derives Algorand's secret from BIP39 mnemonic and using given method and path

Source:
Parameters:
Name Type Attributes Description
mnemonic string

BIP39 mnemonic

method string

Derivation method

path string <optional>

Derivation path

passphrase string <optional>

BIP39 mnemonic passphrase

Returns:
Type:
Promise.<bip39toalgo.DerivationNode>

Derivation node with Algorand secret

Example
// Returns:
// 7b6ec191cb3b77f6593cefaddf0489af47bb65e0f4480391bcedd00caa822d11
// NMRBZNN2RXUNVLVVPVD53GJV6A2A55QWJXMD2KG42N7NQZB67WXYFGONVA
//  1. sorry       6. laugh      11. setup      16. employ     21. favorite   
//  2. aisle       7. tissue     12. kit        17. call       22. gaze       
//  3. similar     8. upset      13. isolate    18. venture    23. maximum    
//  4. royal       9. volcano    14. bonus      19. item       24. abandon    
//  5. unveil     10. beach      15. poem       20. snack      25. leave
mnemonic = 'all all all all all all all all all all all all all all all all all all all all all all all feel'
deriveMnemonic(mnemonic,"slip10-ed25519", "m/44'/283'/0'/0/0")
.then(node => {
    console.log(node.algo.key)
    console.log(node.algo.address)
    words = prettifyWordsTTB(node.algo.words)
    console.log(words)
})

(static) deriveMnemonicTest(testVector) → {void}

Derive mnemonic for given test vector

Source:
Parameters:
Name Type Description
testVector Object
Returns:
Type:
void

Nothing

(static) encodeXY(x, y)

Encodes elliptic curve X-coordinate into Y-coordinate

Source:
Parameters:
Name Type Description
x string

X-coordinate bytes in hexadecimal

y string

Y-coordinate bytes in hexadecimal

(static) ent2bip39words(ent) → {Array.<string>}

Translates entropy into BIP39 mnemonic words

Source:
Parameters:
Name Type Description
ent string
Returns:
Type:
Array.<string>

BI39 words list

(static) entCheckBits(ent, cs) → {string}

Computes BIP39 checksum bits for given entropy

Source:
Parameters:
Name Type Description
ent string

Entropy bytes in hexadecimal

cs number

Checksum length in bits

Returns:
Type:
string

Checksum bits

(static) findBip39Word(word) → {string|undefined}

Find word in BIP39 wordlist

Source:
Parameters:
Name Type Description
word string

BIP39 word to search

Returns:
Type:
string | undefined

Found word

(static) getPublicKey(key, curve) → {string}

Computes public key for given curve

Source:
Parameters:
Name Type Description
key string | bip39toalgo.WordArray

Private key

curve bip39toalgo.CurveParams

Curve parameters

Returns:
Type:
string

Public key in hexadecimal

(static) numsToWords(nums) → {Array.<string>}

Convert integers to BIP39 words

Source:
Parameters:
Name Type Description
nums Array.<number>

11-bit unsigned integers

Returns:
Type:
Array.<string>

List of BIP39 words

(static) parseMnemonic(mnemonic) → {bip39toalgo.Bip39ParsedMnemonicData}

Parses BIP39 mnemonic and verifies validity

Source:
Parameters:
Name Type Description
mnemonic string

(static) prettifyWordsLTR(words) → {string}

Formats list of 25 words in a 5x5 grid, indexed Left-to-Right

Source:
Parameters:
Name Type Description
words bip39toalgo.AlgoSecretWords

Algorand secret words

Returns:
Type:
string

Formatted words list with line breaks

(static) prettifyWordsTTB(words) → {string}

Formats list of 25 words in a 5x5 grid, indexed Top-to-Bottom

Source:
Parameters:
Name Type Description
words bip39toalgo.AlgoSecretWords

Algorand secret words

Returns:
Type:
string

Formatted words list with line breaks

(static) randomAlgoAddress() → {bip39toalgo.AlgoAddressData}

Generates random Algorand address

Source:
Returns:
Type:
bip39toalgo.AlgoAddressData

Algorand's address data

(static) randomWords(size) → {string}

Generates random BIP39 words

Source:
Parameters:
Name Type Description
size number

Entropy size in bytes (16|20|24|28|32)

Returns:
Type:
string

Mnemonic words

(static) rootKey(seed, curve, methodopt) → {Promise.<bip39toalgo.DerivationNode>}

Derive root key (master node) using SLIP10 specs or implementing paper from D. Khovratovich and J. Law "BIP32-Ed25519: Hierarchical Deterministic Keys over a Non-linear Keyspace"

Source:
Parameters:
Name Type Attributes Default Description
seed bip39toalgo.WordArray

Entropy to derive root key

curve bip39toalgo.CurveParams

Curve parameters

method string <optional>
'slip10'

Derivation method (slip10|kholaw)

Returns:
Type:
Promise.<bip39toalgo.DerivationNode>

Promise with derivation node

(static) testMnemonicWords(wordopt, sizeopt)

Generate dummy BIP39 mnemonic for testing

Source:
Parameters:
Name Type Attributes Default Description
word string <optional>
'all'

Dummy BIP39 word to repeat

size number <optional>
24

Number of words (12|15|18|21|24)

Examples
// returns "dog dog dog dog dog dog dog dog dog dog dog dose"
console.log(testMnemonicWords('dog',12).join(' '))
// returns "boy boy boy boy boy boy boy boy boy boy boy boy boy boy boss"
console.log(testMnemonicWords('boy',15).join(' '))
// returns "bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar anxiety"
console.log(testMnemonicWords('bar',24).join(' '))

(static) tests() → {void}

Run tests and log to console

Source:
Returns:
Type:
void

Nothing

Type Definitions

AlgoAddressData

Properties:
Name Type Attributes Description
key string
pub string
address string
chk string <optional>
words bip39toalgo.AlgoSecretWords <optional>

Algorand secret words

Source:
Type:
  • Object

AlgoData

Properties:
Properties
Name Type Description
algo Object
Name Type Attributes Description
key string

Algorand private key in hexadecimal

address address

Algorand public wallet address

words Array.<string>

Algorand mnemonic (25 words)

pub string

Algorand public key in hexadecimal

chk1 string <optional>

Public key cheksum

chk2 string <optional>

Mnemonic cheksum

Source:
Type:
  • Object

AlgoMnemonicData

Properties:
Name Type Description
words bip39toalgo.AlgoSecretWords

Algorand secret words

chk string

Mnemonic checksum

Source:
Type:
  • Object

AlgoParsedMnemonicData

Properties:
Name Type Description
mnemonic string

Parsed Algorand mnemonic

original string

Original mnemonic normalized (NFKD)

words bip39toalgo.AlgoSecretWords

Algorand secret words

key string

Private key in hexadecimal

checksum string

Mnemonic checksum

valid boolean

Mnemonic validity

Source:
Type:
  • Object

AlgoSecretWords

Algorand secret mnemonic (25 BIP39 words)

Source:
Type:
  • Array.<string>

Bip39ParsedMnemonicData

Properties:
Name Type Description
mnemonic string

Parsed Algorand mnemonic

original string

Original mnemonic normalized (NFKD)

words Array.<string>

Algorand secret words

checkbits string

Checksum bits

valid boolean

Mnemonic validity

Source:
Type:
  • Object

CurveParams

Stores order of elliptic curve and SLIP10 modifier for master key generation.

Properties:
Name Type Description
name string

Name of elliptic curve

modifier string

Key to use in HMAC-SHA512 as per SLIP10

order BigInt

Order of the elliptic curve

Source:
Type:
  • Object

DerivationNode

Properties:
Name Type Attributes Description
kL string | bip39toalgo.WordArray

Leftmost 32 bytes of private key

kR string | bip39toalgo.WordArray

Rightmost 32 bytes of private Key

A string | bip39toalgo.WordArray <optional>

32 bytes public key (y coordinatte only)

c string | bip39toalgo.WordArray <optional>

32 bytes chain code

P string | bip39toalgo.WordArray <optional>

32 bytes public key

algo bip39toalgo.AlgoData <optional>
Source:
Type:
  • Object

WordArray

Properties:
Name Type Description
words Array.<number>

Bytes array as signed integers

sigBytes number
Source:
Type:
  • Object