hyperledger-fabric-sdk 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fabric/block_decoder.rb +299 -0
  3. data/lib/fabric/chaincode_response.rb +47 -0
  4. data/lib/fabric/channel.rb +55 -34
  5. data/lib/fabric/client.rb +107 -25
  6. data/lib/fabric/configuration.rb +12 -4
  7. data/lib/fabric/constants.rb +1 -1
  8. data/lib/fabric/crypto_suite.rb +145 -0
  9. data/lib/fabric/enumerator_queue.rb +26 -0
  10. data/lib/fabric/error.rb +52 -0
  11. data/lib/fabric/event_hub.rb +81 -0
  12. data/lib/fabric/helper.rb +31 -0
  13. data/lib/fabric/identity.rb +25 -19
  14. data/lib/fabric/logger.rb +37 -0
  15. data/lib/fabric/orderer.rb +18 -2
  16. data/lib/fabric/peer.rb +15 -36
  17. data/lib/fabric/proposal.rb +100 -0
  18. data/lib/{protos → fabric/protos}/common/collection_pb.rb +14 -14
  19. data/lib/{protos → fabric/protos}/common/common_pb.rb +37 -36
  20. data/lib/fabric/protos/common/configtx_pb.rb +71 -0
  21. data/lib/{protos → fabric/protos}/common/configuration_pb.rb +13 -13
  22. data/lib/{protos → fabric/protos}/common/ledger_pb.rb +2 -2
  23. data/lib/{protos → fabric/protos}/common/policies_pb.rb +19 -19
  24. data/lib/fabric/protos/discovery/protocol_pb.rb +120 -0
  25. data/lib/{protos → fabric/protos}/discovery/protocol_services_pb.rb +0 -1
  26. data/lib/fabric/protos/gossip/message_pb.rb +233 -0
  27. data/lib/{protos → fabric/protos}/gossip/message_services_pb.rb +0 -1
  28. data/lib/{protos → fabric/protos}/idemix/idemix_pb.rb +37 -37
  29. data/lib/{protos → fabric/protos}/ledger/queryresult/kv_query_result_pb.rb +5 -5
  30. data/lib/fabric/protos/ledger/rwset/kvrwset/kv_rwset_pb.rb +85 -0
  31. data/lib/fabric/protos/ledger/rwset/rwset_pb.rb +46 -0
  32. data/lib/{protos → fabric/protos}/msp/identities_pb.rb +4 -4
  33. data/lib/{protos → fabric/protos}/msp/msp_config_pb.rb +27 -27
  34. data/lib/{protos → fabric/protos}/msp/msp_principal_pb.rb +20 -20
  35. data/lib/fabric/protos/orderer/ab_pb.rb +52 -0
  36. data/lib/{protos → fabric/protos}/orderer/ab_services_pb.rb +0 -1
  37. data/lib/fabric/protos/orderer/cluster_pb.rb +31 -0
  38. data/lib/fabric/protos/orderer/cluster_services_pb.rb +31 -0
  39. data/lib/{protos → fabric/protos}/orderer/configuration_pb.rb +11 -10
  40. data/lib/fabric/protos/orderer/etcdraft/configuration_pb.rb +21 -0
  41. data/lib/{protos → fabric/protos}/orderer/kafka_pb.rb +16 -16
  42. data/lib/{protos → fabric/protos}/peer/admin_pb.rb +12 -12
  43. data/lib/{protos → fabric/protos}/peer/admin_services_pb.rb +0 -1
  44. data/lib/{protos → fabric/protos}/peer/chaincode_event_pb.rb +2 -2
  45. data/lib/fabric/protos/peer/chaincode_pb.rb +60 -0
  46. data/lib/fabric/protos/peer/chaincode_shim_pb.rb +129 -0
  47. data/lib/{protos → fabric/protos}/peer/chaincode_shim_services_pb.rb +0 -1
  48. data/lib/{protos → fabric/protos}/peer/configuration_pb.rb +10 -10
  49. data/lib/fabric/protos/peer/events_pb.rb +45 -0
  50. data/lib/fabric/protos/peer/events_services_pb.rb +34 -0
  51. data/lib/{protos → fabric/protos}/peer/peer_pb.rb +5 -5
  52. data/lib/{protos → fabric/protos}/peer/peer_services_pb.rb +0 -1
  53. data/lib/{protos → fabric/protos}/peer/proposal_pb.rb +13 -13
  54. data/lib/{protos → fabric/protos}/peer/proposal_response_pb.rb +11 -11
  55. data/lib/{protos → fabric/protos}/peer/query_pb.rb +10 -10
  56. data/lib/{protos → fabric/protos}/peer/resources_pb.rb +12 -12
  57. data/lib/{protos → fabric/protos}/peer/signed_cc_dep_spec_pb.rb +3 -3
  58. data/lib/{protos → fabric/protos}/peer/transaction_pb.rb +22 -18
  59. data/lib/fabric/protos/token/prover_pb.rb +66 -0
  60. data/lib/fabric/protos/token/prover_services_pb.rb +33 -0
  61. data/lib/fabric/protos/token/transaction_pb.rb +41 -0
  62. data/lib/{protos → fabric/protos}/transientstore/transientstore_pb.rb +4 -4
  63. data/lib/fabric/queue.rb +26 -0
  64. data/lib/fabric/transaction.rb +51 -0
  65. data/lib/fabric/transaction_info.rb +20 -0
  66. data/lib/fabric/version.rb +1 -1
  67. data/lib/fabric.rb +74 -0
  68. data/lib/fabric_ca/attribute.rb +7 -0
  69. data/lib/fabric_ca/client.rb +11 -19
  70. data/lib/fabric_ca/configuration.rb +4 -2
  71. data/lib/fabric_ca/connection.rb +22 -20
  72. data/lib/fabric_ca/error.rb +3 -2
  73. data/lib/fabric_ca/faraday_middleware/basic_auth.rb +3 -3
  74. data/lib/fabric_ca/faraday_middleware/raise_http_exception.rb +13 -13
  75. data/lib/fabric_ca/faraday_middleware/token_auth.rb +10 -12
  76. data/lib/fabric_ca/request.rb +13 -24
  77. data/lib/fabric_ca/version.rb +1 -1
  78. data/lib/fabric_ca.rb +16 -0
  79. data/lib/hyperledger-fabric-sdk.rb +2 -47
  80. metadata +161 -61
  81. data/lib/crypto_suite/ecdsa_aes.rb +0 -86
  82. data/lib/fabric/peer_endorser.rb +0 -85
  83. data/lib/fabric/transaction_id.rb +0 -11
  84. data/lib/fabric/user.rb +0 -24
  85. data/lib/fabric_ca/tools.rb +0 -35
  86. data/lib/protos/common/configtx_pb.rb +0 -71
  87. data/lib/protos/discovery/protocol_pb.rb +0 -119
  88. data/lib/protos/gossip/message_pb.rb +0 -233
  89. data/lib/protos/ledger/rwset/kvrwset/kv_rwset_pb.rb +0 -85
  90. data/lib/protos/ledger/rwset/rwset_pb.rb +0 -46
  91. data/lib/protos/orderer/ab_pb.rb +0 -52
  92. data/lib/protos/peer/chaincode_pb.rb +0 -60
  93. data/lib/protos/peer/chaincode_shim_pb.rb +0 -94
  94. data/lib/protos/peer/events_pb.rb +0 -98
  95. data/lib/protos/peer/events_services_pb.rb +0 -59
