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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8fa092d5243a1f4759ce3735f53b892ffd70741
4
- data.tar.gz: 2befc033218ad775ecada44facf7836498e86371
3
+ metadata.gz: 9f62c21b534bf518ba18041a4ef0035c1b0813da
4
+ data.tar.gz: 1464d4971a9dc7d3d83bf52db905f3fe88a389bb
5
5
  SHA512:
6
- metadata.gz: 93fd95f0d1533ef5cf48eed9e964a03b2320409b6ee6fc3fbb66a75012f94a23c8568742bab6e2086994d1eae99635acac70c0b94254bbb2c7a8fb5448b29f9c
7
- data.tar.gz: 5196595d3e0d36c58c1a3481d2a4924b848583e417e9418954c3f66921255fa0369cc37d3143afaf9d0a3b1fce138fdf551990a48182289cb153b9e7733da19f
6
+ metadata.gz: 8f6fcbd6e1b24b51d11eef2c951de9d06106aa39d14136ede7e6829de8b8afa2c6865968de62de0f37b60e151a2e5dd9712a0be628c50fe4073a505179339629
7
+ data.tar.gz: 9d7d03a789872bea2474f12eb96472e64fd7ed69f25c1a05390fd645363e9c62041860fe7c835ffcc506989f5238714076a166abcab977ae2257f9ed21a891ef
data/.gitignore CHANGED
@@ -5,3 +5,5 @@ pkg
5
5
  .c9
6
6
  .ruby-version
7
7
  .ruby-gemset
8
+ *.swo
9
+ *.swp
data/.travis.yml CHANGED
@@ -1,2 +1,3 @@
1
1
  rvm:
2
2
  - 2.1.0
3
+
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
- MISSING_KEY = 'No Private Key specified. Pass priv_key or set ENV variable PRIV_KEY'
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
@@ -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, "Missing key" unless pem
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, MISSING_KEY unless pem
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(pem = nil)
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(pem ||= get_local_pem_file)
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)
@@ -3,5 +3,5 @@
3
3
  # or https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
4
4
 
5
5
  module BitPay
6
- VERSION = '2.1.0'
6
+ VERSION = '2.1.1'
7
7
  end
@@ -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.0
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-05 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json