vchain_client 1.0.18 → 1.0.19

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: e7d72dd4d8efef4ca8c04acc00a13d5aaec09920
4
- data.tar.gz: 2e1ec1456efbbbe2cf056f1fc252f38ec44c3d68
3
+ metadata.gz: 10de221cf0aacee3a81893294d59c0130a9a15a2
4
+ data.tar.gz: 70d5234b7a43295a03cd48ef89d43613fd6710f9
5
5
  SHA512:
6
- metadata.gz: ba2b70834743cf078d751dfc6334f6a73af53d78b1942e8496875f393b9fa2d047127bd562bc14633bfdf4ad61c46b5f27636cf9174cc5d07e9bc982113738f3
7
- data.tar.gz: 0a8705fe2e25bc638cf5e5c41746c4adc7ca99c96e750d6e4e8140da0a8b0736641dbe3a352e3164a5238f622eff183f478e9026c18a6b872d0a5cdfd8d26913
6
+ metadata.gz: 24db1ae389d4221c1ba41ca9fa591d8c4f4b343b210e092ac5defe17c00da6e71bf045fc63ee8a505611b2182fcef42a6364ae3bf213cf78e87f9af6726263c0
7
+ data.tar.gz: a4c9c63f6dca6323f45a80738d72145cc693b9fc9467f0516246de5d5349e9961dbf3cc9a490160f2df52cec45c0aa38408575ff0a798c08dfb1984ebf32af87
@@ -215,7 +215,7 @@ module VChainClient
215
215
  end
216
216
  end
217
217
 
218
- def signDataPoint(point_type, data, doc_hash, weight, timestamp)
218
+ def signDataPoint(point_type, data, doc_hash, credentials_hash, weight, timestamp)
219
219
 
220
220
  OpenSSL::PKey::EC.send(:alias_method, :private?, :private_key?)
221
221
 
@@ -226,6 +226,7 @@ module VChainClient
226
226
  @log.debug("[Signatures.signDataPoint] input:")
227
227
  @log.debug("-> this_client_id: #{this_client_id}")
228
228
  @log.debug("-> doc_hash: #{doc_hash}")
229
+ @log.debug("-> credentials_hash: #{credentials_hash}")
229
230
  @log.debug("-> weight: "+ weight.to_s)
230
231
  @log.debug("-> timestamp: "+ timestamp.to_s)
231
232
  @log.debug("-> point_type: #{point_type}")
@@ -246,6 +247,7 @@ module VChainClient
246
247
  @log.error("#{e.class}, #{e.message}")
247
248
  @log.error("-> this_client_id: #{this_client_id}")
248
249
  @log.error("-> doc_hash: #{doc_hash}")
250
+ @log.error("-> credentials_hash: #{credentials_hash}")
249
251
  @log.error("-> weight: "+ weight.to_s)
250
252
  @log.error("-> timestamp: "+ timestamp.to_s)
251
253
  @log.error("-> point_type: #{point_type}")
@@ -263,6 +265,7 @@ module VChainClient
263
265
  @log.error("[Signatures.signDataPoint] failed to load private key")
264
266
  @log.error("-> this_client_id: #{this_client_id}")
265
267
  @log.error("-> doc_hash: #{doc_hash}")
268
+ @log.error("-> credentials_hash: #{credentials_hash}")
266
269
  @log.error("-> weight: "+ weight.to_s)
267
270
  @log.error("-> timestamp: "+ timestamp.to_s)
268
271
  @log.error("-> point_type: #{point_type}")
@@ -298,10 +301,12 @@ module VChainClient
298
301
  what_to_sign = field_hash
299
302
  what_to_sign += value_hash
300
303
  what_to_sign += Digest::SHA512.hexdigest(doc_hash)
304
+ what_to_sign += Digest::SHA512.hexdigest(credentials_hash)
301
305
  what_to_sign += point_type
302
306
  what_to_sign += weight.to_s
303
307
  what_to_sign += timestamp.to_s
304
308
  what_to_sign += this_client_id
309
+ what_to_sign += VChainClient::Client::DATA_POINT_VERSION
305
310
 
