chainpoint 0.0.4 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 051b4b3c8b611e0b708bade07138483346547099778e3a20ecdf19b0a65398df
4
- data.tar.gz: 7454712bf2412e6442e4c774c559bf0bb066447ee508232a3f75fbc55e927625
3
+ metadata.gz: 548389f4be90eea5ca691b311038f5f73a87c560d569ac4ad1ae23d05021b9e6
4
+ data.tar.gz: f45ed9177795b2333ebb2f5c15f32a2af3af95a3be498a0d8480235f492e0c44
5
5
  SHA512:
6
- metadata.gz: 7687a27cee4c030d3bf79ab7d5b39a81705e09b0c428081401589d2880721e3932defd3754515c09198a89527f27d9503da125eeb9d4c86d0619119a2df96eed
7
- data.tar.gz: eddeda6efda3f02086c317b7089311e58149fb39ec502efd9270b5e2c01c629bda9a797c26df743cd7bd134f6b89bed583c276047063c60d2bd2aa07a3411fd5
6
+ metadata.gz: ef9d851af3025be0095a333897b1f4fa5abd661166dcd99de5ad3e8c42415f9e1cf172dc3a70d451926d57c419374b2b553ed02e11dad48ff094438c1648f99d
7
+ data.tar.gz: 00f8c1f40fa40290c400836038ff8a4acd39715ec7e912f6db3d7a3f097ba5c496ca8737dcc1ff4ab4cac85d2db9c4738dc576b7a04e1cf8e9bbddb3b278c1d3
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
 
9
9
  # rspec failure tracking
10
10
  .rspec_status
11
+
12
+ .byebug_history
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - 'spec/**/*'
7
+
8
+ Metrics/LineLength:
9
+ Max: 100
10
+
11
+ Style/Documentation:
12
+ Enabled: false
data/.travis.yml CHANGED
@@ -2,4 +2,7 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.0
5
- before_install: gem install bundler -v 1.16.1
5
+ before_install: bundle install
6
+ script:
7
+ - bundle exec rspec -f p
8
+ - bundle exec rubocop
data/Gemfile CHANGED
@@ -1,10 +1,18 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in chainpoint.gemspec
6
8
  gemspec
7
9
 
8
10
  group :development do
9
- gem "yard", "~> 0.9.18"
11
+ gem 'byebug', '~> 11.0', '>= 11.0.1'
12
+ gem 'rubocop', '~> 0.66.0'
13
+ gem 'rubocop-rspec', '~> 1.32'
14
+ gem 'simplecov', '~> 0.16.1'
15
+ gem 'vcr', '~> 4.0'
16
+ gem 'webmock', '~> 3.5', '>= 3.5.1'
17
+ gem 'yard', '~> 0.9.18'
10
18
  end
data/Gemfile.lock CHANGED
@@ -1,14 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chainpoint (0.0.4)
4
+ chainpoint (1.0.1)
5
5
  json
6
+ msgpack
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ addressable (2.6.0)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ ast (2.4.0)
14
+ byebug (11.0.1)
15
+ crack (0.4.3)
16
+ safe_yaml (~> 1.0.0)
10
17
  diff-lcs (1.3)
18
+ docile (1.3.1)
19
+ hashdiff (0.3.8)
20
+ jaro_winkler (1.5.2)
11
21
  json (2.2.0)
22
+ msgpack (1.2.9)
23
+ parallel (1.16.1)
24
+ parser (2.6.2.0)
25
+ ast (~> 2.4.0)
26
+ psych (3.1.0)
27
+ public_suffix (3.0.3)
28
+ rainbow (3.0.0)
12
29
  rake (10.5.0)
13
30
  rspec (3.8.0)
14
31
  rspec-core (~> 3.8.0)
@@ -23,6 +40,29 @@ GEM
23
40
  diff-lcs (>= 1.2.0, < 2.0)
24
41
  rspec-support (~> 3.8.0)
25
42
  rspec-support (3.8.0)
