mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-06 19:03:49 +00:00
Compare commits
316 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90f7a5ec93 | ||
|
|
dd496c82c1 | ||
|
|
1dafc30db4 | ||
|
|
927450e169 | ||
|
|
a67554c649 | ||
|
|
0bc6361db4 | ||
|
|
a98d40c43d | ||
|
|
54a8e781b4 | ||
|
|
c1d6274224 | ||
|
|
c16661aeea | ||
|
|
e9491c7efd | ||
|
|
d07983bc1f | ||
|
|
3aa7677ace | ||
|
|
9e04576e2f | ||
|
|
8131a07115 | ||
|
|
181b5d61e3 | ||
|
|
4dfc681f71 | ||
|
|
dfb4fd1be5 | ||
|
|
aa793f572f | ||
|
|
6973e692b0 | ||
|
|
22f8766947 | ||
|
|
8017442c50 | ||
|
|
82cf26c1cb | ||
|
|
206cbafceb | ||
|
|
9cf02dd452 | ||
|
|
f12242014d | ||
|
|
244c76022a | ||
|
|
516c16d721 | ||
|
|
f7e9fdf002 | ||
|
|
5c203fab6a | ||
|
|
40d542ba58 | ||
|
|
cc3c35487f | ||
|
|
76531b610a | ||
|
|
c845ee6f6e | ||
|
|
c394ec3c4f | ||
|
|
55367b989e | ||
|
|
732613e44c | ||
|
|
9ce31d3509 | ||
|
|
f8fae68efb | ||
|
|
93f3a286db | ||
|
|
3799728c76 | ||
|
|
b130271b2b | ||
|
|
ea2cb91a49 | ||
|
|
bfe1963eaa | ||
|
|
a04946e23e | ||
|
|
700294714c | ||
|
|
d93f2ba9f0 | ||
|
|
96ee8ab0a0 | ||
|
|
659b06a7b8 | ||
|
|
653538cd3a | ||
|
|
1ba5816184 | ||
|
|
0a23f51792 | ||
|
|
b9b3eaf670 | ||
|
|
7b29420f1a | ||
|
|
909297015e | ||
|
|
c7a092db32 | ||
|
|
de5fe245cc | ||
|
|
4dc041d77e | ||
|
|
7cfd04e318 | ||
|
|
d0428a8d21 | ||
|
|
3dbf117928 | ||
|
|
342ff964aa | ||
|
|
75138beed9 | ||
|
|
36523e0d97 | ||
|
|
44e705cd31 | ||
|
|
3e2af09e07 | ||
|
|
907172d6f0 | ||
|
|
394bce7c9e | ||
|
|
bc32c84166 | ||
|
|
76120cb0b4 | ||
|
|
385ee32fd4 | ||
|
|
5b689bd6e7 | ||
|
|
ac537983d9 | ||
|
|
5b2edb3998 | ||
|
|
eee4a60b35 | ||
|
|
dedb054fd8 | ||
|
|
079635cba1 | ||
|
|
5db3540e89 | ||
|
|
b502adc910 | ||
|
|
cab37a96c4 | ||
|
|
b603572295 | ||
|
|
8817e2487a | ||
|
|
c6c86591a9 | ||
|
|
5d1bb7d776 | ||
|
|
ea96c345cc | ||
|
|
318ec4dc9f | ||
|
|
ec38b3a263 | ||
|
|
9cec5dd2b7 | ||
|
|
31264e8bea | ||
|
|
e440d504fb | ||
|
|
786cd442cd | ||
|
|
9f675f2e47 | ||
|
|
e5c4aa4098 | ||
|
|
45e40c288f | ||
|
|
519e9dc728 | ||
|
|
67f18e2a63 | ||
|
|
c4f4208b95 | ||
|
|
881fbe2234 | ||
|
|
c7a1a00040 | ||
|
|
6aa2c1d26d | ||
|
|
9e836ac8e6 | ||
|
|
e2186682ac | ||
|
|
152f0ce966 | ||
|
|
084ff40d4f | ||
|
|
b244e34403 | ||
|
|
e33f4b2704 | ||
|
|
6c733477db | ||
|
|
a36c509c91 | ||
|
|
7d4e4cbe26 | ||
|
|
82e3938afe | ||
|
|
06cd4e7608 | ||
|
|
8b569deeae | ||
|
|
ad59508d7c | ||
|
|
562ece8004 | ||
|
|
8e3b890d26 | ||
|
|
6f53a445ee | ||
|
|
858c29e3be | ||
|
|
5a085aed79 | ||
|
|
7d68d5474e | ||
|
|
21e2e6c951 | ||
|
|
7f59c88dbc | ||
|
|
b85da0745a | ||
|
|
0ae59396f5 | ||
|
|
3451d1a81b | ||
|
|
22bb112ead | ||
|
|
af14981d83 | ||
|
|
9f3c111766 | ||
|
|
c2e4f93870 | ||
|
|
8e2d37d450 | ||
|
|
29040f3c8b | ||
|
|
6746a9a45e | ||
|
|
c768923b77 | ||
|
|
0d0099e633 | ||
|
|
bea736aeae | ||
|
|
31190ced31 | ||
|
|
575ee4de2c | ||
|
|
dfa696859a | ||
|
|
32b5b0363f | ||
|
|
c69e40942e | ||
|
|
8cb07685fd | ||
|
|
81a5a871d9 | ||
|
|
3e7b1ac938 | ||
|
|
16afe3ecbf | ||
|
|
2885ddd5f7 | ||
|
|
f9ab643475 | ||
|
|
17bb7e6953 | ||
|
|
b615704d4a | ||
|
|
c47f0030ec | ||
|
|
cb0300fc7b | ||
|
|
7cbfce747a | ||
|
|
dd99c5fde9 | ||
|
|
c4a09d67eb | ||
|
|
bf13c95fb0 | ||
|
|
30d6779baa | ||
|
|
d0889ab9de | ||
|
|
478e54ad47 | ||
|
|
3b36d6c3ba | ||
|
|
b9f4ee2d4e | ||
|
|
1b419bc615 | ||
|
|
961df0a5a5 | ||
|
|
491948dbcb | ||
|
|
7a11300336 | ||
|
|
dba22db54d | ||
|
|
6cbd3bc8c2 | ||
|
|
74762b369e | ||
|
|
5d7f36e9b2 | ||
|
|
b0be9d8b60 | ||
|
|
9d9fefbb28 | ||
|
|
584d1a41c7 | ||
|
|
a938c2f5a5 | ||
|
|
9f83f0fcd7 | ||
|
|
10980ed68c | ||
|
|
da6b42b2f0 | ||
|
|
5dcc0ce632 | ||
|
|
a34543f81e | ||
|
|
869f5375eb | ||
|
|
47d719a493 | ||
|
|
8aa5ad6ded | ||
|
|
a8cf5a4fd9 | ||
|
|
5c1ad0856a | ||
|
|
d2be7b6fd6 | ||
|
|
f22f7677a6 | ||
|
|
497fcf0e48 | ||
|
|
cceb518d09 | ||
|
|
ae27549baf | ||
|
|
8ba31a8985 | ||
|
|
4735db1064 | ||
|
|
612d6b4206 | ||
|
|
d354a1dfab | ||
|
|
d52d3f3784 | ||
|
|
22c443df83 | ||
|
|
8ffa333bc9 | ||
|
|
717a3ffcb2 | ||
|
|
d4fcdda9fb | ||
|
|
7f65b685b3 | ||
|
|
acf4c9b588 | ||
|
|
10cf809e7c | ||
|
|
3b6786bd51 | ||
|
|
5cdbe4620a | ||
|
|
8253325365 | ||
|
|
d100f3c0cb | ||
|
|
c1322c7c89 | ||
|
|
d9b5b5d0de | ||
|
|
20d077e3af | ||
|
|
97bde20b84 | ||
|
|
b1100c66eb | ||
|
|
d645b98261 | ||
|
|
31b846cf99 | ||
|
|
f1f1e39f89 | ||
|
|
3e4551b082 | ||
|
|
1fe8f5195f | ||
|
|
6f43581752 | ||
|
|
ce349ac99f | ||
|
|
38d1b296df | ||
|
|
a51ef005ac | ||
|
|
e066f14ecf | ||
|
|
628a2f53d4 | ||
|
|
f40c5c2423 | ||
|
|
65afae0b5e | ||
|
|
3381604035 | ||
|
|
ba637be876 | ||
|
|
611f76238d | ||
|
|
011533e4bc | ||
|
|
d2ba387163 | ||
|
|
64425922ae | ||
|
|
cd4425ece7 | ||
|
|
8a516f5529 | ||
|
|
455886617d | ||
|
|
8b2a093c8b | ||
|
|
37f237239a | ||
|
|
cd8893f6c9 | ||
|
|
7ef0db981f | ||
|
|
c4086c2413 | ||
|
|
2866e9d4d4 | ||
|
|
5ed5f6612d | ||
|
|
8c849703eb | ||
|
|
2575538b25 | ||
|
|
376ea8c46d | ||
|
|
a44c45e3c0 | ||
|
|
341700110b | ||
|
|
0529ca55fa | ||
|
|
9f6352d696 | ||
|
|
01e0ec16b9 | ||
|
|
54348219db | ||
|
|
23183e61af | ||
|
|
7d6078040d | ||
|
|
04ec88af5c | ||
|
|
5a1494327f | ||
|
|
e76cd8fbf3 | ||
|
|
7878bb3295 | ||
|
|
43e5cabfcf | ||
|
|
c1a5e79c5f | ||
|
|
3eee87560b | ||
|
|
74f0021ed0 | ||
|
|
d2f5d28e33 | ||
|
|
67df560a3c | ||
|
|
ae51db39a3 | ||
|
|
efe95a35c1 | ||
|
|
8103d17b09 | ||
|
|
e47cd1970f | ||
|
|
d221cd2f37 | ||
|
|
fe3c963b73 | ||
|
|
42fcf83e9b | ||
|
|
b7de1f3d89 | ||
|
|
0afecfc73c | ||
|
|
44a5d363c7 | ||
|
|
f83d786dd7 | ||
|
|
83fefeaf0b | ||
|
|
9d4e17928a | ||
|
|
0f9081e2b5 | ||
|
|
60727c5175 | ||
|
|
0d9c6c5458 | ||
|
|
c990aff819 | ||
|
|
4b1be40dea | ||
|
|
b4d881fbd0 | ||
|
|
cc9ed1c575 | ||
|
|
3b43552ceb | ||
|
|
e96d3876c4 | ||
|
|
0f1cfea04c | ||
|
|
9369eaa6d5 | ||
|
|
4218c87458 | ||
|
|
2ab3faf414 | ||
|
|
6db7516d4a | ||
|
|
0b6e351dce | ||
|
|
6f7fa3539e | ||
|
|
7733ac322b | ||
|
|
530648c174 | ||
|
|
c147cb5e4f | ||
|
|
bddd5d9f95 | ||
|
|
cbd0625ff7 | ||
|
|
bd06face96 | ||
|
|
5c3143888e | ||
|
|
55b878d8d5 | ||
|
|
370e201901 | ||
|
|
6df5b2a100 | ||
|
|
29c30bf33a | ||
|
|
bda303dd53 | ||
|
|
bb381a72ab | ||
|
|
35d9e9fddc | ||
|
|
1e2cc748b0 | ||
|
|
f62138da71 | ||
|
|
95edc76985 | ||
|
|
7d9b5f6871 | ||
|
|
24355c461b | ||
|
|
4b250c83eb | ||
|
|
e32531d9a9 | ||
|
|
ccdd300af3 | ||
|
|
e0f91e2029 | ||
|
|
956e44efd7 | ||
|
|
65cef19412 | ||
|
|
0702ecd352 | ||
|
|
584dbddd37 | ||
|
|
b08caad07e | ||
|
|
f150f0c03a | ||
|
|
e3bed0bfd0 | ||
|
|
0a5d28a7ad |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
node_modules
|
||||
bip39-standalone.html
|
||||
|
||||
99222
bip39-standalone.html
99222
bip39-standalone.html
File diff suppressed because one or more lines are too long
136
changelog.md
136
changelog.md
@@ -1,3 +1,139 @@
|
||||
# 0.4.2
|
||||
|
||||
* Fix ethereum private key format
|
||||
|
||||
# 0.4.1
|
||||
|
||||
* Fix no loading on chrome with third-party cookies blocked
|
||||
* Add EtherCore
|
||||
* Add RSK network
|
||||
* Add DeepOnion segwit parameters
|
||||
* Fix ethereum xpub derivation
|
||||
|
||||
# 0.4.0
|
||||
|
||||
* Third party libraries deduplicated and minified
|
||||
* Add text reminder for multibit wallet change addresses
|
||||
* Seed field can be edited
|
||||
* Add bitcoin regtest parameters
|
||||
* Mnemonic conversion to entropy is hex encoded instead of binary
|
||||
* Entropy type can be manually selected
|
||||
* Add Bitcoin P2WSH and P2WSH-P2SH
|
||||
* Add Czech language
|
||||
|
||||
# 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
|
||||
* Fix DigiByte signing message
|
||||
* Add DeepOnion network
|
||||
* Add EOS network
|
||||
* Add LTC testnetwork
|
||||
* Add DOGE testnetwork
|
||||
* Add Stellar network
|
||||
* Add TWINS network
|
||||
* Add FIX network
|
||||
|
||||
# 0.3.11
|
||||
|
||||
* Add NIX network
|
||||
* Fix coin parameters for NMC, XMY, CLAM, ONX, LKR
|
||||
* Add DEXON network
|
||||
* Add Nebulas network
|
||||
* Add LSP network
|
||||
* Fix Crown network address format
|
||||
* Add Ellaism network
|
||||
* Add Etheresocial network
|
||||
* Add Bolivarcoin network
|
||||
* Force spellcheck and autocomplete to be off
|
||||
|
||||
# 0.3.10
|
||||
|
||||
* Add Phore network
|
||||
* Add Blocknode network
|
||||
* Add Ravencoin network
|
||||
* Add Safecoin network
|
||||
* Add LitecoinZ network
|
||||
* Add LKRcoin network
|
||||
* Update Peercoin scripthash parameter
|
||||
* Add Blockstamp network
|
||||
* Remove old info regarding use of private keys
|
||||
|
||||
# 0.3.9
|
||||
|
||||
* Update BTG signing message
|
||||
* Add segwit parameters for BTG
|
||||
* Add segwit parameters for DigiByte
|
||||
* Add Stash network (see 0.3.8s below)
|
||||
* Add Salus network
|
||||
* Add Cryptoescudo network
|
||||
* Add ExchangeCoin network
|
||||
* Add Artax network
|
||||
* Add BitCloud network
|
||||
* Add Megacoin network
|
||||
* Add Bitcoin Green network
|
||||
* Add ANON network
|
||||
* Add ProjectCoin network
|
||||
* Reword the 'generate' inputs and words
|
||||
* Add note for running http server in python 2
|
||||
* Adjust test to run reliably on slow computers
|
||||
|
||||
# 0.3.8s
|
||||
|
||||
* Add Stash network
|
||||
|
||||
# 0.3.8
|
||||
|
||||
* Add p2wpkh for litecoin
|
||||
* Add more networks - TSTRAT, Hush, ETC, PIRL, CLO, MIX, MUSIC, POA, EXP
|
||||
* Add coinomi/ledger client to BIP32 tab
|
||||
* Fix SYSCOIN and BTX parameters
|
||||
* Remove bip39-standalone.html from repository
|
||||
* Remove duplicate id properties on html elements
|
||||
|
||||
# 0.3.7
|
||||
|
||||
* Update AXE network parameters
|
||||
* Add new networks - Xuez, BTCP, BTCZ, ZCL, ZEN
|
||||
* Add litecoin bech32 params
|
||||
* Fix BIP38 for altcoins
|
||||
* Fix missing span closing tag
|
||||
* Add indicator to UI for when BIP84 is unavailable
|
||||
* Replace hasSegwit variable with test for segwit params
|
||||
* Allow xpub to be used as root key for segwit derivations
|
||||
* Add visual privacy safeguard
|
||||
|
||||
# 0.3.6
|
||||
|
||||
* Add Kobocoin
|
||||
* Update Vertcoin version byte and segwit support
|
||||
* Add Zcash
|
||||
* Korean mnemonics use ascii spaces
|
||||
* Add CashAddr address format for bitcoin cash
|
||||
|
||||
# 0.3.5
|
||||
|
||||
* Fix typo
|
||||
|
||||
22
libs/base-x/LICENSE.md
Normal file
22
libs/base-x/LICENSE.md
Normal 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
44
libs/base-x/package.json
Normal 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
4
libs/base-x/readme.md
Normal 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
161
libs/base-x/ts_src/index.ts
Normal 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
31
libs/base-x/tsconfig.json
Normal 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/**/*"
|
||||
]
|
||||
}
|
||||
244
libs/bitcoinjs-bip38/index.js
Normal file
244
libs/bitcoinjs-bip38/index.js
Normal 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
|
||||
}
|
||||
38
libs/bitcoinjs-bip38/package.json
Normal file
38
libs/bitcoinjs-bip38/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
4
libs/bitcoinjs-bip38/readme.md
Normal file
4
libs/bitcoinjs-bip38/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/bitcoinjs-bip38.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
5
libs/bitcoinjs-lib/bitcoinjs-lib.js
Normal file
5
libs/bitcoinjs-lib/bitcoinjs-lib.js
Normal file
@@ -0,0 +1,5 @@
|
||||
let bitcoin = require('bitcoinjs-lib')
|
||||
|
||||
module.exports = {
|
||||
bitcoin
|
||||
}
|
||||
14
libs/bitcoinjs-lib/package.json
Normal file
14
libs/bitcoinjs-lib/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
5
libs/bitcoinjs-lib/readme.md
Normal file
5
libs/bitcoinjs-lib/readme.md
Normal 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
|
||||
89
libs/combined/index.js
Normal file
89
libs/combined/index.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/* base-x */
|
||||
|
||||
module.exports.basex = require('base-x')
|
||||
|
||||
/* bchaddrjs */
|
||||
|
||||
module.exports.bchaddr = require('bchaddrjs')
|
||||
|
||||
/* bchaddrjs slp */
|
||||
|
||||
module.exports.bchaddrSlp = require('bchaddrjs-slp')
|
||||
|
||||
/* biginteger */
|
||||
|
||||
module.exports.BigInteger = require('javascript-biginteger')
|
||||
|
||||
/* bitcoinjs-bip38 */
|
||||
|
||||
module.exports.bip38 = require('bip38')
|
||||
|
||||
/* bitcoinjs-lib */
|
||||
|
||||
module.exports.bitcoin = require('bitcoinjs-lib')
|
||||
|
||||
/* buffer */
|
||||
|
||||
module.exports.buffer = require('buffer');
|
||||
|
||||
/* elastos */
|
||||
// See https://github.com/iancoleman/bip39/pull/368
|
||||
// and https://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript/tree/iancoleman-bip39
|
||||
|
||||
module.exports.elastosjs = require('elastos-wallet-js')
|
||||
|
||||
/* ethereum-util */
|
||||
|
||||
module.exports.ethUtil = require('ethereumjs-util')
|
||||
|
||||
/* fast-levenshtein */
|
||||
|
||||
module.exports.levenshtein = require('fast-levenshtein')
|
||||
|
||||
/* groestlcoin */
|
||||
|
||||
module.exports.groestlcoinjs = require('groestlcoinjs-lib')
|
||||
|
||||
/* groestlcoin bip38 */
|
||||
|
||||
module.exports.groestlcoinjsBip38 = require('bip38grs')
|
||||
|
||||
/* kjua qr codes */
|
||||
|
||||
module.exports.kjua = require('kjua')
|
||||
|
||||
/* nebulas */
|
||||
|
||||
try {
|
||||
module.exports.nebulas = require('nebulas')
|
||||
}
|
||||
catch (e) {
|
||||
console.warn("Error loading nebulas library");
|
||||
console.warn(e);
|
||||
};
|
||||
|
||||
/* stellar-util */
|
||||
|
||||
let StellarBase = require('stellar-base');
|
||||
let edHd = require('ed25519-hd-key');
|
||||
module.exports.stellarUtil = {
|
||||
getKeypair: function (path, seed) {
|
||||
const result = edHd.derivePath(path, seed);
|
||||
return StellarBase.Keypair.fromRawEd25519Seed(result.key);
|
||||
},
|
||||
dummyNetwork: {
|
||||
bip32: {public: 0, private: 0},
|
||||
messagePrefix: '',
|
||||
pubKeyHash: 0,
|
||||
scriptHash: 0,
|
||||
wif: 0,
|
||||
},
|
||||
}
|
||||
|
||||
/* unorm */
|
||||
|
||||
module.exports.unorm = require('unorm')
|
||||
|
||||
/* zxcvbn */
|
||||
|
||||
module.exports.zxcvbn = require('zxcvbn')
|
||||
17
libs/combined/npm-shrinkwrap.json
generated
Normal file
17
libs/combined/npm-shrinkwrap.json
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"elastos-wallet-js": {
|
||||
"version": "git://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript.git#491dc51b64efaf0a8aae62028b68e2c8e38fde06",
|
||||
"dependencies": {
|
||||
"bitcore-lib-p256": {
|
||||
"version": "0.16.0",
|
||||
"dependencies": {
|
||||
"lodash": {
|
||||
"version": "4.17.12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2241
libs/combined/package-lock.json
generated
Normal file
2241
libs/combined/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
libs/combined/package.json
Normal file
31
libs/combined/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "bip39-tool-external-libs",
|
||||
"version": "0.4.0",
|
||||
"scripts": {
|
||||
"build": "browserify index.js --standalone libs | uglifyjs -c > ../../src/js/bip39-libs.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"base-x": "3.0.7",
|
||||
"bchaddrjs": "0.4.4",
|
||||
"bchaddrjs-slp": "git://github.com/simpleledger/bchaddrjs.git#af16e44a6bfbe4b3980a62dba50e2f68ed864c6b",
|
||||
"bip38": "2.0.2",
|
||||
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
||||
"bitcoinjs-lib": "git://github.com/iancoleman/bitcoinjs-lib.git#v3.3.2_16bit",
|
||||
"buffer": "5.4.3",
|
||||
"ed25519-hd-key": "^1.0.0",
|
||||
"elastos-wallet-js": "git://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript.git#491dc51b64efaf0a8aae62028b68e2c8e38fde06",
|
||||
"ethereumjs-util": "6.0.0",
|
||||
"fast-levenshtein": "2.0.6",
|
||||
"groestlcoinjs-lib": "git://github.com/Groestlcoin/groestlcoinjs-lib.git#3.3.2",
|
||||
"javascript-biginteger": "0.9.2",
|
||||
"kjua": "0.6.0",
|
||||
"nebulas": "0.5.6",
|
||||
"stellar-base": "^0.10.0",
|
||||
"unorm": "1.6.0",
|
||||
"zxcvbn": "4.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"uglify-es": "^3.3.9"
|
||||
}
|
||||
}
|
||||
6
libs/combined/readme.md
Normal file
6
libs/combined/readme.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Generate libs
|
||||
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
736
libs/ethereumjs-util/index.js
Normal file
736
libs/ethereumjs-util/index.js
Normal 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
|
||||
}
|
||||
125
libs/ethereumjs-util/package.json
Normal file
125
libs/ethereumjs-util/package.json
Normal 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/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
4
libs/ethereumjs-util/readme.md
Normal file
4
libs/ethereumjs-util/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/ethereumjs-util.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
1389
libs/stellar-util/package-lock.json
generated
Normal file
1389
libs/stellar-util/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
libs/stellar-util/package.json
Normal file
15
libs/stellar-util/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "stellar-util",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "browserify stellar-util.js > /tmp/stellar-util.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"ed25519-hd-key": "^1.0.0",
|
||||
"stellar-base": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"uglify-es": "^3.3.9"
|
||||
}
|
||||
}
|
||||
4
libs/stellar-util/readme.md
Normal file
4
libs/stellar-util/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/stellar-util.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
16
libs/stellar-util/stellar-util.js
Normal file
16
libs/stellar-util/stellar-util.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const StellarBase = require('stellar-base');
|
||||
const edHd = require('ed25519-hd-key');
|
||||
|
||||
window.stellarUtil = {
|
||||
getKeypair: function (path, seed) {
|
||||
const result = edHd.derivePath(path, seed);
|
||||
return StellarBase.Keypair.fromRawEd25519Seed(result.key);
|
||||
},
|
||||
dummyNetwork: {
|
||||
bip32: {public: 0, private: 0},
|
||||
messagePrefix: '',
|
||||
pubKeyHash: 0,
|
||||
scriptHash: 0,
|
||||
wif: 0,
|
||||
},
|
||||
}
|
||||
@@ -8,7 +8,8 @@ https://iancoleman.io/bip39/
|
||||
|
||||
## Standalone offline version
|
||||
|
||||
Download `bip39-standalone.html`
|
||||
Download `bip39-standalone.html` from
|
||||
[the releases](https://github.com/iancoleman/bip39/releases).
|
||||
|
||||
Open the file in a browser by double clicking it.
|
||||
|
||||
@@ -74,6 +75,9 @@ Before running tests, the site must be served at http://localhost:8000.
|
||||
```
|
||||
$ cd /path/to/bip39/src
|
||||
$ python -m http.server
|
||||
|
||||
or for python2
|
||||
$ python -m SimpleHTTPServer
|
||||
```
|
||||
|
||||
Run tests from the command-line
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -103,3 +103,9 @@ body {
|
||||
overflow-x: scroll;
|
||||
font-family: monospace;
|
||||
}
|
||||
.visual-privacy .private-data {
|
||||
display: none;
|
||||
}
|
||||
.text-weight-normal {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
333
src/index.html
333
src/index.html
@@ -15,7 +15,7 @@
|
||||
<div class="container">
|
||||
|
||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||
<p class="version">v0.3.5</p>
|
||||
<p class="version">v0.4.2</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -36,8 +36,8 @@
|
||||
<div class="col-sm-10">
|
||||
<div class="form-inline">
|
||||
<div class="input-group-inline">
|
||||
<span>Generate a random mnemonic, or enter your own below</span>:
|
||||
<button class="btn generate">Generate</button>
|
||||
<span>Generate a random mnemonic</span>:
|
||||
<button class="btn generate" ><b>GENERATE</b></button>
|
||||
<select id="strength" class="strength form-control">
|
||||
<option value="3">3</option>
|
||||
<option value="6">6</option>
|
||||
@@ -48,7 +48,7 @@
|
||||
<option value="21">21</option>
|
||||
<option value="24">24</option>
|
||||
</select>
|
||||
<span>words</span>.
|
||||
<span>words, or enter your own below</span>.
|
||||
<p class="warning help-block hidden">
|
||||
<span class="text-danger">
|
||||
Mnemonics with less than 12 words have low entropy and may be guessed by an attacker.
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="form-group">
|
||||
<label for="entropy" class="col-sm-2 control-label">Entropy</label>
|
||||
<div class="col-sm-7">
|
||||
<textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards"></textarea>
|
||||
<textarea id="entropy" rows="2" class="entropy private-data form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
<div class="row filter-warning text-danger hidden">
|
||||
<p class="col-sm-12">
|
||||
<strong>
|
||||
@@ -96,19 +96,19 @@
|
||||
<div class="bits col-sm-3 form-control-static"></div>
|
||||
</div>
|
||||
<label class="col-sm-3 control-label">Filtered Entropy</label>
|
||||
<div class="filtered col-sm-9 form-control-static"></div>
|
||||
<div class="filtered private-data col-sm-9 form-control-static"></div>
|
||||
<label class="col-sm-3 control-label">Raw Binary</label>
|
||||
<div class="binary col-sm-9 form-control-static"></div>
|
||||
<div class="binary private-data col-sm-9 form-control-static"></div>
|
||||
<label class="col-sm-3 control-label">Binary Checksum</label>
|
||||
<div class="checksum col-sm-9 form-control-static"> </div>
|
||||
<div class="checksum private-data col-sm-9 form-control-static"> </div>
|
||||
<label class="col-sm-3 control-label">Word Indexes</label>
|
||||
<div class="word-indexes col-sm-9 form-control-static"> </div>
|
||||
<div class="word-indexes private-data col-sm-9 form-control-static"> </div>
|
||||
<label class="col-sm-3 control-label">Mnemonic Length</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="mnemonic-length form-control">
|
||||
<option value="raw" selected>Use Raw Entropy (3 words per 32 bits)</option>
|
||||
<option value="12">12 <span>Words</span></option>
|
||||
<option value="15">15 <span>Words</option>
|
||||
<option value="15">15 <span>Words</span></option>
|
||||
<option value="18">18 <span>Words</span></option>
|
||||
<option value="21">21 <span>Words</span></option>
|
||||
<option value="24">24 <span>Words</span></option>
|
||||
@@ -123,12 +123,42 @@
|
||||
<div class="col-sm-3">
|
||||
<p>Valid entropy values include:</p>
|
||||
<ul>
|
||||
<li><strong>Binary</strong> [0-1]<br>101010011</li>
|
||||
<li><strong>Base 6</strong> [0-5]<br>123434014</li>
|
||||
<li><strong>Dice</strong> [1-6]<br>62535634</li>
|
||||
<li><strong>Base 10</strong> [0-9]<br>90834528</li>
|
||||
<li><strong>Hex</strong> [0-9A-F]<br>4187a8bfd9</li>
|
||||
<li><strong>Card</strong> [A2-9TJQK][CDHS]<br>ahqs9dtc</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="binary">
|
||||
<strong>Binary</strong> [0-1]<br>101010011
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="base 6">
|
||||
<strong>Base 6</strong> [0-5]<br>123434014
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="dice">
|
||||
<strong>Dice</strong> [1-6]<br>62535634
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="base 10">
|
||||
<strong>Base 10</strong> [0-9]<br>90834528
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="hexadecimal" checked>
|
||||
<strong>Hex</strong> [0-9A-F]<br>4187a8bfd9
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="card">
|
||||
<strong>Card</strong> [A2-9TJQK][CDHS]<br>ahqs9dtc
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,6 +172,15 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-10 checkbox">
|
||||
<label>
|
||||
<input type="checkbox" class="privacy-screen-toggle">
|
||||
<span>Hide all private info</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">Mnemonic Language</label>
|
||||
<div class="col-sm-10 languages">
|
||||
@@ -154,25 +193,35 @@
|
||||
<a href="#french" title="French">Français</a>
|
||||
<a href="#italian" title="Italian">Italiano</a>
|
||||
<a href="#korean" title="Korean">한국어</a>
|
||||
<a href="#czech" title="Czech">Čeština</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="phrase" class="phrase form-control" data-show-qr></textarea>
|
||||
<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">
|
||||
<textarea id="passphrase" class="passphrase form-control"></textarea>
|
||||
<textarea id="passphrase" class="passphrase private-data form-control" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="seed" class="col-sm-2 control-label">BIP39 Seed</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="seed" class="seed form-control" readonly="readonly" data-show-qr></textarea>
|
||||
<textarea id="seed" class="seed private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -186,7 +235,7 @@
|
||||
<div class="form-group">
|
||||
<label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="root-key" class="root-key form-control" data-show-qr></textarea>
|
||||
<textarea id="root-key" class="root-key private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group litecoin-ltub-container hidden">
|
||||
@@ -236,35 +285,35 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="purpose" class="col-sm-2 control-label">
|
||||
<label for="purpose-bip44" class="col-sm-2 control-label">
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="purpose" type="text" class="purpose form-control" value="44" readonly>
|
||||
<input id="purpose-bip44" type="text" class="purpose form-control" value="44" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="coin" class="col-sm-2 control-label">
|
||||
<label for="coin-bip44" class="col-sm-2 control-label">
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="coin" type="text" class="coin form-control" value="0" readonly>
|
||||
<input id="coin-bip44" type="text" class="coin form-control" value="0" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="account" class="col-sm-2 control-label">
|
||||
<label for="account-bip44" class="col-sm-2 control-label">
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="account" type="text" class="account form-control" value="0">
|
||||
<input id="account-bip44" type="text" class="account form-control" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="change" class="col-sm-2 control-label">
|
||||
<label for="change-bip44" class="col-sm-2 control-label">
|
||||
<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" 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">
|
||||
@@ -279,7 +328,7 @@
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv" type="text" class="account-xprv form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xprv-bip44" type="text" class="account-xprv private-data form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -287,7 +336,7 @@
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xpub-bip44" type="text" class="account-xpub form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -330,13 +379,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">
|
||||
@@ -354,6 +396,7 @@
|
||||
<div class="col-sm-10">
|
||||
<p class="form-control no-border">
|
||||
<span>Use path <code>m/0'/0</code>.</span>
|
||||
<span>For change addresses use path <code>m/0'/1</code>.</span>
|
||||
</p>
|
||||
<p class="form-control no-border">
|
||||
<span>For more info see</span>
|
||||
@@ -396,35 +439,35 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="purpose" class="col-sm-2 control-label">
|
||||
<label for="purpose-bip49" class="col-sm-2 control-label">
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="purpose" type="text" class="purpose form-control" value="49" readonly>
|
||||
<input id="purpose-bip49" type="text" class="purpose form-control" value="49" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="coin" class="col-sm-2 control-label">
|
||||
<label for="coin-bip49" class="col-sm-2 control-label">
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="coin" type="text" class="coin form-control" value="0" readonly>
|
||||
<input id="coin-bip49" type="text" class="coin form-control" value="0" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="account" class="col-sm-2 control-label">
|
||||
<label for="account-bip49" class="col-sm-2 control-label">
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="account" type="text" class="account form-control" value="0">
|
||||
<input id="account-bip49" type="text" class="account form-control" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="change" class="col-sm-2 control-label">
|
||||
<label for="change-bip49" class="col-sm-2 control-label">
|
||||
<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" type="text" class="change form-control" value="0">
|
||||
<input id="change-bip49" type="text" class="change form-control" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -439,7 +482,7 @@
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv" type="text" class="account-xprv form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xprv-bip49" type="text" class="account-xprv private-data form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -447,7 +490,7 @@
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xpub-bip49" type="text" class="account-xpub form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -497,6 +540,8 @@
|
||||
<select class="form-control bip141-semantics">
|
||||
<option value="p2wpkh">P2WPKH</option>
|
||||
<option value="p2wpkh-p2sh" selected>P2WPKH nested in P2SH</option>
|
||||
<option value="p2wsh">P2WSH (1-of-1 multisig)</option>
|
||||
<option value="p2wsh-p2sh">P2WSH nested in P2SH (1-of-1 multisig)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -506,79 +551,89 @@
|
||||
<div id="bip84" class="tab-pane">
|
||||
<form class="form-horizontal" role="form">
|
||||
<br>
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-10">
|
||||
<p>
|
||||
For more info see the
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki" target="_blank">BIP84 spec</a>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="purpose" class="col-sm-2 control-label">
|
||||
Purpose
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="purpose" type="text" class="purpose form-control" value="84" readonly>
|
||||
<div class="unavailable hidden">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-10">
|
||||
<p>BIP84 is unavailable for this coin.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="coin" class="col-sm-2 control-label">
|
||||
Coin
|
||||
</label>
|
||||
<div class="available">
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-10">
|
||||
<input id="coin" type="text" class="coin form-control" value="0" readonly>
|
||||
<p>
|
||||
For more info see the
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki" target="_blank">BIP84 spec</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="account" class="col-sm-2 control-label">
|
||||
Account
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="account" type="text" class="account form-control" value="0">
|
||||
<div class="form-group">
|
||||
<label for="purpose-bip84" class="col-sm-2 control-label">
|
||||
Purpose
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="purpose-bip84" type="text" class="purpose form-control" value="84" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="change" class="col-sm-2 control-label">
|
||||
External / Internal
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="change" type="text" class="change form-control" value="0">
|
||||
<div class="form-group">
|
||||
<label for="coin-bip84" class="col-sm-2 control-label">
|
||||
Coin
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="coin-bip84" type="text" class="coin form-control" value="0" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<p>The account extended keys can be used for importing to most BIP84 compatible wallets.</p>
|
||||
<div class="form-group">
|
||||
<label for="account-bip84" class="col-sm-2 control-label">
|
||||
Account
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="account-bip84" type="text" class="account form-control" value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="account-xprv" class="col-sm-2 control-label">
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv" type="text" class="account-xprv form-control" readonly data-show-qr></textarea>
|
||||
<div class="form-group">
|
||||
<label for="change-bip84" class="col-sm-2 control-label">
|
||||
External / Internal
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="change-bip84" type="text" class="change form-control" value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="account-xpub" class="col-sm-2 control-label">
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<p>The account extended keys can be used for importing to most BIP84 compatible wallets.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<p>The BIP32 derivation path and extended keys are the basis for the derived addresses.</p>
|
||||
<div class="form-group">
|
||||
<label for="account-xprv" class="col-sm-2 control-label">
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv-bip84" type="text" class="account-xprv private-data form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bip84-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="bip84-path" type="text" class="path form-control" value="m/84'/0'/0'/0" readonly="readonly">
|
||||
<div class="form-group">
|
||||
<label for="account-xpub" class="col-sm-2 control-label">
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub-bip84" type="text" class="account-xpub form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<p>The BIP32 derivation path and extended keys are the basis for the derived addresses.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bip84-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="bip84-path" type="text" class="path form-control" value="m/84'/0'/0'/0" readonly="readonly">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -588,13 +643,13 @@
|
||||
<div class="form-group">
|
||||
<label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Private Key</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly" data-show-qr></textarea>
|
||||
<textarea id="extended-priv-key" class="extended-priv-key private-data form-control" readonly="readonly" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Public Key</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly" data-show-qr></textarea>
|
||||
<textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -608,13 +663,25 @@
|
||||
<h2>Derived Addresses</h2>
|
||||
<p>Note these addresses are derived from the BIP32 Extended Key</p>
|
||||
</div>
|
||||
<div class="col-md-12 use-bitpay-addresses-container hidden">
|
||||
<div class="checkbox">
|
||||
<div class="col-md-12 bch-addr-type-container hidden">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="checkbox" class="use-bitpay-addresses">
|
||||
<input type="radio" value="cashaddr" name="bch-addr-type" class="use-bch-cashaddr-addresses" checked="checked">
|
||||
<span>Use CashAddr addresses for Bitcoin Cash (ie starting with 'q' instead of '1')</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" value="bitpay" name="bch-addr-type" class="use-bch-bitpay-addresses">
|
||||
<span>Use BitPay-style addresses for Bitcoin Cash (ie starting with 'C' instead of '1')</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" value="legacy" name="bch-addr-type" class="use-bch-legacy-addresses">
|
||||
<span>Use legacy addresses for Bitcoin Cash (ie starting with '1')</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="checkbox">
|
||||
@@ -622,10 +689,18 @@
|
||||
<input type="checkbox" class="use-bip38">
|
||||
<span>Encrypt private keys using BIP38 and this password:</span>
|
||||
</label>
|
||||
<input class="bip38-password">
|
||||
<input class="bip38-password private-data" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
|
||||
<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>
|
||||
@@ -676,7 +751,7 @@
|
||||
</div>
|
||||
<div id="csv" class="tab-pane">
|
||||
<div class="col-md-12">
|
||||
<textarea class="csv form-control" rows="25" readonly></textarea>
|
||||
<textarea class="csv form-control" rows="25" readonly autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -717,14 +792,6 @@
|
||||
Read more at the
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki" target="_blank">official BIP49 spec</a>
|
||||
</p>
|
||||
<h3>Private Keys</h3>
|
||||
<p>
|
||||
<span>
|
||||
Use private keys at
|
||||
<a href="https://web.archive.org/web/20150707020924/https://brainwallet.org/" target="_blank">brainwallet.org</a>.
|
||||
</span>
|
||||
<span>Be careful - it can be easy to make mistakes if you don't know what you're doing.</span>
|
||||
</p>
|
||||
<h3 id="entropy-notes">Entropy</h3>
|
||||
<p>
|
||||
<span>Entropy values should not include the BIP39 checksum. This is automatically added by the tool.</span>
|
||||
@@ -887,22 +954,17 @@
|
||||
<td class="index"><span></span></td>
|
||||
<td class="address"><span data-show-qr></span></td>
|
||||
<td class="pubkey"><span data-show-qr></span></td>
|
||||
<td class="privkey"><span data-show-qr></span></td>
|
||||
<td class="privkey private-data"><span data-show-qr></span></td>
|
||||
</tr>
|
||||
</script>
|
||||
<script src="js/polyfill.es6.js"></script>
|
||||
<script src="js/basex.js"></script>
|
||||
<script src="js/unorm.js"></script>
|
||||
<script src="js/jquery-3.2.1.js"></script>
|
||||
<script src="js/bootstrap-3.3.7.js"></script>
|
||||
<script src="js/levenshtein.js"></script>
|
||||
<script src="js/kjua-0.1.1.min.js"></script>
|
||||
<script src="js/bitcoinjs-3.3.2.js"></script>
|
||||
<script src="js/bip39-libs.js"></script>
|
||||
<script src="js/bitcoinjs-extensions.js"></script>
|
||||
<script src="js/bitcoinjs-bip38-2.0.2.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/eos-util.js"></script>
|
||||
<script src="js/sjcl-bip39.js"></script>
|
||||
<script src="js/wordlist_english.js"></script>
|
||||
<script src="js/wordlist_japanese.js"></script>
|
||||
@@ -912,9 +974,8 @@
|
||||
<script src="js/wordlist_french.js"></script>
|
||||
<script src="js/wordlist_italian.js"></script>
|
||||
<script src="js/wordlist_korean.js"></script>
|
||||
<script src="js/wordlist_czech.js"></script>
|
||||
<script src="js/jsbip39.js"></script>
|
||||
<script src="js/biginteger.js"></script>
|
||||
<script src="js/zxcvbn.js"></script>
|
||||
<script src="js/entropy.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
</body>
|
||||
|
||||
2010
src/js/basex.js
2010
src/js/basex.js
File diff suppressed because it is too large
Load Diff
1620
src/js/biginteger.js
1620
src/js/biginteger.js
File diff suppressed because it is too large
Load Diff
1
src/js/bip39-libs.js
Normal file
1
src/js/bip39-libs.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
9
src/js/casinocoin-util.js
Normal file
9
src/js/casinocoin-util.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function convertCasinoCoinAdrr(address) {
|
||||
return libs.basex('cpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2brdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
)
|
||||
}
|
||||
|
||||
function convertCasinoCoinPriv(priv) {
|
||||
return libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
window.Entropy = new (function() {
|
||||
|
||||
var TWO = new BigInteger(2);
|
||||
var TWO = new libs.BigInteger.BigInteger(2);
|
||||
|
||||
// matchers returns an array of the matched events for each type of entropy.
|
||||
// eg
|
||||
@@ -67,9 +67,9 @@ window.Entropy = new (function() {
|
||||
return ints;
|
||||
}
|
||||
|
||||
this.fromString = function(rawEntropyStr) {
|
||||
this.fromString = function(rawEntropyStr, baseStr) {
|
||||
// Find type of entropy being used (binary, hex, dice etc)
|
||||
var base = getBase(rawEntropyStr);
|
||||
var base = getBase(rawEntropyStr, baseStr);
|
||||
// Convert dice to base6 entropy (ie 1-6 to 0-5)
|
||||
// This is done by changing all 6s to 0s
|
||||
if (base.str == "dice") {
|
||||
@@ -103,11 +103,11 @@ window.Entropy = new (function() {
|
||||
// Convert base.ints to BigInteger.
|
||||
// Due to using unusual bases, eg cards of base52, this is not as simple as
|
||||
// using BigInteger.parse()
|
||||
var entropyInt = BigInteger.ZERO;
|
||||
var entropyInt = libs.BigInteger.BigInteger.ZERO;
|
||||
for (var i=base.ints.length-1; i>=0; i--) {
|
||||
var thisInt = BigInteger.parse(base.ints[i]);
|
||||
var thisInt = libs.BigInteger.BigInteger.parse(base.ints[i]);
|
||||
var power = (base.ints.length - 1) - i;
|
||||
var additionalEntropy = BigInteger.parse(base.asInt).pow(power).multiply(thisInt);
|
||||
var additionalEntropy = libs.BigInteger.BigInteger.parse(base.asInt).pow(power).multiply(thisInt);
|
||||
entropyInt = entropyInt.add(additionalEntropy);
|
||||
}
|
||||
// Convert entropy to binary
|
||||
@@ -166,13 +166,14 @@ window.Entropy = new (function() {
|
||||
return s;
|
||||
}
|
||||
|
||||
function getBase(str) {
|
||||
function getBase(str, baseStr) {
|
||||
// Need to get the lowest base for the supplied entropy.
|
||||
// This prevents interpreting, say, dice rolls as hexadecimal.
|
||||
var binaryMatches = matchers.binary(str);
|
||||
var hexMatches = matchers.hex(str);
|
||||
var autodetect = baseStr === undefined;
|
||||
// Find the lowest base that can be used, whilst ignoring any irrelevant chars
|
||||
if (binaryMatches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((binaryMatches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "binary") {
|
||||
var ints = binaryMatches.map(function(i) { return parseInt(i, 2) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -183,7 +184,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var cardMatches = matchers.card(str);
|
||||
if (cardMatches.length >= hexMatches.length / 2) {
|
||||
if ((cardMatches.length >= hexMatches.length / 2 && autodetect) || baseStr === "card") {
|
||||
var ints = convertCardsToInts(cardMatches);
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -194,7 +195,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var diceMatches = matchers.dice(str);
|
||||
if (diceMatches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((diceMatches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "dice") {
|
||||
var ints = diceMatches.map(function(i) { return parseInt(i) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -205,7 +206,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var base6Matches = matchers.base6(str);
|
||||
if (base6Matches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((base6Matches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "base 6") {
|
||||
var ints = base6Matches.map(function(i) { return parseInt(i) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -216,7 +217,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var base10Matches = matchers.base10(str);
|
||||
if (base10Matches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((base10Matches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "base 10") {
|
||||
var ints = base10Matches.map(function(i) { return parseInt(i) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -327,7 +328,7 @@ window.Entropy = new (function() {
|
||||
// Math.LOG2E
|
||||
// log2(8) gave 2.9999999999999996 which when floored causes issues.
|
||||
// So instead use the BigInteger library to get it right.
|
||||
return BigInteger.log(x) / BigInteger.log(2);
|
||||
return libs.BigInteger.BigInteger.log(x) / libs.BigInteger.BigInteger.log(2);
|
||||
};
|
||||
|
||||
// Depends on BigInteger
|
||||
@@ -335,9 +336,9 @@ window.Entropy = new (function() {
|
||||
if (n == 0) {
|
||||
return 1;
|
||||
}
|
||||
f = BigInteger.ONE;
|
||||
f = libs.BigInteger.BigInteger.ONE;
|
||||
for (var i=1; i<=n; i++) {
|
||||
f = f.multiply(new BigInteger(i));
|
||||
f = f.multiply(new libs.BigInteger.BigInteger(i));
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
7414
src/js/eos-util.js
Normal file
7414
src/js/eos-util.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1570
src/js/index.js
1570
src/js/index.js
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -149,7 +157,7 @@ var Mnemonic = function(language) {
|
||||
// Set space correctly depending on the language
|
||||
// see https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md#japanese
|
||||
var space = " ";
|
||||
if (language == "japanese" || language == "korean") {
|
||||
if (language == "japanese") {
|
||||
space = "\u3000"; // ideographic space
|
||||
}
|
||||
return words.join(space);
|
||||
@@ -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
|
||||
|
||||
2
src/js/kjua-0.1.1.min.js
vendored
2
src/js/kjua-0.1.1.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,211 +0,0 @@
|
||||
(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);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
|
||||
*/
|
||||
var Levenshtein = {
|
||||
/**
|
||||
* Calculate levenshtein distance of the two strings.
|
||||
*
|
||||
* @param str1 String the first string.
|
||||
* @param str2 String the second string.
|
||||
* @return Integer the levenshtein distance (0 and above).
|
||||
*/
|
||||
get: function(str1, str2) {
|
||||
// base cases
|
||||
if (str1 === str2) return 0;
|
||||
if (str1.length === 0) return str2.length;
|
||||
if (str2.length === 0) return str1.length;
|
||||
|
||||
// two rows
|
||||
var prevRow = new Array(str2.length + 1),
|
||||
curCol, nextCol, i, j, tmp;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<prevRow.length; ++i) {
|
||||
prevRow[i] = i;
|
||||
}
|
||||
|
||||
// calculate current row distance from previous row
|
||||
for (i=0; i<str1.length; ++i) {
|
||||
nextCol = i + 1;
|
||||
|
||||
for (j=0; j<str2.length; ++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;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// amd
|
||||
if (typeof define !== "undefined" && define !== null && define.amd) {
|
||||
define(function() {
|
||||
return Levenshtein;
|
||||
});
|
||||
}
|
||||
// commonjs
|
||||
else if (typeof module !== "undefined" && module !== null && typeof exports !== "undefined" && module.exports === exports) {
|
||||
module.exports = Levenshtein;
|
||||
}
|
||||
// web worker
|
||||
else if (typeof self !== "undefined" && typeof self.postMessage === 'function' && typeof self.importScripts === 'function') {
|
||||
self.Levenshtein = Levenshtein;
|
||||
}
|
||||
// browser main thread
|
||||
else if (typeof window !== "undefined" && window !== null) {
|
||||
window.Levenshtein = Levenshtein;
|
||||
}
|
||||
}());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
function convertRippleAdrr(address) {
|
||||
return window.basex('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
return libs.basex('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
)
|
||||
}
|
||||
|
||||
function convertRipplePriv(priv) {
|
||||
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
|
||||
return libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// p2wpkh
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcoin.p2wpkh = {
|
||||
libs.bitcoin.networks.bitcoin.p2wpkh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
@@ -15,7 +15,7 @@ bitcoinjs.bitcoin.networks.bitcoin.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.testnet.p2wpkh = {
|
||||
libs.bitcoin.networks.testnet.p2wpkh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
@@ -28,9 +28,22 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.regtest.p2wpkh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x045f1cf6,
|
||||
private: 0x045f18bc
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// p2wpkh in p2sh
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
@@ -43,7 +56,7 @@ bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.testnet.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.testnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
@@ -56,9 +69,118 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkhInP2sh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.regtest.p2wpkhInP2sh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x044a5262,
|
||||
private: 0x044a4e28
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// p2wsh
|
||||
|
||||
libs.bitcoin.networks.bitcoin.p2wsh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x02aa7ed3,
|
||||
private: 0x02aa7a99
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.testnet.p2wsh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
bip32: {
|
||||
public: 0x02575483,
|
||||
private: 0x02575048
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.regtest.p2wsh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x02575483,
|
||||
private: 0x02575048
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// p2wsh in p2sh
|
||||
|
||||
libs.bitcoin.networks.bitcoin.p2wshInP2sh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x0295b43f,
|
||||
private: 0x0295b005
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.testnet.p2wshInP2sh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
bip32: {
|
||||
public: 0x024289ef,
|
||||
private: 0x024285b5
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.regtest.p2wshInP2sh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x024289ef,
|
||||
private: 0x024285b5
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.litecoin.p2wpkh = {
|
||||
baseNetwork: "litecoin",
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bech32: 'ltc',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x30,
|
||||
scriptHash: 0x32,
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.litecoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "litecoin",
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bech32: 'ltc',
|
||||
bip32: {
|
||||
public: 0x01b26ef6,
|
||||
private: 0x01b26792
|
||||
@@ -68,7 +190,7 @@ bitcoinjs.bitcoin.networks.litecoin.p2wpkhInP2sh = {
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fujicoin.p2wpkh = {
|
||||
libs.bitcoin.networks.fujicoin.p2wpkh = {
|
||||
baseNetwork: "fujicoin",
|
||||
messagePrefix: '\x19FujiCoin Signed Message:\n',
|
||||
bech32: 'fc',
|
||||
@@ -81,7 +203,7 @@ bitcoinjs.bitcoin.networks.fujicoin.p2wpkh = {
|
||||
wif: 0xa4
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fujicoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.fujicoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "fujicoin",
|
||||
messagePrefix: '\x19FujiCoin Signed Message:\n',
|
||||
bech32: 'fc',
|
||||
@@ -94,4 +216,471 @@ bitcoinjs.bitcoin.networks.fujicoin.p2wpkhInP2sh = {
|
||||
wif: 0xa4
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.vertcoin.p2wpkh = {
|
||||
baseNetwork: "vertcoin",
|
||||
messagePrefix: '\x18Vertcoin Signed Message:\n',
|
||||
bech32: 'vtc',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 71,
|
||||
scriptHash: 5,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.vertcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "vertcoin",
|
||||
messagePrefix: '\x18Vertcoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 71,
|
||||
scriptHash: 5,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.bgold.p2wpkh = {
|
||||
baseNetwork: "bgold",
|
||||
messagePrefix: '\x1DBitcoin Gold Signed Message:\n',
|
||||
bech32: 'btg',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x17,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.bgold.p2wpkhInP2sh = {
|
||||
baseNetwork: "bgold",
|
||||
messagePrefix: '\x1DBitcoin Gold Signed Message:\n',
|
||||
bech32: 'btg',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x17,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.digibyte.p2wpkh = {
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: 'x19DigiByte Signed Message:\n',
|
||||
bech32: 'dgb',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x3f,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: '\x19DigiByte Signed Message:\n',
|
||||
bech32: 'dgb',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x3f,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.blockstamp.p2wpkh = {
|
||||
baseNetwork: "blockstamp",
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
|
||||
baseNetwork: "blockstamp",
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.nix.p2wpkh = {
|
||||
baseNetwork: "nix",
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bech32: 'nix',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x35,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.nix.p2wpkhInP2sh = {
|
||||
baseNetwork: "nix",
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bech32: 'nix',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x35,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.cpuchain.p2wpkh = {
|
||||
baseNetwork: "cpuchain",
|
||||
messagePrefix: '\x1DCPUchain Signed Message:\n',
|
||||
bech32: 'cpu',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x1c,
|
||||
scriptHash: 0x1e,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
|
||||
baseNetwork: "cpuchain",
|
||||
messagePrefix: '\x1DCPUchain Signed Message:\n',
|
||||
bech32: 'cpu',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x1c,
|
||||
scriptHash: 0x1e,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.monkeyproject.p2wpkh = {
|
||||
baseNetwork: "monkeyproject",
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bech32: 'monkey',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488dde4
|
||||
},
|
||||
pubKeyHash: 0x33,
|
||||
scriptHash: 0x1c,
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
|
||||
baseNetwork: "monkeyproject",
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bech32: 'monkey',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488dde4
|
||||
},
|
||||
pubKeyHash: 0x33,
|
||||
scriptHash: 0x1c,
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
libs.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
|
||||
};
|
||||
|
||||
libs.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
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.bitcore.p2wpkh = {
|
||||
baseNetwork: "bitcore",
|
||||
messagePrefix: '\x18BitCore Signed Message:\n',
|
||||
bech32: 'bitcore',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
},
|
||||
pubKeyHash: 0x03,
|
||||
scriptHash: 0x7D,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
|
||||
baseNetwork: "bitcore",
|
||||
messagePrefix: '\x18BitCore Signed Message:\n',
|
||||
bech32: 'bitcore',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
},
|
||||
pubKeyHash: 0x03,
|
||||
scriptHash: 0x7D,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x37,
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x37,
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.syscoin.p2wpkh = {
|
||||
baseNetwork: "syscoin",
|
||||
messagePrefix: '\x18Syscoin Signed Message:\n',
|
||||
bech32: 'sys',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "syscoin",
|
||||
messagePrefix: '\x18Syscoin Signed Message:\n',
|
||||
bech32: 'sys',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.viacoin.p2wpkh = {
|
||||
baseNetwork: "viacoin",
|
||||
messagePrefix: '\x18Viacoin Signed Message:\n',
|
||||
bech32: 'viacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x47,
|
||||
scriptHash: 0x21,
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "viacoin",
|
||||
messagePrefix: '\x18Viacoin Signed Message:\n',
|
||||
bech32: 'viacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x47,
|
||||
scriptHash: 0x21,
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.litecointestnet.p2wpkh = {
|
||||
baseNetwork: "litecointestnet",
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bech32: 'litecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "litecointestnet",
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bech32: 'litecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.groestlcoin.p2wpkh = {
|
||||
baseNetwork: "groestlcoin",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'grs',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x24,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.groestlcointestnet.p2wpkh = {
|
||||
baseNetwork: "groestlcointestnet",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'tgrs',
|
||||
bip32: {
|
||||
public: 0x045f1cf6,
|
||||
private: 0x045f18bc
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "groestlcoin",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'grs',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x24,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "groestlcointestnet",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'tgrs',
|
||||
bip32: {
|
||||
public: 0x044a5262,
|
||||
private: 0x044a4e28
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.deeponion.p2wpkh = {
|
||||
baseNetwork: "deeponion",
|
||||
messagePrefix: '\x18DeepOnion Signed Message:\n',
|
||||
bech32: 'dpn',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x1f,
|
||||
scriptHash: 0x4e,
|
||||
wif: 0x9f
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.deeponion.p2wpkhInP2sh = {
|
||||
baseNetwork: "deeponion",
|
||||
messagePrefix: '\x18DeepOnion Signed Message:\n',
|
||||
bech32: 'dpn',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x1f,
|
||||
scriptHash: 0x4e,
|
||||
wif: 0x9f
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -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;
|
||||
|
||||
445
src/js/unorm.js
445
src/js/unorm.js
File diff suppressed because one or more lines are too long
14
src/js/wordlist_czech.js
Normal file
14
src/js/wordlist_czech.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1399
tests/spec/tests.js
1399
tests/spec/tests.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user