306
311
  if @log.debug?
307
312
  @log.debug("[Signatures.signDataPoint] field_hash: #{field_hash}")
@@ -320,6 +325,7 @@ module VChainClient
320
325
  @log.error("#{e.class}, #{e.message}")
321
326
  @log.error("-> this_client_id: #{this_client_id}")
322
327
  @log.error("-> doc_hash: #{doc_hash}")
328
+ @log.error("-> credentials_hash: #{credentials_hash}")
323
329
  @log.error("-> weight: "+ weight.to_s)
324
330
  @log.error("-> timestamp: "+ timestamp.to_s)
325
331
  @log.error("-> point_type: #{point_type}")
@@ -337,6 +343,7 @@ module VChainClient
337
343
  @log.error("[Signatures.signDataPoint] failed init EC key")
338
344
  @log.error("-> this_client_id: #{this_client_id}")
339
345
  @log.error("-> doc_hash: #{doc_hash}")
346
+ @log.error("-> credentials_hash: #{credentials_hash}")
340
347
  @log.error("-> weight: "+ weight.to_s)
341
348
  @log.error("-> timestamp: "+ timestamp.to_s)
342
349
  @log.error("-> point_type: #{point_type}")
@@ -367,6 +374,7 @@ module VChainClient
367
374
  @log.error("#{e.class}, #{e.message}")
368
375
  @log.error("-> this_client_id: #{this_client_id}")
369
376
  @log.error("-> doc_hash: #{doc_hash}")
377
+ @log.error("-> credentials_hash: #{credentials_hash}")
370
378
  @log.error("-> weight: "+ weight.to_s)
371
379
  @log.error("-> timestamp: "+ timestamp.to_s)
372
380
  @log.error("-> point_type: #{point_type}")
@@ -385,6 +393,7 @@ module VChainClient
385
393
  @log.error("[Signatures.signDataPoint] failed to sign")
386
394
  @log.error("-> this_client_id: #{this_client_id}")
387
395
  @log.error("-> doc_hash: #{doc_hash}")
396
+ @log.error("-> credentials_hash: #{credentials_hash}")
388
397
  @log.error("-> weight: "+ weight.to_s)
389
398
  @log.error("-> timestamp: "+ timestamp.to_s)
390
399
  @log.error("-> point_type: #{point_type}")
@@ -461,13 +470,14 @@ module VChainClient
461
470
  end
462
471
  end
463
472
 
464
- def checkVerificationSignature(field_hash, data_hash, doc_hash, verification_type, weight, timestamp, blockstack_client_id, pubkey, signature)
473
+ def checkVerificationSignature(field_hash, data_hash, doc_hash, credentials_hash, verification_type, weight, timestamp, blockstack_client_id, pubkey, signature, version)
465
474
 
466
475
  if @log.debug?
467
476
  @log.debug("[Signatures.checkVerificationSignature] input:")
468
477
  @log.debug("-> field_hash: #{field_hash}")
469
478
  @log.debug("-> data_hash: #{data_hash}")
470
479
  @log.debug("-> doc_hash: #{doc_hash}")
480
+ @log.debug("-> credentials_hash: #{credentials_hash}")
471
481
  @log.debug("-> type: #{verification_type}")
472
482
  @log.debug("-> weight: "+ weight.to_s)
473
483
  @log.debug("-> timestamp: "+ timestamp.to_s)
@@ -479,10 +489,12 @@ module VChainClient
479
489
  what_to_check = field_hash
480
490
  what_to_check += data_hash
481
491
  what_to_check += doc_hash
492
+ what_to_check += credentials_hash
482
493
  what_to_check += verification_type
483
494
  what_to_check += weight.to_s
484
495
  what_to_check += timestamp.to_s
485
496
  what_to_check += blockstack_client_id
497
+ what_to_check += version
486
498
 
487
499
  begin
488
500
 
@@ -495,6 +507,7 @@ module VChainClient
495
507
  @log.error("-> field_hash: #{field_hash}")
