class Chainpoint::Proof

Attributes

anchors_complete[R]
hash_id_node[R]
proof[R]

Public Class Methods

new(proof, hash_id_node = nil, anchors_complete = []) click to toggle source
# 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

Public Instance Methods

decode() click to toggle source
# File lib/chainpoint/proof.rb, line 17
def decode
  MessagePack.unpack(
    Zlib::Inflate.inflate(
      Base64.decode64(@proof)
    )
  )
end
verify() click to toggle source
# 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