bitpay-sdk 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -0
- data/lib/bitpay.rb +1 -2
- data/lib/bitpay/key_utils.rb +4 -10
- data/lib/bitpay/version.rb +1 -1
- data/spec/key_utils_spec.rb +0 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f62c21b534bf518ba18041a4ef0035c1b0813da
|
4
|
+
data.tar.gz: 1464d4971a9dc7d3d83bf52db905f3fe88a389bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f6fcbd6e1b24b51d11eef2c951de9d06106aa39d14136ede7e6829de8b8afa2c6865968de62de0f37b60e151a2e5dd9712a0be628c50fe4073a505179339629
|
7
|
+
data.tar.gz: 9d7d03a789872bea2474f12eb96472e64fd7ed69f25c1a05390fd645363e9c62041860fe7c835ffcc506989f5238714076a166abcab977ae2257f9ed21a891ef
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/lib/bitpay.rb
CHANGED
@@ -22,8 +22,7 @@ module BitPay
|
|
22
22
|
# User agent reported to API
|
23
23
|
USER_AGENT = 'ruby-bitpay-client '+VERSION
|
24
24
|
|
25
|
-
|
26
|
-
MISSING_PEM = 'No pem file specified. Pass pem or set ENV variable BITPAY_PEM'
|
25
|
+
MISSING_PEM = 'No pem file specified. Pass pem string'
|
27
26
|
|
28
27
|
class BitPayError < StandardError; end
|
29
28
|
class ArgumentError < ArgumentError; end
|
data/lib/bitpay/key_utils.rb
CHANGED
@@ -37,12 +37,6 @@ module BitPay
|
|
37
37
|
key
|
38
38
|
end
|
39
39
|
|
40
|
-
## Gets private key from ENV variable or local FS
|
41
|
-
#
|
42
|
-
def get_local_pem_file
|
43
|
-
ENV['BITPAY_PEM'] || (raise BitPayError, MISSING_KEY)
|
44
|
-
end
|
45
|
-
|
46
40
|
def get_private_key key
|
47
41
|
key.private_key.to_int.to_s(16)
|
48
42
|
end
|
@@ -53,18 +47,18 @@ module BitPay
|
|
53
47
|
end
|
54
48
|
|
55
49
|
def get_private_key_from_pem pem
|
56
|
-
raise BitPayError,
|
50
|
+
raise BitPayError, MISSING_PEM
|
57
51
|
key = OpenSSL::PKey::EC.new(pem)
|
58
52
|
get_private_key key
|
59
53
|
end
|
60
54
|
|
61
55
|
def get_public_key_from_pem pem
|
62
|
-
raise BitPayError,
|
56
|
+
raise BitPayError, MISSING_PEM unless pem
|
63
57
|
key = OpenSSL::PKey::EC.new(pem)
|
64
58
|
get_public_key key
|
65
59
|
end
|
66
60
|
|
67
|
-
def generate_sin_from_pem
|
61
|
+
def generate_sin_from_pem pem
|
68
62
|
#http://blog.bitpay.com/2014/07/01/bitauth-for-decentralized-authentication.html
|
69
63
|
#https://en.bitcoin.it/wiki/Identity_protocol_v1
|
70
64
|
|
@@ -72,7 +66,7 @@ module BitPay
|
|
72
66
|
# hence the requirement to use [].pack("H*") to convert to binary for each step
|
73
67
|
|
74
68
|
#Generate Private Key
|
75
|
-
key = OpenSSL::PKey::EC.new
|
69
|
+
key = OpenSSL::PKey::EC.new pem
|
76
70
|
key.public_key.group.point_conversion_form = :compressed
|
77
71
|
public_key = key.public_key.to_bn.to_s(2)
|
78
72
|
step_one = Digest::SHA256.hexdigest(public_key)
|
data/lib/bitpay/version.rb
CHANGED
data/spec/key_utils_spec.rb
CHANGED
@@ -3,19 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe BitPay::KeyUtils do
|
4
4
|
let(:key_utils) {BitPay::KeyUtils}
|
5
5
|
|
6
|
-
|
7
|
-
describe '.get_local_private_key' do
|
8
|
-
it "should get the key from the ENV['PRIV_KEY'] variable" do
|
9
|
-
stub_const('ENV', {'BITPAY_PEM' => PEM})
|
10
|
-
expect(key_utils.get_local_pem_file).to eq(PEM)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should throw an error if the ENV['PRIV_KEY'] variable is not set" do
|
14
|
-
expect {key_utils.get_local_pem_file}.to raise_error( BitPay::BitPayError )
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
6
|
describe '.generate_pem' do
|
20
7
|
it 'should generate a pem string' do
|
21
8
|
regex = /BEGIN\ EC\ PRIVATE\ KEY/
|
@@ -42,11 +29,6 @@ describe BitPay::KeyUtils do
|
|
42
29
|
expect(key_utils.generate_sin_from_pem(pem)).to eq sin
|
43
30
|
end
|
44
31
|
|
45
|
-
it 'will attempt to use an env variable if no key is provided' do
|
46
|
-
stub_const('ENV', {'BITPAY_PEM' => PEM})
|
47
|
-
expect(key_utils.generate_sin_from_pem(nil)).to eq sin
|
48
|
-
end
|
49
|
-
|
50
32
|
end
|
51
33
|
|
52
34
|
context "errors when priv_key is not provided" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitpay-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitpay, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|