Skip to content

Instantly share code, notes, and snippets.

@hackervera
Created July 27, 2017 05:43
Show Gist options
  • Save hackervera/d2bc25b31b5bec68774c64d358ffdf03 to your computer and use it in GitHub Desktop.
Save hackervera/d2bc25b31b5bec68774c64d358ffdf03 to your computer and use it in GitHub Desktop.
require "bundler"
require "pp"
Bundler.require
description = RDF::Turtle::Reader.new(STDIN)
graph = RDF::Graph.new << description
query = graph.query(predicate: RDF::URI('http://xmlns.com/wot/0.1/assurance')).first
subject_uri = query && query.subject.to_s
signature_uri = query && query.object.to_s
if signature_uri && signature_uri =~ /urn:ipfs:(.*)/
signature = RestClient.get("http://ipfs.io/ipfs/#{$1}").body
puts signature
end
if subject_uri && subject_uri =~ /urn:ipfs:(.*)/
profile = RestClient.get("http://ipfs.io/ipfs/#{$1}").body
puts profile
graph = RDF::Graph.new << RDF::Turtle::Reader.new(profile)
query = graph.query(predicate: RDF::URI('http://xmlns.com/wot/0.1/hasKey')).first
public_key_uri = query && query.object.to_s
public_key = RestClient.get(public_key_uri).body
puts public_key
end
crypto = GPGME::Crypto.new
GPGME::Key.import(public_key)
crypto.verify(GPGME::Data.new(signature), signed_text: profile){|signature| p signature.inspect; p signature.valid? }
cat ipfs.ttl |ruby app.rb
<urn:ipfs:QmYJXcwDU72gQDSbNFo41Z7sLJU9LVivRx485r41owmXWY> <http://xmlns.com/wot/0.1/assurance> <urn:ipfs:QmbdooNUQM3efGjPByB485CicqZFZRbxFGCmauzJkUEAbb> .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment