vchain_client 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vchain_client.rb +66 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5331089e365d13a224dc8b586d015a5b38de6929
4
- data.tar.gz: a6883aff699c11c312a38f66cdf4a7142f606853
3
+ metadata.gz: fa130280366a0e4e56548c9a15435e04db999452
4
+ data.tar.gz: 4d18e892a688984d0687191cf2ea6420214613a8
5
5
  SHA512:
6
- metadata.gz: d393052fc49844ce44434dfda1a277cf516fca9a6455c907acd73f5c4982069d5f1582f71422b4f66b06637d40f4fb639ce368f8d2212cb3dc23d0d0e95687d9
7
- data.tar.gz: 0d1dafe6329b2a54c9622ce358b1578488e7b5a11820200a2ccc4a1ef0456df65f98a13f9e910645717c54f7addf0de79940b421f6a8679bd75be6cf7aafb7b9
6
+ metadata.gz: ed11a5f60b243789441434726c5724e24964cefaf5c4b0d36059723170396cbdc94bbf6f315a4d18016cb0a317ad52c4c631af382a8a213248aa97e2b350f269
7
+ data.tar.gz: 414e34150172826ceab35559cb32d7fad5c1fe99256a526aa4e7613a6490caeb98c0e84475c3681cc685a2805898ce3c4711bf4711e3f53bae44efd9574aeb82
data/lib/vchain_client.rb CHANGED
@@ -297,6 +297,72 @@ module VChainClient
297
297
  end
298
298
  end
299
299
 
300
+ def self.generateBlockstackCommand(config)
301
+ blockstack_id = config["blockstack_id"]
302
+
303
+ #A1 pubkey
304
+ public_key_location = config["public_key_location"]
305
+ pub_key = File.read(public_key_location)
306
+ pub_key.slice! "-----BEGIN PUBLIC KEY-----\n"
307
+ pub_key.slice! "\n-----END PUBLIC KEY-----\n"
308
+ pub_key_aligned = pub_key.gsub(/\n/, "")
309
+
310
+ #A2 vchain_client_id
311
+ vchain_client_id = config["vchain_client_id"]
312
+
313
+ #A3 validator_sig
314
+ validator_sig = nil
315
+ if config.key?("validator_sig")
316
+ validator_sig = config["validator_sig"]
317
+ end
318
+
319
+ #A4 validator_vchain_id
320
+ validator_vchain_id = "da93b5f7-2295-4435-a67a-4fc226eca3ac"
321
+
322
+ #A5 validator_blockstack_id
323
+ validator_blockstack_id = "vchain_core_01.id"
324
+
325
+ #A6 vchain_role
326
+ vchain_role = config["role"]
327
+
328
+ #A7 sig_version
329
+ sig_version = "1"
330
+
331
+ #A8 client_sig
332
+ client_sig = nil
333
+ priv_key_path = config["private_key_location"]
334
+ priv_key = File.read(priv_key_path)
335
+ whole_sign = vchain_client_id + vchain_role + blockstack_id + pub_key + sig_version
336
+ ec = OpenSSL::PKey::EC.new(priv_key)
337
+ digest = OpenSSL::Digest::SHA256.new
338
+ whole_signature = ec.sign(digest, whole_sign)
339
+ client_sig = Base64.encode64(whole_signature).gsub(/\n/, "")
340
+
341
+ if validator_sig == nil
342
+
343
+ puts "blockstack_id = " + blockstack_id
344
+ puts "vchain_client_id = " + vchain_client_id
345
+ puts "pub_key = "+ pub_key_aligned
346
+ puts "validator_vchain_id = "+ validator_vchain_id
347
+ puts "vchain_role = " + vchain_role
348
+ puts "client_sig = " + client_sig
349
+
350
+ else
351
+ puts "BLOCKSTACK_DEBUG=1 blockstack update "+ blockstack_id +" '$ORIGIN "+ blockstack_id +"
352
+ $TTL 3600
353
+ A1 TXT \""+ pub_key_aligned +"\"
354
+ A2 TXT \""+ vchain_client_id +"\"
355
+ A3 TXT \""+ validator_sig +"\"
356
+ A4 TXT \""+ validator_vchain_id +"\"
357
+ A5 TXT \""+ validator_blockstack_id +"\"
358
+ A6 TXT \""+ vchain_role +"\"
359
+ A7 TXT \""+ sig_version +"\"
360
+ A8 TXT \""+ client_sig +"\"
361
+ _tcp._http URI 10 1 \"http://example.com\"
362
+ '"
363
+ end
364
+ end
365
+
300
366
  end
301
367
 
302
368
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vchain_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandr Gorelik