Compare commits

..

84 Commits

Author SHA1 Message Date
Ian Coleman
76531b610a Release v0.3.14 2019-12-02 10:46:49 +11:00
Ian Coleman
c845ee6f6e Fix energyweb test 2019-12-02 10:44:35 +11:00
Ian Coleman
c394ec3c4f Revert "Fix tests for Pull Request 371"
This reverts commit b130271b2b.
2019-12-02 10:25:09 +11:00
Ian Coleman
55367b989e Partially revert Pull 371 BIP44 Default Change 2019-12-02 10:24:37 +11:00
Ian Coleman
732613e44c Release v0.3.13 2019-11-11 12:42:52 +11:00
Ian Coleman
9ce31d3509 Move hardened addresses checkbox to address table 2019-11-11 12:32:50 +11:00
Ian Coleman
f8fae68efb Fix typo splitPhrase/phraseSplit 2019-11-11 11:41:45 +11:00
Ian Coleman
93f3a286db Add test for Pull Request 370 THT Thought network 2019-11-11 11:35:17 +11:00
Ian Coleman
3799728c76 Run all tests instead of only specific new tests 2019-11-11 11:23:54 +11:00
Ian Coleman
b130271b2b Fix tests for Pull Request 371 2019-11-11 11:19:18 +11:00
Ian Coleman
ea2cb91a49 Tidy up split phrase warning
Make red only when danger is present
Align neatly with the rest of the UI
Increase size of text area to show all three rows, although it still
overflows on 24 words.
2019-11-11 11:04:23 +11:00
Ian Coleman
bfe1963eaa Add test for Pull Request 319 EnergyWeb 2019-11-11 10:55:26 +11:00
Ian Coleman
a04946e23e Add test for Pull Request 279 split phrase cards 2019-11-11 10:53:20 +11:00
Ian Coleman
700294714c Raw entropy is interpreted as binary
For example, using abandon abandon ability becomes 8 zeros but how does
the entropy field know it's hex and not binary? It assumes the
worst-case scenario of binary, so entropy should be shown in binary.

Perhaps if entropy type is explicitly selected in the future this can be
changed back to using hex. But while magical assumptions exist, binary
it must be.
2019-11-11 10:31:14 +11:00
Ian Coleman
d93f2ba9f0 Remove trailing comments 2019-11-11 10:15:49 +11:00
Ian Coleman
96ee8ab0a0 Replace tabs with spaces as per rest of the file 2019-11-11 10:15:17 +11:00
Ian Coleman
659b06a7b8 Test for Pull Request 271 2019-11-11 10:11:40 +11:00
Ian Coleman
653538cd3a Reverse some changes from adding thought network 2019-11-11 10:04:20 +11:00
Ian Coleman
1ba5816184 Fix elastos changes 2019-11-11 10:01:51 +11:00
iancoleman
0a23f51792 Merge pull request #370 from thoughtnetwork/master
added Thought network spec
2019-11-11 09:56:49 +11:00
iancoleman
b9b3eaf670 Merge branch 'master' into master 2019-11-11 09:56:10 +11:00
iancoleman
7b29420f1a Merge pull request #371 from immae/master
Add a button to remove the "change" in the derivation path for ethereum
2019-11-11 09:54:29 +11:00
iancoleman
909297015e Merge branch 'master' into master 2019-11-11 09:54:07 +11:00
iancoleman
c7a092db32 Merge pull request #368 from johnnynanjiang/elastos-pr
Add Elastos
2019-11-11 09:47:35 +11:00
iancoleman
de5fe245cc Merge pull request #357 from PavlosTze/enable-segwit
Enable segwit for MONKEY, BCA, BTX, MONA, SYS, VIA, DOGEt, LTCt
2019-11-11 09:36:14 +11:00
iancoleman
4dc041d77e Merge pull request #319 from energywebfoundation/master
Add EWT
2019-11-11 09:35:13 +11:00
iancoleman
7cfd04e318 Merge pull request #280 from mctrivia/add-hack-time-for-split-cards
Add hack time calculation for Split Mnemonic Cards
2019-11-11 09:34:37 +11:00
iancoleman
d0428a8d21 Merge pull request #279 from mctrivia/master
Added Split Phrase Card Output
2019-11-11 09:28:28 +11:00
iancoleman
3dbf117928 Merge pull request #271 from cernekee/local
Allow converting mnemonic back to raw entropy value
2019-11-11 09:21:07 +11:00
iancoleman
342ff964aa Merge pull request #255 from dalijolijo/master
Fix wrong addresses for BTDX and MEC
2019-11-11 09:13:11 +11:00
Andrew
75138beed9 added Thought network spec 2019-11-05 11:26:58 -05:00
Nan Jiang
36523e0d97 Add Elastos 2019-10-30 13:58:32 +11:00
Ismaël Bouya
44e705cd31 Add a button to remove the "change" in the derivation path for ethereum 2019-10-29 01:24:15 +01:00
Pavlos Tzegiannakis
3e2af09e07 Merge branch 'enable-segwit' of https://github.com/PavlosTze/bip39 into enable-segwit 2019-09-17 10:10:01 +03:00
Pavlos Tzegiannakis
907172d6f0 Fix syscoin 2019-09-17 10:09:37 +03:00
iancoleman
394bce7c9e Merge branch 'master' into enable-segwit 2019-09-16 10:48:38 +10:00
iancoleman
bc32c84166 Merge pull request #353 from Groestlcoin/add-groestlcoin
Add Groestlcoin with Tests
2019-09-16 10:46:32 +10:00
HashEngineering
76120cb0b4 Add Groestlcoin 2019-09-13 06:27:59 -07:00
Pavlos Tzegiannakis
385ee32fd4 Enable segwit for MONKEY, BCA, BTX, MONA, SYS, VIA, DOGEt, LTCt 2019-09-13 16:10:08 +03:00
Ian Coleman
5b689bd6e7 Fix trailing whitespace 2019-09-13 10:15:15 +10:00
Ian Coleman
ac537983d9 Add base-x to libs directory 2019-09-12 21:00:45 +10:00
Ian Coleman
5b2edb3998 Fix typo in path for build script 2019-09-12 15:57:05 +10:00
Ian Coleman
eee4a60b35 Add instructions for manual changes for zcash 2019-09-12 15:56:40 +10:00
Ian Coleman
dedb054fd8 Add ethereumjs-util to libs directory 2019-09-12 15:29:10 +10:00
Ian Coleman
079635cba1 Change levenshtein library to fixed version 2.0.6 2019-09-12 15:04:09 +10:00
Ian Coleman
5db3540e89 Add bitcoinjs-bip38 to libs directory 2019-09-12 14:42:40 +10:00
Ian Coleman
b502adc910 Add bitcoinjs-lib to libs directory 2019-09-12 14:23:53 +10:00
Ian Coleman
cab37a96c4 Compile stellar-util to /tmp 2019-09-12 13:37:22 +10:00
Ian Coleman
b603572295 Fix test failing due to timeout 2019-09-12 11:58:32 +10:00
Ian Coleman
8817e2487a Fix CPUchain test 2019-09-12 10:39:03 +10:00
iancoleman
c6c86591a9 Merge pull request #352 from PavlosTze/bsv-rpd-monkey-arya
Support BSV, RPD, MONKEY, ARYA
2019-09-12 10:36:30 +10:00
iancoleman
5d1bb7d776 Merge pull request #355 from zhanghangorg/master
Zencash renamed Horizen
2019-09-12 10:14:33 +10:00
iancoleman
ea96c345cc Merge pull request #356 from skironDotNet/HUSH3
Added HUSH3 encoding and kept old as Legacy for users to be able to
2019-09-12 10:13:37 +10:00
Pawel Cioch
318ec4dc9f Added HUSH3 encoding and kept old as Legacy for users to be able to cross verify 2019-09-10 22:11:28 -05:00
zhanghang
ec38b3a263 Zencash was renamed Horizen in 2018 2019-09-11 10:55:02 +08:00
zhanghang
9cec5dd2b7 Zencash was renamed Horizen in 2018 2019-09-11 10:53:21 +08:00
Pavlos Tzegiannakis
31264e8bea Support BSV, RPD, MONKEY, ARYA 2019-09-02 09:58:09 +03:00
iancoleman
e440d504fb Merge pull request #345 from flyfoxuk/master
Added CSC (CasinoCoin) with test
2019-08-01 10:02:07 +10:00
iancoleman
786cd442cd Merge pull request #342 from minkcrypto/master
Add CPUchain support
2019-08-01 10:01:28 +10:00
iancoleman
9f675f2e47 Merge branch 'master' into master 2019-08-01 10:01:17 +10:00
iancoleman
e5c4aa4098 Merge pull request #341 from Cryptarchist/support_wagerr
Add support for Wagerr
2019-08-01 10:00:06 +10:00
Chris
45e40c288f Added CSC (CasinoCoin) with test 2019-07-18 11:50:14 +01:00
Min Khang Aung
519e9dc728 Add CPUchain support 2019-07-17 05:02:28 +09:00
Cryptarchist
67f18e2a63 Add support for Wagerr 2019-07-16 13:31:54 +01:00
iancoleman
c4f4208b95 Merge pull request #340 from sile16/master
Added support for VeChain, hdcoin 818, same address formats as ETH
2019-07-16 10:51:48 +10:00
Matt Robertson
881fbe2234 add test for VeChain 2019-07-04 14:18:30 -05:00
Matt Robertson
c7a1a00040 Added support for VeChain, hdcoin 818, same address formats as ETH 2019-07-04 13:20:14 -05:00
Ian Coleman
6aa2c1d26d Reorder release process steps
Should verify before publishing and promoting.
2019-07-04 12:41:38 +10:00
Garrett MacDonald
f9ab643475 compile index 2019-04-25 10:44:56 +02:00
Garrett MacDonald
17bb7e6953 Delete index.html 2019-04-25 10:44:41 +02:00
Garrett MacDonald
b615704d4a Delete index.html 2019-04-25 10:44:27 +02:00
Garrett MacDonald
c47f0030ec Add index compiled 2019-04-25 10:44:08 +02:00
Garrett MacDonald
cb0300fc7b Compiled inedex
1
2019-04-25 10:43:08 +02:00
Garrett MacDonald
7cbfce747a Compiled Index 2019-04-25 10:42:14 +02:00
Garrett MacDonald
dd99c5fde9 Add EWT 2019-04-24 17:17:05 +02:00
Matthew Cornelisse
5cdbe4620a added code to calculate hack time of split cards 2018-11-28 01:12:29 -06:00
Matthew Cornelisse
8253325365 added split card warning 2018-11-28 01:11:41 -06:00
Matthew Cornelisse
d100f3c0cb added hack time message 2018-11-28 01:10:34 -06:00
Matthew Cornelisse
c1322c7c89 wrong folder 2018-11-28 01:09:51 -06:00
Matthew Cornelisse
d9b5b5d0de added hack time message 2018-11-28 01:03:22 -06:00
Matthew Cornelisse
97bde20b84 Added 2/3 Seed Card 2018-11-20 02:23:51 -06:00
Matthew Cornelisse
b1100c66eb Added 2/3 Seed Card 2018-11-20 02:23:19 -06:00
Kevin Cernekee
611f76238d Allow converting mnemonic back to raw entropy value
Currently, this sequence produces an unexpected result:

1) Navigate to bip39-standalone.html

2) Paste a known-good mnemonic into the BIP39 Mnemonic field

3) Select "Show entropy details"

This will erase the BIP39 Mnemonic field and most of the derived
address/key information.  It shows an empty Entropy field, and zeroes
for Event Count, Bits Per Event, Raw Entropy Words, Total Bits, etc.
However, it will show valid Word Indexes and BIP39 Seed.

The way to fix it is to convert the mnemonic back into a raw entropy
value and populate it in DOM.entropy, so that everything stays
consistent.  This will only happen if the mnemonic is manually entered
by the user, not if phraseChanged() is triggered by hand-editing the
entropy value.
2018-10-28 15:10:51 -07:00
David
7ef0db981f Fix wrong addresses for BTDX and MEC 2018-09-21 11:16:29 +02:00
35 changed files with 49446 additions and 290 deletions

View File

@@ -1,3 +1,27 @@
# 0.3.14
* Ethereum uses standard BIP44 as per majority of wallets (Issue 378)
# 0.3.13
* Add Thought network
* Add Energyweb network
* Add Elastos network
* Add Groestlcoin
* Fix for syscoin network
* Add BSV, RPD, MONKEY, ARYA
* Rename Zencash to Horizen
* Update Hush network
* Add CasinoCoin
* Add CPUchain
* Add Wagerr
* Add VeChain
* Option to not use 'change' field for ethereum networks in bip45
* Add segwit parameters for MONKEY, BCA, BTC, MONA, SYS, VIA, DOGEt, LTCt
* Convert mnemonic back to raw entropy
* Add 2-of-3 phrase cards
* Move position of hardened addresses checkbox to address table
# 0.3.12
* Fix typos

22
libs/base-x/LICENSE.md Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2018 base-x contributors
Copyright (c) 2014-2018 The Bitcoin Core developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

44
libs/base-x/package.json Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "base-x",
"version": "3.0.7",
"description": "Fast base encoding / decoding of any given alphabet",
"keywords": [
"base-x",
"base58",
"base62",
"base64",
"crypto",
"crytography",
"decode",
"decoding",
"encode",
"encoding"
],
"homepage": "https://github.com/cryptocoinjs/base-x",
"bugs": {
"url": "https://github.com/cryptocoinjs/base-x/issues"
},
"license": "MIT",
"author": "Daniel Cousens",
"files": [
"src"
],
"main": "src/index.js",
"types": "src/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/cryptocoinjs/base-x.git"
},
"scripts": {
"build": "tsc -p ./tsconfig.json ; standard --fix; browserify src/index.js --standalone basex > /tmp/base-x.js"
},
"devDependencies": {
"@types/node": "12.0.10",
"standard": "^10.0.3",
"tape": "^4.5.1",
"typescript": "3.5.2"
},
"dependencies": {
"safe-buffer": "^5.0.1"
}
}

4
libs/base-x/readme.md Normal file
View File

@@ -0,0 +1,4 @@
Build (will create a bundle and copy it to /tmp/base-x.js):
npm install
npm run build

161
libs/base-x/ts_src/index.ts Normal file
View File

@@ -0,0 +1,161 @@
// base-x encoding / decoding
// Copyright (c) 2018 base-x contributors
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
// Distributed under the MIT software license, see the accompanying
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
// @ts-ignore
const _Buffer = require('safe-buffer').Buffer;
function base (ALPHABET: string): base.BaseConverter {
if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long')
const BASE_MAP = new Uint8Array(256)
BASE_MAP.fill(255)
for (let i = 0; i < ALPHABET.length; i++) {
const x = ALPHABET.charAt(i)
const xc = x.charCodeAt(0)
if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous')
BASE_MAP[xc] = i
}
const BASE = ALPHABET.length
const LEADER = ALPHABET.charAt(0)
const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
function encode (source: Buffer): string {
if (!_Buffer.isBuffer(source)) throw new TypeError('Expected Buffer')
if (source.length === 0) return ''
// Skip & count leading zeroes.
let zeroes = 0
let length = 0
let pbegin = 0
const pend = source.length
while (pbegin !== pend && source[pbegin] === 0) {
pbegin++
zeroes++
}
// Allocate enough space in big-endian base58 representation.
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0
const b58 = new Uint8Array(size)
// Process the bytes.
while (pbegin !== pend) {
let carry = source[pbegin]
// Apply "b58 = b58 * 256 + ch".
let i = 0
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
carry += (256 * b58[it1]) >>> 0
b58[it1] = (carry % BASE) >>> 0
carry = (carry / BASE) >>> 0
}
if (carry !== 0) throw new Error('Non-zero carry')
length = i
pbegin++
}
// Skip leading zeroes in base58 result.
let it2 = size - length
while (it2 !== size && b58[it2] === 0) {
it2++
}
// Translate the result into a string.
let str = LEADER.repeat(zeroes)
for (; it2 < size; ++it2) str += ALPHABET.charAt(b58[it2])
return str
}
function decodeUnsafe (source: string): Buffer | undefined {
if (typeof source !== 'string') throw new TypeError('Expected String')
if (source.length === 0) return _Buffer.alloc(0)
let psz = 0
// Skip leading spaces.
if (source[psz] === ' ') return
// Skip and count leading '1's.
let zeroes = 0
let length = 0
while (source[psz] === LEADER) {
zeroes++
psz++
}
// Allocate enough space in big-endian base256 representation.
const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
const b256 = new Uint8Array(size)
// Process the characters.
while (source[psz]) {
// Decode character
let carry = BASE_MAP[source.charCodeAt(psz)]
// Invalid character
if (carry === 255) return
let i = 0
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
carry += (BASE * b256[it3]) >>> 0
b256[it3] = (carry % 256) >>> 0
carry = (carry / 256) >>> 0
}
if (carry !== 0) throw new Error('Non-zero carry')
length = i
psz++
}
// Skip trailing spaces.
if (source[psz] === ' ') return
// Skip leading zeroes in b256.
let it4 = size - length
while (it4 !== size && b256[it4] === 0) {
it4++
}
const vch = _Buffer.allocUnsafe(zeroes + (size - it4))
vch.fill(0x00, 0, zeroes)
let j = zeroes
while (it4 !== size) {
vch[j++] = b256[it4++]
}
return vch
}
function decode (string: string): Buffer {
const buffer = decodeUnsafe(string)
if (buffer) return buffer
throw new Error('Non-base' + BASE + ' character')
}
return {
encode: encode,
decodeUnsafe: decodeUnsafe,
decode: decode
}
}
export = base;
declare namespace base {
interface BaseConverter {
encode(buffer: Buffer): string;
decodeUnsafe(string: string): Buffer | undefined;
decode(string: string): Buffer;
}
}

31
libs/base-x/tsconfig.json Normal file
View File

@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"outDir": "./src",
"declaration": true,
"rootDir": "./ts_src",
"types": [
"node"
],
"allowJs": false,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"esModuleInterop": false,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"ts_src/**/*.ts"
],
"exclude": [
"**/*.spec.ts",
"node_modules/**/*"
]
}

View File

@@ -0,0 +1,244 @@
var aes = require('browserify-aes')
var assert = require('assert')
var Buffer = require('safe-buffer').Buffer
var bs58check = require('bs58check')
var createHash = require('create-hash')
var scrypt = require('scryptsy')
var xor = require('buffer-xor/inplace')
var ecurve = require('ecurve')
var curve = ecurve.getCurveByName('secp256k1')
var BigInteger = require('bigi')
// constants
var SCRYPT_PARAMS = {
N: 16384, // specified by BIP38
r: 8,
p: 8
}
var NULL = Buffer.alloc(0)
function hash160 (buffer) {
var hash
try {
hash = createHash('rmd160')
} catch (e) {
hash = createHash('ripemd160')
}
return hash.update(
createHash('sha256').update(buffer).digest()
).digest()
}
function hash256 (buffer) {
return createHash('sha256').update(
createHash('sha256').update(buffer).digest()
).digest()
}
function getAddress (d, compressed) {
var Q = curve.G.multiply(d).getEncoded(compressed)
var hash = hash160(Q)
var payload = Buffer.allocUnsafe(21)
payload.writeUInt8(0x00, 0) // XXX TODO FIXME bitcoin only??? damn you BIP38
hash.copy(payload, 1)
return bs58check.encode(payload)
}
function encryptRaw (buffer, compressed, passphrase, progressCallback, scryptParams) {
if (buffer.length !== 32) throw new Error('Invalid private key length')
scryptParams = scryptParams || SCRYPT_PARAMS
var d = BigInteger.fromBuffer(buffer)
var address = getAddress(d, compressed)
var secret = Buffer.from(passphrase, 'utf8')
var salt = hash256(address).slice(0, 4)
var N = scryptParams.N
var r = scryptParams.r
var p = scryptParams.p
var scryptBuf = scrypt(secret, salt, N, r, p, 64, progressCallback)
var derivedHalf1 = scryptBuf.slice(0, 32)
var derivedHalf2 = scryptBuf.slice(32, 64)
var xorBuf = xor(derivedHalf1, buffer)
var cipher = aes.createCipheriv('aes-256-ecb', derivedHalf2, NULL)
cipher.setAutoPadding(false)
cipher.end(xorBuf)
var cipherText = cipher.read()
// 0x01 | 0x42 | flagByte | salt (4) | cipherText (32)
var result = Buffer.allocUnsafe(7 + 32)
result.writeUInt8(0x01, 0)
result.writeUInt8(0x42, 1)
result.writeUInt8(compressed ? 0xe0 : 0xc0, 2)
salt.copy(result, 3)
cipherText.copy(result, 7)
return result
}
function encrypt (buffer, compressed, passphrase, progressCallback, scryptParams) {
return bs58check.encode(encryptRaw(buffer, compressed, passphrase, progressCallback, scryptParams))
}
// some of the techniques borrowed from: https://github.com/pointbiz/bitaddress.org
function decryptRaw (buffer, passphrase, progressCallback, scryptParams) {
// 39 bytes: 2 bytes prefix, 37 bytes payload
if (buffer.length !== 39) throw new Error('Invalid BIP38 data length')
if (buffer.readUInt8(0) !== 0x01) throw new Error('Invalid BIP38 prefix')
scryptParams = scryptParams || SCRYPT_PARAMS
// check if BIP38 EC multiply
var type = buffer.readUInt8(1)
if (type === 0x43) return decryptECMult(buffer, passphrase, progressCallback, scryptParams)
if (type !== 0x42) throw new Error('Invalid BIP38 type')
passphrase = Buffer.from(passphrase, 'utf8')
var flagByte = buffer.readUInt8(2)
var compressed = flagByte === 0xe0
if (!compressed && flagByte !== 0xc0) throw new Error('Invalid BIP38 compression flag')
var N = scryptParams.N
var r = scryptParams.r
var p = scryptParams.p
var salt = buffer.slice(3, 7)
var scryptBuf = scrypt(passphrase, salt, N, r, p, 64, progressCallback)
var derivedHalf1 = scryptBuf.slice(0, 32)
var derivedHalf2 = scryptBuf.slice(32, 64)
var privKeyBuf = buffer.slice(7, 7 + 32)
var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, NULL)
decipher.setAutoPadding(false)
decipher.end(privKeyBuf)
var plainText = decipher.read()
var privateKey = xor(derivedHalf1, plainText)
// verify salt matches address
var d = BigInteger.fromBuffer(privateKey)
var address = getAddress(d, compressed)
var checksum = hash256(address).slice(0, 4)
assert.deepStrictEqual(salt, checksum)
return {
privateKey: privateKey,
compressed: compressed
}
}
function decrypt (string, passphrase, progressCallback, scryptParams) {
return decryptRaw(bs58check.decode(string), passphrase, progressCallback, scryptParams)
}
function decryptECMult (buffer, passphrase, progressCallback, scryptParams) {
passphrase = Buffer.from(passphrase, 'utf8')
buffer = buffer.slice(1) // FIXME: we can avoid this
scryptParams = scryptParams || SCRYPT_PARAMS
var flag = buffer.readUInt8(1)
var compressed = (flag & 0x20) !== 0
var hasLotSeq = (flag & 0x04) !== 0
assert.strictEqual((flag & 0x24), flag, 'Invalid private key.')
var addressHash = buffer.slice(2, 6)
var ownerEntropy = buffer.slice(6, 14)
var ownerSalt
// 4 bytes ownerSalt if 4 bytes lot/sequence
if (hasLotSeq) {
ownerSalt = ownerEntropy.slice(0, 4)
// else, 8 bytes ownerSalt
} else {
ownerSalt = ownerEntropy
}
var encryptedPart1 = buffer.slice(14, 22) // First 8 bytes
var encryptedPart2 = buffer.slice(22, 38) // 16 bytes
var N = scryptParams.N
var r = scryptParams.r
var p = scryptParams.p
var preFactor = scrypt(passphrase, ownerSalt, N, r, p, 32, progressCallback)
var passFactor
if (hasLotSeq) {
var hashTarget = Buffer.concat([preFactor, ownerEntropy])
passFactor = hash256(hashTarget)
} else {
passFactor = preFactor
}
var passInt = BigInteger.fromBuffer(passFactor)
var passPoint = curve.G.multiply(passInt).getEncoded(true)
var seedBPass = scrypt(passPoint, Buffer.concat([addressHash, ownerEntropy]), 1024, 1, 1, 64)
var derivedHalf1 = seedBPass.slice(0, 32)
var derivedHalf2 = seedBPass.slice(32, 64)
var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, Buffer.alloc(0))
decipher.setAutoPadding(false)
decipher.end(encryptedPart2)
var decryptedPart2 = decipher.read()
var tmp = xor(decryptedPart2, derivedHalf1.slice(16, 32))
var seedBPart2 = tmp.slice(8, 16)
var decipher2 = aes.createDecipheriv('aes-256-ecb', derivedHalf2, Buffer.alloc(0))
decipher2.setAutoPadding(false)
decipher2.write(encryptedPart1) // first 8 bytes
decipher2.end(tmp.slice(0, 8)) // last 8 bytes
var seedBPart1 = xor(decipher2.read(), derivedHalf1.slice(0, 16))
var seedB = Buffer.concat([seedBPart1, seedBPart2], 24)
var factorB = BigInteger.fromBuffer(hash256(seedB))
// d = passFactor * factorB (mod n)
var d = passInt.multiply(factorB).mod(curve.n)
return {
privateKey: d.toBuffer(32),
compressed: compressed
}
}
function verify (string) {
var decoded = bs58check.decodeUnsafe(string)
if (!decoded) return false
if (decoded.length !== 39) return false
if (decoded.readUInt8(0) !== 0x01) return false
var type = decoded.readUInt8(1)
var flag = decoded.readUInt8(2)
// encrypted WIF
if (type === 0x42) {
if (flag !== 0xc0 && flag !== 0xe0) return false
// EC mult
} else if (type === 0x43) {
if ((flag & ~0x24)) return false
} else {
return false
}
return true
}
module.exports = {
decrypt: decrypt,
decryptECMult: decryptECMult,
decryptRaw: decryptRaw,
encrypt: encrypt,
encryptRaw: encryptRaw,
verify: verify
}

View File

@@ -0,0 +1,38 @@
{
"name": "bip38",
"version": "2.0.2",
"description": "BIP38 is a standard process to encrypt Bitcoin and crypto currency private keys that is impervious to brute force attacks thus protecting the user.",
"main": "index.js",
"keywords": [
"bitcoin",
"crypto",
"cryptography",
"litecoin"
],
"homepage": "http://cryptocoinjs.com/modules/currency/bip38/",
"author": "JP Richardson",
"dependencies": {
"bigi": "^1.2.0",
"browserify-aes": "^1.0.1",
"bs58check": "<3.0.0",
"buffer-xor": "^1.0.2",
"create-hash": "^1.1.1",
"ecurve": "^1.0.0",
"scryptsy": "^2.0.0"
},
"devDependencies": {
},
"repository": {
"url": "git@github.com:bitcoinjs/bip38.git",
"type": "git"
},
"scripts": {
"browser-test": "mochify --wd -R spec --timeout 100000",
"build": "browserify index.js --standalone bitcoinjs-bip38 > /tmp/bitcoinjs-bip38.js",
"coverage": "istanbul cover _mocha -- --reporter list test/*.js",
"coveralls": "npm run-script coverage && coveralls < coverage/lcov.info",
"standard": "standard",
"test": "npm run standard && npm run unit",
"unit": "mocha --ui bdd --timeout 240000"
}
}

View File

@@ -0,0 +1,4 @@
Build (will create a bundle and copy it to /tmp/bitcoinjs-bip38.js):
npm install
npm run build

View File

@@ -0,0 +1,5 @@
let bitcoin = require('bitcoinjs-lib')
module.exports = {
bitcoin
}

View File

@@ -0,0 +1,14 @@
{
"name": "bitcoinjs-lib",
"version": "3.3.2",
"scripts": {
"build": "browserify bitcoinjs-lib.js --standalone bitcoinjs > /tmp/bitcoinjs-lib.js"
},
"dependencies": {
"bitcoinjs-lib": "3.3.2"
},
"devDependencies": {
"browserify": "^16.2.3",
"uglify-es": "^3.3.9"
}
}

View File

@@ -0,0 +1,5 @@
Build (will create a bundle and copy it to /tmp/bitcoinjs-lib.js):
npm install
npm run build
manually add changes in https://github.com/iancoleman/bip39/commit/0702ecd3520c44cb8016f80329dcb5a3c8df88fc

View File

@@ -0,0 +1,736 @@
const createKeccakHash = require('keccak')
const secp256k1 = require('secp256k1')
const assert = require('assert')
const rlp = require('rlp')
const BN = require('bn.js')
const createHash = require('create-hash')
const Buffer = require('safe-buffer').Buffer
Object.assign(exports, require('ethjs-util'))
/**
* the max integer that this VM can handle (a ```BN```)
* @var {BN} MAX_INTEGER
*/
exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)
/**
* 2^256 (a ```BN```)
* @var {BN} TWO_POW256
*/
exports.TWO_POW256 = new BN('10000000000000000000000000000000000000000000000000000000000000000', 16)
/**
* Keccak-256 hash of null (a ```String```)
* @var {String} KECCAK256_NULL_S
*/
exports.KECCAK256_NULL_S = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
/**
* Keccak-256 hash of null (a ```Buffer```)
* @var {Buffer} KECCAK256_NULL
*/
exports.KECCAK256_NULL = Buffer.from(exports.KECCAK256_NULL_S, 'hex')
/**
* Keccak-256 of an RLP of an empty array (a ```String```)
* @var {String} KECCAK256_RLP_ARRAY_S
*/
exports.KECCAK256_RLP_ARRAY_S = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
/**
* Keccak-256 of an RLP of an empty array (a ```Buffer```)
* @var {Buffer} KECCAK256_RLP_ARRAY
*/
exports.KECCAK256_RLP_ARRAY = Buffer.from(exports.KECCAK256_RLP_ARRAY_S, 'hex')
/**
* Keccak-256 hash of the RLP of null (a ```String```)
* @var {String} KECCAK256_RLP_S
*/
exports.KECCAK256_RLP_S = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
/**
* Keccak-256 hash of the RLP of null (a ```Buffer```)
* @var {Buffer} KECCAK256_RLP
*/
exports.KECCAK256_RLP = Buffer.from(exports.KECCAK256_RLP_S, 'hex')
/**
* [`BN`](https://github.com/indutny/bn.js)
* @var {Function}
*/
exports.BN = BN
/**
* [`rlp`](https://github.com/ethereumjs/rlp)
* @var {Function}
*/
exports.rlp = rlp
/**
* [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)
* @var {Object}
*/
exports.secp256k1 = secp256k1
/**
* Returns a buffer filled with 0s
* @method zeros
* @param {Number} bytes the number of bytes the buffer should be
* @return {Buffer}
*/
exports.zeros = function (bytes) {
return Buffer.allocUnsafe(bytes).fill(0)
}
/**
* Returns a zero address
* @method zeroAddress
* @return {String}
*/
exports.zeroAddress = function () {
const addressLength = 20
const zeroAddress = exports.zeros(addressLength)
return exports.bufferToHex(zeroAddress)
}
/**
* Left Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
* Or it truncates the beginning if it exceeds.
* @method lsetLength
* @param {Buffer|Array} msg the value to pad
* @param {Number} length the number of bytes the output should be
* @param {Boolean} [right=false] whether to start padding form the left or right
* @return {Buffer|Array}
*/
exports.setLengthLeft = exports.setLength = function (msg, length, right) {
const buf = exports.zeros(length)
msg = exports.toBuffer(msg)
if (right) {
if (msg.length < length) {
msg.copy(buf)
return buf
}
return msg.slice(0, length)
} else {
if (msg.length < length) {
msg.copy(buf, length - msg.length)
return buf
}
return msg.slice(-length)
}
}
/**
* Right Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
* Or it truncates the beginning if it exceeds.
* @param {Buffer|Array} msg the value to pad
* @param {Number} length the number of bytes the output should be
* @return {Buffer|Array}
*/
exports.setLengthRight = function (msg, length) {
return exports.setLength(msg, length, true)
}
/**
* Trims leading zeros from a `Buffer` or an `Array`
* @param {Buffer|Array|String} a
* @return {Buffer|Array|String}
*/
exports.unpad = exports.stripZeros = function (a) {
a = exports.stripHexPrefix(a)
let first = a[0]
while (a.length > 0 && first.toString() === '0') {
a = a.slice(1)
first = a[0]
}
return a
}
/**
* Attempts to turn a value into a `Buffer`. As input it supports `Buffer`, `String`, `Number`, null/undefined, `BN` and other objects with a `toArray()` method.
* @param {*} v the value
*/
exports.toBuffer = function (v) {
if (!Buffer.isBuffer(v)) {
if (Array.isArray(v)) {
v = Buffer.from(v)
} else if (typeof v === 'string') {
if (exports.isHexString(v)) {
v = Buffer.from(exports.padToEven(exports.stripHexPrefix(v)), 'hex')
} else {
v = Buffer.from(v)
}
} else if (typeof v === 'number') {
v = exports.intToBuffer(v)
} else if (v === null || v === undefined) {
v = Buffer.allocUnsafe(0)
} else if (BN.isBN(v)) {
v = v.toArrayLike(Buffer)
} else if (v.toArray) {
// converts a BN to a Buffer
v = Buffer.from(v.toArray())
} else {
throw new Error('invalid type')
}
}
return v
}
/**
* Converts a `Buffer` to a `Number`
* @param {Buffer} buf
* @return {Number}
* @throws If the input number exceeds 53 bits.
*/
exports.bufferToInt = function (buf) {
return new BN(exports.toBuffer(buf)).toNumber()
}
/**
* Converts a `Buffer` into a hex `String`
* @param {Buffer} buf
* @return {String}
*/
exports.bufferToHex = function (buf) {
buf = exports.toBuffer(buf)
return '0x' + buf.toString('hex')
}
/**
* Interprets a `Buffer` as a signed integer and returns a `BN`. Assumes 256-bit numbers.
* @param {Buffer} num
* @return {BN}
*/
exports.fromSigned = function (num) {
return new BN(num).fromTwos(256)
}
/**
* Converts a `BN` to an unsigned integer and returns it as a `Buffer`. Assumes 256-bit numbers.
* @param {BN} num
* @return {Buffer}
*/
exports.toUnsigned = function (num) {
return Buffer.from(num.toTwos(256).toArray())
}
/**
* Creates Keccak hash of the input
* @param {Buffer|Array|String|Number} a the input data
* @param {Number} [bits=256] the Keccak width
* @return {Buffer}
*/
exports.keccak = function (a, bits) {
a = exports.toBuffer(a)
if (!bits) bits = 256
return createKeccakHash('keccak' + bits).update(a).digest()
}
/**
* Creates Keccak-256 hash of the input, alias for keccak(a, 256)
* @param {Buffer|Array|String|Number} a the input data
* @return {Buffer}
*/
exports.keccak256 = function (a) {
return exports.keccak(a)
}
/**
* Creates SHA256 hash of the input
* @param {Buffer|Array|String|Number} a the input data
* @return {Buffer}
*/
exports.sha256 = function (a) {
a = exports.toBuffer(a)
return createHash('sha256').update(a).digest()
}
/**
* Creates RIPEMD160 hash of the input
* @param {Buffer|Array|String|Number} a the input data
* @param {Boolean} padded whether it should be padded to 256 bits or not
* @return {Buffer}
*/
exports.ripemd160 = function (a, padded) {
a = exports.toBuffer(a)
const hash = createHash('rmd160').update(a).digest()
if (padded === true) {
return exports.setLength(hash, 32)
} else {
return hash
}
}
/**
* Creates SHA-3 hash of the RLP encoded version of the input
* @param {Buffer|Array|String|Number} a the input data
* @return {Buffer}
*/
exports.rlphash = function (a) {
return exports.keccak(rlp.encode(a))
}
/**
* Checks if the private key satisfies the rules of the curve secp256k1.
* @param {Buffer} privateKey
* @return {Boolean}
*/
exports.isValidPrivate = function (privateKey) {
return secp256k1.privateKeyVerify(privateKey)
}
/**
* Checks if the public key satisfies the rules of the curve secp256k1
* and the requirements of Ethereum.
* @param {Buffer} publicKey The two points of an uncompressed key, unless sanitize is enabled
* @param {Boolean} [sanitize=false] Accept public keys in other formats
* @return {Boolean}
*/
exports.isValidPublic = function (publicKey, sanitize) {
if (publicKey.length === 64) {
// Convert to SEC1 for secp256k1
return secp256k1.publicKeyVerify(Buffer.concat([ Buffer.from([4]), publicKey ]))
}
if (!sanitize) {
return false
}
return secp256k1.publicKeyVerify(publicKey)
}
/**
* Returns the ethereum address of a given public key.
* Accepts "Ethereum public keys" and SEC1 encoded keys.
* @param {Buffer} pubKey The two points of an uncompressed key, unless sanitize is enabled
* @param {Boolean} [sanitize=false] Accept public keys in other formats
* @return {Buffer}
*/
exports.pubToAddress = exports.publicToAddress = function (pubKey, sanitize) {
pubKey = exports.toBuffer(pubKey)
if (sanitize && (pubKey.length !== 64)) {
pubKey = secp256k1.publicKeyConvert(pubKey, false).slice(1)
}
assert(pubKey.length === 64)
// Only take the lower 160bits of the hash
return exports.keccak(pubKey).slice(-20)
}
/**
* Returns the ethereum public key of a given private key
* @param {Buffer} privateKey A private key must be 256 bits wide
* @return {Buffer}
*/
const privateToPublic = exports.privateToPublic = function (privateKey) {
privateKey = exports.toBuffer(privateKey)
// skip the type flag and use the X, Y points
return secp256k1.publicKeyCreate(privateKey, false).slice(1)
}
/**
* Converts a public key to the Ethereum format.
* @param {Buffer} publicKey
* @return {Buffer}
*/
exports.importPublic = function (publicKey) {
publicKey = exports.toBuffer(publicKey)
if (publicKey.length !== 64) {
publicKey = secp256k1.publicKeyConvert(publicKey, false).slice(1)
}
return publicKey
}
/**
* ECDSA sign
* @param {Buffer} msgHash
* @param {Buffer} privateKey
* @param {Number} [chainId]
* @return {Object}
*/
exports.ecsign = function (msgHash, privateKey, chainId) {
const sig = secp256k1.sign(msgHash, privateKey)
const ret = {}
ret.r = sig.signature.slice(0, 32)
ret.s = sig.signature.slice(32, 64)
ret.v = chainId ? sig.recovery + (chainId * 2 + 35) : sig.recovery + 27
return ret
}
/**
* Returns the keccak-256 hash of `message`, prefixed with the header used by the `eth_sign` RPC call.
* The output of this function can be fed into `ecsign` to produce the same signature as the `eth_sign`
* call for a given `message`, or fed to `ecrecover` along with a signature to recover the public key
* used to produce the signature.
* @param message
* @returns {Buffer} hash
*/
exports.hashPersonalMessage = function (message) {
const prefix = exports.toBuffer('\u0019Ethereum Signed Message:\n' + message.length.toString())
return exports.keccak(Buffer.concat([prefix, message]))
}
/**
* ECDSA public key recovery from signature
* @param {Buffer} msgHash
* @param {Number} v
* @param {Buffer} r
* @param {Buffer} s
* @param {Number} [chainId]
* @return {Buffer} publicKey
*/
exports.ecrecover = function (msgHash, v, r, s, chainId) {
const signature = Buffer.concat([exports.setLength(r, 32), exports.setLength(s, 32)], 64)
const recovery = calculateSigRecovery(v, chainId)
if (!isValidSigRecovery(recovery)) {
throw new Error('Invalid signature v value')
}
const senderPubKey = secp256k1.recover(msgHash, signature, recovery)
return secp256k1.publicKeyConvert(senderPubKey, false).slice(1)
}
/**
* Convert signature parameters into the format of `eth_sign` RPC method
* @param {Number} v
* @param {Buffer} r
* @param {Buffer} s
* @param {Number} [chainId]
* @return {String} sig
*/
exports.toRpcSig = function (v, r, s, chainId) {
let recovery = calculateSigRecovery(v, chainId)
if (!isValidSigRecovery(recovery)) {
throw new Error('Invalid signature v value')
}
// geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin
return exports.bufferToHex(Buffer.concat([
exports.setLengthLeft(r, 32),
exports.setLengthLeft(s, 32),
exports.toBuffer(v)
]))
}
/**
* Convert signature format of the `eth_sign` RPC method to signature parameters
* NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053
* @param {String} sig
* @return {Object}
*/
exports.fromRpcSig = function (sig) {
sig = exports.toBuffer(sig)
// NOTE: with potential introduction of chainId this might need to be updated
if (sig.length !== 65) {
throw new Error('Invalid signature length')
}
let v = sig[64]
// support both versions of `eth_sign` responses
if (v < 27) {
v += 27
}
return {
v: v,
r: sig.slice(0, 32),
s: sig.slice(32, 64)
}
}
/**
* Returns the ethereum address of a given private key
* @param {Buffer} privateKey A private key must be 256 bits wide
* @return {Buffer}
*/
exports.privateToAddress = function (privateKey) {
return exports.publicToAddress(privateToPublic(privateKey))
}
/**
* Checks if the address is a valid. Accepts checksummed addresses too
* @param {String} address
* @return {Boolean}
*/
exports.isValidAddress = function (address) {
return /^0x[0-9a-fA-F]{40}$/.test(address)
}
/**
* Checks if a given address is a zero address
* @method isZeroAddress
* @param {String} address
* @return {Boolean}
*/
exports.isZeroAddress = function (address) {
const zeroAddress = exports.zeroAddress()
return zeroAddress === exports.addHexPrefix(address)
}
/**
* Returns a checksummed address
* @param {String} address
* @return {String}
*/
exports.toChecksumAddress = function (address) {
address = exports.stripHexPrefix(address).toLowerCase()
const hash = exports.keccak(address).toString('hex')
let ret = '0x'
for (let i = 0; i < address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += address[i].toUpperCase()
} else {
ret += address[i]
}
}
return ret
}
/**
* Checks if the address is a valid checksummed address
* @param {Buffer} address
* @return {Boolean}
*/
exports.isValidChecksumAddress = function (address) {
return exports.isValidAddress(address) && (exports.toChecksumAddress(address) === address)
}
/**
* Generates an address of a newly created contract
* @param {Buffer} from the address which is creating this new address
* @param {Buffer} nonce the nonce of the from account
* @return {Buffer}
*/
exports.generateAddress = function (from, nonce) {
from = exports.toBuffer(from)
nonce = new BN(nonce)
if (nonce.isZero()) {
// in RLP we want to encode null in the case of zero nonce
// read the RLP documentation for an answer if you dare
nonce = null
} else {
nonce = Buffer.from(nonce.toArray())
}
// Only take the lower 160bits of the hash
return exports.rlphash([from, nonce]).slice(-20)
}
/**
* Generates an address for a contract created using CREATE2
* @param {Buffer} from the address which is creating this new address
* @param {Buffer} salt a salt
* @param {Buffer} initCode the init code of the contract being created
* @return {Buffer}
*/
exports.generateAddress2 = function (from, salt, initCode) {
from = exports.toBuffer(from)
salt = exports.toBuffer(salt)
initCode = exports.toBuffer(initCode)
assert(from.length === 20)
assert(salt.length === 32)
let address = exports.keccak256(Buffer.concat([
Buffer.from('ff', 'hex'),
from,
salt,
exports.keccak256(initCode)
]))
return address.slice(-20)
}
/**
* Returns true if the supplied address belongs to a precompiled account (Byzantium)
* @param {Buffer|String} address
* @return {Boolean}
*/
exports.isPrecompiled = function (address) {
const a = exports.unpad(address)
return a.length === 1 && a[0] >= 1 && a[0] <= 8
}
/**
* Adds "0x" to a given `String` if it does not already start with "0x"
* @param {String} str
* @return {String}
*/
exports.addHexPrefix = function (str) {
if (typeof str !== 'string') {
return str
}
return exports.isHexPrefixed(str) ? str : '0x' + str
}
/**
* Validate ECDSA signature
* @method isValidSignature
* @param {Buffer} v
* @param {Buffer} r
* @param {Buffer} s
* @param {Boolean} [homestead=true]
* @param {Number} [chainId]
* @return {Boolean}
*/
exports.isValidSignature = function (v, r, s, homestead, chainId) {
const SECP256K1_N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16)
const SECP256K1_N = new BN('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 16)
if (r.length !== 32 || s.length !== 32) {
return false
}
if (!isValidSigRecovery(calculateSigRecovery(v, chainId))) {
return false
}
r = new BN(r)
s = new BN(s)
if (r.isZero() || r.gt(SECP256K1_N) || s.isZero() || s.gt(SECP256K1_N)) {
return false
}
if ((homestead === false) && (new BN(s).cmp(SECP256K1_N_DIV_2) === 1)) {
return false
}
return true
}
/**
* Converts a `Buffer` or `Array` to JSON
* @param {Buffer|Array} ba
* @return {Array|String|null}
*/
exports.baToJSON = function (ba) {
if (Buffer.isBuffer(ba)) {
return '0x' + ba.toString('hex')
} else if (ba instanceof Array) {
const array = []
for (let i = 0; i < ba.length; i++) {
array.push(exports.baToJSON(ba[i]))
}
return array
}
}
/**
* Defines properties on a `Object`. It make the assumption that underlying data is binary.
* @param {Object} self the `Object` to define properties on
* @param {Array} fields an array fields to define. Fields can contain:
* * `name` - the name of the properties
* * `length` - the number of bytes the field can have
* * `allowLess` - if the field can be less than the length
* * `allowEmpty`
* @param {*} data data to be validated against the definitions
*/
exports.defineProperties = function (self, fields, data) {
self.raw = []
self._fields = []
// attach the `toJSON`
self.toJSON = function (label) {
if (label) {
const obj = {}
self._fields.forEach((field) => {
obj[field] = '0x' + self[field].toString('hex')
})
return obj
}
return exports.baToJSON(this.raw)
}
self.serialize = function serialize () {
return rlp.encode(self.raw)
}
fields.forEach((field, i) => {
self._fields.push(field.name)
function getter () {
return self.raw[i]
}
function setter (v) {
v = exports.toBuffer(v)
if (v.toString('hex') === '00' && !field.allowZero) {
v = Buffer.allocUnsafe(0)
}
if (field.allowLess && field.length) {
v = exports.stripZeros(v)
assert(field.length >= v.length, 'The field ' + field.name + ' must not have more ' + field.length + ' bytes')
} else if (!(field.allowZero && v.length === 0) && field.length) {
assert(field.length === v.length, 'The field ' + field.name + ' must have byte length of ' + field.length)
}
self.raw[i] = v
}
Object.defineProperty(self, field.name, {
enumerable: true,
configurable: true,
get: getter,
set: setter
})
if (field.default) {
self[field.name] = field.default
}
// attach alias
if (field.alias) {
Object.defineProperty(self, field.alias, {
enumerable: false,
configurable: true,
set: setter,
get: getter
})
}
})
// if the constuctor is passed data
if (data) {
if (typeof data === 'string') {
data = Buffer.from(exports.stripHexPrefix(data), 'hex')
}
if (Buffer.isBuffer(data)) {
data = rlp.decode(data)
}
if (Array.isArray(data)) {
if (data.length > self._fields.length) {
throw (new Error('wrong number of fields in data'))
}
// make sure all the items are buffers
data.forEach((d, i) => {
self[self._fields[i]] = exports.toBuffer(d)
})
} else if (typeof data === 'object') {
const keys = Object.keys(data)
fields.forEach((field) => {
if (keys.indexOf(field.name) !== -1) self[field.name] = data[field.name]
if (keys.indexOf(field.alias) !== -1) self[field.alias] = data[field.alias]
})
} else {
throw new Error('invalid data')
}
}
}
function calculateSigRecovery (v, chainId) {
return chainId ? v - (2 * chainId + 35) : v - 27
}
function isValidSigRecovery (recovery) {
return recovery === 0 || recovery === 1
}

View File

@@ -0,0 +1,125 @@
{
"name": "ethereumjs-util",
"version": "6.0.0",
"description": "a collection of utility functions for Ethereum",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"build": "browserify index.js -s ethUtil -o /tmp/ethereumjs-util.js",
"coverage": "npm run build:dist && istanbul cover _mocha",
"coveralls": "npm run coverage && coveralls <coverage/lcov.info",
"lint": "standard",
"prepublishOnly": "npm run test && npm run build:dist",
"test": "npm run lint && npm run test:node && npm run test:browser",
"test:browser": "npm run build:dist && karma start karma.conf.js",
"test:node": "npm run build:dist && istanbul test mocha -- --reporter spec",
"build:dist": "babel index.js --source-root ./ -d ./dist",
"build:docs": "documentation build ./index.js --github --sort-order='alpha' -f md > ./docs/index.md"
},
"repository": {
"type": "git",
"url": "https://github.com/ethereumjs/ethereumjs-util.git"
},
"keywords": [
"ethereum",
"utilties"
],
"author": "mjbecze <mjbecze@gmail.com>",
"contributors": [
{
"name": "Tim Coulter",
"email": "tim@timothyjcoulter.com",
"url": "https://github.com/tcoulter",
"contributions": 1,
"additions": 2,
"deletions": 2
},
{
"name": "Nick Dodson",
"url": "https://github.com/SilentCicero",
"contributions": 2,
"additions": 26,
"deletions": 2
},
{
"name": "Mr. Chico",
"url": "https://github.com/MrChico",
"contributions": 1,
"additions": 11,
"deletions": 1
},
{
"name": "Dũng Trần",
"email": "tad88.dev@gmail.com",
"url": "https://github.com/tad88dev",
"contributions": 2,
"additions": 5,
"deletions": 5
},
{
"name": "Alex Beregszaszi",
"email": "alex@rtfs.hu",
"url": "https://github.com/axic",
"contributions": 77,
"additions": 1796,
"deletions": 642
},
{
"name": "Taylor Gerring",
"url": "https://github.com/tgerring",
"contributions": 1,
"additions": 1,
"deletions": 1
},
{
"name": "Kirill Fomichev",
"email": "fanatid@ya.ru",
"url": "https://github.com/fanatid",
"contributions": 8,
"additions": 32,
"deletions": 16
},
{
"name": "kumavis",
"email": "aaron@kumavis.me",
"url": "https://github.com/kumavis",
"contributions": 2,
"additions": 2,
"deletions": 2
},
{
"name": "Alexander Sinyagin",
"email": "sinyagin.alexander@gmail.com",
"url": "https://github.com/asinyagin",
"contributions": 1,
"additions": 3,
"deletions": 1
}
],
"license": "MPL-2.0",
"bugs": {
"url": "https://github.com/ethereumjs/ethereumjs-util/issues"
},
"homepage": "https://github.com/ethereumjs/ethereumjs-util",
"dependencies": {
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
"ethjs-util": "^0.1.6",
"keccak": "^1.0.2",
"rlp": "^2.0.0",
"safe-buffer": "^5.1.1",
"secp256k1": "^3.0.1"
},
"devDependencies": {},
"standard": {
"globals": [
"describe",
"it"
],
"ignore": [
"dist/**"
]
}
}

View File

@@ -0,0 +1,4 @@
Build (will create a bundle and copy it to /tmp/ethereumjs-util.js):
npm install
npm run build

View File

@@ -2,7 +2,7 @@
"name": "stellar-util",
"version": "0.0.1",
"scripts": {
"build": "browserify stellar-util.js > ../../src/js/stellar-util.js"
"build": "browserify stellar-util.js > /tmp/stellar-util.js"
},
"dependencies": {
"ed25519-hd-key": "^1.0.0",

View File

@@ -1,5 +1,4 @@
Build (will create a bundle and copy it to ../../src/stellar-util.js):
Build (will create a bundle and copy it to /tmp/stellar-util.js):
npm install
npm run build

View File

@@ -17,7 +17,7 @@ created with the following steps:
1. include the changelog for this release as text for the release
1. attach signature.txt.asc
1. attach the bip39-standalone.html file
1. Add a new post to twitter from @bip39tool with the version, link and hash
1. Publish to any hosted locations (eg iancoleman.github.io/bip39)
1. Download the file from the release and confirm it hashes to the expected value `sha256sum bip39-standalone.html`
1. Download the signature from the release and verify it. `gpg --verify signature.txt.asc`
1. Publish to any hosted locations (eg iancoleman.github.io/bip39)
1. Add a new post to twitter from @bip39tool with the version, link and hash

View File

@@ -15,7 +15,7 @@
<div class="container">
<h1 class="text-center">Mnemonic Code Converter</h1>
<p class="version">v0.3.12</p>
<p class="version">v0.3.14</p>
<hr>
<div class="row">
<div class="col-md-12">
@@ -172,6 +172,15 @@
<textarea id="phrase" class="phrase private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
</div>
</div>
<div class="form-group">
<label for="phrase" class="col-sm-2 control-label">BIP39 Split Mnemonic</label>
<div class="col-sm-10">
<textarea id="phraseSplit" class="phraseSplit private-data form-control" title="Only 2 of 3 cards needed to recover." rows="3"></textarea>
<p class="help-block">
<span id="phraseSplitWarn" class="phraseSplitWarn"></span>
</p>
</div>
</div>
<div class="form-group">
<label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
<div class="col-sm-10">
@@ -273,7 +282,7 @@
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
</label>
<div class="col-sm-10">
<input id="change-bip44" type="text" class="change form-control" value="0">
<input id="change-bip44" type="text" class="change form-control" value="0">
</div>
</div>
<div class="form-group">
@@ -339,13 +348,6 @@
<input id="bip32-path" type="text" class="path form-control" value="m/0">
</div>
</div>
<div class="form-group">
<div class="col-sm-2"></div>
<label class="col-sm-10">
<input class="hardened-addresses" type="checkbox">
<span>Use hardened addresses</span>
</label>
</div>
<div class="form-group">
<label for="core-path" class="col-sm-2 control-label">Bitcoin Core</label>
<div class="col-sm-10">
@@ -657,6 +659,14 @@
<span>Enabling BIP38 means each key will take several minutes to generate.</span>
</div>
</div>
<div class="col-md-12">
<div class="checkbox">
<label>
<input class="hardened-addresses" type="checkbox">
<span>Use hardened addresses</span>
</label>
</div>
</div>
<ul class="addresses-type nav nav-tabs" role="tablist">
<li id="table-tab" class="active">
<a href="#table" role="tab" data-toggle="tab">Table</a>
@@ -923,9 +933,13 @@
<script src="js/bitcoinjs-3.3.2.js"></script>
<script src="js/bitcoinjs-extensions.js"></script>
<script src="js/bitcoinjs-bip38-2.0.2.js"></script>
<script src="js/groestlcoinjs-3.3.2.js"></script>
<script src="js/groestlcoinjs-bip38-2.0.2.js"></script>
<script src="js/elastos-1.0.9.min.js"></script>
<script src="js/segwit-parameters.js"></script>
<script src="js/ethereumjs-util.js"></script>
<script src="js/ripple-util.js"></script>
<script src="js/casinocoin-util.js"></script>
<script src="js/bchaddrjs-0.2.1.js"></script>
<script src="js/nebulas-account.js"></script>
<script src="js/eos-util.js"></script>

View File

@@ -8596,13 +8596,13 @@ module.exports={
"OP_CHECKMULTISIGVERIFY": 175,
"OP_NOP1": 176,
"OP_NOP2": 177,
"OP_CHECKLOCKTIMEVERIFY": 177,
"OP_NOP3": 178,
"OP_CHECKSEQUENCEVERIFY": 178,
"OP_NOP4": 179,
"OP_NOP5": 180,
"OP_NOP6": 181,
@@ -15165,4 +15165,4 @@ module.exports = {
}).call(this,require("buffer").Buffer)
},{"bs58check":83,"buffer":5}]},{},[34])(34)
});
});

View File

@@ -18123,7 +18123,7 @@ module.exports = function privateDecrypt(private_key, enc, reverse) {
} else {
padding = 4;
}
var key = parseKeys(private_key);
var k = key.modulus.byteLength();
if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
@@ -22690,13 +22690,13 @@ Script.prototype.runInContext = function (context) {
if (!(context instanceof Context)) {
throw new TypeError("needs a 'context' argument.");
}
var iframe = document.createElement('iframe');
if (!iframe.style) iframe.style = {};
iframe.style.display = 'none';
document.body.appendChild(iframe);
var win = iframe.contentWindow;
var wEval = win.eval, wExecScript = win.execScript;
@@ -22705,7 +22705,7 @@ Script.prototype.runInContext = function (context) {
wExecScript.call(win, 'null');
wEval = win.eval;
}
forEach(Object_keys(context), function (key) {
win[key] = context[key];
});
@@ -22714,11 +22714,11 @@ Script.prototype.runInContext = function (context) {
win[key] = context[key];
}
});
var winKeys = Object_keys(win);
var res = wEval.call(win, this.code);
forEach(Object_keys(win), function (key) {
// Avoid copying circular objects like `top` and `window` by only
// updating existing context properties or new properties in the `win`
@@ -22733,9 +22733,9 @@ Script.prototype.runInContext = function (context) {
defineProp(context, key, win[key]);
}
});
document.body.removeChild(iframe);
return res;
};
@@ -27914,4 +27914,4 @@ Sha512.prototype._hash = function () {
module.exports = Sha512
},{"./hash":195,"inherits":189,"safe-buffer":193}]},{},[150])(150)
});
});

View File

@@ -801,6 +801,28 @@ bitcoinjs.bitcoin.networks.gridcoin = {
wif: 0xbe,
};
bitcoinjs.bitcoin.networks.groestlcoin = {
messagePrefix: '\x19GroestlCoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 36,
scriptHash: 5,
wif: 128,
}
bitcoinjs.bitcoin.networks.groestlcointestnet = {
messagePrefix: '\x19GroestlCoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef,
}
bitcoinjs.bitcoin.networks.gulden = {
messagePrefix: '\x18Guldencoin Signed Message:\n',
bip32: {
@@ -1462,6 +1484,17 @@ bitcoinjs.bitcoin.networks.hush = {
wif: 0x80,
};
bitcoinjs.bitcoin.networks.hush3 = {
messagePrefix: '\x18Hush Signed Message:\n',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4,
},
pubKeyHash: 0x3C,
scriptHash: 0x55,
wif: 0xBC,
};
bitcoinjs.bitcoin.networks.zclassic = {
messagePrefix: '\x18Zcash Signed Message:\n',
bip32: {
@@ -1615,3 +1648,93 @@ bitcoinjs.bitcoin.networks.deeponion = {
scriptHash: 0x4E,
wif: 0x9F,
};
bitcoinjs.bitcoin.networks.cpuchain = {
messagePrefix: 'x18CPUchain Signed Message:\n',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4,
},
pubKeyHash: 0x1C,
scriptHash: 0x1E,
wif: 0x80,
};
bitcoinjs.bitcoin.networks.wagerr = {
messagePrefix: 'unused',
bip32: {
public: 0x022d2533,
private: 0x0221312b
},
pubKeyHash: 0x49,
scriptHash: 0x3f,
wif: 0xc7
};
bitcoinjs.bitcoin.networks.bitcoinsv = {
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80
};
bitcoinjs.bitcoin.networks.monkeyproject = {
messagePrefix: 'Monkey Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488dde4
},
pubKeyHash: 0x33,
scriptHash: 0x1c,
wif: 0x37
};
bitcoinjs.bitcoin.networks.rapids = {
messagePrefix: 'DarkNet Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x3d,
scriptHash: 0x06,
wif: 0x2e
};
bitcoinjs.bitcoin.networks.aryacoin = {
messagePrefix: '\x18Aryacoin Signed Message:\n',
bech32: 'arya',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4,
},
pubKeyHash: 0x17,
scriptHash: 0x6f,
wif: 0x97
};
bitcoinjs.bitcoin.networks.thought = {
messagePrefix: 'unused',
bip32: {
public: 0xFbC6A00D,
private: 0x5AEBD8C6
},
pubKeyHash: 0x07,
scriptHash: 0x09,
wif: 0x7B
};
bitcoinjs.bitcoin.networks.elastos = {
messagePrefix: 'unused',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4,
},
pubKeyHash: 0x21,
scriptHash: 0xc4, // TODO set this correctly, same as BTC for now
wif: 0xef // TODO set this correctly, same as BTC for now
};

View File

@@ -0,0 +1,9 @@
function convertCasinoCoinAdrr(address) {
return window.basex('cpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2brdeCg65jkm8oFqi1tuvAxyz').encode(
window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
)
}
function convertCasinoCoinPriv(priv) {
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
}

69
src/js/elastos-1.0.9.min.js vendored Normal file

File diff suppressed because one or more lines are too long

17951
src/js/groestlcoinjs-3.3.2.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -44,6 +44,8 @@
DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning");
DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
DOM.phrase = $(".phrase");
DOM.phraseSplit = $(".phraseSplit");
DOM.phraseSplitWarn = $(".phraseSplitWarn");
DOM.passphrase = $(".passphrase");
DOM.generateContainer = $(".generate-container");
DOM.generate = $(".generate");
@@ -232,7 +234,14 @@
if (phraseChangeTimeoutEvent != null) {
clearTimeout(phraseChangeTimeoutEvent);
}
phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
phraseChangeTimeoutEvent = setTimeout(function() {
phraseChanged();
var entropy = mnemonic.toRawEntropyBin(DOM.phrase.val());
if (entropy !== null) {
DOM.entropyMnemonicLength.val("raw");
DOM.entropy.val(entropy);
}
}, 400);
}
function phraseChanged() {
@@ -251,6 +260,7 @@
calcForDerivationPath();
// Show the word indexes
showWordIndexes();
writeSplitPhrase(phrase);
}
function tabChanged() {
@@ -297,6 +307,7 @@
clearDisplay();
clearEntropyFeedback();
DOM.phrase.val("");
DOM.phraseSplit.val("");
showValidationError("Blank entropy");
return;
}
@@ -331,6 +342,7 @@
showPending();
// Clear existing mnemonic and passphrase
DOM.phrase.val("");
DOM.phraseSplit.val("");
DOM.passphrase.val("");
seed = null;
if (rootKeyChangedTimeoutEvent != null) {
@@ -488,9 +500,16 @@
function calcBip32RootKeyFromSeed(phrase, passphrase) {
seed = mnemonic.toSeed(phrase, passphrase);
bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network);
if(isGRS())
bip32RootKey = groestlcoinjs.HDNode.fromSeedHex(seed, network);
}
function calcBip32RootKeyFromBase58(rootKeyBase58) {
if(isGRS()) {
calcBip32RootKeyFromBase58GRS(rootKeyBase58);
return;
}
// try parsing with various segwit network params since this extended
// key may be from any one of them.
if (networkHasSegwit()) {
@@ -525,6 +544,41 @@
bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
}
function calcBip32RootKeyFromBase58GRS(rootKeyBase58) {
// try parsing with various segwit network params since this extended
// key may be from any one of them.
if (networkHasSegwit()) {
var n = network;
if ("baseNetwork" in n) {
n = bitcoinjs.bitcoin.networks[n.baseNetwork];
}
// try parsing using base network params
try {
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
return;
}
catch (e) {}
// try parsing using p2wpkh params
if ("p2wpkh" in n) {
try {
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
return;
}
catch (e) {}
}
// try parsing using p2wpkh-in-p2sh network params
if ("p2wpkhInP2sh" in n) {
try {
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
return;
}
catch (e) {}
}
}
// try the network params as currently specified
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
}
function calcBip32ExtendedKey(path) {
// Check there's a root key to derive from
if (!bip32RootKey) {
@@ -552,7 +606,7 @@
extendedKey = extendedKey.derive(index);
}
}
return extendedKey
return extendedKey;
}
function showValidationError(errorText) {
@@ -595,6 +649,9 @@
}
function validateRootKey(rootKeyBase58) {
if(isGRS())
return validateRootKeyGRS(rootKeyBase58);
// try various segwit network params since this extended key may be from
// any one of them.
if (networkHasSegwit()) {
@@ -635,6 +692,47 @@
return "";
}
function validateRootKeyGRS(rootKeyBase58) {
// try various segwit network params since this extended key may be from
// any one of them.
if (networkHasSegwit()) {
var n = network;
if ("baseNetwork" in n) {
n = bitcoinjs.bitcoin.networks[n.baseNetwork];
}
// try parsing using base network params
try {
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
return "";
}
catch (e) {}
// try parsing using p2wpkh params
if ("p2wpkh" in n) {
try {
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
return "";
}
catch (e) {}
}
// try parsing using p2wpkh-in-p2sh network params
if ("p2wpkhInP2sh" in n) {
try {
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
return "";
}
catch (e) {}
}
}
// try the network params as currently specified
try {
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
}
catch (e) {
return "Invalid root key";
}
return "";
}
function getDerivationPath() {
if (bip44TabSelected()) {
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
@@ -745,6 +843,14 @@
return false;
}
function isGRS() {
return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet";
}
function isELA() {
return networks[DOM.network.val()].name == "ELA - Elastos"
}
function displayBip44Info() {
// Get the derivation path for the account
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
@@ -758,9 +864,14 @@
var accountExtendedKey = calcBip32ExtendedKey(path);
var accountXprv = accountExtendedKey.toBase58();
var accountXpub = accountExtendedKey.neutered().toBase58();
// Display the extended keys
DOM.bip44accountXprv.val(accountXprv);
DOM.bip44accountXpub.val(accountXpub);
if (isELA()) {
displayBip44InfoForELA();
}
}
function displayBip49Info() {
@@ -816,6 +927,10 @@
clearAddressesList();
var initialAddressCount = parseInt(DOM.rowsToAdd.val());
displayAddresses(0, initialAddressCount);
if (isELA()) {
displayBip32InfoForELA();
}
}
function displayAddresses(start, total) {
@@ -888,6 +1003,9 @@
var useUncompressed = useBip38;
if (useUncompressed) {
keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
if(isGRS())
keyPair = new groestlcoinjs.ECPair(keyPair.d, null, { network: network, compressed: false });
}
// get address
var address = keyPair.getAddress().toString();
@@ -898,9 +1016,14 @@
privkey = keyPair.toWIF();
// BIP38 encode private key if required
if (useBip38) {
privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
});
if(isGRS())
privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
}, null, networks[DOM.network.val()].name.includes("Testnet"));
else
privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
});
}
}
// get pubkey
@@ -910,18 +1033,7 @@
indexText = indexText + "'";
}
// Ethereum values are different
if ((networks[DOM.network.val()].name == "ETH - Ethereum")
|| (networks[DOM.network.val()].name == "ETC - Ethereum Classic")
|| (networks[DOM.network.val()].name == "PIRL - Pirl")
|| (networks[DOM.network.val()].name == "MIX - MIX")
|| (networks[DOM.network.val()].name == "MUSIC - Musicoin")
|| (networks[DOM.network.val()].name == "POA - Poa")
|| (networks[DOM.network.val()].name == "EXP - Expanse")
|| (networks[DOM.network.val()].name == "CLO - Callisto")
|| (networks[DOM.network.val()].name == "DXN - DEXON")
|| (networks[DOM.network.val()].name == "ELLA - Ellaism")
|| (networks[DOM.network.val()].name == "ESN - Ethersocial Network")
) {
if (networkIsEthereum()) {
var privKeyBuffer = keyPair.d.toBuffer(32);
privkey = privKeyBuffer.toString('hex');
var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
@@ -958,6 +1070,11 @@
privkey = convertRipplePriv(privkey);
address = convertRippleAdrr(address);
}
// CasinoCoin values are different
if (networks[DOM.network.val()].name == "CSC - CasinoCoin") {
privkey = convertCasinoCoinPriv(privkey);
address = convertCasinoCoinAdrr(address);
}
// Bitcoin Cash address format may vary
if (networks[DOM.network.val()].name == "BCH - Bitcoin Cash") {
var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
@@ -1004,6 +1121,36 @@
privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32));
}
//Groestlcoin Addresses are different
if(isGRS()) {
if (isSegwit) {
if (!segwitAvailable) {
return;
}
if (isP2wpkh) {
address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
}
else if (isP2wpkhInP2sh) {
address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
}
}
//non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
}
if (isELA()) {
let elaAddress = calcAddressForELA(
seed,
parseIntNoNaN(DOM.bip44coin.val(), 0),
parseIntNoNaN(DOM.bip44account.val(), 0),
parseIntNoNaN(DOM.bip44change.val(), 0),
index
);
address = elaAddress.address;
privkey = elaAddress.privateKey;
pubkey = elaAddress.publicKey;
}
addAddressToList(indexText, address, pubkey, privkey);
if (isLast) {
hidePending();
@@ -1295,6 +1442,49 @@
return phrase;
}
function writeSplitPhrase(phrase) {
var wordCount = phrase.split(/\s/g).length;
var left=[];
for (var i=0;i<wordCount;i++) left.push(i);
var group=[[],[],[]],
groupI=-1;
var seed = Math.abs(sjcl.hash.sha256.hash(phrase)[0])% 2147483647;
while (left.length>0) {
groupI=(groupI+1)%3;
seed = seed * 16807 % 2147483647;
var selected=Math.floor(left.length*(seed - 1) / 2147483646);
group[groupI].push(left[selected]);
left.splice(selected,1);
}
var cards=[phrase.split(/\s/g),phrase.split(/\s/g),phrase.split(/\s/g)];
for (var i=0;i<3;i++) {
for (var ii=0;ii<wordCount/3;ii++) cards[i][group[i][ii]]='XXXX';
cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]);
}
DOM.phraseSplit.val(cards.join("\r\n"));
var triesPerSecond=10000000000;
var hackTime=Math.pow(2,wordCount*10/3)/triesPerSecond;
var displayRedText = false;
if (hackTime<1) {
hackTime="<1 second";
displayRedText = true;
} else if (hackTime<86400) {
hackTime=Math.floor(hackTime)+" seconds";
displayRedText = true;
} else if(hackTime<31557600) {
hackTime=Math.floor(hackTime/86400)+" days";
displayRedText = true;
} else {
hackTime=Math.floor(hackTime/31557600)+" years";
}
DOM.phraseSplitWarn.html("Time to hack with only one card: "+hackTime);
if (displayRedText) {
DOM.phraseSplitWarn.addClass("text-danger");
} else {
DOM.phraseSplitWarn.removeClass("text-danger");
}
}
function isUsingOwnEntropy() {
return DOM.useEntropy.prop("checked");
}
@@ -1352,6 +1542,7 @@
var phrase = mnemonic.toMnemonic(entropyArr);
// Set the mnemonic in the UI
DOM.phrase.val(phrase);
writeSplitPhrase(phrase);
// Show the word indexes
showWordIndexes();
// Show the checksum
@@ -1515,6 +1706,23 @@
return DOM.bip32tab.hasClass("active");
}
function networkIsEthereum() {
var name = networks[DOM.network.val()].name;
return (name == "ETH - Ethereum")
|| (name == "ETC - Ethereum Classic")
|| (name == "EWT - EnergyWeb")
|| (name == "PIRL - Pirl")
|| (name == "MIX - MIX")
|| (name == "MUSIC - Musicoin")
|| (name == "POA - Poa")
|| (name == "EXP - Expanse")
|| (name == "CLO - Callisto")
|| (name == "DXN - DEXON")
|| (name == "ELLA - Ellaism")
|| (name == "ESN - Ethersocial Network")
|| (name == "VET - VeChain")
}
function networkHasSegwit() {
var n = network;
if ("baseNetwork" in network) {
@@ -1690,6 +1898,13 @@
setHdCoin(161);
},
},
{
name: "ARYA - Aryacoin",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.aryacoin;
setHdCoin(357);
},
},
{
name: "AUR - Auroracoin",
onSelect: function() {
@@ -1703,8 +1918,8 @@
network = bitcoinjs.bitcoin.networks.axe;
setHdCoin(4242);
},
},
{
},
{
name: "ANON - ANON",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.anon;
@@ -1760,7 +1975,7 @@
setHdCoin(2941);
},
},
{
{
name: "tBND - Blocknode Testnet",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.blocknode_testnet;
@@ -1781,7 +1996,7 @@
setHdCoin(91);
},
},
{
{
name: "BST - BlockStamp",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.blockstamp;
@@ -1809,7 +2024,7 @@
setHdCoin(1);
},
},
{
{
name: "BITG - Bitcoin Green",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoingreen;
@@ -1823,6 +2038,13 @@
setHdCoin(183);
},
},
{
name: "BSV - BitcoinSV",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoinsv;
setHdCoin(236);
},
},
{
name: "BTCZ - Bitcoinz",
onSelect: function() {
@@ -1901,6 +2123,13 @@
setHdCoin(71);
},
},
{
name: "CPU - CPUchain",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.cpuchain;
setHdCoin(363);
},
},
{
name: "CRAVE - Crave",
onSelect: function() {
@@ -1922,6 +2151,13 @@
setHdCoin(72);
},
},
{
name: "CSC - CasinoCoin",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(359);
},
},
{
name: "DASH - Dash",
onSelect: function() {
@@ -2013,6 +2249,13 @@
setHdCoin(78);
},
},
{
name: "ELA - Elastos",
onSelect: function () {
network = bitcoinjs.bitcoin.networks.elastos;
setHdCoin(2305);
},
},
{
name: "ELLA - Ellaism",
segwitAvailable: false,
@@ -2064,7 +2307,14 @@
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(60);
},
},
},
{
name: "EWT - EnergyWeb",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(246);
},
},
{
name: "EXCL - Exclusivecoin",
onSelect: function() {
@@ -2157,6 +2407,20 @@
setHdCoin(84);
},
},
{
name: "GRS - Groestlcoin",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.groestlcoin;
setHdCoin(17);
},
},
{
name: "GRS - Groestlcoin Testnet",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.groestlcointestnet;
setHdCoin(1);
},
},
{
name: "HNC - Helleniccoin",
onSelect: function() {
@@ -2164,13 +2428,20 @@
setHdCoin(168);
},
},
{
name: "HUSH - Hush",
{
name: "HUSH - Hush (Legacy)",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.hush;
setHdCoin(197);
},
},
{
name: "HUSH - Hush3",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.hush3;
setHdCoin(197);
},
},
{
name: "INSN - Insane",
onSelect: function() {
@@ -2317,6 +2588,13 @@
setHdCoin(22);
},
},
{
name: "MONK - Monkey Project",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.monkeyproject,
setHdCoin(214);
},
},
{
name: "MUSIC - Musicoin",
segwitAvailable: false,
@@ -2437,7 +2715,7 @@
setHdCoin(174);
},
},
{
{
name: "PHR - Phore",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.phore;
@@ -2502,7 +2780,7 @@
setHdCoin(6);
},
},
{
{
name: "PRJ - ProjectCoin",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.projectcoin;
@@ -2523,6 +2801,13 @@
setHdCoin(122);
},
},
{
name: "RPD - Rapids",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.rapids;
setHdCoin(320);
},
},
{
name: "RVN - Ravencoin",
onSelect: function() {
@@ -2558,7 +2843,7 @@
setHdCoin(19165);
},
},
{
{
name: "SLS - Salus",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.salus;
@@ -2656,6 +2941,13 @@
setHdCoin(113);
},
},
{
name: "THT - Thought",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.thought;
setHdCoin(1618);
},
},
{
name: "TOA - Toa",
onSelect: function() {
@@ -2705,6 +2997,13 @@
setHdCoin(33);
},
},
{
name: "VET - VeChain",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(818);
},
},
{
name: "VIA - Viacoin",
onSelect: function() {
@@ -2733,6 +3032,13 @@
setHdCoin(28);
},
},
{
name: "WGR - Wagerr",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.wagerr;
setHdCoin(7825266);
},
},
{
name: "WC - Wincoin",
onSelect: function() {
@@ -2740,7 +3046,7 @@
setHdCoin(181);
},
},
{
{
name: "XAX - Artax",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.artax;
@@ -2826,7 +3132,7 @@
},
},
{
name: "ZEN - Zencash",
name: "ZEN - Horizen",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.zencash;
setHdCoin(121);
@@ -2865,6 +3171,56 @@
}
]
// ELA - Elastos functions - begin
function displayBip44InfoForELA() {
if (!isELA()) {
return;
}
var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
var account = parseIntNoNaN(DOM.bip44account.val(), 0);
// Calculate the account extended keys
var accountXprv = elastosjs.getAccountExtendedPrivateKey(seed, coin, account);
var accountXpub = elastosjs.getAccountExtendedPublicKey(seed, coin, account);
// Display the extended keys
DOM.bip44accountXprv.val(accountXprv);
DOM.bip44accountXpub.val(accountXpub);
}
function displayBip32InfoForELA() {
if (!isELA()) {
return;
}
var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
var account = parseIntNoNaN(DOM.bip44account.val(), 0);
var change = parseIntNoNaN(DOM.bip44change.val(), 0);
DOM.extendedPrivKey.val(elastosjs.getBip32ExtendedPrivateKey(seed, coin, account, change));
DOM.extendedPubKey.val(elastosjs.getBip32ExtendedPublicKey(seed, coin, account, change));
// Display the addresses and privkeys
clearAddressesList();
var initialAddressCount = parseInt(DOM.rowsToAdd.val());
displayAddresses(0, initialAddressCount);
}
function calcAddressForELA(seed, coin, account, change, index) {
if (!isELA()) {
return;
}
var publicKey = elastosjs.getDerivedPublicKey(elastosjs.getMasterPublicKey(seed), change, index);
return {
privateKey: elastosjs.getDerivedPrivateKey(seed, coin, account, change, index),
publicKey: publicKey,
address: elastosjs.getAddress(publicKey.toString('hex'))
};
}
// ELA - Elastos functions - end
init();
})();

View File

@@ -97,22 +97,10 @@ var Mnemonic = function(language) {
}
self.check = function(mnemonic) {
var mnemonic = self.splitWords(mnemonic);
if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
return false
var b = mnemonicToBinaryString(mnemonic);
if (b === null) {
return false;
}
// idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
var idx = [];
for (var i=0; i<mnemonic.length; i++) {
var word = mnemonic[i];
var wordIndex = wordlist.indexOf(word);
if (wordIndex == -1) {
return false;
}
var binaryIndex = zfill(wordIndex.toString(2), 11);
idx.push(binaryIndex);
}
var b = idx.join('');
var l = b.length;
//d = b[:l / 33 * 32]
//h = b[-l / 33:]
@@ -128,6 +116,26 @@ var Mnemonic = function(language) {
return h == nh;
}
self.toRawEntropyHex = function(mnemonic) {
var b = mnemonicToBinaryString(mnemonic);
if (b === null)
return null;
var d = b.substring(0, b.length / 33 * 32);
var nd = binaryStringToWordArray(d);
var h = "";
for (var i=0; i<nd.length; i++) {
h += ('0000000' + nd[i].toString(16)).slice(-8);
}
return h;
}
self.toRawEntropyBin = function(mnemonic) {
var b = mnemonicToBinaryString(mnemonic);
var d = b.substring(0, b.length / 33 * 32);
return d;
}
self.toSeed = function(mnemonic, passphrase) {
passphrase = passphrase || '';
mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks
@@ -200,6 +208,25 @@ var Mnemonic = function(language) {
return a;
}
function mnemonicToBinaryString(mnemonic) {
var mnemonic = self.splitWords(mnemonic);
if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
return null;
}
// idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
var idx = [];
for (var i=0; i<mnemonic.length; i++) {
var word = mnemonic[i];
var wordIndex = wordlist.indexOf(word);
if (wordIndex == -1) {
return null;
}
var binaryIndex = zfill(wordIndex.toString(2), 11);
idx.push(binaryIndex);
}
return idx.join('');
}
// Pad a numeric string on the left with zero digits until the given width
// is reached.
// Note this differs to the python implementation because it does not

View File

@@ -1,38 +1,17 @@
// source
// https://github.com/hiddentao/fast-levenshtein/blob/2.0.6/levenshtein.js
(function() {
'use strict';
/**
* Extend an Object with another Object's properties.
*
* The source objects are specified as additional arguments.
*
* @param dst Object the object to extend.
*
* @return Object the final object.
*/
var _extend = function(dst) {
var sources = Array.prototype.slice.call(arguments, 1);
for (var i=0; i<sources.length; ++i) {
var src = sources[i];
for (var p in src) {
if (src.hasOwnProperty(p)) dst[p] = src[p];
}
}
return dst;
};
/**
* Defer execution of given function.
* @param {Function} func
*/
var _defer = function(func) {
if (typeof setImmediate === 'function') {
return setImmediate(func);
} else {
return setTimeout(func, 0);
}
};
var collator;
try {
collator = (typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined") ? Intl.Collator("generic", { sensitivity: "base" }) : null;
} catch (err){
console.log("Collator could not be initialized and wouldn't be used");
}
// arrays to re-use
var prevRow = [],
str2Char = [];
/**
* Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
@@ -43,148 +22,96 @@
*
* @param str1 String the first string.
* @param str2 String the second string.
* @param [options] Additional options.
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
* @return Integer the levenshtein distance (0 and above).
*/
get: function(str1, str2) {
get: function(str1, str2, options) {
var useCollator = (options && collator && options.useCollator);
var str1Len = str1.length,
str2Len = str2.length;
// base cases
if (str1 === str2) return 0;
if (str1.length === 0) return str2.length;
if (str2.length === 0) return str1.length;
if (str1Len === 0) return str2Len;
if (str2Len === 0) return str1Len;
// two rows
var prevRow = new Array(str2.length + 1),
curCol, nextCol, i, j, tmp;
var curCol, nextCol, i, j, tmp;
// initialise previous row
for (i=0; i<prevRow.length; ++i) {
for (i=0; i<str2Len; ++i) {
prevRow[i] = i;
str2Char[i] = str2.charCodeAt(i);
}
prevRow[str2Len] = str2Len;
// calculate current row distance from previous row
for (i=0; i<str1.length; ++i) {
nextCol = i + 1;
var strCmp;
if (useCollator) {
// calculate current row distance from previous row using collator
for (i = 0; i < str1Len; ++i) {
nextCol = i + 1;
for (j=0; j<str2.length; ++j) {
curCol = nextCol;
for (j = 0; j < str2Len; ++j) {
curCol = nextCol;
// substution
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
// insertion
tmp = curCol + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// deletion
tmp = prevRow[j + 1] + 1;
if (nextCol > tmp) {
nextCol = tmp;
// substution
strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j]));
nextCol = prevRow[j] + (strCmp ? 0 : 1);
// insertion
tmp = curCol + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// deletion
tmp = prevRow[j + 1] + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// copy current col value into previous (in preparation for next iteration)
prevRow[j] = curCol;
}
// copy current col value into previous (in preparation for next iteration)
prevRow[j] = curCol;
// copy last col value into previous (in preparation for next iteration)
prevRow[j] = nextCol;
}
// copy last col value into previous (in preparation for next iteration)
prevRow[j] = nextCol;
}
else {
// calculate current row distance from previous row without collator
for (i = 0; i < str1Len; ++i) {
nextCol = i + 1;
for (j = 0; j < str2Len; ++j) {
curCol = nextCol;
// substution
strCmp = str1.charCodeAt(i) === str2Char[j];
nextCol = prevRow[j] + (strCmp ? 0 : 1);
// insertion
tmp = curCol + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// deletion
tmp = prevRow[j + 1] + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// copy current col value into previous (in preparation for next iteration)
prevRow[j] = curCol;
}
// copy last col value into previous (in preparation for next iteration)
prevRow[j] = nextCol;
}
}
return nextCol;
},
/**
* Asynchronously calculate levenshtein distance of the two strings.
*
* @param str1 String the first string.
* @param str2 String the second string.
* @param cb Function callback function with signature: function(Error err, int distance)
* @param [options] Object additional options.
* @param [options.progress] Function progress callback with signature: function(percentComplete)
*/
getAsync: function(str1, str2, cb, options) {
options = _extend({}, {
progress: null
}, options);
// base cases
if (str1 === str2) return cb(null, 0);
if (str1.length === 0) return cb(null, str2.length);
if (str2.length === 0) return cb(null, str1.length);
// two rows
var prevRow = new Array(str2.length + 1),
curCol, nextCol,
i, j, tmp,
startTime, currentTime;
// initialise previous row
for (i=0; i<prevRow.length; ++i) {
prevRow[i] = i;
}
nextCol = 1;
i = 0;
j = -1;
var __calculate = function() {
// reset timer
startTime = new Date().valueOf();
currentTime = startTime;
// keep going until one second has elapsed
while (currentTime - startTime < 1000) {
// reached end of current row?
if (str2.length <= (++j)) {
// copy current into previous (in preparation for next iteration)
prevRow[j] = nextCol;
// if already done all chars
if (str1.length <= (++i)) {
return cb(null, nextCol);
}
// else if we have more left to do
else {
nextCol = i + 1;
j = 0;
}
}
// calculation
curCol = nextCol;
// substution
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
// insertion
tmp = curCol + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// deletion
tmp = prevRow[j + 1] + 1;
if (nextCol > tmp) {
nextCol = tmp;
}
// copy current into previous (in preparation for next iteration)
prevRow[j] = curCol;
// get current time
currentTime = new Date().valueOf();
}
// send a progress update?
if (null !== options.progress) {
try {
options.progress.call(null, (i * 100.0/ str1.length));
} catch (err) {
return cb('Progress callback: ' + err.toString());
}
}
// next iteration
_defer(__calculate);
};
__calculate();
}
};

View File

@@ -21709,7 +21709,7 @@ module.exports = function privateDecrypt(private_key, enc, reverse) {
} else {
padding = 4;
}
var key = parseKeys(private_key);
var k = key.modulus.byteLength();
if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
@@ -27194,13 +27194,13 @@ Script.prototype.runInContext = function (context) {
if (!(context instanceof Context)) {
throw new TypeError("needs a 'context' argument.");
}
var iframe = document.createElement('iframe');
if (!iframe.style) iframe.style = {};
iframe.style.display = 'none';
document.body.appendChild(iframe);
var win = iframe.contentWindow;
var wEval = win.eval, wExecScript = win.execScript;
@@ -27209,7 +27209,7 @@ Script.prototype.runInContext = function (context) {
wExecScript.call(win, 'null');
wEval = win.eval;
}
forEach(Object_keys(context), function (key) {
win[key] = context[key];
});
@@ -27218,11 +27218,11 @@ Script.prototype.runInContext = function (context) {
win[key] = context[key];
}
});
var winKeys = Object_keys(win);
var res = wEval.call(win, this.code);
forEach(Object_keys(win), function (key) {
// Avoid copying circular objects like `top` and `window` by only
// updating existing context properties or new properties in the `win`
@@ -27237,9 +27237,9 @@ Script.prototype.runInContext = function (context) {
defineProp(context, key, win[key]);
}
});
document.body.removeChild(iframe);
return res;
};

View File

@@ -6,5 +6,5 @@ function convertRippleAdrr(address) {
function convertRipplePriv(priv) {
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
}
}

View File

@@ -173,7 +173,7 @@ bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
};
bitcoinjs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
baseNetwork: "digibyte",
baseNetwork: "digibyte",
messagePrefix: '\x19DigiByte Signed Message:\n',
bech32: 'dgb',
bip32: {
@@ -199,7 +199,7 @@ bitcoinjs.bitcoin.networks.blockstamp.p2wpkh = {
};
bitcoinjs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
baseNetwork: "blockstamp",
baseNetwork: "blockstamp",
messagePrefix: '\x18BlockStamp Signed Message:\n',
bech32: 'bc',
bip32: {
@@ -225,7 +225,7 @@ bitcoinjs.bitcoin.networks.nix.p2wpkh = {
};
bitcoinjs.bitcoin.networks.nix.p2wpkhInP2sh = {
baseNetwork: "nix",
baseNetwork: "nix",
messagePrefix: '\x18Nix Signed Message:\n',
bech32: 'nix',
bip32: {
@@ -236,4 +236,317 @@ bitcoinjs.bitcoin.networks.nix.p2wpkhInP2sh = {
scriptHash: 0x35,
wif: 0x80,
};
bitcoinjs.bitcoin.networks.cpuchain.p2wpkh = {
baseNetwork: "cpuchain",
messagePrefix: '\x1DCPUchain Signed Message:\n',
bech32: 'cpu',
bip32: {
public: 0x04b24746,
private: 0x04b2430c
},
pubKeyHash: 0x1c,
scriptHash: 0x1e,
wif: 0x80,
};
bitcoinjs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
baseNetwork: "cpuchain",
messagePrefix: '\x1DCPUchain Signed Message:\n',
bech32: 'cpu',
bip32: {
public: 0x049d7cb2,
private: 0x049d7878
},
pubKeyHash: 0x1c,
scriptHash: 0x1e,
wif: 0x80,
};
bitcoinjs.bitcoin.networks.monkeyproject.p2wpkh = {
baseNetwork: "monkeyproject",
messagePrefix: 'Monkey Signed Message:\n',
bech32: 'monkey',
bip32: {
public: 0x0488b21e,
private: 0x0488dde4
},
pubKeyHash: 0x33,
scriptHash: 0x1c,
wif: 0x37
};
bitcoinjs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
baseNetwork: "monkeyproject",
messagePrefix: 'Monkey Signed Message:\n',
bech32: 'monkey',
bip32: {
public: 0x0488b21e,
private: 0x0488dde4
},
pubKeyHash: 0x33,
scriptHash: 0x1c,
wif: 0x37
};
bitcoinjs.bitcoin.networks.atom.p2wpkh = {
baseNetwork: "atom",
messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
bech32: 'atom',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4
},
pubKeyHash: 0x17,
scriptHash: 0x0a,
wif: 0x80
};
bitcoinjs.bitcoin.networks.atom.p2wpkhInP2sh = {
baseNetwork: "atom",
messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
bech32: 'atom',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4
},
pubKeyHash: 0x17,
scriptHash: 0x0a,
wif: 0x80
};
bitcoinjs.bitcoin.networks.bitcore.p2wpkh = {
baseNetwork: "bitcore",
messagePrefix: '\x18BitCore Signed Message:\n',
bech32: 'bitcore',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4
},
pubKeyHash: 0x03,
scriptHash: 0x7D,
wif: 0x80
};
bitcoinjs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
baseNetwork: "bitcore",
messagePrefix: '\x18BitCore Signed Message:\n',
bech32: 'bitcore',
bip32: {
public: 0x0488B21E,
private: 0x0488ADE4
},
pubKeyHash: 0x03,
scriptHash: 0x7D,
wif: 0x80
};
bitcoinjs.bitcoin.networks.monacoin.p2wpkh = {
baseNetwork: "monacoin",
messagePrefix: '\x18Monacoin Signed Message:\n',
bech32: 'monacoin',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x32,
scriptHash: 0x37,
wif: 0xb0
};
bitcoinjs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
baseNetwork: "monacoin",
messagePrefix: '\x18Monacoin Signed Message:\n',
bech32: 'monacoin',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x32,
scriptHash: 0x37,
wif: 0xb0
};
bitcoinjs.bitcoin.networks.syscoin.p2wpkh = {
baseNetwork: "syscoin",
messagePrefix: '\x18Syscoin Signed Message:\n',
bech32: 'sys',
bip32: {
public: 0x04b24746,
private: 0x04b2430c
},
pubKeyHash: 0x3f,
scriptHash: 0x05,
wif: 0x80
};
bitcoinjs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
baseNetwork: "syscoin",
messagePrefix: '\x18Syscoin Signed Message:\n',
bech32: 'sys',
bip32: {
public: 0x049d7cb2,
private: 0x049d7878
},
pubKeyHash: 0x3f,
scriptHash: 0x05,
wif: 0x80
};
bitcoinjs.bitcoin.networks.viacoin.p2wpkh = {
baseNetwork: "viacoin",
messagePrefix: '\x18Viacoin Signed Message:\n',
bech32: 'viacoin',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x47,
scriptHash: 0x21,
wif: 0xc7
};
bitcoinjs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
baseNetwork: "viacoin",
messagePrefix: '\x18Viacoin Signed Message:\n',
bech32: 'viacoin',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x47,
scriptHash: 0x21,
wif: 0xc7
};
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
baseNetwork: "dogecointestnet",
messagePrefix: '\x19Dogecoin Signed Message:\n',
bech32: 'dogecointestnet',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x71,
scriptHash: 0xc4,
wif: 0xf1
};
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
baseNetwork: "dogecointestnet",
messagePrefix: '\x19Dogecoin Signed Message:\n',
bech32: 'dogecointestnet',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x71,
scriptHash: 0xc4,
wif: 0xf1
};
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
baseNetwork: "dogecointestnet",
messagePrefix: '\x19Dogecoin Signed Message:\n',
bech32: 'dogecointestnet',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x71,
scriptHash: 0xc4,
wif: 0xf1
};
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
baseNetwork: "dogecointestnet",
messagePrefix: '\x19Dogecoin Signed Message:\n',
bech32: 'dogecointestnet',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x71,
scriptHash: 0xc4,
wif: 0xf1
};
bitcoinjs.bitcoin.networks.litecointestnet.p2wpkh = {
baseNetwork: "litecointestnet",
messagePrefix: '\x18Litecoin Signed Message:\n',
bech32: 'litecointestnet',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef
};
bitcoinjs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
baseNetwork: "litecointestnet",
messagePrefix: '\x18Litecoin Signed Message:\n',
bech32: 'litecointestnet',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef
};
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkh = {
baseNetwork: "groestlcoin",
messagePrefix: '\x19GroestlCoin Signed Message:\n',
bech32: 'grs',
bip32: {
public: 0x04b24746,
private: 0x04b2430c
},
pubKeyHash: 0x24,
scriptHash: 0x05,
wif: 0x80,
};
bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkh = {
baseNetwork: "groestlcointestnet",
messagePrefix: '\x19GroestlCoin Signed Message:\n',
bech32: 'tgrs',
bip32: {
public: 0x045f1cf6,
private: 0x045f18bc
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef
};
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
baseNetwork: "groestlcoin",
messagePrefix: '\x19GroestlCoin Signed Message:\n',
bech32: 'grs',
bip32: {
public: 0x049d7cb2,
private: 0x049d7878
},
pubKeyHash: 0x24,
scriptHash: 0x05,
wif: 0x80,
};
bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
baseNetwork: "groestlcointestnet",
messagePrefix: '\x19GroestlCoin Signed Message:\n',
bech32: 'tgrs',
bip32: {
public: 0x044a5262,
private: 0x044a4e28
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef
};
})();