metadata CHANGED
@@ -1,35 +1,160 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperledger-fabric-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Kirshin(kirshin)
8
8
  - "(qiusugang)"
9
- - Bryan Padron(djlazz3)
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
12
  date: 2019-11-12 00:00:00.000000000 Z
14
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.8'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.8'
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday_middleware
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.13'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.13'
42
+ - !ruby/object:Gem::Dependency
43
+ name: faraday
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.17'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.17'
56
+ - !ruby/object:Gem::Dependency
57
+ name: grpc
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.25'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.25'
70
+ - !ruby/object:Gem::Dependency
71
+ name: digest-sha3
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.1'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.1'
15
84
  description: ''
16
85
  email:
17
86
  executables: []
18
87
  extensions: []
19
88
  extra_rdoc_files: []
20
89
  files:
21
- - lib/crypto_suite/ecdsa_aes.rb
90
+ - lib/fabric.rb
91
+ - lib/fabric/block_decoder.rb
92
+ - lib/fabric/chaincode_response.rb
22
93
  - lib/fabric/channel.rb
23
94
  - lib/fabric/client.rb
24
95
  - lib/fabric/configuration.rb
25
96
  - lib/fabric/constants.rb
97
+ - lib/fabric/crypto_suite.rb
98
+ - lib/fabric/enumerator_queue.rb
99
+ - lib/fabric/error.rb
100
+ - lib/fabric/event_hub.rb
101
+ - lib/fabric/helper.rb
26
102
  - lib/fabric/identity.rb
