Skip to content

Commit 60f860f

Browse files
committed
README: explain CLI
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent cad5034 commit 60f860f

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Go implementation of offset-based native UnixFS proofs.
1010
- [Proof format](#proof-format)
1111
- [Use-case analysis and security](#use-case-analysis-and-security)
1212
- [Proof sizes and benchmark](#proof-sizes-and-benchmark)
13+
- [CLI](#cli)
1314
- [Roadmap](#roadmap)
1415
- [Contributing](#contributing)
1516
- [License](#license)
@@ -31,7 +32,7 @@ Consider the following UnixFS DAG file with a fanout factor of 3:
3132

3233

3334
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.
3536
- Square nodes contain chunks of the original file data.
3637
- The indigo colored nodes are necessary nodes to make the proof verify that the target block (red) is at the specified offset.
3738

@@ -67,15 +68,37 @@ Notice that if the prover has missing internal nodes of the UnixFS, then the imp
6768

6869

6970
## 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 (**).
7172

7273
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_.
7374

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)]`.
85+
For example:
86+
- `ufsproof verify QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 1300 proof.car`
87+
88+
89+
Closing the loop:
90+
```
91+
$ ufsproof prove QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 1300 | ufsproof verify QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 1300
92+
The proof is valid
93+
$ ufsproof prove QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 10 | ufsproof verify QmUavJLgtkQy6wW2j1J1A5cAP6UQt3XLQjsArsU2ZYmgSo 50000000
94+
The proof is NOT valid
95+
```
96+
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+
7498
## Roadmap
7599
The following bullets will probably be implemented soon:
76100
- [ ] Allow direct leaf Cid proof (non-offset based); a bit offtopic for this lib and not sure entirely useful.
77101
- [ ] 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.
79102
- [ ] Allow strict mode proof validation; maybe it makes sense to fail faster in some cases, nbd.
80103
- [ ] CLI for validation from DealID in Filecoin network; maybe fun, but `Labels` are unverified.
81104
- [ ] godocs

0 commit comments

Comments
 (0)