fabric-gateway 0.5.0 → 0.6.0

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
  SHA256:
3
- metadata.gz: 440a8fa889f826b8b34b4036566bfe969a9daac00f38e5ee3a0898a815a85be5
4
- data.tar.gz: bb959422d092506445984a7a1b6370a290febf6c01b1edfaecbfc6e2b82da5f2
3
+ metadata.gz: 97655326a3d8126a2a70b6a58063695c944b6620e9b2b8611ed4962d4d95337e
4
+ data.tar.gz: b7d8f9b3ae323335e40477bd4f66943d8c1a72e194e6624c53dcbc495ab01d4b
5
5
  SHA512:
6
- metadata.gz: b44c4324907688d7049a48a018d245812ee3f563ade9707fc52742c41f35f618f05442a1bfe442f1d0efa02be7fc4aca258edee70bbd698b3a4da01683568484
7
- data.tar.gz: eea0cfad7d97571c24da1eeec72958bafc737f90c6a9f808a657adb50faca2312a15ce8b227ac8db6385f9fe7a31f01e9e157c999065b8ed95973788dbaf5cdd
6
+ metadata.gz: f8a83cf4492950b145988ce9a7aaf88c49da2a7f23e3e2559f9f4a95ced9997d8bb567696a52995504ae49de90a80c7825055e6affc61b5fab251f9f29eabeeb
7
+ data.tar.gz: 4b406361a801e789d1bffd7059c595d5f46f76e30e4b8a9c6262fd7d06f381b767b0a1f4f649a37dd6452595352f3f150b43f9e85a920cffc051cfe5e7087c27
@@ -19,19 +19,21 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['2.6', '2.7', '3.0']
22
+ ruby-version: ['3.0', '3.1', '3.2']
23
23
 
24
24
  steps:
25
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v4
26
26
  - name: Set up Ruby
27
27
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
28
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
29
  # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
30
+ uses: ruby/setup-ruby@master
31
31
  with:
32
32
  ruby-version: ${{ matrix.ruby-version }}
33
33
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
34
  - name: Run tests
35
35
  run: bundle exec rake
36
- env:
37
- CODECOV_TOKEN: 4b75ccca-3149-4610-99fb-3a5aeff4ff00
36
+ - uses: codecov/codecov-action@v3
37
+ with:
38
+ token: 4b75ccca-3149-4610-99fb-3a5aeff4ff00
39
+
@@ -8,10 +8,10 @@ jobs:
8
8
 
9
9
  steps:
10
10
  - uses: actions/checkout@v2
11
- - name: Set up Ruby 2.7
11
+ - name: Set up Ruby 3.0
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: 2.7
14
+ ruby-version: 3.0
15
15
  - name: Cache gems
16
16
  uses: actions/cache@v1
17
17
  with:
@@ -22,7 +22,6 @@ jobs:
22
22
  - name: Install gems
23
23
  run: |
24
24
  bundle config path vendor/bundle
25
- bundle config set without 'default doc job cable storage ujs test db'
26
25
  bundle install --jobs 4 --retry 3
27
26
  - name: Run RuboCop
28
27
  run: bundle exec rubocop --parallel
@@ -11,7 +11,7 @@ jobs:
11
11
  - name: Set up Ruby 2.7
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: 2.7
14
+ ruby-version: 3.2
15
15
  - name: Cache gems
16
16
  uses: actions/cache@v1
17
17
  with:
@@ -22,7 +22,6 @@ jobs:
22
22
  - name: Install gems
23
23
  run: |
24
24
  bundle config path vendor/bundle
25
- bundle config set without 'default doc job cable storage ujs test db'
26
25
  bundle install --jobs 4 --retry 3
27
26
  - name: Run yard stats
28
27
  run: bundle exec yard stats --list-undoc --no-cache --fail-on-warning
data/.rubocop.yml CHANGED
@@ -9,7 +9,7 @@ Metrics/BlockLength:
9
9
 
10
10
  AllCops:
11
11
  NewCops: enable
12
- TargetRubyVersion: 2.6
12
+ TargetRubyVersion: 3.0
13
13
  Exclude:
14
14
  - vendor/bundle/**/*
15
15
  # exclude protoc generated code
@@ -20,4 +20,6 @@ AllCops:
20
20
  - 'lib/orderer/*'
21
21
  - 'lib/peer/*'
22
22
 
