Merkletree
A merkle tree (with proofs) in Go as per RFC6962
Install / Use
/learn @arriqaaq/MerkletreeREADME
merkletree
An implementation of a merkle tree based on the specification provided for Certificate Transparency
Usage
package main
import (
"fmt"
"github.com/arriqaaq/merkletree"
)
/*
The binary Merkle Tree with 7 leaves:
hash
/ \
/ \
/ \
/ \
/ \
k l
/ \ / \
/ \ / \
/ \ / \
g h i j
/ \ / \ / \ |
a b c d e f d6
| | | | | |
d0 d1 d2 d3 d4 d5
*/
func makeleaves() (D [][]byte) {
for i := 0; i < 7; i++ {
v := "d" + strconv.FormatInt(int64(i), 10)
D = append(D, []byte(v))
}
return
}
func main() {
tree := merkletree.NewTree()
// Insert
D := makeleaves()
tree := NewTree(D)
// Root Hash
hash:=tree.Hash()
// Path
// The audit path for d0 is [b, h, l].
path := tree.Path(0)
// Proof
// The consistency proof between hash0 and hash is PROOF(3, D[7]) = [c,
// d, g, l]. c, g are used to verify hash0, and d, l are additionally
// used to show hash is consistent with hash0.
proof := tree.Proof(3)
}
Reference
Related Skills
node-connect
337.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
337.4kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
