Class: Chainpoint::Proof
- Inherits:
-
Object
- Object
- Chainpoint::Proof
- Defined in:
- lib/chainpoint/proof.rb
Instance Attribute Summary collapse
-
#anchors_complete ⇒ Object
readonly
Returns the value of attribute anchors_complete.
-
#hash_id_node ⇒ Object
readonly
Returns the value of attribute hash_id_node.
-
#proof ⇒ Object
readonly
Returns the value of attribute proof.
Instance Method Summary collapse
- #decode ⇒ Object
-
#initialize(proof, hash_id_node = nil, anchors_complete = []) ⇒ Proof
constructor
A new instance of Proof.
- #verify ⇒ Object
Constructor Details
#initialize(proof, hash_id_node = nil, anchors_complete = []) ⇒ Proof
Returns a new instance of Proof
11 12 13 14 15 |
# File 'lib/chainpoint/proof.rb', line 11 def initialize(proof, hash_id_node = nil, anchors_complete = []) @proof = proof @hash_id_node = hash_id_node @anchors_complete = anchors_complete end |
Instance Attribute Details
#anchors_complete ⇒ Object (readonly)
Returns the value of attribute anchors_complete
9 10 11 |
# File 'lib/chainpoint/proof.rb', line 9 def anchors_complete @anchors_complete end |
#hash_id_node ⇒ Object (readonly)
Returns the value of attribute hash_id_node
9 10 11 |
# File 'lib/chainpoint/proof.rb', line 9 def hash_id_node @hash_id_node end |
#proof ⇒ Object (readonly)
Returns the value of attribute proof
9 10 11 |
# File 'lib/chainpoint/proof.rb', line 9 def proof @proof end |
Instance Method Details
#decode ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/chainpoint/proof.rb', line 17 def decode MessagePack.unpack( Zlib::Inflate.inflate( Base64.decode64(@proof) ) ) end |
#verify ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/chainpoint/proof.rb', line 25 def verify uri = URI(Chainpoint.select_nodes(1).first + '/verify') request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') request.body = { proofs: [@proof] }.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| http.request(request) end JSON.parse(response.body).first end |