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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cb9a4011cc4d1836a9b58041479ffef0eb01dbe
4
- data.tar.gz: cb6201d16e72ff7b1a98c7e3291f70a8293f6dd6
3
+ metadata.gz: d07b16c38a63e61a0a8773b1940107785552ece1
4
+ data.tar.gz: b8e51732594e613f8530e0f887f8acf4dfa6151f
5
5
  SHA512:
6
- metadata.gz: b1e4ddc192d0ca5c581950a4d98f5ae98f057e1c8a2d82406043f48a6bfe3c132557bb715a39c153374535fad761178c9400fc151d6a55f021d806ccde885e4a
7
- data.tar.gz: 65c8782b864522f2fb55f484e70bf60677c9aada26915fd193ddfaf7f70d6a7bab2d94376958be75e9b93cdafa754761e578f702e3276d95f584aa3cc9812c94
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).
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "digest-sha3", "~> 1.1.0"
31
31
  spec.add_dependency "rlp", "~> 0.7.3"
32
32
  spec.add_dependency "bip_mnemonic"
33
+ spec.add_dependency "eth"
33
34
  end
@@ -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
@@ -4,5 +4,9 @@ module Bip44
4
4
  node = @wallet_node.node_for_path(path)
5
5
  node.to_address
6
6
  end
7
+
8
+ def bitcoin_address
9
+ @wallet_node.public_key.to_hex
10
+ end
7
11
  end
8
12
  end
@@ -1,27 +1,15 @@
1
1
  module Bip44
2
2
  module Ethereum
3
3
  def get_ethereum_address(path)
4
- node = @wallet_node.node_for_path(path)
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(node.public_key.to_bytes, group) # a point
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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Bip44
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.13"
3
3
  end
@@ -42,10 +42,6 @@ module Bip44
42
42
  @wallet_node.to_bip32(:private)
43
43
  end
44
44
 
45
- def public_key
46
- @wallet_node.public_key.to_hex
47
- end
48
-
49
45
  def private_key
50
46
  @wallet_node.private_key.to_hex
51
47
  end
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.10
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-24 00:00:00.000000000 Z
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: