Seele Doc
Search…
Seele HD Wallet Specification
1
Title: Seele HD Wallet Specification
2
Author: Tinoma
3
Created: 2020-01-15
Copied!

PURPOSE

For compatibility between HD (Hierarchical Deterministic) Wallets that follows the BIP44 schema, this document aims to specify the rules of address discovery for supporting Seele.

SCHEME

  • Specification:
Field
Value
Comments
purpose
44'
BIP44 purpose.
coin_type
456'
Registered here.
account
0'
Assume first account.
change
0
Assume external chain.
address_index
x
Find the first address encountered in each shard. Four addresses in total.
  • Example:
1
{
2
mnemonic: "hurdle broccoli blast rug mixed expire soldier able maze heavy jeans equip"
3
}
4
// According to the specification above,
5
// among the addresses discovered as shown below:
6
// address[1] is chosen for shard 1
7
// address[3] is chosen for shard 2
8
// address[2] is chosen for shard 3
9
// address[0] is chosen for shard 4
Copied!
Path
Address
Shard
m/44'/456'/0'/0/0
0x...de48c8d41ff280091
4
m/44'/456'/0'/0/1
0x...722a597a01aa80d01
1
m/44'/456'/0'/0/2
0x...68ae8b413efb55891
3
m/44'/456'/0'/0/3
0x...3be0587deb333c771
2
m/44'/456'/0'/0/4
0x...c9f82c473615956c1
3
m/44'/456'/0'/0/5
0x...076e71ade650ec5d1
2
m/44'/456'/0'/0/6
0x...49994f209553e24c1
1
...
...
...
  • JS pseudo code:
1
const bip32 = require('bip32');
2
const bip39 = require('bip39');
3
const bip44 = require('bip44');
4
// return seele address from privateKey
5
function addressOfprivateKey(privateKey){...}
6
// return seele shard from address
7
function shardOfAddress(address){...}
8
//
9
function accountFromWord(word){
10
var seed = bip39.mnemonicToSeedSync(word).toString('hex')
11
return accountFromSeed(seed)
12
}
13
14
function accountFromSeed(seed){
15
var seedbuf = Buffer.from(seed, 'hex')
16
var rootobj = bip32.fromSeed(seedbuf)
17
var account = []
18
for ( var shard = 1 ; shard <= 4 ; shard++ ){
19
var addr = { p: null, a: null, s:null }
20
var i = 0
21
while( addr.s != shard ){
22
addr.i = i
23
addr.p = '0x' + rootobj.derivePath(`m/44'/${bip44.SEELE.index}'/0'/0/${i}`).privateKey.toString('hex')
24
addr.a = addressOfprivateKey(addr.p)
25
addr.s = shardOfAddress(addr.a)
26
i++;
27
}
28
account.push(addr)
29
}
30
return account
31
}
32
const mnemonic = "hurdle broccoli blast rug mixed expire soldier able maze heavy jeans equip"
33
const account = accountFromWord(mnemonic)
34
console.log(account);
35
// expects
36
// [
37
// {
38
// s: 1,
39
// p: '0x6f713371e6d5d513fe66b9f6f5974aec46c0a9a5fdd49d24b48128519e6efb1e',
40
// a: '0x5fc511565316e45e84f3383722a597a01aa80d01',
41
// i: 1
42
// },
43
// {
44
// s: 2,
45
// p: '0xa457b3adedecddacfa1b08f97a6ed8e25b5ed4b1a9692d725c5ed87bd80e36a1',
46
// a: '0xac5d5a1fc5ebbea4f2044b33be0587deb333c771',
47
// i: 3
48
// },
49
// {
50
// s: 3,
51
// p: '0x19350808989722ee84dda5fe20686ca8af5cf7671e5193d3e0cddf039901a3da',
52
// a: '0x14130ff8b350230ca326fd468ae8b413efb55891',
53
// i: 2
54
// },
55
// {
56
// s: 4,
57
// p: '0xb168d0823a616d111ba4abf4c27bb9331d3326dedde270d9b0bc77b767c6744e',
58
// a: '0x05df8b2bf801195092f218dde48c8d41ff280091',
59
// i: 0
60
// }
61
// ]
Copied!

REFERENCE

  • EIP601 Ethereum hierarchy for deterministic wallets
  • BIP44 Multi-Account Hierarchy for Deterministic Wallets
  • BIP43 Purpose Field for Deterministic Wallets
  • BIP39 Mnemonic code for generating deterministic keys
  • BIP32 Hierarchical Deterministic Wallets
Copy link