vchain_client 1.0.30 → 1.0.31

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vchain_client.rb +28 -2
  3. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4284af3786825b9f4ba931166806dca6753abe37
4
- data.tar.gz: fae59220bb596f6b395002f7c505c7a758d5ecfc
3
+ metadata.gz: 3848407bff9307524e2cf0c071c8766ab44c84bc
4
+ data.tar.gz: 6846755d6ffe38288e2e950aa5116bb5a87fe124
5
5
  SHA512:
6
- metadata.gz: 71770851b7c1544369155b078652ae5c836ec135a43fc1555d80ebffc84e360a977e07d73049ba7433adcb7fdd8a26bf30a329b3c3ca7e74689850d769a0b436
7
- data.tar.gz: 8235ab8121cbe25477fb7e0e173896eb8ecfa7fead84c8fcd5dd4e6119d8ce413524386747f56c92e93ef7a8839a8951e3d3cbd95bd0199cadc4709c709cc000
6
+ metadata.gz: ee3478bb3b48ebcbb4579cf3a1a64137e1992603f136d0a39cee59078dc6ae17a64338657a0f20691b37c56c0277161795ebbfe4a11a762b6e0ecc1f19e027a1
7
+ data.tar.gz: ca515a0c3f81dab0df028fe189bcfb45bfb4bc34ca2b4d572464727a88a782445d084c8b6795831bf35c675a23ab76ee15ca8d130877d2db8bdeb458248b921e
data/lib/vchain_client.rb CHANGED
@@ -5,6 +5,7 @@ module VChainClient
5
5
  require 'rest-client'
6
6
  require 'base64'
7
7
  require 'openssl'
8
+ require 'openssl-pkey-ec-ies'
8
9
  require 'log4r'
9
10
  require 'json'
10
11
 
@@ -26,7 +27,7 @@ module VChainClient
26
27
 
27
28
  DATA_POINT_VERSION = "1"
28
29
 
29
- CLIENT_LIB_VERSION = "1.0.30"
30
+ CLIENT_LIB_VERSION = "1.0.31"
30
31
 
31
32
  @config = nil
32
33
  @log = nil
@@ -804,6 +805,8 @@ module VChainClient
804
805
 
805
806
  def check(input, is_already_hashed = false, preffered_decision_algo = nil)
806
807
 
808
+ blockstackClient = VChainClient::BlockstackClient.new(@config)
809
+
807
810
  client_id = @config["client_id"]
808
811
 
809
812
  api_url = @config["api"]["url"] + "v0.2/check/";
@@ -847,6 +850,29 @@ module VChainClient
847
850
  @log.debug(document)
848
851
  end
849
852
 
853
+ ## let's encode message using vchain public key
854
+ vchain_pubkey_body = blockstackClient.getPublicKey("vchain_core_01.id")
855
+
856
+ if vchain_pubkey_body == nil
857
+ if @log.error?
858
+ @log.error("[check] failed to get vchain public key")
859
+ end
860
+
861
+ return false
862
+ end
863
+
864
+ vchain_pubkey_str = "-----BEGIN PUBLIC KEY-----\n"
865
+ vchain_pubkey_str += vchain_pubkey_body
866
+ vchain_pubkey_str += "\n-----END PUBLIC KEY-----"
867
+
868
+ vchain_pubkey = OpenSSL::PKey::EC::IES.new(vchain_pubkey_str)
869
+
870
+ encrypted_doc = Base64.encode64(vchain_pubkey.public_encrypt(document.to_json))
871
+
872
+ puts encrypted_doc
873
+
874
+ exit 0
875
+
850
876
  req = nil
851
877
 
852
878
  begin
@@ -859,7 +885,7 @@ module VChainClient
859
885
  res = RestClient::Resource.new api_url
860
886
  end
861
887
 
862
- req = res.post document.to_json, :content_type => 'application/json'
888
+ req = res.post encrypted_doc, :content_type => 'application/json'
863
889
 
864
890
  if req.code != 200
865
891
 
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.30
4
+ version: 1.0.31
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-03-01 00:00:00.000000000 Z
11
+ date: 2017-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log4r
@@ -70,6 +70,26 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 2.0.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: openssl-pkey-ec-ies
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: 0.0.1
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.1
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.1
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 0.0.1
73
93
  description: Fully functional client for VChain Platform written on Ruby. For more
74
94
  info visit https://bitbucket.org/vchain_dev/ruby-client
75
95
  email: alexander@vchain.tech