23
-
23
+ RSpec/SpecFilePathFormat:
24
+ Exclude:
25
+ - spec/fabric/entities/*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.5
1
+ 3.2.2
data/Gemfile CHANGED
@@ -7,3 +7,12 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 12.3.3'
9
9
  gem 'rspec', '~> 3.0'
10
+
11
+ gem 'factory_bot', '~> 6.3.0'
12
+ gem 'grpc-tools', '~> 1.59.0'
13
+ gem 'rubocop', '~> 1.57', '>= 1.57.1'
14
+ gem 'rubocop-rspec', '~> 2.24.1'
15
+ gem 'simplecov', '~> 0.22.0'
16
+ gem 'simplecov-cobertura', '~> 2.1'
17
+ gem 'timecop', '~> 0.9.8'
18
+ gem 'yard', '~> 0.9.34'
data/Rakefile CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
- require 'rake/notes/rake_task'
6
5
 
7
6
  RSpec::Core::RakeTask.new(:spec)
8
7
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Ruby port of the Hyperledger Fabric Gateway SDK'
13
13
  spec.homepage = 'https://github.com/ethicalidentity/fabric-gateway-ruby'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.0')
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
 
@@ -28,17 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.bindir = 'exe'
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
- spec.add_dependency('google-protobuf', '>= 3.19.1')
31
+ spec.add_dependency('google-protobuf', '~> 3.24', '>= 3.24.4')
32
32
  spec.add_dependency('grpc', '~> 1.42')
33
- spec.add_development_dependency('codecov', '~> 0.6.0')
34
- spec.add_development_dependency('factory_bot', '~> 6.2.0')
35
- spec.add_development_dependency('grpc-tools', '~> 1.46.2')
36
- spec.add_development_dependency('rake-notes', '~> 0.2.0')
37
- spec.add_development_dependency('rubocop', '~> 1.23.0')
38
- spec.add_development_dependency('rubocop-rspec', '~> 2.6.0')
39
- spec.add_development_dependency('simplecov', '~> 0.21.2')
40
- spec.add_development_dependency('timecop', '~> 0.9.4')
41
- spec.add_development_dependency('yard', '~> 0.9.27')
42
33
  spec.metadata = {
43
34
  'rubygems_mfa_required' => 'true'
44
35
  }
@@ -40,7 +40,7 @@ module Fabric
40
40
 
41
41
  def verify(public_key, message, signature)
42
42
  digest = digest message
43
- openssl_pkey = openssl_pkey_from_public_key public_key
43
+ openssl_pkey = pkey_from_public_key public_key
44
44
  sequence = OpenSSL::ASN1.decode signature
45
45
  return false unless check_malleability sequence, openssl_pkey.group.order
46
46
 
@@ -48,8 +48,7 @@ module Fabric
48
48
  end
49
49
 
50
50
  def generate_private_key
51
- key = OpenSSL::PKey::EC.new curve
52
- key.generate_key!
51
+ key = OpenSSL::PKey::EC.generate(curve)
53
52
 
54
53
  key.private_key.to_s(16).downcase
55
54
  end
@@ -133,15 +132,35 @@ module Fabric
133
132
  aes.update(encrypted_data) + aes.final
134
133
  end
135
134
 
136
- def pkey_pem_from_private_key(private_key)
135
+ # when https://github.com/ruby/openssl/pull/555 gets merged, consider refactoring
136
+ # the code here
137
+ # rubocop:disable Metrics/AbcSize
138
+ # rubocop:disable Metrics/MethodLength
139
+ def pkey_from_private_key(private_key)
137
140
  public_key = restore_public_key private_key
138
- key = OpenSSL::PKey::EC.new curve
139
- key.private_key = OpenSSL::BN.new private_key, 16
140
- key.public_key = OpenSSL::PKey::EC::Point.new key.group,
141
- OpenSSL::BN.new(public_key, 16)
142
141
 
143
- pkey = OpenSSL::PKey::EC.new(key.public_key.group)
144
- pkey.public_key = key.public_key
142
+ group = OpenSSL::PKey::EC::Group.new(curve)
143
+
144
+ private_key_bn = OpenSSL::BN.new(private_key, 16)
145
+ public_key_bn = OpenSSL::BN.new(public_key, 16)
146
+ public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
147
+
148
+ asn1 = OpenSSL::ASN1::Sequence(
149
+ [
150
+ OpenSSL::ASN1::Integer.new(1),
151
+ OpenSSL::ASN1::OctetString(private_key_bn.to_s(2)),
152
+ OpenSSL::ASN1::ObjectId(curve, 0, :EXPLICIT),
153
+ OpenSSL::ASN1::BitString(public_key_point.to_octet_string(:uncompressed), 1, :EXPLICIT)
154
+ ]
155
+ )
156
+
157
+ OpenSSL::PKey::EC.new(asn1.to_der)
158
+ end
159
+ # rubocop:enable Metrics/AbcSize
160
+ # rubocop:enable Metrics/MethodLength
161
+
162
+ def pem_from_private_key(private_key)
163
+ pkey = pkey_from_private_key(private_key)
145
164
 
146
165
  pkey.to_pem
147
166
  end
@@ -151,29 +170,33 @@ module Fabric
151
170
  key.private_key.to_s(16).downcase
152
171
  end
153
172
 
154
- def pkey_from_x509_certificate(certificate)
173
+ def public_key_from_x509_certificate(certificate)
155
174
  cert = OpenSSL::X509::Certificate.new(certificate)
156
175
  cert.public_key.public_key.to_bn.to_s(16).downcase
157
176
  end
158
177
 
159
- def openssl_pkey_from_public_key(public_key)
160
- pkey = OpenSSL::PKey::EC.new curve
161
- pkey.public_key = OpenSSL::PKey::EC::Point.new(pkey.group, OpenSSL::BN.new(public_key, 16))
178
+ # rubocop:disable Metrics/MethodLength
179
+ def pkey_from_public_key(public_key)
180
+ group = OpenSSL::PKey::EC::Group.new(curve)
162
181
 
163
- pkey
164
- end
182
+ public_key_bn = OpenSSL::BN.new(public_key, 16)
183
+ public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
165
184
 
166
- private
167
-
168
- def pkey_from_private_key(private_key)
169
- public_key = restore_public_key private_key
170
- key = OpenSSL::PKey::EC.new curve
171
- key.private_key = OpenSSL::BN.new private_key, 16
172
- key.public_key = OpenSSL::PKey::EC::Point.new key.group,
173
- OpenSSL::BN.new(public_key, 16)
185
+ asn1 = OpenSSL::ASN1::Sequence.new(
186
+ [
187
+ OpenSSL::ASN1::Sequence.new([
188
+ OpenSSL::ASN1::ObjectId.new('id-ecPublicKey'),
189
+ OpenSSL::ASN1::ObjectId.new(group.curve_name)
190
+ ]),
191
+ OpenSSL::ASN1::BitString.new(public_key_point.to_octet_string(:uncompressed))
192
+ ]
193
+ )
174
194
 
175
- key
195
+ OpenSSL::PKey::EC.new(asn1.to_der)
176
196
  end
197
+ # rubocop:enable Metrics/MethodLength
198
+
199
+ private
177
200
 
178
201
  # barely understand this code - this link provides a good explanation:
179
202
  # http://coders-errand.com/malleability-ecdsa-signatures/
@@ -42,7 +42,7 @@ module Fabric
42
42
  # @return [boolean] true if valid, false otherwise
43
43
  #
44
44
  def validate_key_integrity
45
- cert_pubkey = @crypto_suite.pkey_from_x509_certificate(certificate)
45
+ cert_pubkey = @crypto_suite.public_key_from_x509_certificate(certificate)
46
46
  priv_pubkey = @crypto_suite.restore_public_key(@private_key)
47
47
 
48
48
  @public_key == cert_pubkey && @public_key == priv_pubkey
@@ -6,9 +6,9 @@ module Fabric
6
6
  #
7
7
  class Status
8
8
  TRANSACTION_STATUSES = ::Protos::TxValidationCode.constants.map(&::Protos::TxValidationCode.method(:const_get))
9
- .collect do |i|
9
+ .to_h do |i|
10
10
  [::Protos::TxValidationCode.lookup(i), i]
11
- end.to_h
11
+ end
12
12
 
13
13
  # @return [Integer] Block number in which the transaction committed.
14
14
  attr_reader :block_number
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fabric
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabric-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Chan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-05 00:00:00.000000000 Z
11
+ date: 2023-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.24'
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: 3.19.1
22
+ version: 3.24.4
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.24'
24
30
  - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: 3.19.1
32
+ version: 3.24.4
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: grpc
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -38,132 +44,6 @@ dependencies:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '1.42'
41
- - !ruby/object:Gem::Dependency
42
- name: codecov
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.6.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.6.0
55
- - !ruby/object:Gem::Dependency
56
- name: factory_bot
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 6.2.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 6.2.0
69
- - !ruby/object:Gem::Dependency
70
- name: grpc-tools
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.46.2
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.46.2
83
- - !ruby/object:Gem::Dependency
84
- name: rake-notes
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.2.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.2.0
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 1.23.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 1.23.0
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 2.6.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 2.6.0
125
- - !ruby/object:Gem::Dependency
126
- name: simplecov
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 0.21.2
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.21.2
139
- - !ruby/object:Gem::Dependency
140
- name: timecop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 0.9.4
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 0.9.4
153
- - !ruby/object:Gem::Dependency
154
- name: yard
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: 0.9.27
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 0.9.27
167
47
  description: Ruby port of the Hyperledger Fabric Gateway SDK
168
48
  email:
169
49
  - jonathan.chan@ethicalidentity.com
@@ -237,7 +117,7 @@ licenses:
237
117
  - MIT
238
118
  metadata:
239
119
  rubygems_mfa_required: 'true'
240
- post_install_message:
120
+ post_install_message:
241
121
  rdoc_options: []
242
122
  require_paths:
243
123
  - lib
@@ -245,15 +125,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
125
  requirements:
246
126
  - - ">="
247
127
  - !ruby/object:Gem::Version
248
- version: 2.6.0
128
+ version: '3.0'
249
129
  required_rubygems_version: !ruby/object:Gem::Requirement
250
130
  requirements:
251
131
  - - ">="
252
132
  - !ruby/object:Gem::Version
253
133
  version: '0'
254
134
  requirements: []
255
- rubygems_version: 3.1.6
256
- signing_key:
135
+ rubygems_version: 3.4.10
136
+ signing_key:
257
137
  specification_version: 4
258
138
  summary: Hyperledger Fabric Gateway SDK
259
139
  test_files: []