Skip to content

Instantly share code, notes, and snippets.

@jgriffiths
Created March 14, 2016 06:27
Show Gist options
  • Save jgriffiths/29634a7131772cabd97d to your computer and use it in GitHub Desktop.
Save jgriffiths/29634a7131772cabd97d to your computer and use it in GitHub Desktop.
BIP39 (Mnemonic)
-----------------
# Docs
# https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
# Reference python impl
# https://github.com/trezor/python-mnemonic
# No C reference impl yet.
The plugin (plugins/it.greenaddress.cordova/BIP39.java) only exposes:
BIP39::calcSeed(salt, password)
returns <block of data>
And theres a javascript impl of the same functionality here:
www/greenaddress.it/static/js/greenwallet/mnemonics/mnemonic_seed.js
The rest of the API is at:
www/greenaddress.it/static/js/greenwallet/mnemonics/services.js.
- How much do we want to expose? default wordlists or have the user pass them in etc.
- Settings (number of rounds, number of words/bits etc) should be changable ideally.
- Need to be able to register callbacks for GUIs to upadte progress etc
- Need callbacks for h/w as well
BIP38 (Passphrase protected private key)
----------------------------------------
# Docs
# https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki
Python impl at https://github.com/maxweisspoker/pybip38
C# impl at https://github.com/MetacoSA/NBitcoin/tree/master/NBitcoin/BIP38
No reference c impl yet.
The plugin (plugins/it.greenaddress.cordova/BIP39.java) only exposes:
BIP38::encrypt(key_json, password, cur_coin (BTC/BTT))
data_json is a list of 32 byte values as ints
BUG: Java doesn't validate the int passed in - will casting throw in java? still bad, no good error msg
returns serialisedKey: KeyFormatter(password, network).serializeKey(ECKeyPair(dat_json, compressed=true))
BIP38::decrypt(b58, password, cur_coin (BTC/BTT)
b58 is the serialised key
returns keyPair: KeyFormatter(password, network).parseSerializeKey(b58)
BIP38::encrypt_raw(data_json, password)
data_json is a list of 32 byte values as ints
BUG: Java doesn't validate the int passed in - will casting throw in java? still bad, no good error msg
returns <raw encrypted bytes>
BIP38::decrypt_raw(data_json, password)
data_json is a list of 36 byte values as ints (32 + checksum)
BUG: Java doesn't validate the int passed in - will casting throw in java? still bad, no good error msg
returns <raw decrypted bytes>
- Why the 2 APIs, need to look at what bitsofproof lib is providing here
- Needs scrypt, c BSD lib here: https://github.com/technion/libscrypt but its windows unfriendly
- Do we want to include dependencies like scrypt and secp256k?
- Do we want to expose the underlying low level primitives?
- Language bindings - Java, Javascript, Python are a must.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment