You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Go implementation of offset-based native UnixFS proofs.
10
10
-[Proof format](#proof-format)
11
11
-[Use-case analysis and security](#use-case-analysis-and-security)
12
12
-[Proof sizes and benchmark](#proof-sizes-and-benchmark)
13
+
-[CLI](#cli)
13
14
-[Roadmap](#roadmap)
14
15
-[Contributing](#contributing)
15
16
-[License](#license)
@@ -31,7 +32,7 @@ Consider the following UnixFS DAG file with a fanout factor of 3:
31
32
32
33
33
34
Considering a verifer is asking a prover to provide a proof that it contains the corresponding block at the _file level offset_ X, the prover generates the subdag inside the green zone:
34
-
-Roundo nodes are internal DAG nodes that are somewhat small-ish and don't contain file data.
35
+
-Round nodes are internal DAG nodes that are somewhat small-ish and don't contain file data.
35
36
- Square nodes contain chunks of the original file data.
36
37
- The indigo colored nodes are necessary nodes to make the proof verify that the target block (red) is at the specified offset.
37
38
@@ -67,15 +68,37 @@ Notice that if the prover has missing internal nodes of the UnixFS, then the imp
67
68
68
69
69
70
## Proof sizes and benchmark
70
-
The size of the proof should be already close to the minimal level. Notice that these proofs are pretty big for the single reason that no assumptions are made of DAG layout nor chunking. Thus internal nodes at visited levels include many children. If we're able to have some extra assumptions as fixed-size chunking, then we could potentially ignore untargeted raw leaves which are the biggest in size, and only include the targeted (red) leaf node.
71
+
The size of the proof should be already close to the minimal level. Notice that these proofs are pretty big for the single reason that no assumptions are made of DAG layout nor chunking. Thus internal nodes at visited levels include many children. If we're able to have some extra assumptions as fixed-size chunking, then we could potentially ignore untargeted raw leaves which are the biggest in size, and only include the targeted (red) leaf node. For this reason, a proof for an offset could serve for all the left-sided blocks sharing the same parent (**).
71
72
72
73
Generating and verifying proofs are mostly symmetrical operations. The current implementation is very naive and not optimized in any way. Being stricter with the spec CAR serialization block order can make the implementation faster. Probably, not a big deal unless you're generating proofs for thousands of _Cids_.
73
74
75
+
## CLI
76
+
A simple CLI `ufsproof` is provided which allows to easily generate and verify proofs, which can be installed running `make install`.
77
+
78
+
To generate proofs, run `ufsproof prove [cid] [offset]` which prints in stdout the proof for block of Cid at the provided offset.
79
+
For example:
80
+
-`ufsproof prove QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 1300`: assumes that the Cid is stored in an IPFS API at `/ip4/127.0.0.1/tcp/5001`.
81
+
-`ufsproof prove QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 1300 > proof.car`: stores the proof in a file.
82
+
-`ufsproof prove --car-file mydag.car QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 1300`: uses a CAR file instead of an IPFS API.
83
+
84
+
To verify proofs, run `ufsproof verify [cid] [offset] [proof-path:(optional, by default stdin)]`.
Remember that because of (**) mentioned in _Proof sizes and benchmark_ is possible to have a valid proof message on some offsets greater than the proved one.
97
+
74
98
## Roadmap
75
99
The following bullets will probably be implemented soon:
76
100
-[ ] Allow direct leaf Cid proof (non-offset based); a bit offtopic for this lib and not sure entirely useful.
77
101
-[ ] Benchmarks, may be fun but nothing entirely useful for now.
78
-
-[ ] CLI command wirable to `go-ipfs`. The lib already supports any `DAGService` so anything can be pluggable.
79
102
-[ ] Allow strict mode proof validation; maybe it makes sense to fail faster in some cases, nbd.
80
103
-[ ] CLI for validation from DealID in Filecoin network; maybe fun, but `Labels` are unverified.
0 commit comments