43
+ rubocop (0.66.0)
44
+ jaro_winkler (~> 1.5.1)
45
+ parallel (~> 1.10)
46
+ parser (>= 2.5, != 2.5.1.1)
47
+ psych (>= 3.1.0)
48
+ rainbow (>= 2.2.2, < 4.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 1.6)
51
+ rubocop-rspec (1.32.0)
52
+ rubocop (>= 0.60.0)
53
+ ruby-progressbar (1.10.0)
54
+ safe_yaml (1.0.5)
55
+ simplecov (0.16.1)
56
+ docile (~> 1.1)
57
+ json (>= 1.8, < 3)
58
+ simplecov-html (~> 0.10.0)
59
+ simplecov-html (0.10.2)
60
+ unicode-display_width (1.5.0)
61
+ vcr (4.0.0)
62
+ webmock (3.5.1)
63
+ addressable (>= 2.3.6)
64
+ crack (>= 0.3.2)
65
+ hashdiff
26
66
  yard (0.9.18)
27
67
 
28
68
  PLATFORMS
@@ -30,9 +70,15 @@ PLATFORMS
30
70
 
31
71
  DEPENDENCIES
32
72
  bundler (~> 1.16)
73
+ byebug (~> 11.0, >= 11.0.1)
33
74
  chainpoint!
34
75
  rake (~> 10.0)
35
76
  rspec (~> 3.0)
77
+ rubocop (~> 0.66.0)
78
+ rubocop-rspec (~> 1.32)
79
+ simplecov (~> 0.16.1)
80
+ vcr (~> 4.0)
81
+ webmock (~> 3.5, >= 3.5.1)
36
82
  yard (~> 0.9.18)
37
83
 
38
84
  BUNDLED WITH
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # Chainpoint
2
2
 
