rubycoin 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +13 -0
- data/MIT-LICENSE +21 -0
- data/README.md +75 -0
- data/lib/ruby_coin/address.rb +87 -0
- data/lib/ruby_coin/bitcoin.rb +10 -0
- data/lib/ruby_coin/bitcoin/address.rb +32 -0
- data/lib/ruby_coin/dogecoin.rb +10 -0
- data/lib/ruby_coin/dogecoin/address.rb +32 -0
- data/lib/ruby_coin/feathercoin.rb +10 -0
- data/lib/ruby_coin/feathercoin/address.rb +32 -0
- data/lib/ruby_coin/litecoin.rb +10 -0
- data/lib/ruby_coin/litecoin/address.rb +32 -0
- data/lib/ruby_coin/megacoin.rb +10 -0
- data/lib/ruby_coin/megacoin/address.rb +32 -0
- data/lib/ruby_coin/namecoin.rb +10 -0
- data/lib/ruby_coin/namecoin/address.rb +32 -0
- data/lib/ruby_coin/peercoin.rb +10 -0
- data/lib/ruby_coin/peercoin/address.rb +32 -0
- data/lib/ruby_coin/primecoin.rb +10 -0
- data/lib/ruby_coin/primecoin/address.rb +32 -0
- data/lib/ruby_coin/quarkcoin.rb +10 -0
- data/lib/ruby_coin/quarkcoin/address.rb +32 -0
- data/lib/ruby_coin/utilities.rb +11 -0
- data/lib/ruby_coin/version.rb +10 -0
- data/lib/ruby_coin/worldcoin.rb +10 -0
- data/lib/ruby_coin/worldcoin/address.rb +32 -0
- data/lib/rubycoin.rb +34 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f4e557b7cda2e62af025117c0d5f17249edebd0
|
4
|
+
data.tar.gz: 1343e831de98c92e7d533481635a408bd2a9e580
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c999a5c41a842c64ee57fb68c365217527c65011edd54ee62ca48f057e4c1f8fb51c532ffa3954a54f1f05ff01632c0c2b86121058a4e01bb825588d4ca597dc
|
7
|
+
data.tar.gz: 6a840e94937cf8b75a634315244a75c0f656f718e5fe8535fc162b9e73fe75c0d743f4b476df2b07d14bec384316b32dde7faa1920f5182d47a170b46ec0da8d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
- **v0.0.12** - Added compress key option support
|
3
|
+
- **v0.0.11** - Added Worldcoin support
|
4
|
+
- **v0.0.10** - Added Megacoin support
|
5
|
+
- **v0.0.9** - Added Primecoin support
|
6
|
+
- **v0.0.8** - Added Feathercoin support
|
7
|
+
- **v0.0.7** - Added Namecoin support
|
8
|
+
- **v0.0.6** - Dogecoin gets compressed wallet support
|
9
|
+
- **v0.0.5** - Added Dogecoin address generation capabilities
|
10
|
+
- **v0.0.4** - Added Peercoin address generation capabilities
|
11
|
+
- **v0.0.3** - Added Litecoin address generation capabilities
|
12
|
+
- **v0.0.2** - Readme and usage instructions
|
13
|
+
- **v0.0.1** - Basic implementation for uncompressed addresses for Bitcoin
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2010-2014 Amol Hatwar
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# RubyCoin
|
2
|
+
RubyCoin **aims** to be the one library that rules them all crypto-currencies. Currently, only the following crypto-currencies are supported:
|
3
|
+
|
4
|
+
1. Bitcoin
|
5
|
+
2. Peercoin
|
6
|
+
3. Litecoin
|
7
|
+
4. Dogecoin
|
8
|
+
5. Namecoin
|
9
|
+
6. Feathercoin
|
10
|
+
7. Primecoin
|
11
|
+
8. Megacoin
|
12
|
+
9. Worldcoin
|
13
|
+
10. Quarkcoin
|
14
|
+
|
15
|
+
However, adding support for other crypto-currencies is fairly simple and contributions and pull-requests are always welcome.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
Installing the gem is trivial. It has extremely few dependencies besides OpenSSL.
|
19
|
+
|
20
|
+
$ gem install rubycoin
|
21
|
+
|
22
|
+
Or, if you are using bundler in your project, add the following line to your Gemfile and you're ready to roll.
|
23
|
+
|
24
|
+
gem 'rubycoin'
|
25
|
+
|
26
|
+
## Using RubyCoin
|
27
|
+
Using RubyCoin for generating addresses and private keys is extremely simple. Say if you'd want to generate a Bitcoin address, all you need to do is make a new Bitcoin address object like so:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'rubycoin'
|
31
|
+
|
32
|
+
btc = RubyCoin::Bitcoin::Address.new
|
33
|
+
btc.address # 1HGvB7sN6XBhz7Sd2TSz4Yt1vCqWvZZbTD
|
34
|
+
btc.private_key # KzJCkE79nZ7Ha8W4NtyjdJNFpjghuFwq5AxjKkPWCauY3NNKvjny
|
35
|
+
```
|
36
|
+
|
37
|
+
By default, compressed keys and addresses will be generated as they are the preferred standard. However, should you need uncompressed keys and addresses, all you need is to call new the following way:
|
38
|
+
|
39
|
+
RubyCoin::Bitcoin::Address.new(format: :uncompressed)
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
It is **likely** that RubyCoin will support deterministic and hierarchial wallets in the future once the security implications are completely understood.
|
43
|
+
|
44
|
+
Currently, the primary goal is to be able to generate addresses for as many as crypto-currencies as possible. The main candidates are:
|
45
|
+
|
46
|
+
1. ~~Litecoin~~
|
47
|
+
2. ~~Peercoin~~
|
48
|
+
3. ~~Dogecoin~~
|
49
|
+
4. Mastercoin
|
50
|
+
5. ~~Namecoin~~
|
51
|
+
6. ~~Quark~~
|
52
|
+
7. ~~Feathercoin~~
|
53
|
+
8. ~~Primecoin~~
|
54
|
+
9. ~~Megacoin~~
|
55
|
+
10. Infinitecoin
|
56
|
+
11. Novacoin
|
57
|
+
12. ~~Worldcoin~~
|
58
|
+
13. Darkcoin
|
59
|
+
14. Vertcoin
|
60
|
+
15. Maxcoin
|
61
|
+
|
62
|
+
Once the address generation mechanism and API is fairly stable for these currencies, signing messages and interacting will respective block-chains over the network **may** be considered.
|
63
|
+
|
64
|
+
Also, complete test coverage will be neat. It is currently **absent**. However, you can check generated addresses and keys manually by using the tools like [Brainwallet](http://brainwallet.org/).
|
65
|
+
|
66
|
+
## Authors
|
67
|
+
|
68
|
+
- [Amol Hatwar](http://www.hatwar.org/)
|
69
|
+
- [Girish Tryambake](http://www.tryambake.org/)
|
70
|
+
|
71
|
+
## License
|
72
|
+
The code in this repository is released under the liberal MIT license. A copy can be found in the `LICENSE` file.
|
73
|
+
|
74
|
+
## Copyright
|
75
|
+
Copyright © 2010-2014 - Amol Hatwar.
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
class Address
|
3
|
+
include RubyCoin::Utilities
|
4
|
+
|
5
|
+
attr_accessor :curve, :private_key, :public_key, :compressed
|
6
|
+
|
7
|
+
def initialize(seed, *args)
|
8
|
+
options = extract_options!(args)
|
9
|
+
|
10
|
+
case options[:format]
|
11
|
+
when :uncompressed
|
12
|
+
@compressed = false
|
13
|
+
else
|
14
|
+
@compressed = true
|
15
|
+
end
|
16
|
+
|
17
|
+
self.curve = ::OpenSSL::PKey::EC.new(seed, *args)
|
18
|
+
|
19
|
+
curve.generate_key
|
20
|
+
curve.private_key? ? init_private_key : nil_private_key
|
21
|
+
curve.public_key? ? init_public_key : nil_public_key
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :secret, :private_key
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
address
|
28
|
+
end
|
29
|
+
|
30
|
+
def compressed?
|
31
|
+
!!@compressed
|
32
|
+
end
|
33
|
+
|
34
|
+
def public_key
|
35
|
+
case compressed?
|
36
|
+
when true
|
37
|
+
# TODO: Optimize y-coord parity checking
|
38
|
+
curve.public_key.y.to_i(16).even? ?
|
39
|
+
'02' + curve.public_key.x.rjust(32, '0') :
|
40
|
+
'03' + curve.public_key.x.rjust(32, '0')
|
41
|
+
else
|
42
|
+
@public_key
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
def hash160(hex)
|
48
|
+
Digest::RMD160.hexdigest(Digest::SHA256.digest([hex].pack('H*')))
|
49
|
+
end
|
50
|
+
|
51
|
+
def checksum(hex)
|
52
|
+
Digest::SHA256.hexdigest(
|
53
|
+
Digest::SHA256.digest(
|
54
|
+
[hex].pack('H*')
|
55
|
+
))[0...8]
|
56
|
+
end
|
57
|
+
|
58
|
+
def number_to_base(number, alpha)
|
59
|
+
string, base = '', alpha.size
|
60
|
+
while(number >= base)
|
61
|
+
mod = number % base
|
62
|
+
string = alpha[mod,1] + string
|
63
|
+
number = (number - mod)/base
|
64
|
+
end
|
65
|
+
alpha[number,1] + string
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def init_private_key
|
70
|
+
@private_key = curve.private_key.to_hex
|
71
|
+
end
|
72
|
+
|
73
|
+
def init_public_key
|
74
|
+
@public_key = curve.public_key.to_hex
|
75
|
+
end
|
76
|
+
|
77
|
+
def nil_private_key
|
78
|
+
@private_key = nil
|
79
|
+
nil_public_key
|
80
|
+
end
|
81
|
+
|
82
|
+
def nil_public_key
|
83
|
+
@address = nil
|
84
|
+
@public_key = nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Bitcoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
'1' + encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Dogecoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Feathercoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Litecoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Megacoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Namecoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Peercoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Primecoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(compressed=true, *args)
|
5
|
+
super(CURVE_TYPE, compressed, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Quarkcoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubyCoin
|
2
|
+
module Worldcoin
|
3
|
+
class Address < RubyCoin::Address
|
4
|
+
def initialize(*args)
|
5
|
+
super(CURVE_TYPE, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def address
|
9
|
+
encode_address
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash(hex)
|
13
|
+
PUBKEY_VER + hash160(hex)
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
key = compressed? ? @private_key + '01' : @private_key
|
18
|
+
hex = PRIKEY_VER + key
|
19
|
+
sum = checksum(hex)
|
20
|
+
|
21
|
+
number_to_base((hex + sum).to_i(16), ADDR_CHARS)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def encode_address
|
26
|
+
hash = version_hash(public_key)
|
27
|
+
sum = checksum(hash)
|
28
|
+
number_to_base((hash + sum).to_i(16), ADDR_CHARS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/rubycoin.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'digest/sha2'
|
2
|
+
require 'digest/rmd160'
|
3
|
+
require 'openssl'
|
4
|
+
|
5
|
+
module RubyCoin
|
6
|
+
end
|
7
|
+
|
8
|
+
require_relative 'ruby_coin/version'
|
9
|
+
require_relative 'ruby_coin/utilities'
|
10
|
+
require_relative 'ruby_coin/address'
|
11
|
+
|
12
|
+
require_relative 'ruby_coin/bitcoin'
|
13
|
+
require_relative 'ruby_coin/litecoin'
|
14
|
+
require_relative 'ruby_coin/peercoin'
|
15
|
+
require_relative 'ruby_coin/dogecoin'
|
16
|
+
require_relative 'ruby_coin/namecoin'
|
17
|
+
require_relative 'ruby_coin/feathercoin'
|
18
|
+
require_relative 'ruby_coin/primecoin'
|
19
|
+
require_relative 'ruby_coin/megacoin'
|
20
|
+
require_relative 'ruby_coin/worldcoin'
|
21
|
+
require_relative 'ruby_coin/quarkcoin'
|
22
|
+
|
23
|
+
# Monkeypatch OpenSSL for utility methods
|
24
|
+
module ::OpenSSL
|
25
|
+
class BN
|
26
|
+
def to_hex; to_i.to_s(16).rjust(64, '0'); end
|
27
|
+
end
|
28
|
+
|
29
|
+
class PKey::EC::Point
|
30
|
+
def to_hex; to_bn.to_i.to_s(16).rjust(130, '0'); end
|
31
|
+
def x; to_hex[2..65]; end
|
32
|
+
def y; to_hex[66..130]; end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubycoin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amol Hatwar
|
8
|
+
- Girish Tryambake
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Use multiple crypto-currencies with ease
|
15
|
+
email: amol@hatwar.org
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- MIT-LICENSE
|
22
|
+
- README.md
|
23
|
+
- lib/ruby_coin/address.rb
|
24
|
+
- lib/ruby_coin/bitcoin.rb
|
25
|
+
- lib/ruby_coin/bitcoin/address.rb
|
26
|
+
- lib/ruby_coin/dogecoin.rb
|
27
|
+
- lib/ruby_coin/dogecoin/address.rb
|
28
|
+
- lib/ruby_coin/feathercoin.rb
|
29
|
+
- lib/ruby_coin/feathercoin/address.rb
|
30
|
+
- lib/ruby_coin/litecoin.rb
|
31
|
+
- lib/ruby_coin/litecoin/address.rb
|
32
|
+
- lib/ruby_coin/megacoin.rb
|
33
|
+
- lib/ruby_coin/megacoin/address.rb
|
34
|
+
- lib/ruby_coin/namecoin.rb
|
35
|
+
- lib/ruby_coin/namecoin/address.rb
|
36
|
+
- lib/ruby_coin/peercoin.rb
|
37
|
+
- lib/ruby_coin/peercoin/address.rb
|
38
|
+
- lib/ruby_coin/primecoin.rb
|
39
|
+
- lib/ruby_coin/primecoin/address.rb
|
40
|
+
- lib/ruby_coin/quarkcoin.rb
|
41
|
+
- lib/ruby_coin/quarkcoin/address.rb
|
42
|
+
- lib/ruby_coin/utilities.rb
|
43
|
+
- lib/ruby_coin/version.rb
|
44
|
+
- lib/ruby_coin/worldcoin.rb
|
45
|
+
- lib/ruby_coin/worldcoin/address.rb
|
46
|
+
- lib/rubycoin.rb
|
47
|
+
homepage: https://github.com/AxisOfEval/rubycoin
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 2.2.0
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: One library to rule them all!
|
71
|
+
test_files: []
|