103
+ - lib/fabric/logger.rb
27
104
  - lib/fabric/orderer.rb
28
105
  - lib/fabric/peer.rb
29
- - lib/fabric/peer_endorser.rb
30
- - lib/fabric/transaction_id.rb
31
- - lib/fabric/user.rb
106
+ - lib/fabric/proposal.rb
107
+ - lib/fabric/protos/common/collection_pb.rb
108
+ - lib/fabric/protos/common/common_pb.rb
109
+ - lib/fabric/protos/common/configtx_pb.rb
110
+ - lib/fabric/protos/common/configuration_pb.rb
111
+ - lib/fabric/protos/common/ledger_pb.rb
112
+ - lib/fabric/protos/common/policies_pb.rb
113
+ - lib/fabric/protos/discovery/protocol_pb.rb
114
+ - lib/fabric/protos/discovery/protocol_services_pb.rb
115
+ - lib/fabric/protos/gossip/message_pb.rb
116
+ - lib/fabric/protos/gossip/message_services_pb.rb
117
+ - lib/fabric/protos/idemix/idemix_pb.rb
118
+ - lib/fabric/protos/ledger/queryresult/kv_query_result_pb.rb
119
+ - lib/fabric/protos/ledger/rwset/kvrwset/kv_rwset_pb.rb
120
+ - lib/fabric/protos/ledger/rwset/rwset_pb.rb
121
+ - lib/fabric/protos/msp/identities_pb.rb
122
+ - lib/fabric/protos/msp/msp_config_pb.rb
123
+ - lib/fabric/protos/msp/msp_principal_pb.rb
124
+ - lib/fabric/protos/orderer/ab_pb.rb
125
+ - lib/fabric/protos/orderer/ab_services_pb.rb
126
+ - lib/fabric/protos/orderer/cluster_pb.rb
127
+ - lib/fabric/protos/orderer/cluster_services_pb.rb
128
+ - lib/fabric/protos/orderer/configuration_pb.rb
129
+ - lib/fabric/protos/orderer/etcdraft/configuration_pb.rb
130
+ - lib/fabric/protos/orderer/kafka_pb.rb
131
+ - lib/fabric/protos/peer/admin_pb.rb
132
+ - lib/fabric/protos/peer/admin_services_pb.rb
133
+ - lib/fabric/protos/peer/chaincode_event_pb.rb
134
+ - lib/fabric/protos/peer/chaincode_pb.rb
135
+ - lib/fabric/protos/peer/chaincode_shim_pb.rb
136
+ - lib/fabric/protos/peer/chaincode_shim_services_pb.rb
137
+ - lib/fabric/protos/peer/configuration_pb.rb
138
+ - lib/fabric/protos/peer/events_pb.rb
139
+ - lib/fabric/protos/peer/events_services_pb.rb
140
+ - lib/fabric/protos/peer/peer_pb.rb
141
+ - lib/fabric/protos/peer/peer_services_pb.rb
142
+ - lib/fabric/protos/peer/proposal_pb.rb
143
+ - lib/fabric/protos/peer/proposal_response_pb.rb
144
+ - lib/fabric/protos/peer/query_pb.rb
145
+ - lib/fabric/protos/peer/resources_pb.rb
146
+ - lib/fabric/protos/peer/signed_cc_dep_spec_pb.rb
147
+ - lib/fabric/protos/peer/transaction_pb.rb
148
+ - lib/fabric/protos/token/prover_pb.rb
149
+ - lib/fabric/protos/token/prover_services_pb.rb
150
+ - lib/fabric/protos/token/transaction_pb.rb
151
+ - lib/fabric/protos/transientstore/transientstore_pb.rb
152
+ - lib/fabric/queue.rb
153
+ - lib/fabric/transaction.rb
154
+ - lib/fabric/transaction_info.rb
32
155
  - lib/fabric/version.rb
156
+ - lib/fabric_ca.rb
157
+ - lib/fabric_ca/attribute.rb
33
158
  - lib/fabric_ca/client.rb
34
159
  - lib/fabric_ca/configuration.rb
35
160
  - lib/fabric_ca/connection.rb
@@ -39,48 +164,8 @@ files:
39
164
  - lib/fabric_ca/faraday_middleware/token_auth.rb
40
165
  - lib/fabric_ca/request.rb
41
166
  - lib/fabric_ca/response.rb
42
- - lib/fabric_ca/tools.rb
43
167
  - lib/fabric_ca/version.rb
44
168
  - lib/hyperledger-fabric-sdk.rb
45
- - lib/protos/common/collection_pb.rb
46
- - lib/protos/common/common_pb.rb
47
- - lib/protos/common/configtx_pb.rb
48
- - lib/protos/common/configuration_pb.rb
49
- - lib/protos/common/ledger_pb.rb
50
- - lib/protos/common/policies_pb.rb
51
- - lib/protos/discovery/protocol_pb.rb
52
- - lib/protos/discovery/protocol_services_pb.rb
53
- - lib/protos/gossip/message_pb.rb
54
- - lib/protos/gossip/message_services_pb.rb
55
- - lib/protos/idemix/idemix_pb.rb
56
- - lib/protos/ledger/queryresult/kv_query_result_pb.rb
57
- - lib/protos/ledger/rwset/kvrwset/kv_rwset_pb.rb
58
- - lib/protos/ledger/rwset/rwset_pb.rb
59
- - lib/protos/msp/identities_pb.rb
60
- - lib/protos/msp/msp_config_pb.rb
61
- - lib/protos/msp/msp_principal_pb.rb
62
- - lib/protos/orderer/ab_pb.rb
63
- - lib/protos/orderer/ab_services_pb.rb
64
- - lib/protos/orderer/configuration_pb.rb
65
- - lib/protos/orderer/kafka_pb.rb
66
- - lib/protos/peer/admin_pb.rb
67
- - lib/protos/peer/admin_services_pb.rb
68
- - lib/protos/peer/chaincode_event_pb.rb
69
- - lib/protos/peer/chaincode_pb.rb
70
- - lib/protos/peer/chaincode_shim_pb.rb
71
- - lib/protos/peer/chaincode_shim_services_pb.rb
72
- - lib/protos/peer/configuration_pb.rb
73
- - lib/protos/peer/events_pb.rb
74
- - lib/protos/peer/events_services_pb.rb
75
- - lib/protos/peer/peer_pb.rb
76
- - lib/protos/peer/peer_services_pb.rb
77
- - lib/protos/peer/proposal_pb.rb
78
- - lib/protos/peer/proposal_response_pb.rb
79
- - lib/protos/peer/query_pb.rb
80
- - lib/protos/peer/resources_pb.rb
81
- - lib/protos/peer/signed_cc_dep_spec_pb.rb
82
- - lib/protos/peer/transaction_pb.rb
83
- - lib/protos/transientstore/transientstore_pb.rb
84
169
  homepage: https://github.com/kirshin/hyperledger-fabric-sdk
85
170
  licenses: []
86
171
  metadata: {}
@@ -88,23 +173,38 @@ post_install_message:
88
173
  rdoc_options: []
89
174
  require_paths:
90
175
  - lib
91
- - lib/crypto_suite
92
176
  - lib/fabric
177
+ - lib/fabric/protos/commmon
178
+ - lib/fabric/protos/discovery
179
+ - lib/fabric/protos/gossip
180
+ - lib/fabric/protos/idemix
181
+ - lib/fabric/protos/ledger
182
+ - lib/fabric/protos/ledger/queryresult
183
+ - lib/fabric/protos/ledger/rwset
184
+ - lib/fabric/protos/ledger/rwset/kvrwset
185
+ - lib/fabric/protos/msp
186
+ - lib/fabric/protos/orderer
187
+ - lib/fabric/protos/orderer/etcdraft
188
+ - lib/fabric/protos/peer
189
+ - lib/fabric/protos/token
190
+ - lib/fabric/protos/transientstore
191
+ - lib/fabric/protos/definitions
192
+ - lib/fabric/protos/definitions/commmon
193
+ - lib/fabric/protos/definitions/discovery
194
+ - lib/fabric/protos/definitions/gossip
195
+ - lib/fabric/protos/definitions/idemix
196
+ - lib/fabric/protos/definitions/ledger
197
+ - lib/fabric/protos/definitions/ledger/queryresult
198
+ - lib/fabric/protos/definitions/ledger/rwset
199
+ - lib/fabric/protos/definitions/ledger/rwset/kvrwset
200
+ - lib/fabric/protos/definitions/msp
201
+ - lib/fabric/protos/definitions/orderer
202
+ - lib/fabric/protos/definitions/orderer/etcdraft
203
+ - lib/fabric/protos/definitions/peer
204
+ - lib/fabric/protos/definitions/token
205
+ - lib/fabric/protos/definitions/transientstore
93
206
  - lib/fabric_ca
94
207
  - lib/fabric_ca/faraday_middleware
95
- - lib/protos
96
- - lib/protos/commmon
97
- - lib/protos/discovery
98
- - lib/protos/gossip
99
- - lib/protos/idemix
100
- - lib/protos/ledger
101
- - lib/protos/ledger/queryresult
102
- - lib/protos/ledger/rwset
103
- - lib/protos/ledger/rwset/kvrwset
104
- - lib/protos/msp
105
- - lib/protos/orderer
106
- - lib/protos/peer
107
- - lib/protos/transientstore
108
208
  required_ruby_version: !ruby/object:Gem::Requirement
109
209
  requirements:
110
210
  - - ">="
@@ -1,86 +0,0 @@
1
- require 'openssl'
2
-
3
- module CryptoSuite
4
- class ECDSA_AES
5
- DEFAULT_KEY_SIZE = 256.freeze
6
- DEFAULT_NONCE_LENGTH = 24.freeze
7
- DEFAULT_DIGEST_ALGORITHM = 'SHA256'.freeze
8
- DEFAULT_AES_KEY_SIZE = 128.freeze
9
-
10
- EC_CURVES = { 256 => 'prime256v1', 384 => 'secp384r1' }.freeze
11
-
12
- attr_reader :key_size, :nonce_length, :digest_algorithm, :digest, :cipher
13
-
14
- def initialize(opts = {})
15
- @key_size = opts[:key_size] || DEFAULT_KEY_SIZE
16
- @nonce_length = opts[:nonce_length] || DEFAULT_NONCE_LENGTH
17
- @digest_algorithm = opts[:digest_algorithm] || DEFAULT_DIGEST_ALGORITHM
18
- @digest = OpenSSL::Digest.new(digest_algorithm)
19
- @cipher = OpenSSL::Cipher::AES.new(opts[:aes_key_size] || DEFAULT_AES_KEY_SIZE, :CBC)
20
- end
21
-
22
- def generate_nonce
23
- OpenSSL::Random.random_bytes nonce_length
24
- end
25
-
26
- def hexdigest(message)
27
- @digest.hexdigest message
28
- end
29
-
30
- def digest(message)
31
- @digest.digest message
32
- end
33
-
34
- def sign(private_key, msg)
35
- key = OpenSSL::PKey::EC.new private_key
36
- signature = key.dsa_sign_asn1 msg
37
- sequence = OpenSSL::ASN1.decode signature
38
- sequence = prevent_malleability sequence, key.group.order
39
-
40
- sequence.to_der
41
- end
42
-
43
- def generate_private_key
44
- key = OpenSSL::PKey::EC.new EC_CURVES[key_size]
45
- key.generate_key!
46
-
47
- key.to_pem
48
- end
49
-
50
- def generate_csr(private_key, options = [])
51
- key = OpenSSL::PKey::EC.new private_key
52
- req = OpenSSL::X509::Request.new
53
- req.public_key = key
54
- req.subject = OpenSSL::X509::Name.new(options)
55
- req.sign key, @digest
56
-
57
- req
58
- end
59
-
60
- def encrypt(key, iv, message)
61
- cipher.encrypt key, iv
62
-
63
- Base64.strict_encode64(cipher.update(message) + cipher.final)
64
- end
65
-
66
- def decrypt(key, iv, message)
67
- cipher.decrypt key, iv
68
-
69
- cipher.update(Base64.strict_decode64(message)) + cipher.final
70
- rescue OpenSSL::Cipher::CipherError
71
- nil
72
- end
73
-
74
- private
75
-
76
- def prevent_malleability(sequence, order)
77
- half_order = order >> 1
78
-
79
- if (half_key = sequence.value[1].value) > half_order
80
- sequence.value[1].value = order - half_key
81
- end
82
-
83
- sequence
84
- end
85
- end
86
- end
@@ -1,85 +0,0 @@
1
- require 'peer/peer_services_pb'
2
-
3
- module Fabric
4
- class PeerEndorser
5
- def self.send_transaction_proposal(request, channel_id, identity_context)
6
- args = request[:args].unshift request[:function]
7
-
8
- transaction = request[:transaction]
9
-
10
- channel_header = build_channel_header Common::HeaderType::ENDORSER_TRANSACTION,
11
- channel_id, transaction.id, request[:chaincode_id]
12
- header = build_header channel_header, identity_context.identity, transaction.nonce
13
- proposal = build_proposal header, request[:chaincode_id], args
14
- signed_proposal = sign_proposal identity_context.identity, proposal
15
-
16
- responses = send_peers_process_proposal request[:targets], signed_proposal
17
-
18
- { responses: responses, proposal: proposal, header: header }
19
- end
20
-
21
- private
22
-
23
- def self.build_header(channel_header, identity, nonce)
24
- signature_header = Common::SignatureHeader.new creator: identity.serialize,
25
- nonce: nonce
26
-
27
- Common::Header.new channel_header: channel_header.to_proto,
28
- signature_header: signature_header.to_proto
29
- end
30
-
31
- def self.build_channel_header(type, channel_id, tx_id, chaincode_id)
32
- attrs = { type: type, channel_id: channel_id, tx_id: tx_id }
33
- attrs[:extension] = build_channel_header_extension(chaincode_id).to_proto if chaincode_id
34
- attrs[:timestamp] = build_current_timestamp
35
- attrs[:version] = Constants::CHANNEL_HEADER_VERSION
36
-
37
- Common::ChannelHeader.new attrs
38
- end
39
-
40
- def self.build_channel_header_extension(chaincode_id)
41
- id = Protos::ChaincodeID.new name: chaincode_id
42
-
43
- Protos::ChaincodeHeaderExtension.new chaincode_id: id
44
- end
45
-
46
- def self.build_current_timestamp
47
- now = Time.current
48
-
49
- Google::Protobuf::Timestamp.new seconds: now.to_i, nanos: now.sec
50
- end
51
-
52
- def self.build_proposal(header, chaincode_id, args)
53
- chaincode_proposal = build_chaincode_proposal chaincode_id, args
54
-
55
- Protos::Proposal.new header: header.to_proto,
56
- payload: chaincode_proposal.to_proto
57
- end
58
-
59
- def self.build_chaincode_proposal(chaincode_id, args)
60
- id = Protos::ChaincodeID.new name: chaincode_id
61
- chaincode_input = Protos::ChaincodeInput.new args: args
62
- chaincode_spec = Protos::ChaincodeSpec.new type: Protos::ChaincodeSpec::Type::GOLANG,
63
- chaincode_id: id,
64
- input: chaincode_input
65
- chaincode_invocation_spec =
66
- Protos::ChaincodeInvocationSpec.new chaincode_spec: chaincode_spec
67
-
68
- Protos::ChaincodeProposalPayload.new input: chaincode_invocation_spec.to_proto
69
- end
70
-
71
- def self.sign_proposal(identity, proposal)
72
- proposal_bytes = proposal.to_proto
73
- signature = identity.sign(proposal_bytes)
74
-
75
- Protos::SignedProposal.new proposal_bytes: proposal_bytes,
76
- signature: signature
77
- end
78
-
79
- def self.send_peers_process_proposal(peers, proposal)
80
- peers.map do |peer|
81
- peer.send_process_proposal(proposal)
82
- end
83
- end
84
- end
85
- end
@@ -1,11 +0,0 @@
1
- module Fabric
2
- class TransactionID
3
- attr_reader :nonce, :identity_context, :id
4
-
5
- def initialize(identity_context)
6
- @identity_context = identity_context
7
- @nonce = identity_context.crypto_suite.generate_nonce
8
- @id = identity_context.crypto_suite.hexdigest(nonce + identity_context.identity.serialize)
9
- end
10
- end
11
- end
data/lib/fabric/user.rb DELETED
@@ -1,24 +0,0 @@
1
- module Fabric
2
- class User
3
- attr_reader :username, :roles, :affiliation,
4
- :identity, :crypto_suite
5
-
6
- def initialize(args)
7
- @crypto_suite = args[:crypto_suite]
8
- @username = args[:username]
9
- @roles = args[:roles] || []
10
- @affiliation = args[:affiliation]
11
- @identity = nil
12
- end
13
-
14
- def enroll(opts)
15
- opts[:crypto_suite] = crypto_suite
16
-
17
- @identity = Identity.new opts
18
- end
19
-
20
- def enrolled?
21
- identity
22
- end
23
- end
24
- end
@@ -1,35 +0,0 @@
1
- module FabricCA
2
- module Tools
3
- HEADER_IDENTIFIER = [1, 2, 3, 4, 5, 6, 9].freeze
4
-
5
- def self.extract_attributes(pem)
6
- extensions = extract_extensions pem
7
-
8
- attributes = {}
9
- extensions[HEADER_IDENTIFIER.join('.')].to_s.split('#').each do |key|
10
- id, num = key.split('->')
11
-
12
- attributes[id] = extensions[build_attribute_id(HEADER_IDENTIFIER, num.to_i).join('.')]
13
- end
14
-
15
- attributes
16
- end
17
-
18
- def self.extract_extensions(pem)
19
- certificate = OpenSSL::X509::Certificate.new pem
20
- extensions = {}
21
- certificate.extensions.each { |ext| extensions[ext.oid] = ext.value }
22
-
23
- extensions
24
- end
25
-
26
- private
27
-
28
- def self.build_attribute_id(header_identifier, step)
29
- numbers = header_identifier.dup
30
- numbers[-1] += step
31
-
32
- numbers
33
- end
34
- end
35
- end
@@ -1,71 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: common/configtx.proto
3
-
4
- require 'google/protobuf'
5
-
6
- require 'common/common_pb'
7
- require 'common/policies_pb'
8
- Google::Protobuf::DescriptorPool.generated_pool.build do
9
- add_message "common.ConfigEnvelope" do
10
- optional :config, :message, 1, "common.Config"
11
- optional :last_update, :message, 2, "common.Envelope"
12
- end
13
- add_message "common.ConfigGroupSchema" do
14
- map :groups, :string, :message, 1, "common.ConfigGroupSchema"
15
- map :values, :string, :message, 2, "common.ConfigValueSchema"
16
- map :policies, :string, :message, 3, "common.ConfigPolicySchema"
17
- end
18
- add_message "common.ConfigValueSchema" do
19
- end
20
- add_message "common.ConfigPolicySchema" do
21
- end
22
- add_message "common.Config" do
23
- optional :sequence, :uint64, 1
24
- optional :channel_group, :message, 2, "common.ConfigGroup"
25
- end
26
- add_message "common.ConfigUpdateEnvelope" do
27
- optional :config_update, :bytes, 1
28
- repeated :signatures, :message, 2, "common.ConfigSignature"
29
- end
30
- add_message "common.ConfigUpdate" do
31
- optional :channel_id, :string, 1
32
- optional :read_set, :message, 2, "common.ConfigGroup"
33
- optional :write_set, :message, 3, "common.ConfigGroup"
34
- map :isolated_data, :string, :bytes, 5
35
- end
36
- add_message "common.ConfigGroup" do
37
- optional :version, :uint64, 1
38
- map :groups, :string, :message, 2, "common.ConfigGroup"
39
- map :values, :string, :message, 3, "common.ConfigValue"
40
- map :policies, :string, :message, 4, "common.ConfigPolicy"
41
- optional :mod_policy, :string, 5
42
- end
43
- add_message "common.ConfigValue" do
44
- optional :version, :uint64, 1
45
- optional :value, :bytes, 2
46
- optional :mod_policy, :string, 3
47
- end
48
- add_message "common.ConfigPolicy" do
49
- optional :version, :uint64, 1
50
- optional :policy, :message, 2, "common.Policy"
51
- optional :mod_policy, :string, 3
52
- end
53
- add_message "common.ConfigSignature" do
54
- optional :signature_header, :bytes, 1
55
- optional :signature, :bytes, 2
56
- end
57
- end
58
-
59
- module Common
60
- ConfigEnvelope = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigEnvelope").msgclass
61
- ConfigGroupSchema = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigGroupSchema").msgclass
62
- ConfigValueSchema = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigValueSchema").msgclass
63
- ConfigPolicySchema = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigPolicySchema").msgclass
64
- Config = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.Config").msgclass
65
- ConfigUpdateEnvelope = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigUpdateEnvelope").msgclass
66
- ConfigUpdate = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigUpdate").msgclass
67
- ConfigGroup = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigGroup").msgclass
68
- ConfigValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigValue").msgclass
69
- ConfigPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigPolicy").msgclass
70
- ConfigSignature = Google::Protobuf::DescriptorPool.generated_pool.lookup("common.ConfigSignature").msgclass
71
- end