3
+ [![Build Status](https://travis-ci.org/KenjiOhtsuka/chainpoint_gem.svg?branch=master)](https://travis-ci.org/KenjiOhtsuka/chainpoint_gem)
4
+
3
5
  [![Gem Version](https://badge.fury.io/rb/chainpoint.svg)](https://badge.fury.io/rb/chainpoint)
4
6
 
5
7
  [Rubygem Page](https://rubygems.org/gems/chainpoint)
6
8
 
7
- [API Document](https://kenjiohtsuka.github.io/chainpoint_gem/)
9
+ [API Documentation](https://kenjiohtsuka.github.io/chainpoint_gem/)
8
10
 
9
- This is gem for request to Tierion Chainpoint.
10
- For Chainpoint, look at [Chainpoint Node HTTP API](https://github.com/chainpoint/chainpoint-node/wiki/Node-HTTP-API).
11
+ A client for creating and verifying [Chainpoint](https://chainpoint.org/) proofs.
11
12
 
12
13
  ## Installation
13
14
 
@@ -21,98 +22,109 @@ And then execute:
21
22
 
22
23
  $ bundle
23
24
 
24
-
25
25
  Or install it yourself as:
26
26
 
27
27
  $ gem install chainpoint
28
28
 
29
29
  ## Usage
30
30
 
31
- ### Create Instance
31
+ ### Initialize new hash object
32
32
 
33
33
  ```ruby
34
- require 'chainpoint'
35
- chainpoint = Chainpoint.new
34
+ sha256 = '09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b'
35
+ chainpoint_hash = ChainPoint::Hash.new(sha256)
36
36
  ```
37
37
 
38
- ### Submit Hash
38
+ `Chainpoint::Hash.from_data` is a convenience method to create a new `Chainpoint::Hash` from raw
39
+ data:
39
40
 
40
41
  ```ruby
41
- # hash is SHA256
42
- # hash = '2fbe59be2be10a4fdeca9c6d3e9f56fc56fb3ee9a8ef2e9be37fced60c264681'
43
- chainpoint.submit(hash)
42
+ chainpoint_hash = Chainpoint::Hash.from_data('hello, world')
43
+ # => #<Chainpoint::Hash @hash="09ca7e4eaa6e8ae9c7d26116712918...>
44
44
  ```
45
45
 
46
- #### Response
46
+ ### Submit Hash
47
+
48
+ Use this function to submit a hash, and receive back the proof handles needed to later retrieve a
49
+ proof.
50
+
51
+ By default hashes are submitted to three Nodes to help ensure a proof will become available at the appropriate time. Only one such proof need be permanently stored, the others provide redundancy.
47
52
 
48
53
  ```ruby
54
+ chainpoint_hash = Chainpoint::Hash.from_data('hello, world')
55
+ proof_handles = chainpoint_hash.submit
56
+ # =>
49
57
  [
50
58
  {
51
- "hash_id_node" => "1d1aa8a0-8f42-11e8-967f-01a68adfc010",
52
- "hash" => "2fbe59be2be10a4fdeca9c6d3e9f56fc56fb3ee9a8ef2e9be37fced60c264681"
53
- "uri" => "http://45.77.197.76"
59
+ 'hash_id_node' => '1d1aa8a0-8f42-11e8-967f-01a68adfc010',
60
+ 'uri' => 'http://45.77.197.76'
54
61
  }
62
+ ...
55
63
  ]
56
64
 
57
65
  ```
58
66
 
59
- Or, use `submit_data`:
67
+ ### Get Proof
68
+
69
+ Once a hash has been submitted, it contains proof handles that can be used to retrieve the proof.
70
+ It's likely that you will be retrieving proofs at a later time, so it is possible to initialize
71
+ a `Chainpoint::Hash` object with proof handle data returned from a previous submit.
72
+
73
+ A `Chainpoint::Proof` representing the first valid proof will be returned, or `nil` if there is no valid proof.
60
74
 
61
75
  ```ruby
62
- chainpoint.submit_data("text")
63
- ```
76
+ chainpoint_hash = Chainpoint::Hash.new(sha256, proof_handles: proof_handles)
77
+ chainpoint_hash.proof
64
78
 
65
- ### Get Proof
79
+ #=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal"]>
80
+ ```
66
81
 
67
- Only the node that a hash was submitted to can retrieve the proof, so initialize the client with
68
- the uri from the submit response and pass the hash_id_node from the same response:
82
+ You may also pass an anchor type to return only proofs matching that type. By default chainpoint
83
+ anchors to a Calendar blockchain (`cal`) which usually completes in about 10s and to the Bitcoin blockchain `btc` which usually completes in about 2h.
69
84
 
70
85
  ```ruby
71
- chainpoint = Chainpoint.new('http://45.77.197.76')
72
- chainpoint.get_proof(hash_id_node)
86
+ proof = Chainpoint::Hash.new(sha256, proof_handles: proof_handles).proof('btc')
87
+ #=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal", "btc"]>
73
88
  ```
74
89
 
75
- #### Response
90
+ ### Decode a Proof
76
91
 
77
- ```
78
- [
79
- {
80
- "hash_id_node"=>"a50eb4d0-8f20-11e8-8da8-0133565a0e60",
81
- "proof"=>"eJyNVMGOHDUQ5SP4BI7MTpXLLtt9Wolf4JTLyC6XmZaWmdF0JyHHhAtH9hMgizYgLkgoR/5jJD6G6tlN0O6ClEN3q22/V69cr+qHd5ey38363fzXdp4P07Bev6SxXeyP36xlW8bdYT/u5vULuplfHfS3rz4u3WzLtD1dul415KquKkLxvamULNxIcw/cxZ5Kqrkk7U7tIMUu2hjEseeEvy80m7Ftdvumpy9KAK2+wSp1BytETavUSloBEgUOBZTh/RkyPa/fjvOsd8hNmf90gHYwrpz/GvIAYQB49pFe9seFPoEXCg/oMxSjl9icBldLeEy/IP+bPjx7V49lJ1udrt/8clWqXv0h5WqzLO2Pm7u9t/vD9Pdnn7/+6er05Vnp2IZPyfL1z/vD7bQtKxf4DD7rWMCfkMNj8I+7cZoHDOS8I/AwtBijbx08Bo1aNUPKDTxV7uQoOQ6JtFLqQcEqlynVXtmD1wa5umhlpViJXER2JTTA0JisotC8OKeVMVgmkaVnAUQObCCreQJK9nos8NJ7xS4ZmIu65ok8lALdfNMFU0mYkodmvkKq3jF5VukSu0fhQFEeEh5Pl4196GjZmi89InaS1LnZr7rQagWDmRhkAo5UpMZumwAVs4+a6hPCnDGbex1LK8Bm94TYcs/dW7ZCuWVEqAGc3S9HbdW4oPvlE13P/ISwphyyL+yT3Wlk5hwqhhTsvq0zavApaFMO6HO09J1a7fpC3RGaRH1CyLFbGTwZh6+lcGzeBIWUk5fMORfruu5IQgZXoZnPzNN9KfkSMj5xTbYUncvxg3GsjAMOH8aEXPw7H5ZxMZj1h3vEWY5YEPOzqki3wKU5cz0hSEiNkwjXDsRm/CKliSegiFhRTf9isPJAzu1dU03X358H0VsL9ut9n43t9j7szfPjOF2fLv5P4tpQumvluL4HrJde/wcFK5lW",
82
- "anchors_complete"=>["cal"]
83
- }
84
- ]
92
+ A `Chainpoint::Proof` object contains a binary representation of the proof can be converted to JSON to view the Chainpoint JSON Schema:
93
+
94
+ ```ruby
95
+ proof.decode
96
+ # =>
85
97
  ```
86
98
 
87
- ### Verify
99
+ ### Verify a Proof
88
100
 
89
- Pass proof value which is shown on calling `get_proof`.
101
+ You can verify a proof against each of the blockchains the proof has been anchored to:
90
102
 
91
103
  ```ruby
92
- c.verify('eJyNVMGOHDUQ5SP4BI7MTpXLLtt9Wolf4JTLyC6XmZaWmdF0JyHHhAtH9hMgizYgLkgoR/5jJD6G6tlN0O6ClEN3q22/V69cr+qHd5ey38363fzXdp4P07Bev6SxXeyP36xlW8bdYT/u5vULuplfHfS3rz4u3WzLtD1dul415KquKkLxvamULNxIcw/cxZ5Kqrkk7U7tIMUu2hjEseeEvy80m7Ftdvumpy9KAK2+wSp1BytETavUSloBEgUOBZTh/RkyPa/fjvOsd8hNmf90gHYwrpz/GvIAYQB49pFe9seFPoEXCg/oMxSjl9icBldLeEy/IP+bPjx7V49lJ1udrt/8clWqXv0h5WqzLO2Pm7u9t/vD9Pdnn7/+6er05Vnp2IZPyfL1z/vD7bQtKxf4DD7rWMCfkMNj8I+7cZoHDOS8I/AwtBijbx08Bo1aNUPKDTxV7uQoOQ6JtFLqQcEqlynVXtmD1wa5umhlpViJXER2JTTA0JisotC8OKeVMVgmkaVnAUQObCCreQJK9nos8NJ7xS4ZmIu65ok8lALdfNMFU0mYkodmvkKq3jF5VukSu0fhQFEeEh5Pl4196GjZmi89InaS1LnZr7rQagWDmRhkAo5UpMZumwAVs4+a6hPCnDGbex1LK8Bm94TYcs/dW7ZCuWVEqAGc3S9HbdW4oPvlE13P/ISwphyyL+yT3Wlk5hwqhhTsvq0zavApaFMO6HO09J1a7fpC3RGaRH1CyLFbGTwZh6+lcGzeBIWUk5fMORfruu5IQgZXoZnPzNN9KfkSMj5xTbYUncvxg3GsjAMOH8aEXPw7H5ZxMZj1h3vEWY5YEPOzqki3wKU5cz0hSEiNkwjXDsRm/CKliSegiFhRTf9isPJAzu1dU03X358H0VsL9ut9n43t9j7szfPjOF2fLv5P4tpQumvluL4HrJde/wcFK5lW')
104
+ proof.verify
93
105
  ```
94
106
 
95
107
  #### Response
96
108
 
97
109
  ```ruby
98
- [
99
- {
100
- "proof_index"=>0,
101
- "hash"=>"2fbe59be2be10a4fdeca9c6d3e9f56fc56fb3ee9a8ef2e9be37fced60c264681",
102
- "hash_id_node"=>"a50eb4d0-8f20-11e8-8da8-0133565a0e60",
103
- "hash_submitted_node_at"=>"2018-07-24T09:05:00Z",
104
- "hash_id_core"=>"a804c350-8f20-11e8-890a-01c7d2e52ba5",
105
- "hash_submitted_core_at"=>"2018-07-24T09:05:05Z",
106
- "anchors"=>[
107
- {
108
- "branch"=>"cal_anchor_branch",
109
- "type"=>"cal",
110
- "valid"=>true
111
- }
112
- ],
113
- "status"=>"verified"
114
- }
115
- ]
110
+ {
111
+ "proof_index" => 0,
112
+ "hash" => "09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b",
113
+ "hash_id_node" => "1672f730-536b-11e9-9241-015d8fee1e71",
114
+ "hash_submitted_node_at" => "2019-03-31T04:11:41Z",
115
+ "hash_id_core" => "18456d40-536b-11e9-8c0f-016fe824db22",
116
+ "hash_submitted_core_at" => "2019-03-31T04:11:44Z",
117
+ "anchors" => [
118
+ {
119
+ "branch" => "cal_anchor_branch",
120
+ "type" => "cal",
121
+ "valid" => true,
122
+ "block_id" => "2967333", "block_value" => "74e2b62f68463f53105b65d57c729e5488b7833d6ebb259561b84e43d826c7ea"
123
+ }
124
+ ],
125
+ "status"=>"verified"
126
+ }
127
+
116
128
  ```
117
129
 
118
130
  ## Development
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
5
9
 
6
- task :default => :spec
10
+ task default: %i[rubocop spec]
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "chainpoint"
4
+ require 'bundler/setup'
5
+ require 'chainpoint'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "chainpoint"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/chainpoint.gemspec CHANGED
@@ -1,32 +1,34 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "chainpoint/version"
5
+ require 'chainpoint/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "chainpoint"
8
+ spec.name = 'chainpoint'
8
9
  spec.version = Chainpoint::VERSION
9
10
  spec.date = '2018-07-24'
10
- spec.authors = ["Kenji Ohtsuka"]
11
- spec.email = ["kok.fdcm@gmail.com"]
11
+ spec.authors = ['Kenji Ohtsuka']
12
+ spec.email = ['kok.fdcm@gmail.com']
12
13
 
13
- spec.summary = "Chainpoint request library"
14
- #spec.description = %q{TODO: Write a longer description or delete this line.}
15
- spec.homepage = "https://github.com/KenjiOhtsuka/chainpoint_gem"
14
+ spec.summary = 'Chainpoint request library'
15
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
16
+ spec.homepage = 'https://github.com/KenjiOhtsuka/chainpoint_gem'
16
17
 
17
- spec.add_runtime_dependency "json"
18
+ spec.add_runtime_dependency 'json'
19
+ spec.add_runtime_dependency 'msgpack'
18
20
  spec.required_ruby_version = '>= 2.5.0'
19
21
 
20
22
  spec.license = 'GPL-3.0'
21
23
 
22
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
25
  f.match(%r{^(test|spec|features)/})
24
26
  end
25
- spec.bindir = "exe"
27
+ spec.bindir = 'exe'
26
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
29
+ spec.require_paths = ['lib']
28
30
 
29
- spec.add_development_dependency "bundler", "~> 1.16"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency 'bundler', '~> 1.16'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
34
  end