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 +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +12 -0
- data/.travis.yml +4 -1
- data/Gemfile +11 -3
- data/Gemfile.lock +47 -1
- data/README.md +65 -53
- data/Rakefile +7 -3
- data/bin/console +4 -3
- data/chainpoint.gemspec +17 -15
- data/docs/Chainpoint/Hash.html +636 -0
- data/docs/Chainpoint/Proof.html +567 -0
- data/docs/Chainpoint/ProofHandle.html +475 -0
- data/docs/Chainpoint.html +50 -838
- data/docs/_index.html +39 -2
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +70 -57
- data/docs/index.html +70 -57
- data/docs/method_list.html +97 -17
- data/docs/top-level-namespace.html +3 -3
- data/lib/chainpoint/hash.rb +62 -0
- data/lib/chainpoint/proof.rb +37 -0
- data/lib/chainpoint/proof_handle.rb +33 -0
- data/lib/chainpoint/version.rb +18 -18
- data/lib/chainpoint.rb +35 -130
- metadata +22 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 548389f4be90eea5ca691b311038f5f73a87c560d569ac4ad1ae23d05021b9e6
|
4
|
+
data.tar.gz: f45ed9177795b2333ebb2f5c15f32a2af3af95a3be498a0d8480235f492e0c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef9d851af3025be0095a333897b1f4fa5abd661166dcd99de5ad3e8c42415f9e1cf172dc3a70d451926d57c419374b2b553ed02e11dad48ff094438c1648f99d
|
7
|
+
data.tar.gz: 00f8c1f40fa40290c400836038ff8a4acd39715ec7e912f6db3d7a3f097ba5c496ca8737dcc1ff4ab4cac85d2db9c4738dc576b7a04e1cf8e9bbddb3b278c1d3
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
|
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 (
|
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
|
+
[](https://travis-ci.org/KenjiOhtsuka/chainpoint_gem)
|
4
|
+
|
3
5
|
[](https://badge.fury.io/rb/chainpoint)
|
4
6
|
|
5
7
|
[Rubygem Page](https://rubygems.org/gems/chainpoint)
|
6
8
|
|
7
|
-
[API
|
9
|
+
[API Documentation](https://kenjiohtsuka.github.io/chainpoint_gem/)
|
8
10
|
|
9
|
-
|
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
|
-
###
|
31
|
+
### Initialize new hash object
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
|
35
|
-
|
34
|
+
sha256 = '09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b'
|
35
|
+
chainpoint_hash = ChainPoint::Hash.new(sha256)
|
36
36
|
```
|
37
37
|
|
38
|
-
|
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
|
-
|
42
|
-
# hash
|
43
|
-
chainpoint.submit(hash)
|
42
|
+
chainpoint_hash = Chainpoint::Hash.from_data('hello, world')
|
43
|
+
# => #<Chainpoint::Hash @hash="09ca7e4eaa6e8ae9c7d26116712918...>
|
44
44
|
```
|
45
45
|
|
46
|
-
|
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
|
-
|
52
|
-
|
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
|
-
|
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
|
-
|
63
|
-
|
76
|
+
chainpoint_hash = Chainpoint::Hash.new(sha256, proof_handles: proof_handles)
|
77
|
+
chainpoint_hash.proof
|
64
78
|
|
65
|
-
|
79
|
+
#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal"]>
|
80
|
+
```
|
66
81
|
|
67
|
-
|
68
|
-
|
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
|
-
|
72
|
-
|
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
|
-
|
90
|
+
### Decode a Proof
|
76
91
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
101
|
+
You can verify a proof against each of the blockchains the proof has been anchored to:
|
90
102
|
|
91
103
|
```ruby
|
92
|
-
|
104
|
+
proof.verify
|
93
105
|
```
|
94
106
|
|
95
107
|
#### Response
|
96
108
|
|
97
109
|
```ruby
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
2
|
-
|
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 :
|
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
|
4
|
-
require
|
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
|
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(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'chainpoint/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'chainpoint'
|
8
9
|
spec.version = Chainpoint::VERSION
|
9
10
|
spec.date = '2018-07-24'
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
11
|
+
spec.authors = ['Kenji Ohtsuka']
|
12
|
+
spec.email = ['kok.fdcm@gmail.com']
|
12
13
|
|
13
|
-
spec.summary =
|
14
|
-
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
15
|
-
spec.homepage =
|
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
|
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
|
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 =
|
27
|
+
spec.bindir = 'exe'
|
26
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
29
|
+
spec.require_paths = ['lib']
|
28
30
|
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
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
|