496
508
  @log.error("-> data_hash: #{data_hash}")
497
509
  @log.error("-> doc_hash: #{doc_hash}")
510
+ @log.error("-> credentials_hash: #{credentials_hash}")
498
511
  @log.error("-> verification_type: #{verification_type}")
499
512
  @log.error("-> timestamp: "+ timestamp.to_s)
500
513
  @log.error("-> weight: "+ weight.to_s)
data/lib/vchain_client.rb CHANGED
@@ -22,6 +22,8 @@ module VChainClient
22
22
  FIELD_TYPE_TRAVEL_DOCUMENT_HASHED = "fbb6889f44061c2a91e17a411cf168f9457981257a5e0a31fb706cd5cd1e64c263780a42a1fd858ee69429869ab2e2c53b9d94c4a26946f2b0c12f8ce2812d6b"
23
23
  FIELD_TYPE_TEST_DOCUMENT_HASHED = "e061cf61078d74025ab1d136e0a78785097b8ef721107e940cac1ca836ed5fa6af907344b761447274ce0558d95d4126e94e11f04eb70c3885afcc96f9cfe985"
24
24
 
25
+ DATA_POINT_VERSION = "1"
26
+
25
27
  @config = nil
26
28
  @log = nil
27
29
 
@@ -210,6 +212,8 @@ module VChainClient
210
212
 
211
213
  doc_hash = self.get_doc_hash(document)
212
214
 
215
+ credentials_hash = self.get_credentials_hash(document)
216
+
213
217
  if weight > 1
214
218
 
215
219
  weight = 1
@@ -235,11 +239,11 @@ module VChainClient
235
239
 
236
240
  begin
237
241
 
238
- point_signatures = signaturesHelper.signDataPoint(point_type, document, doc_hash, weight, timestamp)
242
+ point_signatures = signaturesHelper.signDataPoint(point_type, document, doc_hash, credentials_hash, weight, timestamp)
239
243
 
240
244
  rescue => e
241
245
  if @log.error?
242
- @log.error("[verify] Signatures.signVerification raised exception")
246
+ @log.error("[verify] Signatures.signDataPoint raised exception")
243
247
  @log.error("#{e.class}, #{e.message}")
244
248
  @log.error("-> point_type: "+ point_type)
245
249
  @log.error("-> weight: "+ weight.to_s)
@@ -255,7 +259,7 @@ module VChainClient
255
259
 
256
260
  if point_signatures == nil
257
261
  if @log.error?
258
- @log.error("[verify] failed to Signatures.signVerification")
262
+ @log.error("[verify] failed to Signatures.signDataPoint")
259
263
  @log.error("-> point_type: "+ point_type)
260
264
  @log.error("-> weight: "+ weight.to_s)
261
265
  @log.error("-> timestamp: "+ timestamp.to_s)
@@ -816,7 +820,7 @@ module VChainClient
816
820
  end
817
821
 
818
822
  # 1d. check data_point_hash
819
- checksum_to_hash = data_point["field_hash"] + data_point["data_hash"] + data_point["doc_hash"] + data_point["type"] + data_point["issuer_sig"] + data_point["issuer_id"] + data_point["validator_sig"] + data_point["validator_id"] + data_point["weight"] + data_point["timestamp"]
823
+ checksum_to_hash = data_point["field_hash"] + data_point["data_hash"] + data_point["doc_hash"] + data_point["credentials_hash"] + data_point["type"] + data_point["issuer_sig"] + data_point["issuer_id"] + data_point["validator_sig"] + data_point["validator_id"] + data_point["weight"] + data_point["timestamp"] + data_point["version"]
820
824
  checksum = Digest::SHA512.hexdigest(checksum_to_hash)
821
825
  if checksum != data_point["data_point_hash"]
822
826
  if @log.error?
@@ -1144,12 +1148,13 @@ module VChainClient
1144
1148
 
1145
1149
  begin
1146
1150
 
1147
- if !signaturesHelper.checkVerificationSignature(data_point["field_hash"], data_point["data_hash"], data_point["doc_hash"], data_point["type"], data_point["weight"], data_point["timestamp"], data_point["issuer_id"], verificator_pubkey, Base64.decode64(data_point["issuer_sig"]))
1151
+ if !signaturesHelper.checkVerificationSignature(data_point["field_hash"], data_point["data_hash"], data_point["doc_hash"], data_point["credentials_hash"], data_point["type"], data_point["weight"], data_point["timestamp"], data_point["issuer_id"], verificator_pubkey, Base64.decode64(data_point["issuer_sig"]), data_point["version"])
1148
1152
  if @log.error?
1149
1153
  @log.error("[check] not a valid verification - failed to check verificator signature")
1150
1154
  @log.error("--> field_hash: "+ data_point["field_hash"])
1151
1155
  @log.error("--> data_hash: "+ data_point["data_hash"])
1152
1156
  @log.error("--> doc_hash: "+ data_point["doc_hash"])
1157
+ @log.error("--> credentials_hash: "+ data_point["credentials_hash"])
1153
1158
  @log.error("--> type: "+ data_point["type"])
1154
1159
  @log.error("--> weight: "+ data_point["weight"].to_s)
1155
1160
  @log.error("--> timestamp: "+ data_point["timestamp"].to_s)
@@ -1168,6 +1173,7 @@ module VChainClient
1168
1173
  @log.error("--> field_hash: "+ data_point["field_hash"])
1169
1174
  @log.error("--> data_hash: "+ data_point["data_hash"])
1170
1175
  @log.error("--> doc_hash: "+ data_point["doc_hash"])
1176
+ @log.error("--> credentials_hash: "+ data_point["credentials_hash"])
1171
1177
  @log.error("--> type: "+ data_point["type"])
1172
1178
  @log.error("--> weight: "+ data_point["weight"].to_s)
1173
1179
  @log.error("--> timestamp: "+ data_point["timestamp"].to_s)
@@ -1212,12 +1218,13 @@ module VChainClient
1212
1218
 
1213
1219
  begin
1214
1220
 
1215
- if !signaturesHelper.checkVerificationSignature(data_point["field_hash"], data_point["data_hash"], data_point["doc_hash"], data_point["type"], data_point["weight"], data_point["timestamp"], data_point["validator_id"], validator_pubkey, Base64.decode64(data_point["validator_sig"]))
1221
+ if !signaturesHelper.checkVerificationSignature(data_point["field_hash"], data_point["data_hash"], data_point["doc_hash"], data_point["credentials_hash"], data_point["type"], data_point["weight"], data_point["timestamp"], data_point["validator_id"], validator_pubkey, Base64.decode64(data_point["validator_sig"]), data_point["version"])
1216
1222
  if @log.error?
1217
1223
  @log.error("[check] not a valid verification - failed to check validator signature")
1218
1224
  @log.error("--> field_hash: "+ data_point["field_hash"])
1219
1225
  @log.error("--> data_hash: "+ data_point["data_hash"])
1220
1226
  @log.error("--> doc_hash: "+ data_point["doc_hash"])
1227
+ @log.error("--> credentials_hash: "+ data_point["credentials_hash"])
1221
1228
  @log.error("--> type: "+ data_point["type"])
1222
1229
  @log.error("--> weight: "+ data_point["weight"].to_s)
1223
1230
  @log.error("--> timestamp: "+ data_point["timestamp"].to_s)
@@ -1236,6 +1243,7 @@ module VChainClient
1236
1243
  @log.error("--> field_hash: "+ data_point["field_hash"])
1237
1244
  @log.error("--> data_hash: "+ data_point["data_hash"])
1238
1245
  @log.error("--> doc_hash: "+ data_point["doc_hash"])
1246
+ @log.error("--> credentials_hash: "+ data_point["credentials_hash"])
1239
1247
  @log.error("--> type: "+ data_point["type"])
1240
1248
  @log.error("--> weight: "+ data_point["weight"].to_s)
1241
1249
  @log.error("--> timestamp: "+ data_point["timestamp"].to_s)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vchain_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.18
4
+ version: 1.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandr Gorelik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log4r