• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created 11 months ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create Merkle trees from your directories.

merkdir

merkdir creates Merkle trees from your directories, and can generate inclusion proofs for any files in those directories.

Use case

Let's say you have a bunch of files in your ~/Documents folder, some public, some private. Run merkdir on the directory, and you get a root hash which anonymously represents all your documents. Now you can publish that, sign it, timestamp it, whatever you like.

At some later date, you can publish one of these (unchanged) documents along with the inclusion proof generated by merkdir. This will provably connect the file back to root hash that you published/signed/etc in the past.

Using the power of Merkle trees, merkdir allows you to prove things about millions of files at once. It can make signing or timestamping all the files in your home directory efficient and secure.

The real world applications are slim, but interesting. Maybe I'm a whistleblower with thousands of files, but I don't want to release them all right now. This tool allows you to easily prove that a file you release later was part of the original collection.

Another use case might be an organization that has a large archive of important files. This tool allows them to efficiently sign all of these files by just signing the root hash.

Install

Pre-built binaries can be installed from the releases page. Otherwise you can build from source by using just. The Go compiler is of course required.

If you use Homebrew, you can install merkdir through the my personal tap.

brew tap makew0rld/tap
brew install merkdir

You can update it with:

brew upgrade merkdir

Usage

# Create a Merkle tree that holds hashes of all your documents
$ merkdir gen -o documents_tree.merkdir ~/Documents
Finding files...
Found 2339 files. Starting hashing...
 100% |████████████████████████████████████████| (1.6/1.6 GB, 5.0 GB/s)        
Root hash: 3e1db8e48dd101bed67ccd117ad011fa76aca26c38ce1ab1612010d5140618b1

# Now publish that hash, sign it, etc
# If you need it again:
$ merkdir root --hex documents_tree.merkdir
3e1db8e48dd101bed67ccd117ad011fa76aca26c38ce1ab1612010d5140618b1

# Generate a proof for one file
$ merkdir inclusion -t documents_tree.merkdir -f "name/of/file.txt" -o my_proof.merkdir
# Now publish that along with the file itself
# This proves the file is a part of the tree represented by the root hash

# Verify that a file on disk hasn't changed since the tree was generated
$ merkdir verify-file -t my_merkle_tree.merkdir -n "name/of/file.txt"

# Verify an inclusion proof you received
# You get the root hash as output, and must compare it to the expected root hash
$ merkdir verify-inclusion -p some_inclusion_proof.bin -f path/to/file.pdf --hex
3e1db8e48dd101bed67ccd117ad011fa76aca26c38ce1ab1612010d5140618b1

# Or compare it to a root hash directly:
$ merkdir verify-inclusion -p some_inclusion_proof.bin -f path/to/file.pdf --hash "abc123..."
OK: proof and file match given root hash

# Get info on a tree file
$ merkdir info documents_tree.merkdir
Root hash: 3e1db8e48dd101bed67ccd117ad011fa76aca26c38ce1ab1612010d5140618b1
FS root: /home/makeworld/Documents
Num. of files: 2339
Creation time: 2023-12-26 19:33:29 -0500 EST

# Or for a proof, relative to the tree it's from
$ merkdir info -p some_proof.merkdir documents_tree.merkdir
File index: 2137
File name: My Document.ods
Nonce: bc0d0ba51259d0ba0475f754bc4a7cf4
Proof length: 10 hashes

All merkdir output files are CBOR, so they can be easily used by other tools.

Security

merkdir uses the fast and secure BLAKE3 hash algorithm.

Inclusion proofs are designed to be shared publicly, and so don't expose filenames or even direct file hashes. The only information relevant to your filesystem that they reveal is the number of files in the original Merkle tree.

Alternatives

Other tools like IPFS or Iroh also create Merkle trees over directories. The main difference is the merkdir is singularly focused on doing this, and crucially makes generating inclusion proofs easy. Currently I'm not aware of a way to generate inclusion proofs with these tools.

License

merkdir is licensed under the GPL v3.0. See the LICENSE file for details.

More Repositories

1

amfora

A fancy terminal browser for the Gemini protocol.
Go
1,139
star
2

dither

A fast, correct image dithering library in Go.
Go
360
star
3

didder

An extensive, fast, and accurate command-line image dithering tool.
Go
351
star
4

md2gemini

File converter from Markdown to Gemini.
Python
163
star
5

gemget

Command line downloader for the Gemini protocol.
Go
68
star
6

go-gemini

Client and server library for the Gemini protocol, in Go.
Go
59
star
7

gemlikes

A liking and comment system for the Gemini protocol.
Go
51
star
8

neartalk

NearTalk is chat platform to talk to people nearby.
Go
22
star
9

fmrl

A protocol for status messages. See what your friends are up to!
20
star
10

days

Command-line tool for calculating the number of days between given dates: days until, days since, days from
Go
13
star
11

wordle-badger2040

Wordle on the Badger 2040
Python
13
star
12

lannet

A little web on the LAN
Go
10
star
13

geohashing

xkcd geohashing, but it actually works.
Python
9
star
14

go-isemoji

Go library to test if a string is an emoji.
Go
8
star
15

live-glitch

Realtime glitch art effects with Python and OpenCV.
Python
6
star
16

tiktok-link

Reddit bot that runs OCR on TikTok videos and links back to the creator's page
Python
5
star
17

whatsup

The reference server implementation for the fmrl protocol.
Go
5
star
18

go-gemini-socks5

SOCKS5 proxy for go-gemini
Go
4
star
19

ipfs-demo

A offline, mesh-networking demo of IPFS, for use by tomesh.net
Python
3
star
20

makeworld.space

HTML
2
star
21

rfcts

Bash scripts for RFC 3161 trusted timestamping
Shell
2
star
22

homebrew-tap

Ruby
1
star
23

reddit-news-skill

Reads out news headlines from r/worldnews on reddit
Python
1
star
24

processing

Code I've written in Processing (Java) that isn't a major project
Processing
1
star