View File

@@ -26,13 +26,13 @@ var sjcl = {
/** @namespace Key exchange functions. Right now only SRP is implemented. */
keyexchange: {},
/** @namespace Block cipher modes of operation. */
mode: {},
/** @namespace Miscellaneous. HMAC and PBKDF2. */
misc: {},
/**
* @namespace Bit array encoders and decoders.
*
@@ -43,7 +43,7 @@ var sjcl = {
* the method names are "fromBits" and "toBits".
*/
codec: {},
/** @namespace Exceptions. */
exception: {
/** @constructor Ciphertext is corrupt. */
@@ -51,13 +51,13 @@ var sjcl = {
this.toString = function() { return "CORRUPT: "+this.message; };
this.message = message;
},
/** @constructor Invalid parameter. */
invalid: function(message) {
this.toString = function() { return "INVALID: "+this.message; };
this.message = message;
},
/** @constructor Bug or missing feature in SJCL. @constructor */
bug: function(message) {
this.toString = function() { return "BUG: "+this.message; };
@@ -159,7 +159,7 @@ sjcl.bitArray = {
if (a1.length === 0 || a2.length === 0) {
return a1.concat(a2);
}
var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
if (shift === 32) {
return a1.concat(a2);
@@ -245,7 +245,7 @@ sjcl.bitArray = {
_shiftRight: function (a, shift, carry, out) {
var i, last2=0, shift2;
if (out === undefined) { out = []; }
for (; shift >= 32; shift -= 32) {
out.push(carry);
carry = 0;
@@ -253,7 +253,7 @@ sjcl.bitArray = {
if (shift === 0) {
return out.concat(a);
}
for (i=0; i<a.length; i++) {
out.push(carry | a[i]>>>shift);
carry = a[i] << (32-shift);
@@ -263,7 +263,7 @@ sjcl.bitArray = {
out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
return out;
},
/** xor a block of 4 words together.
* @private
*/
@@ -295,7 +295,7 @@ sjcl.bitArray = {
* @author Mike Hamburg
* @author Dan Boneh
*/
/** @namespace UTF-8 strings */
sjcl.codec.utf8String = {
/** Convert from a bitArray to a UTF-8 string. */
@@ -310,7 +310,7 @@ sjcl.codec.utf8String = {
}
return decodeURIComponent(escape(out));
},
/** Convert from a UTF-8 string to a bitArray. */
toBits: function (str) {
str = unescape(encodeURIComponent(str));
@@ -412,7 +412,7 @@ sjcl.hash.sha512.prototype = {
* @constant
*/
blockSize: 1024,
/**
* Reset the hash state.
* @return this
@@ -423,7 +423,7 @@ sjcl.hash.sha512.prototype = {
this._length = 0;
return this;
},
/**
* Input several words to the hash.
* @param {bitArray|String} data the data to hash.
@@ -441,7 +441,7 @@ sjcl.hash.sha512.prototype = {
}
return this;
},
/**
* Complete hashing and output the hash value.
* @return {bitArray} The hash value, an array of 16 big-endian words.
@@ -736,12 +736,12 @@ sjcl.misc.hmac = function (key, Hash) {
if (key.length > bs) {
key = Hash.hash(key);
}
for (i=0; i<bs; i++) {
exKey[0][i] = key[i]^0x36363636;
exKey[1][i] = key[i]^0x5C5C5C5C;
}
this._baseHash[0].update(exKey[0]);
this._baseHash[1].update(exKey[1]);
this._resultHash = new Hash(this._baseHash[0]);
@@ -804,34 +804,34 @@ sjcl.misc.hmac.prototype.digest = function () {
*/
sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
count = count || 1000;
if (length < 0 || count < 0) {
throw sjcl.exception.invalid("invalid params to pbkdf2");
}
if (typeof password === "string") {
password = sjcl.codec.utf8String.toBits(password);
}
if (typeof salt === "string") {
salt = sjcl.codec.utf8String.toBits(salt);
}
Prff = Prff || sjcl.misc.hmac;
var prf = new Prff(password),
u, ui, i, j, k, out = [], b = sjcl.bitArray;
for (k = 1; 32 * out.length < (length || 1); k++) {
u = ui = prf.encrypt(b.concat(salt,[k]));
for (i=1; i<count; i++) {
ui = prf.encrypt(ui);
for (j=0; j<ui.length; j++) {
u[j] ^= ui[j];
}
}
out = out.concat(u);
}
@@ -890,7 +890,7 @@ sjcl.hash.sha256.prototype = {
* @constant
*/
blockSize: 512,
/**
* Reset the hash state.
* @return this
@@ -901,7 +901,7 @@ sjcl.hash.sha256.prototype = {
this._length = 0;
return this;
},
/**
* Input several words to the hash.
* @param {bitArray|String} data the data to hash.
@@ -919,7 +919,7 @@ sjcl.hash.sha256.prototype = {
}
return this;
},
/**
* Complete hashing and output the hash value.
* @return {bitArray} The hash value, an array of 8 big-endian words.
@@ -929,12 +929,12 @@ sjcl.hash.sha256.prototype = {
// Round out and push the buffer
b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
// Round out the buffer to a multiple of 16 words, less the 2 length words.
for (i = b.length + 2; i & 15; i++) {
b.push(0);
}
// append the length
b.push(Math.floor(this._length / 0x100000000));
b.push(this._length | 0);
@@ -955,7 +955,7 @@ sjcl.hash.sha256.prototype = {
/*
_init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
*/
/**
* The SHA-256 hash key, to be precomputed.
* @private
@@ -990,7 +990,7 @@ sjcl.hash.sha256.prototype = {
continue outer;
}
}
if (i<8) {
this._init[i] = frac(Math.pow(prime, 1/2));
}
@@ -998,13 +998,13 @@ sjcl.hash.sha256.prototype = {
i++;
}
},
/**
* Perform one cycle of SHA-256.
* @param {bitArray} words one block of words.
* @private
*/
_block:function (words) {
_block:function (words) {
var i, tmp, a, b,
w = words.slice(0),
h = this._h,
@@ -1032,13 +1032,13 @@ sjcl.hash.sha256.prototype = {
} else {
a = w[(i+1 ) & 15];
b = w[(i+14) & 15];
tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
(b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
w[i&15] + w[(i+9) & 15]) | 0;
}
tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
// shift register
h7 = h6; h6 = h5; h5 = h4;
h4 = h3 + tmp | 0;

View File

@@ -13146,7 +13146,7 @@ Cursor.prototype.fill = function(value, length)
{
length = this.buffer().length - this.tell();
}
this.buffer().fill(value, this.tell(), this.tell() + length);
this.seek('+', length);
@@ -42404,13 +42404,13 @@ Script.prototype.runInContext = function (context) {
if (!(context instanceof Context)) {
throw new TypeError("needs a 'context' argument.");
}
var iframe = document.createElement('iframe');
if (!iframe.style) iframe.style = {};
iframe.style.display = 'none';
document.body.appendChild(iframe);
var win = iframe.contentWindow;
var wEval = win.eval, wExecScript = win.execScript;
@@ -42419,7 +42419,7 @@ Script.prototype.runInContext = function (context) {
wExecScript.call(win, 'null');
wEval = win.eval;
}
forEach(Object_keys(context), function (key) {
win[key] = context[key];
});
@@ -42428,11 +42428,11 @@ Script.prototype.runInContext = function (context) {
win[key] = context[key];
}
});
var winKeys = Object_keys(win);
var res = wEval.call(win, this.code);
forEach(Object_keys(win), function (key) {
// Avoid copying circular objects like `top` and `window` by only
// updating existing context properties or new properties in the `win`
@@ -42447,9 +42447,9 @@ Script.prototype.runInContext = function (context) {
defineProp(context, key, win[key]);
}
});
document.body.removeChild(iframe);
return res;
};

View File

@@ -434,6 +434,14 @@ it('Allows selection of ripple', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of casinocoin', function(done) {
var params = {
selectText: "CSC - CasinoCoin",
firstAddress: "c3P5EUb27Pzk9dcGt4s7zQDQj4sC6Y81mT",
phrase: "ill clump only blind unit burden thing track silver cloth review awake useful craft whale all satisfy else trophy sunset walk vanish hope valve",
};
testNetwork(done, params);
});
it('Allows selection of dogecoin', function(done) {
var params = {
selectText: "DOGE - Dogecoin",
@@ -724,6 +732,13 @@ it('Allows selection of Asiacoin', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of Aryacoin', function(done) {
var params = {
selectText: "ARYA - Aryacoin",
firstAddress: "Abr6gX25KaU9BpwD34UfsL3A4n89NvYYSf",
};
testNetwork(done, params);
});
it('Allows selection of Auroracoin', function(done) {
var params = {
selectText: "AUR - Auroracoin",
@@ -766,6 +781,13 @@ it('Allows selection of Bitcoin Private', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of Bitcoin SV', function(done) {
var params = {
selectText: "BSV - BitcoinSV",
firstAddress: "1N4mgtE5yxifch9jWs7Sds6oVqxdy2t576",
};
testNetwork(done, params);
});
it('Allows selection of Bitcoinz', function(done) {
var params = {
selectText: "BTCZ - Bitcoinz",
@@ -829,6 +851,13 @@ it('Allows selection of Compcoin', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of CPUchain', function(done) {
var params = {
selectText: "CPU - CPUchain",
firstAddress: "CWSpLpW7jS4mBHJnkz3mmL5s3yQMg93zK8",
};
testNetwork(done, params);
});
it('Allows selection of Crave', function(done) {
var params = {
selectText: "CRAVE - Crave",
@@ -1165,6 +1194,13 @@ it('Allows selection of Putincoin', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of Rapids', function(done) {
var params = {
selectText: "RPD - Rapids",
firstAddress: "Ri8XxUdZaXS5LqxmFJcFEjFinkaMbmhSUp",
};
testNetwork(done, params);
});
it('Allows selection of Ravencoin', function(done) {
var params = {
selectText: "RVN - Ravencoin",
@@ -1319,6 +1355,13 @@ it('Allows selection of Vpncoin', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of VeChain', function(done) {
var params = {
selectText: "VET - VeChain",
firstAddress: "0xdba55B1B6070f3a733D5eDFf35F0da4A00E455F2",
};
testNetwork(done, params);
});
it('Allows selection of Whitecoin', function(done) {
var params = {
selectText: "XWC - Whitecoin",
@@ -1354,9 +1397,9 @@ it('Allows selection of Zclassic', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of Zencash', function(done) {
it('Allows selection of Horizen', function(done) {
var params = {
selectText: "ZEN - Zencash",
selectText: "ZEN - Horizen",
firstAddress: "znWh9XASyW2dZq5tck84wFjiwuqVysi7q3p",
};
testNetwork(done, params);
@@ -1389,6 +1432,14 @@ it('Allows selection of MIX', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of Monkey Project', function(done) {
var params = {
selectText: "MONK - Monkey Project",
firstAddress: "MnLrcnnUzKnf7TzufjRe5DLZqQJz18oYyu",
};
testNetwork(done, params);
});
it('Allows selection of Musicoin', function(done) {
var params = {
selectText: "MUSIC - Musicoin",
@@ -1419,11 +1470,18 @@ it('Allows selection of Callisto', function(done) {
});
it('Allows selection of HUSH', function(done) {
var params = {
selectText: "HUSH - Hush",
selectText: "HUSH - Hush (Legacy)",
firstAddress: "t1g6rLXUnJaiJuu4q4zmJjoa9Gk4fwKpiuA",
};
testNetwork(done, params);
});
it('Allows selection of HUSH3', function(done) {
var params = {
selectText: "HUSH - Hush3",
firstAddress: "RXWSQhwvw5jHPGP8bjwJhWoRnMLBnuPDKD",
};
testNetwork(done, params);
});
it('Allows selection of ExchangeCoin', function(done) {
var params = {
selectText: "EXCC - ExchangeCoin",
@@ -1529,6 +1587,48 @@ it('Allows selection of Stellar', function(done) {
};
testNetwork(done, params);
});
it('Allows selection of Wagerr', function(done) {
var params = {
selectText: "WGR - Wagerr",
firstAddress: "WYiVgQU39VcQxcnacoCiaZHZZLjDCJoS95",
};
testNetwork(done, params);
});
it('Allows selection of Groestlcoin', function(done) {
var params = {
selectText: "GRS - Groestlcoin",
firstAddress: "FZycsFvZ1eH1hbtyjBpAgJSukVw1bN6PBN",
};
testNetwork(done, params);
});
it('Allows selection of Groestlcoin Testnet', function(done) {
var params = {
selectText: "GRS - Groestlcoin Testnet",
firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiygRPne9",
};
testNetwork(done, params);
});
it('Allows selection of Elastos', function(done) {
var params = {
selectText: "ELA - Elastos",
firstAddress: "EMccDcsn3SwPDcfeQMf3w7utqi8ioWYtkg",
};
testNetwork(done, params);
});
it('Allows selection of Energyweb', function(done) {
var params = {
selectText: "EWT - EnergyWeb",
firstAddress: "0x22171474844Fc7E8E99A3A69CCf1eDb5574FdD4c",
};
testNetwork(done, params);
});
it('Allows selection of Thought', function(done) {
var params = {
selectText: "THT - Thought",
firstAddress: "4B1Bh9GibDarFQrhtYU8krpc7WSjgGfYvo",
};
testNetwork(done, params);
});
// BIP39 seed is set from phrase
it('Sets the bip39 seed from the prhase', function(done) {
@@ -2109,6 +2209,7 @@ it('Ignores excess whitespace in the mnemonic', function(done) {
// Github Issue 23: Part 1: Use correct derivation path when changing tabs
// https://github.com/iancoleman/bip39/issues/23
// This test was failing for default timeout of 5000ms so changed it to +10s
it('Uses the correct derivation path when changing tabs', function(done) {
// 1) and 2) set the phrase
driver.findElement(By.css('.phrase'))
@@ -2133,7 +2234,7 @@ it('Uses the correct derivation path when changing tabs', function(done) {
});
});
});
});
}, generateDelay + 10000);
// Github Issue 23 Part 2: Coin selection in derivation path
// https://github.com/iancoleman/bip39/issues/23#issuecomment-238011920
@@ -3991,6 +4092,27 @@ it('Shows litecoin BIP49 addresses', function(done) {
});
});
it('Shows Groestlcoin BIP49 addresses', function(done) {
driver.findElement(By.css('.phrase'))
.sendKeys('abandon abandon ability');
selectNetwork("GRS - Groestlcoin");
driver.findElement(By.css('#bip49-tab a'))
.click()
// bip49 addresses are shown
driver.sleep(generateDelay).then(function() {
driver.findElement(By.css('#bip49 .available'))
.getAttribute("class")
.then(function(classes) {
expect(classes).not.toContain("hidden");
// check first address
getFirstAddress(function(address) {
expect(address).toBe("3HXSCZwCypLyixMsF4Z1sN49noJtrm8gnX");
done();
});
});
});
});
it('Can use root keys to generate segwit table rows', function(done) {
// segwit uses ypub / zpub instead of xpub but the root key should still
// be valid regardless of the encoding used to import that key.
@@ -4010,4 +4132,57 @@ it('Can use root keys to generate segwit table rows', function(done) {
});
});
// Pull Request 271
// Allow converting mnemonic back to raw entropy value
it('Converts mnemonics into raw entropy', function(done) {
driver.findElement(By.css('.phrase'))
.sendKeys('abandon abandon about');
driver.sleep(generateDelay).then(function() {
driver.findElement(By.css('.use-entropy'))
.click();
driver.findElement(By.css('.entropy'))
.getAttribute("value")
.then(function(entropy) {
expect(entropy).toBe("00000000000000000000000000000001");
driver.findElement(By.css('.phrase'))
.getAttribute("value")
.then(function(phrase) {
expect(phrase).toBe("abandon abandon about");
done();
});
});
});
});
// Pull Request 279
// Added Split Phrase Card Output
it('Shows split prase cards', function(done) {
var originalPhrase = "ugly charge strong giant once anchor capable october thumb inject dwarf legal alley mixture shoot";
var originalWords = originalPhrase.split(' ');
driver.findElement(By.css('.phrase'))
.sendKeys(originalPhrase);
driver.sleep(generateDelay).then(function() {
driver.findElement(By.css('.phraseSplit'))
.getAttribute("value")
.then(function(cardsStr) {
var cards = cardsStr.split("\n");
expect(cards.length).toBe(3);
// test all 2-of-3 combos can be used to form full phrase
var combos = [[0,1],[0,2],[1,2]];
for (var i=0; i<combos.length; i++) {
var combo = combos[i];
var a = combo[0];
var b = combo[1];
var phrase = cards[a] + " " + cards[b];
// check all original words are present
for (var j=0; j<originalWords.length; j++) {
var originalWord = originalWords[j];
expect(phrase).toContain(originalWord);
}
}
done();
});
});
});
});