chainpoint 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ca102ab0e0bf21e5b5552e812422cf764d92e0f8
4
+ data.tar.gz: b598527a3ab46d634d6fac275a90da91a7c3cb0b
5
+ SHA512:
6
+ metadata.gz: fff9306abe294da101ae3780e3de575f3fd417b52b3b5963208acc4a52f7afe2d14f032049e69c7314cb993b10eb5b8a2f38b97abaed54be6d9b523f21bb5611
7
+ data.tar.gz: 7e99109c45d7a9a16ec4424d905aeab94bec41e1396bdf9a4ab0baf11e1f6610d0e621831e400775f110e4bed901473d659bb72a96c019dfdd2ead54423d7a3c
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in chainpoint.gemspec
6
+ gemspec
@@ -0,0 +1,51 @@
1
+ # Chainpoint
2
+
3
+ This is gem for request to Chainpoint.
4
+ For Chainpoint, look at [Chainpoint Node HTTP API](https://github.com/chainpoint/chainpoint-node/wiki/Node-HTTP-API).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'chainpoint'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install chainpoint
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ # hash is SHA250
27
+ # hash = '2fbe59be2be10a4fdeca9c6d3e9f56fc56fb3ee9a8ef2e9be37fced60c264681'
28
+ ChainPoint.submit(hash)
29
+ # => {"meta"=>{"submitted_at"=>"2018-07-24T13:04:35Z", "processing_hints"=>{"cal"=>"2018-07-24T13:04:50Z", "btc"=>"2018-07-24T14:05:35Z"}}, "hashes"=>[{"hash_id_node"=>"1d1aa8a0-8f42-11e8-967f-01a68adfc010", "hash"=>"2fbe59be2be10a4fdeca9c6d3e9f56fc56fb3ee9a8ef2e9be37fced60c264681"}]}
30
+ ```
31
+
32
+ ```ruby
33
+ Chainpoint.get_proof(hash_id_node)
34
+ # => [{"hash_id_node"=>"a50eb4d0-8f20-11e8-8da8-0133565a0e60", "proof"=>"eJyNVMGOHDUQ5SP4BI7MTpXLLtt9Wolf4JTLyC6XmZaWmdF0JyHHhAtH9hMgizYgLkgoR/5jJD6G6tlN0O6ClEN3q22/V69cr+qHd5ey38363fzXdp4P07Bev6SxXeyP36xlW8bdYT/u5vULuplfHfS3rz4u3WzLtD1dul415KquKkLxvamULNxIcw/cxZ5Kqrkk7U7tIMUu2hjEseeEvy80m7Ftdvumpy9KAK2+wSp1BytETavUSloBEgUOBZTh/RkyPa/fjvOsd8hNmf90gHYwrpz/GvIAYQB49pFe9seFPoEXCg/oMxSjl9icBldLeEy/IP+bPjx7V49lJ1udrt/8clWqXv0h5WqzLO2Pm7u9t/vD9Pdnn7/+6er05Vnp2IZPyfL1z/vD7bQtKxf4DD7rWMCfkMNj8I+7cZoHDOS8I/AwtBijbx08Bo1aNUPKDTxV7uQoOQ6JtFLqQcEqlynVXtmD1wa5umhlpViJXER2JTTA0JisotC8OKeVMVgmkaVnAUQObCCreQJK9nos8NJ7xS4ZmIu65ok8lALdfNMFU0mYkodmvkKq3jF5VukSu0fhQFEeEh5Pl4196GjZmi89InaS1LnZr7rQagWDmRhkAo5U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qhhTsvq0zavApaFMO6HO09J1a7fpC3RGaRH1CyLFbGTwZh6+lcGzeBIWUk5fMORfruu5IQgZXoZnPzNN9KfkSMj5xTbYUncvxg3GsjAMOH8aEXPw7H5ZxMZj1h3vEWY5YEPOzqki3wKU5cz0hSEiNkwjXDsRm/CKliSegiFhRTf9isPJAzu1dU03X358H0VsL9ut9n43t9j7szfPjOF2fLv5P4tpQumvluL4HrJde/wcFK5lW')
39
+ # => [{"proof_index"=>0, "hash"=>"2fbe59be2be10a4fdeca9c6d3e9f56fc56fb3ee9a8ef2e9be37fced60c264681", "hash_id_node"=>"a50eb4d0-8f20-11e8-8da8-0133565a0e60", "hash_submitted_node_at"=>"2018-07-24T09:05:00Z", "hash_id_core"=>"a804c350-8f20-11e8-890a-01c7d2e52ba5", "hash_submitted_core_at"=>"2018-07-24T09:05:05Z", "anchors"=>[{"branch"=>"cal_anchor_branch", "type"=>"cal", "valid"=>true}], "status"=>"verified"}]
40
+
41
+ ```
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on [GitHub chainpoint](https://github.com/KenjiOhtsuka/chainpoint_gem).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "chainpoint"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "chainpoint/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chainpoint"
8
+ spec.version = Chainpoint::VERSION
9
+ spec.date = '2018-07-24'
10
+ spec.authors = ["Kenji Ohtsuka"]
11
+ spec.email = ["kok.fdcm@gmail.com"]
12
+
13
+ spec.summary = "Chainpoint request library"
14
+ #spec.description = %q{TODO: Write a longer description or delete this line.}
15
+ #spec.homepage = "TODO: Put your gem's website or public repo URL here."
16
+
17
+ spec.add_runtime_dependency "json"
18
+
19
+ spec.license = 'GPL-3.0'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ #spec.bindir = "exe"
25
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ #spec.require_paths = ["lib"]
27
+
28
+ #spec.add_development_dependency "bundler", "~> 1.16"
29
+ #spec.add_development_dependency "rake", "~> 10.0"
30
+ #spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
@@ -0,0 +1,58 @@
1
+ require "chainpoint/version"
2
+ require "net/https"
3
+ require "json"
4
+ require "digest"
5
+
6
+ module Chainpoint
7
+ def self.pickup_server()
8
+ uri = URI(pickup_node_list_server)
9
+ r = Net::HTTP.get(uri)
10
+ j = JSON.parse(r)
11
+ return j[rand(j.length)]["public_uri"]
12
+ end
13
+
14
+ def self.submit_data(data)
15
+ hash = Digest::SHA256.digest(data).unpack('H*')[0]
16
+ return submit(hash)
17
+ end
18
+
19
+ def self.submit(hash)
20
+ uri = URI(pickup_server + "/hashes")
21
+ req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
22
+ req.body = {hashes: [hash]}.to_json
23
+ res = Net::HTTP.start(
24
+ uri.hostname, uri.port, use_ssl: uri.scheme == "https"
25
+ ) do |http|
26
+ http.request(req)
27
+ end
28
+ return JSON.parse(res.body)
29
+ end
30
+
31
+ def self.get_proof(hash_id_node)
32
+ uri = URI(pickup_server + '/proofs/' + hash_id_node)
33
+ r = Net::HTTP.get(uri)
34
+ return JSON.parse(r)
35
+ end
36
+
37
+ def self.verify(proof)
38
+ uri = URI(pickup_server + "/verify")
39
+ req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
40
+ req.body = {proofs: [proof]}.to_json
41
+ res = Net::HTTP.start(
42
+ uri.hostname, uri.port, use_ssl: uri.scheme == "https"
43
+ ) do |http|
44
+ http.request(req)
45
+ end
46
+ return JSON.parse(res.body)
47
+ end
48
+
49
+ private
50
+ def self.pickup_node_list_server
51
+ endpoint_array = [
52
+ 'https://a.chainpoint.org/nodes/random',
53
+ 'https://b.chainpoint.org/nodes/random',
54
+ 'https://c.chainpoint.org/nodes/random'
55
+ ]
56
+ return endpoint_array[rand(endpoint_array.length)]
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module Chainpoint
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chainpoint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kenji Ohtsuka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - kok.fdcm@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - Gemfile
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - chainpoint.gemspec
43
+ - lib/chainpoint.rb
44
+ - lib/chainpoint/version.rb
45
+ homepage:
46
+ licenses:
47
+ - GPL-3.0
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.6.8
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Chainpoint request library
69
+ test_files: []