chainpoint 1.0.1 → 1.1.0
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/CONTRIBUTING.md +0 -4
- data/Gemfile.lock +1 -1
- data/docs/Chainpoint.html +1 -1
- data/docs/Chainpoint/Hash.html +21 -29
- data/docs/Chainpoint/Proof.html +1 -1
- data/docs/Chainpoint/ProofHandle.html +30 -11
- data/docs/_index.html +1 -1
- data/docs/file.README.html +115 -99
- data/docs/index.html +115 -99
- data/docs/top-level-namespace.html +1 -1
- data/lib/chainpoint/hash.rb +8 -4
- data/lib/chainpoint/proof_handle.rb +3 -0
- data/lib/chainpoint/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 796ce2adab4a449fac66b9c72d63dc66b58b3099cf3b628fdf70bbda84738fea
|
4
|
+
data.tar.gz: '0383d3809e8ce71933b82b684d8b21f74bd6c04c6c8862062182d94d0fc50708'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1363402475ee61afa4a0bec6652524d996a7b75dade446f7e2bfcb6452b344f6c96dc957d6e2006193f6cf6c4c6721f9bc330cf48f0ab43b51f31e58af6eb7f
|
7
|
+
data.tar.gz: 17ec808be1e80d1faa37cabb0112ee60b296b1a6550429a12d19dab7301687dcc1f5d659de18cd5650352360c88b938a814a7ad18ec95f29263b4e4b669e52dc
|
data/CONTRIBUTING.md
CHANGED
@@ -3,8 +3,4 @@
|
|
3
3
|
## When you change the code
|
4
4
|
|
5
5
|
* Checkout your branch from the develop branch, and create a pull request to the develop branch.
|
6
|
-
* Create the document with the following command:
|
7
|
-
```sh
|
8
|
-
yard doc -o docs
|
9
|
-
```
|
10
6
|
* Don't forget to update `README.md` if it is needed.
|
data/Gemfile.lock
CHANGED
data/docs/Chainpoint.html
CHANGED
@@ -228,7 +228,7 @@ href="http://www.gnu.org/licenses">www.gnu.org/licenses</a>/>.</p>
|
|
228
228
|
</div>
|
229
229
|
|
230
230
|
<div id="footer">
|
231
|
-
Generated on
|
231
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
232
232
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
233
233
|
0.9.18 (ruby-2.5.1).
|
234
234
|
</div>
|
data/docs/Chainpoint/Hash.html
CHANGED
@@ -163,8 +163,6 @@
|
|
163
163
|
|
164
164
|
|
165
165
|
|
166
|
-
<span class="note title readonly">readonly</span>
|
167
|
-
|
168
166
|
|
169
167
|
|
170
168
|
|
@@ -351,20 +349,14 @@
|
|
351
349
|
15
|
352
350
|
16
|
353
351
|
17
|
354
|
-
18
|
355
|
-
19
|
356
|
-
20
|
357
|
-
21</pre>
|
352
|
+
18</pre>
|
358
353
|
</td>
|
359
354
|
<td>
|
360
355
|
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line 15</span>
|
361
356
|
|
362
357
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>proof_handles:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
363
358
|
<span class='ivar'>@hash</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
|
364
|
-
<span class='
|
365
|
-
<span class='id identifier rubyid_proof_handles'>proof_handles</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
|
366
|
-
<span class='const'><span class='object_link'><a href="ProofHandle.html" title="Chainpoint::ProofHandle (class)">ProofHandle</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ProofHandle.html#initialize-instance_method" title="Chainpoint::ProofHandle#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:uri</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:node_hash_id</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
367
|
-
<span class='kw'>end</span>
|
359
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_proof_handles'>proof_handles</span> <span class='op'>=</span> <span class='id identifier rubyid_proof_handles'>proof_handles</span>
|
368
360
|
<span class='kw'>end</span></pre>
|
369
361
|
</td>
|
370
362
|
</tr>
|
@@ -420,11 +412,11 @@
|
|
420
412
|
</div>
|
421
413
|
|
422
414
|
|
423
|
-
<span id=""></span>
|
415
|
+
<span id="proof_handles=-instance_method"></span>
|
424
416
|
<div class="method_details ">
|
425
417
|
<h3 class="signature " id="proof_handles-instance_method">
|
426
418
|
|
427
|
-
#<strong>proof_handles</strong> ⇒ <tt>Object</tt>
|
419
|
+
#<strong>proof_handles</strong> ⇒ <tt>Object</tt>
|
428
420
|
|
429
421
|
|
430
422
|
|
@@ -520,16 +512,16 @@
|
|
520
512
|
<pre class="lines">
|
521
513
|
|
522
514
|
|
515
|
+
30
|
516
|
+
31
|
517
|
+
32
|
523
518
|
33
|
524
519
|
34
|
525
520
|
35
|
526
|
-
36
|
527
|
-
37
|
528
|
-
38
|
529
|
-
39</pre>
|
521
|
+
36</pre>
|
530
522
|
</td>
|
531
523
|
<td>
|
532
|
-
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line
|
524
|
+
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line 30</span>
|
533
525
|
|
534
526
|
<span class='kw'>def</span> <span class='id identifier rubyid_proof'>proof</span><span class='lparen'>(</span><span class='id identifier rubyid_anchor_type'>anchor_type</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
535
527
|
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@proof_handles</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
|
@@ -558,18 +550,18 @@
|
|
558
550
|
<pre class="lines">
|
559
551
|
|
560
552
|
|
553
|
+
20
|
554
|
+
21
|
555
|
+
22
|
561
556
|
23
|
562
557
|
24
|
563
558
|
25
|
564
559
|
26
|
565
560
|
27
|
566
|
-
28
|
567
|
-
29
|
568
|
-
30
|
569
|
-
31</pre>
|
561
|
+
28</pre>
|
570
562
|
</td>
|
571
563
|
<td>
|
572
|
-
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line
|
564
|
+
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line 20</span>
|
573
565
|
|
574
566
|
<span class='kw'>def</span> <span class='id identifier rubyid_submit'>submit</span>
|
575
567
|
<span class='ivar'>@proof_handles</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_select_nodes'><span class='object_link'><a href="../Chainpoint.html#select_nodes-class_method" title="Chainpoint.select_nodes (method)">select_nodes</a></span></span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#NUM_SERVERS-constant" title="Chainpoint::Hash::NUM_SERVERS (constant)">NUM_SERVERS</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flat_map'>flat_map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_uri'>uri</span><span class='op'>|</span>
|
@@ -600,15 +592,15 @@
|
|
600
592
|
<pre class="lines">
|
601
593
|
|
602
594
|
|
603
|
-
41
|
604
|
-
42
|
605
|
-
43
|
606
|
-
44
|
607
595
|
45
|
608
|
-
46
|
596
|
+
46
|
597
|
+
47
|
598
|
+
48
|
599
|
+
49
|
600
|
+
50</pre>
|
609
601
|
</td>
|
610
602
|
<td>
|
611
|
-
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line
|
603
|
+
<pre class="code"><span class="info file"># File 'lib/chainpoint/hash.rb', line 45</span>
|
612
604
|
|
613
605
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_h'>to_h</span>
|
614
606
|
<span class='lbrace'>{</span>
|
@@ -626,7 +618,7 @@
|
|
626
618
|
</div>
|
627
619
|
|
628
620
|
<div id="footer">
|
629
|
-
Generated on
|
621
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
630
622
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
631
623
|
0.9.18 (ruby-2.5.1).
|
632
624
|
</div>
|
data/docs/Chainpoint/Proof.html
CHANGED
@@ -557,7 +557,7 @@
|
|
557
557
|
</div>
|
558
558
|
|
559
559
|
<div id="footer">
|
560
|
-
Generated on
|
560
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
561
561
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
562
562
|
0.9.18 (ruby-2.5.1).
|
563
563
|
</div>
|
@@ -272,6 +272,19 @@
|
|
272
272
|
</div>
|
273
273
|
<div class="tags">
|
274
274
|
|
275
|
+
<p class="tag_title">Raises:</p>
|
276
|
+
<ul class="raise">
|
277
|
+
|
278
|
+
<li>
|
279
|
+
|
280
|
+
|
281
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
</li>
|
286
|
+
|
287
|
+
</ul>
|
275
288
|
|
276
289
|
</div><table class="source_code">
|
277
290
|
<tr>
|
@@ -282,12 +295,18 @@
|
|
282
295
|
7
|
283
296
|
8
|
284
297
|
9
|
285
|
-
10
|
298
|
+
10
|
299
|
+
11
|
300
|
+
12
|
301
|
+
13</pre>
|
286
302
|
</td>
|
287
303
|
<td>
|
288
304
|
<pre class="code"><span class="info file"># File 'lib/chainpoint/proof_handle.rb', line 7</span>
|
289
305
|
|
290
306
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='comma'>,</span> <span class='id identifier rubyid_node_hash_id'>node_hash_id</span><span class='rparen'>)</span>
|
307
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Proof Handle uri not specified</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_uri'>uri</span>
|
308
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Proof Handle node_hash_id not specified</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_node_hash_id'>node_hash_id</span>
|
309
|
+
|
291
310
|
<span class='ivar'>@uri</span> <span class='op'>=</span> <span class='id identifier rubyid_uri'>uri</span>
|
292
311
|
<span class='ivar'>@node_hash_id</span> <span class='op'>=</span> <span class='id identifier rubyid_node_hash_id'>node_hash_id</span>
|
293
312
|
<span class='kw'>end</span></pre>
|
@@ -409,15 +428,15 @@
|
|
409
428
|
<pre class="lines">
|
410
429
|
|
411
430
|
|
412
|
-
12
|
413
|
-
13
|
414
|
-
14
|
415
431
|
15
|
416
432
|
16
|
417
|
-
17
|
433
|
+
17
|
434
|
+
18
|
435
|
+
19
|
436
|
+
20</pre>
|
418
437
|
</td>
|
419
438
|
<td>
|
420
|
-
<pre class="code"><span class="info file"># File 'lib/chainpoint/proof_handle.rb', line
|
439
|
+
<pre class="code"><span class="info file"># File 'lib/chainpoint/proof_handle.rb', line 15</span>
|
421
440
|
|
422
441
|
<span class='kw'>def</span> <span class='id identifier rubyid_proof'>proof</span>
|
423
442
|
<span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_request_proof'>request_proof</span>
|
@@ -445,12 +464,12 @@
|
|
445
464
|
<pre class="lines">
|
446
465
|
|
447
466
|
|
448
|
-
|
449
|
-
|
450
|
-
|
467
|
+
22
|
468
|
+
23
|
469
|
+
24</pre>
|
451
470
|
</td>
|
452
471
|
<td>
|
453
|
-
<pre class="code"><span class="info file"># File 'lib/chainpoint/proof_handle.rb', line
|
472
|
+
<pre class="code"><span class="info file"># File 'lib/chainpoint/proof_handle.rb', line 22</span>
|
454
473
|
|
455
474
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_h'>to_h</span>
|
456
475
|
<span class='lbrace'>{</span> <span class='label'>uri:</span> <span class='ivar'>@uri</span><span class='comma'>,</span> <span class='label'>node_hash_id:</span> <span class='ivar'>@node_hash_id</span> <span class='rbrace'>}</span>
|
@@ -465,7 +484,7 @@
|
|
465
484
|
</div>
|
466
485
|
|
467
486
|
<div id="footer">
|
468
|
-
Generated on
|
487
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
469
488
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
470
489
|
0.9.18 (ruby-2.5.1).
|
471
490
|
</div>
|
data/docs/_index.html
CHANGED
@@ -134,7 +134,7 @@
|
|
134
134
|
</div>
|
135
135
|
|
136
136
|
<div id="footer">
|
137
|
-
Generated on
|
137
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
138
138
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
139
139
|
0.9.18 (ruby-2.5.1).
|
140
140
|
</div>
|
data/docs/file.README.html
CHANGED
@@ -57,25 +57,29 @@
|
|
57
57
|
<div class="clear"></div>
|
58
58
|
</div>
|
59
59
|
|
60
|
-
<div id="content"><div id='filecontents'
|
60
|
+
<div id="content"><div id='filecontents'>
|
61
|
+
<h1 id="label-Chainpoint">Chainpoint</h1>
|
61
62
|
|
62
|
-
<p><a href="https://travis-ci.org/KenjiOhtsuka/chainpoint_gem"><img
|
63
|
+
<p><a href="https://travis-ci.org/KenjiOhtsuka/chainpoint_gem"><img
|
64
|
+
src="https://travis-ci.org/KenjiOhtsuka/chainpoint_gem.svg?branch=master"></a></p>
|
63
65
|
|
64
|
-
<p><a href="https://badge.fury.io/rb/chainpoint"><img
|
66
|
+
<p><a href="https://badge.fury.io/rb/chainpoint"><img
|
67
|
+
src="https://badge.fury.io/rb/chainpoint.svg"></a></p>
|
65
68
|
|
66
69
|
<p><a href="https://rubygems.org/gems/chainpoint">Rubygem Page</a></p>
|
67
70
|
|
68
|
-
<p><a href="https://kenjiohtsuka.github.io/chainpoint_gem/">API
|
71
|
+
<p><a href="https://kenjiohtsuka.github.io/chainpoint_gem/">API
|
72
|
+
Documentation</a></p>
|
69
73
|
|
70
|
-
<p>A client for creating and verifying <a
|
74
|
+
<p>A client for creating and verifying <a
|
75
|
+
href="https://chainpoint.org/">Chainpoint</a> proofs.</p>
|
71
76
|
|
72
|
-
<h2 id="
|
77
|
+
<h2 id="label-Installation">Installation</h2>
|
73
78
|
|
74
|
-
<p>Add this line to your application
|
79
|
+
<p>Add this line to your application's Gemfile:</p>
|
75
80
|
|
76
|
-
<
|
77
|
-
|
78
|
-
</code></p>
|
81
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>chainpoint</span><span class='tstring_end'>'</span></span>
|
82
|
+
</code></pre>
|
79
83
|
|
80
84
|
<p>And then execute:</p>
|
81
85
|
|
@@ -87,126 +91,138 @@ gem 'chainpoint'
|
|
87
91
|
<pre class="code ruby"><code class="ruby">$ gem install chainpoint
|
88
92
|
</code></pre>
|
89
93
|
|
90
|
-
<h2 id="
|
94
|
+
<h2 id="label-Usage">Usage</h2>
|
91
95
|
|
92
|
-
<h3 id="
|
96
|
+
<h3 id="label-Initialize+new+hash+object">Initialize new hash object</h3>
|
93
97
|
|
94
|
-
<
|
95
|
-
|
96
|
-
|
97
|
-
</code></p>
|
98
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sha256'>sha256</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b</span><span class='tstring_end'>'</span></span>
|
99
|
+
<span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span> <span class='op'>=</span> <span class='const'>ChainPoint</span><span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_sha256'>sha256</span><span class='rparen'>)</span>
|
100
|
+
</code></pre>
|
98
101
|
|
99
|
-
<p><code>Chainpoint::Hash.from_data</code> is a convenience method to create a
|
100
|
-
data:</p>
|
102
|
+
<p><code>Chainpoint::Hash.from_data</code> is a convenience method to create a
|
103
|
+
new <code>Chainpoint::Hash</code> from raw data:</p>
|
101
104
|
|
102
|
-
<
|
103
|
-
|
104
|
-
|
105
|
-
</code></p>
|
105
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Chainpoint/Hash.html" title="Chainpoint::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_data'><span class='object_link'><a href="Chainpoint/Hash.html#from_data-class_method" title="Chainpoint::Hash.from_data (method)">from_data</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>hello, world</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
106
|
+
<span class='comment'># => #<Chainpoint::Hash @hash="09ca7e4eaa6e8ae9c7d26116712918...>
|
107
|
+
</span></code></pre>
|
106
108
|
|
107
|
-
<h3 id="
|
109
|
+
<h3 id="label-Submit+Hash">Submit Hash</h3>
|
108
110
|
|
109
|
-
<p>Use this function to submit a hash, and receive back the proof handles
|
110
|
-
proof.</p>
|
111
|
+
<p>Use this function to submit a hash, and receive back the proof handles
|
112
|
+
needed to later retrieve a proof.</p>
|
111
113
|
|
112
|
-
<p>By default hashes are submitted to three Nodes to help ensure a proof will
|
114
|
+
<p>By default hashes are submitted to three Nodes to help ensure a proof will
|
115
|
+
become available at the appropriate time. Only one such proof need be
|
116
|
+
permanently stored, the others provide redundancy.</p>
|
113
117
|
|
114
|
-
<
|
115
|
-
chainpoint_hash = Chainpoint::Hash.from_data(‘hello, world’)
|
118
|
+
<pre class="code ruby"><code class="ruby">chainpoint_hash = Chainpoint::Hash.from_data('hello, world')
|
116
119
|
proof_handles = chainpoint_hash.submit
|
117
120
|
# =>
|
118
121
|
[
|
119
122
|
{
|
120
|
-
|
121
|
-
|
123
|
+
'hash_id_node' => '1d1aa8a0-8f42-11e8-967f-01a68adfc010',
|
124
|
+
'uri' => 'http://45.77.197.76'
|
122
125
|
}
|
123
|
-
|
124
|
-
]
|
125
|
-
|
126
|
-
<p>```</p>
|
127
|
-
|
128
|
-
<h3 id="get-proof">Get Proof</h3>
|
129
|
-
|
130
|
-
<p>Once a hash has been submitted, it contains proof handles that can be used to retrieve the proof.
|
131
|
-
It’s likely that you will be retrieving proofs at a later time, so it is possible to initialize
|
132
|
-
a <code>Chainpoint::Hash</code> object with proof handle data returned from a previous submit.</p>
|
133
|
-
|
134
|
-
<p>A <code>Chainpoint::Proof</code> representing the first valid proof will be returned, or <code>nil</code> if there is no valid proof.</p>
|
135
|
-
|
136
|
-
<p>```ruby
|
137
|
-
chainpoint_hash = Chainpoint::Hash.new(sha256, proof_handles: proof_handles)
|
138
|
-
chainpoint_hash.proof</p>
|
139
|
-
|
140
|
-
<h1 id="chainpointproof-proofejynk71ufdex0-hashidnode1672f730-1-anchorscompletecal">=> #<Chainpoint::Proof @proof=”eJyNk71uFDEx0=…”, @hash_id_node=”1672f730-…1”, @anchors_complete=[“cal”]></h1>
|
141
|
-
<p>```</p>
|
142
|
-
|
143
|
-
<p>You may also pass an anchor type to return only proofs matching that type. By default chainpoint
|
144
|
-
anchors to a Calendar blockchain (<code>cal</code>) which usually completes in about 10s and to the Bitcoin blockchain <code>btc</code> which usually completes in about 2h.</p>
|
145
|
-
|
146
|
-
<p><code>ruby
|
147
|
-
proof = Chainpoint::Hash.new(sha256, proof_handles: proof_handles).proof('btc')
|
148
|
-
#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal", "btc"]>
|
149
|
-
</code></p>
|
126
|
+
...
|
127
|
+
]
|
128
|
+
</code></pre>
|
150
129
|
|
151
|
-
<h3 id="
|
130
|
+
<h3 id="label-Get+Proof">Get Proof</h3>
|
152
131
|
|
153
|
-
<p>
|
132
|
+
<p>Once a hash has been submitted, it contains proof handles that can be used
|
133
|
+
to retrieve the proof. It's likely that you will be retrieving proofs
|
134
|
+
at a later time, so it is possible to initialize a
|
135
|
+
<code>Chainpoint::Hash</code> object with proof handle data returned from a
|
136
|
+
previous submit.</p>
|
154
137
|
|
155
|
-
<p
|
156
|
-
proof
|
157
|
-
# =>
|
158
|
-
</code></p>
|
138
|
+
<p>A <code>Chainpoint::Proof</code> representing the first valid proof will be
|
139
|
+
returned, or <code>nil</code> if there is no valid proof.</p>
|
159
140
|
|
160
|
-
<
|
141
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Chainpoint/Hash.html" title="Chainpoint::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Chainpoint/Hash.html#initialize-instance_method" title="Chainpoint::Hash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_sha256'>sha256</span><span class='comma'>,</span> <span class='label'>proof_handles:</span> <span class='id identifier rubyid_proof_handles'>proof_handles</span><span class='rparen'>)</span>
|
142
|
+
<span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span><span class='period'>.</span><span class='id identifier rubyid_proof'>proof</span>
|
161
143
|
|
162
|
-
<
|
144
|
+
<span class='comment'>#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal"]>
|
145
|
+
</span></code></pre>
|
163
146
|
|
164
|
-
<p
|
165
|
-
|
166
|
-
|
147
|
+
<p>You may also pass an anchor type to return only proofs matching that type.
|
148
|
+
By default chainpoint anchors to a Calendar blockchain (<code>cal</code>)
|
149
|
+
which usually completes in about 10s and to the Bitcoin blockchain
|
150
|
+
<code>btc</code> which usually completes in about 2h.</p>
|
167
151
|
|
168
|
-
<
|
152
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_proof'>proof</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Chainpoint/Hash.html" title="Chainpoint::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Chainpoint/Hash.html#initialize-instance_method" title="Chainpoint::Hash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_sha256'>sha256</span><span class='comma'>,</span> <span class='label'>proof_handles:</span> <span class='id identifier rubyid_proof_handles'>proof_handles</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_proof'><span class='object_link'><a href="Chainpoint/Hash.html#proof-instance_method" title="Chainpoint::Hash#proof (method)">proof</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>btc</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
153
|
+
<span class='comment'>#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal", "btc"]>
|
154
|
+
</span></code></pre>
|
169
155
|
|
170
|
-
<
|
171
|
-
{
|
172
|
-
“proof_index” => 0,
|
173
|
-
“hash” => “09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b”,
|
174
|
-
“hash_id_node” => “1672f730-536b-11e9-9241-015d8fee1e71”,
|
175
|
-
“hash_submitted_node_at” => “2019-03-31T04:11:41Z”,
|
176
|
-
“hash_id_core” => “18456d40-536b-11e9-8c0f-016fe824db22”,
|
177
|
-
“hash_submitted_core_at” => “2019-03-31T04:11:44Z”,
|
178
|
-
“anchors” => [
|
179
|
-
{
|
180
|
-
“branch” => “cal_anchor_branch”,
|
181
|
-
“type” => “cal”,
|
182
|
-
“valid” => true,
|
183
|
-
“block_id” => “2967333”, “block_value” => “74e2b62f68463f53105b65d57c729e5488b7833d6ebb259561b84e43d826c7ea”
|
184
|
-
}
|
185
|
-
],
|
186
|
-
“status”=>”verified”
|
187
|
-
}</p>
|
156
|
+
<h3 id="label-Decode+a+Proof">Decode a Proof</h3>
|
188
157
|
|
189
|
-
<p
|
158
|
+
<p>A <code>Chainpoint::Proof</code> object contains a binary representation of
|
159
|
+
the proof can be converted to JSON to view the Chainpoint JSON Schema:</p>
|
190
160
|
|
191
|
-
<
|
161
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_proof'>proof</span><span class='period'>.</span><span class='id identifier rubyid_decode'>decode</span>
|
162
|
+
<span class='comment'># =>
|
163
|
+
</span></code></pre>
|
192
164
|
|
193
|
-
<
|
165
|
+
<h3 id="label-Verify+a+Proof">Verify a Proof</h3>
|
194
166
|
|
195
|
-
<p>
|
167
|
+
<p>You can verify a proof against each of the blockchains the proof has been
|
168
|
+
anchored to:</p>
|
196
169
|
|
197
|
-
<
|
198
|
-
|
199
|
-
<p>Bug reports and pull requests are welcome on <a href="https://github.com/KenjiOhtsuka/chainpoint_gem">GitHub chainpoint</a>.</p>
|
170
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_proof'>proof</span><span class='period'>.</span><span class='id identifier rubyid_verify'>verify</span>
|
171
|
+
</code></pre>
|
200
172
|
|
201
|
-
<
|
173
|
+
<h4 id="label-Response">Response</h4>
|
174
|
+
|
175
|
+
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span>
|
176
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>proof_index</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='int'>0</span><span class='comma'>,</span>
|
177
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
178
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_id_node</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1672f730-536b-11e9-9241-015d8fee1e71</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
179
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_submitted_node_at</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2019-03-31T04:11:41Z</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
180
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_id_core</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>18456d40-536b-11e9-8c0f-016fe824db22</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
181
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_submitted_core_at</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2019-03-31T04:11:44Z</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
182
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>anchors</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='lbracket'>[</span>
|
183
|
+
<span class='lbrace'>{</span>
|
184
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>branch</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>cal_anchor_branch</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
185
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>type</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>cal</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
186
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>valid</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='kw'>true</span><span class='comma'>,</span>
|
187
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>block_id</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2967333</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>block_value</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>74e2b62f68463f53105b65d57c729e5488b7833d6ebb259561b84e43d826c7ea</span><span class='tstring_end'>"</span></span>
|
188
|
+
<span class='rbrace'>}</span>
|
189
|
+
<span class='rbracket'>]</span><span class='comma'>,</span>
|
190
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>status</span><span class='tstring_end'>"</span></span><span class='op'>=></span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>verified</span><span class='tstring_end'>"</span></span>
|
191
|
+
<span class='rbrace'>}</span>
|
192
|
+
</code></pre>
|
202
193
|
|
203
|
-
<
|
204
|
-
|
205
|
-
</
|
194
|
+
<h2 id="label-Development">Development</h2>
|
195
|
+
|
196
|
+
<p>After checking out the repo, run <code>bin/setup</code> to install
|
197
|
+
dependencies. Then, run <code>rake spec</code> to run the tests. You can
|
198
|
+
also run <code>bin/console</code> for an interactive prompt that will allow
|
199
|
+
you to experiment.</p>
|
200
|
+
|
201
|
+
<p>To install this gem onto your local machine, run <code>bundle exec rake
|
202
|
+
install</code>. To release a new version, update the version number in
|
203
|
+
<code>version.rb</code>, and then run <code>bundle exec rake
|
204
|
+
release</code>, which will create a git tag for the version, push git
|
205
|
+
commits and tags, and push the <code>.gem</code> file to <a
|
206
|
+
href="https://rubygems.org">rubygems.org</a>.</p>
|
207
|
+
|
208
|
+
<h2 id="label-Contributing">Contributing</h2>
|
209
|
+
|
210
|
+
<p>Bug reports and pull requests are welcome on <a
|
211
|
+
href="https://github.com/KenjiOhtsuka/chainpoint_gem">GitHub
|
212
|
+
chainpoint</a>.</p>
|
213
|
+
|
214
|
+
<h2 id="label-Other">Other</h2>
|
215
|
+
<ul><li>
|
216
|
+
<p>PHP <a
|
217
|
+
href="https://packagist.org/packages/kenji-otsuka/chainpoint">Composer
|
218
|
+
Package</a> and its <a
|
219
|
+
href="https://github.com/KenjiOhtsuka/chainpoint_php">GitHub
|
220
|
+
Repository</a>.</p>
|
221
|
+
</li></ul>
|
206
222
|
</div></div>
|
207
223
|
|
208
224
|
<div id="footer">
|
209
|
-
Generated on
|
225
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
210
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
211
227
|
0.9.18 (ruby-2.5.1).
|
212
228
|
</div>
|
data/docs/index.html
CHANGED
@@ -57,25 +57,29 @@
|
|
57
57
|
<div class="clear"></div>
|
58
58
|
</div>
|
59
59
|
|
60
|
-
<div id="content"><div id='filecontents'
|
60
|
+
<div id="content"><div id='filecontents'>
|
61
|
+
<h1 id="label-Chainpoint">Chainpoint</h1>
|
61
62
|
|
62
|
-
<p><a href="https://travis-ci.org/KenjiOhtsuka/chainpoint_gem"><img
|
63
|
+
<p><a href="https://travis-ci.org/KenjiOhtsuka/chainpoint_gem"><img
|
64
|
+
src="https://travis-ci.org/KenjiOhtsuka/chainpoint_gem.svg?branch=master"></a></p>
|
63
65
|
|
64
|
-
<p><a href="https://badge.fury.io/rb/chainpoint"><img
|
66
|
+
<p><a href="https://badge.fury.io/rb/chainpoint"><img
|
67
|
+
src="https://badge.fury.io/rb/chainpoint.svg"></a></p>
|
65
68
|
|
66
69
|
<p><a href="https://rubygems.org/gems/chainpoint">Rubygem Page</a></p>
|
67
70
|
|
68
|
-
<p><a href="https://kenjiohtsuka.github.io/chainpoint_gem/">API
|
71
|
+
<p><a href="https://kenjiohtsuka.github.io/chainpoint_gem/">API
|
72
|
+
Documentation</a></p>
|
69
73
|
|
70
|
-
<p>A client for creating and verifying <a
|
74
|
+
<p>A client for creating and verifying <a
|
75
|
+
href="https://chainpoint.org/">Chainpoint</a> proofs.</p>
|
71
76
|
|
72
|
-
<h2 id="
|
77
|
+
<h2 id="label-Installation">Installation</h2>
|
73
78
|
|
74
|
-
<p>Add this line to your application
|
79
|
+
<p>Add this line to your application's Gemfile:</p>
|
75
80
|
|
76
|
-
<
|
77
|
-
|
78
|
-
</code></p>
|
81
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>chainpoint</span><span class='tstring_end'>'</span></span>
|
82
|
+
</code></pre>
|
79
83
|
|
80
84
|
<p>And then execute:</p>
|
81
85
|
|
@@ -87,126 +91,138 @@ gem 'chainpoint'
|
|
87
91
|
<pre class="code ruby"><code class="ruby">$ gem install chainpoint
|
88
92
|
</code></pre>
|
89
93
|
|
90
|
-
<h2 id="
|
94
|
+
<h2 id="label-Usage">Usage</h2>
|
91
95
|
|
92
|
-
<h3 id="
|
96
|
+
<h3 id="label-Initialize+new+hash+object">Initialize new hash object</h3>
|
93
97
|
|
94
|
-
<
|
95
|
-
|
96
|
-
|
97
|
-
</code></p>
|
98
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sha256'>sha256</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b</span><span class='tstring_end'>'</span></span>
|
99
|
+
<span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span> <span class='op'>=</span> <span class='const'>ChainPoint</span><span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_sha256'>sha256</span><span class='rparen'>)</span>
|
100
|
+
</code></pre>
|
98
101
|
|
99
|
-
<p><code>Chainpoint::Hash.from_data</code> is a convenience method to create a
|
100
|
-
data:</p>
|
102
|
+
<p><code>Chainpoint::Hash.from_data</code> is a convenience method to create a
|
103
|
+
new <code>Chainpoint::Hash</code> from raw data:</p>
|
101
104
|
|
102
|
-
<
|
103
|
-
|
104
|
-
|
105
|
-
</code></p>
|
105
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Chainpoint/Hash.html" title="Chainpoint::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_data'><span class='object_link'><a href="Chainpoint/Hash.html#from_data-class_method" title="Chainpoint::Hash.from_data (method)">from_data</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>hello, world</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
106
|
+
<span class='comment'># => #<Chainpoint::Hash @hash="09ca7e4eaa6e8ae9c7d26116712918...>
|
107
|
+
</span></code></pre>
|
106
108
|
|
107
|
-
<h3 id="
|
109
|
+
<h3 id="label-Submit+Hash">Submit Hash</h3>
|
108
110
|
|
109
|
-
<p>Use this function to submit a hash, and receive back the proof handles
|
110
|
-
proof.</p>
|
111
|
+
<p>Use this function to submit a hash, and receive back the proof handles
|
112
|
+
needed to later retrieve a proof.</p>
|
111
113
|
|
112
|
-
<p>By default hashes are submitted to three Nodes to help ensure a proof will
|
114
|
+
<p>By default hashes are submitted to three Nodes to help ensure a proof will
|
115
|
+
become available at the appropriate time. Only one such proof need be
|
116
|
+
permanently stored, the others provide redundancy.</p>
|
113
117
|
|
114
|
-
<
|
115
|
-
chainpoint_hash = Chainpoint::Hash.from_data(‘hello, world’)
|
118
|
+
<pre class="code ruby"><code class="ruby">chainpoint_hash = Chainpoint::Hash.from_data('hello, world')
|
116
119
|
proof_handles = chainpoint_hash.submit
|
117
120
|
# =>
|
118
121
|
[
|
119
122
|
{
|
120
|
-
|
121
|
-
|
123
|
+
'hash_id_node' => '1d1aa8a0-8f42-11e8-967f-01a68adfc010',
|
124
|
+
'uri' => 'http://45.77.197.76'
|
122
125
|
}
|
123
|
-
|
124
|
-
]
|
125
|
-
|
126
|
-
<p>```</p>
|
127
|
-
|
128
|
-
<h3 id="get-proof">Get Proof</h3>
|
129
|
-
|
130
|
-
<p>Once a hash has been submitted, it contains proof handles that can be used to retrieve the proof.
|
131
|
-
It’s likely that you will be retrieving proofs at a later time, so it is possible to initialize
|
132
|
-
a <code>Chainpoint::Hash</code> object with proof handle data returned from a previous submit.</p>
|
133
|
-
|
134
|
-
<p>A <code>Chainpoint::Proof</code> representing the first valid proof will be returned, or <code>nil</code> if there is no valid proof.</p>
|
135
|
-
|
136
|
-
<p>```ruby
|
137
|
-
chainpoint_hash = Chainpoint::Hash.new(sha256, proof_handles: proof_handles)
|
138
|
-
chainpoint_hash.proof</p>
|
139
|
-
|
140
|
-
<h1 id="chainpointproof-proofejynk71ufdex0-hashidnode1672f730-1-anchorscompletecal">=> #<Chainpoint::Proof @proof=”eJyNk71uFDEx0=…”, @hash_id_node=”1672f730-…1”, @anchors_complete=[“cal”]></h1>
|
141
|
-
<p>```</p>
|
142
|
-
|
143
|
-
<p>You may also pass an anchor type to return only proofs matching that type. By default chainpoint
|
144
|
-
anchors to a Calendar blockchain (<code>cal</code>) which usually completes in about 10s and to the Bitcoin blockchain <code>btc</code> which usually completes in about 2h.</p>
|
145
|
-
|
146
|
-
<p><code>ruby
|
147
|
-
proof = Chainpoint::Hash.new(sha256, proof_handles: proof_handles).proof('btc')
|
148
|
-
#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal", "btc"]>
|
149
|
-
</code></p>
|
126
|
+
...
|
127
|
+
]
|
128
|
+
</code></pre>
|
150
129
|
|
151
|
-
<h3 id="
|
130
|
+
<h3 id="label-Get+Proof">Get Proof</h3>
|
152
131
|
|
153
|
-
<p>
|
132
|
+
<p>Once a hash has been submitted, it contains proof handles that can be used
|
133
|
+
to retrieve the proof. It's likely that you will be retrieving proofs
|
134
|
+
at a later time, so it is possible to initialize a
|
135
|
+
<code>Chainpoint::Hash</code> object with proof handle data returned from a
|
136
|
+
previous submit.</p>
|
154
137
|
|
155
|
-
<p
|
156
|
-
proof
|
157
|
-
# =>
|
158
|
-
</code></p>
|
138
|
+
<p>A <code>Chainpoint::Proof</code> representing the first valid proof will be
|
139
|
+
returned, or <code>nil</code> if there is no valid proof.</p>
|
159
140
|
|
160
|
-
<
|
141
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Chainpoint/Hash.html" title="Chainpoint::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Chainpoint/Hash.html#initialize-instance_method" title="Chainpoint::Hash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_sha256'>sha256</span><span class='comma'>,</span> <span class='label'>proof_handles:</span> <span class='id identifier rubyid_proof_handles'>proof_handles</span><span class='rparen'>)</span>
|
142
|
+
<span class='id identifier rubyid_chainpoint_hash'>chainpoint_hash</span><span class='period'>.</span><span class='id identifier rubyid_proof'>proof</span>
|
161
143
|
|
162
|
-
<
|
144
|
+
<span class='comment'>#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal"]>
|
145
|
+
</span></code></pre>
|
163
146
|
|
164
|
-
<p
|
165
|
-
|
166
|
-
|
147
|
+
<p>You may also pass an anchor type to return only proofs matching that type.
|
148
|
+
By default chainpoint anchors to a Calendar blockchain (<code>cal</code>)
|
149
|
+
which usually completes in about 10s and to the Bitcoin blockchain
|
150
|
+
<code>btc</code> which usually completes in about 2h.</p>
|
167
151
|
|
168
|
-
<
|
152
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_proof'>proof</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Chainpoint.html" title="Chainpoint (module)">Chainpoint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Chainpoint/Hash.html" title="Chainpoint::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Chainpoint/Hash.html#initialize-instance_method" title="Chainpoint::Hash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_sha256'>sha256</span><span class='comma'>,</span> <span class='label'>proof_handles:</span> <span class='id identifier rubyid_proof_handles'>proof_handles</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_proof'><span class='object_link'><a href="Chainpoint/Hash.html#proof-instance_method" title="Chainpoint::Hash#proof (method)">proof</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>btc</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
153
|
+
<span class='comment'>#=> #<Chainpoint::Proof @proof="eJyNk71uFDEx0=...", @hash_id_node="1672f730-...1", @anchors_complete=["cal", "btc"]>
|
154
|
+
</span></code></pre>
|
169
155
|
|
170
|
-
<
|
171
|
-
{
|
172
|
-
“proof_index” => 0,
|
173
|
-
“hash” => “09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b”,
|
174
|
-
“hash_id_node” => “1672f730-536b-11e9-9241-015d8fee1e71”,
|
175
|
-
“hash_submitted_node_at” => “2019-03-31T04:11:41Z”,
|
176
|
-
“hash_id_core” => “18456d40-536b-11e9-8c0f-016fe824db22”,
|
177
|
-
“hash_submitted_core_at” => “2019-03-31T04:11:44Z”,
|
178
|
-
“anchors” => [
|
179
|
-
{
|
180
|
-
“branch” => “cal_anchor_branch”,
|
181
|
-
“type” => “cal”,
|
182
|
-
“valid” => true,
|
183
|
-
“block_id” => “2967333”, “block_value” => “74e2b62f68463f53105b65d57c729e5488b7833d6ebb259561b84e43d826c7ea”
|
184
|
-
}
|
185
|
-
],
|
186
|
-
“status”=>”verified”
|
187
|
-
}</p>
|
156
|
+
<h3 id="label-Decode+a+Proof">Decode a Proof</h3>
|
188
157
|
|
189
|
-
<p
|
158
|
+
<p>A <code>Chainpoint::Proof</code> object contains a binary representation of
|
159
|
+
the proof can be converted to JSON to view the Chainpoint JSON Schema:</p>
|
190
160
|
|
191
|
-
<
|
161
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_proof'>proof</span><span class='period'>.</span><span class='id identifier rubyid_decode'>decode</span>
|
162
|
+
<span class='comment'># =>
|
163
|
+
</span></code></pre>
|
192
164
|
|
193
|
-
<
|
165
|
+
<h3 id="label-Verify+a+Proof">Verify a Proof</h3>
|
194
166
|
|
195
|
-
<p>
|
167
|
+
<p>You can verify a proof against each of the blockchains the proof has been
|
168
|
+
anchored to:</p>
|
196
169
|
|
197
|
-
<
|
198
|
-
|
199
|
-
<p>Bug reports and pull requests are welcome on <a href="https://github.com/KenjiOhtsuka/chainpoint_gem">GitHub chainpoint</a>.</p>
|
170
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_proof'>proof</span><span class='period'>.</span><span class='id identifier rubyid_verify'>verify</span>
|
171
|
+
</code></pre>
|
200
172
|
|
201
|
-
<
|
173
|
+
<h4 id="label-Response">Response</h4>
|
174
|
+
|
175
|
+
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span>
|
176
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>proof_index</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='int'>0</span><span class='comma'>,</span>
|
177
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
178
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_id_node</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1672f730-536b-11e9-9241-015d8fee1e71</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
179
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_submitted_node_at</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2019-03-31T04:11:41Z</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
180
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_id_core</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>18456d40-536b-11e9-8c0f-016fe824db22</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
181
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>hash_submitted_core_at</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2019-03-31T04:11:44Z</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
182
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>anchors</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='lbracket'>[</span>
|
183
|
+
<span class='lbrace'>{</span>
|
184
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>branch</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>cal_anchor_branch</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
185
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>type</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>cal</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
186
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>valid</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='kw'>true</span><span class='comma'>,</span>
|
187
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>block_id</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2967333</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>block_value</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>74e2b62f68463f53105b65d57c729e5488b7833d6ebb259561b84e43d826c7ea</span><span class='tstring_end'>"</span></span>
|
188
|
+
<span class='rbrace'>}</span>
|
189
|
+
<span class='rbracket'>]</span><span class='comma'>,</span>
|
190
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>status</span><span class='tstring_end'>"</span></span><span class='op'>=></span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>verified</span><span class='tstring_end'>"</span></span>
|
191
|
+
<span class='rbrace'>}</span>
|
192
|
+
</code></pre>
|
202
193
|
|
203
|
-
<
|
204
|
-
|
205
|
-
</
|
194
|
+
<h2 id="label-Development">Development</h2>
|
195
|
+
|
196
|
+
<p>After checking out the repo, run <code>bin/setup</code> to install
|
197
|
+
dependencies. Then, run <code>rake spec</code> to run the tests. You can
|
198
|
+
also run <code>bin/console</code> for an interactive prompt that will allow
|
199
|
+
you to experiment.</p>
|
200
|
+
|
201
|
+
<p>To install this gem onto your local machine, run <code>bundle exec rake
|
202
|
+
install</code>. To release a new version, update the version number in
|
203
|
+
<code>version.rb</code>, and then run <code>bundle exec rake
|
204
|
+
release</code>, which will create a git tag for the version, push git
|
205
|
+
commits and tags, and push the <code>.gem</code> file to <a
|
206
|
+
href="https://rubygems.org">rubygems.org</a>.</p>
|
207
|
+
|
208
|
+
<h2 id="label-Contributing">Contributing</h2>
|
209
|
+
|
210
|
+
<p>Bug reports and pull requests are welcome on <a
|
211
|
+
href="https://github.com/KenjiOhtsuka/chainpoint_gem">GitHub
|
212
|
+
chainpoint</a>.</p>
|
213
|
+
|
214
|
+
<h2 id="label-Other">Other</h2>
|
215
|
+
<ul><li>
|
216
|
+
<p>PHP <a
|
217
|
+
href="https://packagist.org/packages/kenji-otsuka/chainpoint">Composer
|
218
|
+
Package</a> and its <a
|
219
|
+
href="https://github.com/KenjiOhtsuka/chainpoint_php">GitHub
|
220
|
+
Repository</a>.</p>
|
221
|
+
</li></ul>
|
206
222
|
</div></div>
|
207
223
|
|
208
224
|
<div id="footer">
|
209
|
-
Generated on
|
225
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
210
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
211
227
|
0.9.18 (ruby-2.5.1).
|
212
228
|
</div>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Thu Apr 11 16:23:25 2019 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.18 (ruby-2.5.1).
|
106
106
|
</div>
|
data/lib/chainpoint/hash.rb
CHANGED
@@ -14,10 +14,7 @@ module Chainpoint
|
|
14
14
|
|
15
15
|
def initialize(hash, proof_handles: [])
|
16
16
|
@hash = hash
|
17
|
-
|
18
|
-
proof_handles.map do |data|
|
19
|
-
ProofHandle.new(data[:uri], data[:node_hash_id])
|
20
|
-
end
|
17
|
+
self.proof_handles = proof_handles
|
21
18
|
end
|
22
19
|
|
23
20
|
def submit
|
@@ -38,6 +35,13 @@ module Chainpoint
|
|
38
35
|
anchor_type ? proofs.find { |p| p.anchors_complete.include?(anchor_type) } : proofs.first
|
39
36
|
end
|
40
37
|
|
38
|
+
def proof_handles=(handles)
|
39
|
+
@proof_handles = handles.map do |data|
|
40
|
+
data.transform_keys!(&:to_sym)
|
41
|
+
ProofHandle.new(data[:uri], data[:node_hash_id])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
41
45
|
def to_h
|
42
46
|
{
|
43
47
|
hash: @hash,
|
@@ -5,6 +5,9 @@ module Chainpoint
|
|
5
5
|
attr_reader :uri, :node_hash_id
|
6
6
|
|
7
7
|
def initialize(uri, node_hash_id)
|
8
|
+
raise ArgumentError, 'Proof Handle uri not specified' unless uri
|
9
|
+
raise ArgumentError, 'Proof Handle node_hash_id not specified' unless node_hash_id
|
10
|
+
|
8
11
|
@uri = uri
|
9
12
|
@node_hash_id = node_hash_id
|
10
13
|
end
|
data/lib/chainpoint/version.rb
CHANGED