bip44 0.2.10 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/bip44.gemspec +1 -0
- data/lib/bip44.rb +6 -0
- data/lib/bip44/bitcoin.rb +4 -0
- data/lib/bip44/ethereum.rb +4 -16
- data/lib/bip44/utils.rb +7 -0
- data/lib/bip44/version.rb +1 -1
- data/lib/bip44/wallet.rb +0 -4
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d07b16c38a63e61a0a8773b1940107785552ece1
|
4
|
+
data.tar.gz: b8e51732594e613f8530e0f887f8acf4dfa6151f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 940b94fb6817a97677822b14d40405668fccd9972c98ef9521fa8d21e86beb133474a12cf1befd6b24bf845f70882de13b24839ed67b48a4e247d9c9a4f30c4d
|
7
|
+
data.tar.gz: 239f1b700dbbc94b9911346c6f830aea4beb85b3a9729d86c4a30cf396f0ebae7d141c87b1f8c78273abeb54a8155d5477ee76ca242759c0770d5a68d384556d
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# ip44 for ruby
|
2
2
|
|
3
|
+
IMPORTANT: there is a serious bug of version <= 0.2.12, so use >= 0.2.13
|
4
|
+
|
3
5
|
A ruby library to generate multi coin addresses from a hierarchical deterministic wallet according to the [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) standard.
|
4
6
|
|
5
7
|
Internally it uses [money-tree](https://github.com/GemHQ/money-tree) for the deterministic private and public keys which allows to use many additional features like deriving address from mnemonic backups (BIP32).
|
data/bip44.gemspec
CHANGED
data/lib/bip44.rb
CHANGED
@@ -4,6 +4,7 @@ require 'digest/sha3'
|
|
4
4
|
require 'rlp'
|
5
5
|
require 'money-tree'
|
6
6
|
require 'bip_mnemonic'
|
7
|
+
require 'eth'
|
7
8
|
require 'bip44/utils'
|
8
9
|
require 'bip44/bitcoin'
|
9
10
|
require 'bip44/ethereum'
|
@@ -31,4 +32,9 @@ module Bip44
|
|
31
32
|
puts 'bitcoin xprv: ' + bitcoin_wallet.xprv
|
32
33
|
puts 'bitcoin xpub: ' + bitcoin_wallet.xpub
|
33
34
|
end
|
35
|
+
|
36
|
+
def self.print()
|
37
|
+
words = 'roof never second cheese sock blast ride country picnic purpose federal ignore'
|
38
|
+
|
39
|
+
end
|
34
40
|
end
|
data/lib/bip44/bitcoin.rb
CHANGED
data/lib/bip44/ethereum.rb
CHANGED
@@ -1,27 +1,15 @@
|
|
1
1
|
module Bip44
|
2
2
|
module Ethereum
|
3
3
|
def get_ethereum_address(path)
|
4
|
-
|
5
|
-
|
6
|
-
# from bitcoin public key to ethereum public key
|
7
|
-
group = ECDSA::Group::Secp256k1
|
8
|
-
public_key = ECDSA::Format::PointOctetString.decode(node.public_key.to_bytes, group) # a point
|
9
|
-
ethereum_public = public_key.x.to_s(16) + public_key.y.to_s(16)
|
10
|
-
|
11
|
-
# from ethereum public key to ethereum address
|
12
|
-
bytes = Bip44::Utils.hex_to_bin(ethereum_public)
|
13
|
-
address_bytes = Digest::SHA3.new(256).digest(bytes)[-20..-1]
|
14
|
-
address = Bip44::Utils.bin_to_hex(address_bytes)
|
15
|
-
Bip44::Utils.prefix_hex(address)
|
4
|
+
sub_wallet = sub_wallet(path)
|
5
|
+
sub_wallet.ethereum_address
|
16
6
|
end
|
17
7
|
|
18
8
|
def ethereum_address
|
19
|
-
node = @wallet_node
|
20
|
-
|
21
9
|
# from bitcoin public key to ethereum public key
|
22
10
|
group = ECDSA::Group::Secp256k1
|
23
|
-
public_key = ECDSA::Format::PointOctetString.decode(
|
24
|
-
ethereum_public = public_key.x.to_s(16) + public_key.y.to_s(16)
|
11
|
+
public_key = ECDSA::Format::PointOctetString.decode(@wallet_node.public_key.to_bytes, group) # a point
|
12
|
+
ethereum_public = Utils.padding64(public_key.x.to_s(16)) + Utils.padding64(public_key.y.to_s(16))
|
25
13
|
|
26
14
|
# from ethereum public key to ethereum address
|
27
15
|
bytes = Bip44::Utils.hex_to_bin(ethereum_public)
|
data/lib/bip44/utils.rb
CHANGED
@@ -8,6 +8,13 @@ module Bip44
|
|
8
8
|
RLP::Utils.encode_hex string
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.padding64(str)
|
12
|
+
if str =~ /^0x[a-f0-9]*/
|
13
|
+
str = str[2 .. str.length-1]
|
14
|
+
end
|
15
|
+
str.rjust(64, '0')
|
16
|
+
end
|
17
|
+
|
11
18
|
def self.prefix_hex(hex)
|
12
19
|
hex.match(/\A0x/) ? hex : "0x#{hex}"
|
13
20
|
end
|
data/lib/bip44/version.rb
CHANGED
data/lib/bip44/wallet.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bip44
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wuminzhe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: eth
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: A ruby library to generate Ethereum addresses from a hierarchical deterministic
|
126
140
|
wallet according to the BIP44 standard.
|
127
141
|
email:
|