{"id":13411719,"url":"https://github.com/bobg/merkle","last_synced_at":"2026-03-03T04:55:40.561Z","repository":{"id":56819866,"uuid":"152885497","full_name":"bobg/merkle","owner":"bobg","description":"Merkle hash trees","archived":false,"fork":false,"pushed_at":"2024-07-10T15:21:35.000Z","size":52,"stargazers_count":16,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-31T20:48:40.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/bobg/merkle","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bobg.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-13T15:25:10.000Z","updated_at":"2024-07-30T05:17:38.000Z","dependencies_parsed_at":"2024-10-26T07:58:16.315Z","dependency_job_id":"609f9f6c-a312-460e-bdab-e454437a0cba","html_url":"https://github.com/bobg/merkle","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fmerkle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fmerkle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fmerkle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fmerkle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bobg","download_url":"https://codeload.github.com/bobg/merkle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618656,"owners_count":20320272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:16.144Z","updated_at":"2026-03-03T04:55:35.306Z","avatar_url":"https://github.com/bobg.png","language":"Go","funding_links":[],"categories":["Data Integration Frameworks","Data Structures and Algorithms","数据结构与算法","Uncategorized","Generators","Data Structures"],"sub_categories":["Trees","树","Advanced Console UIs"],"readme":"# Merkle - Efficient calculation of merkle roots and proofs\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bobg/merkle.svg)](https://pkg.go.dev/github.com/bobg/merkle)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bobg/merkle)](https://goreportcard.com/report/github.com/bobg/merkle)\n[![Tests](https://github.com/bobg/merkle/actions/workflows/go.yml/badge.svg)](https://github.com/bobg/merkle/actions/workflows/go.yml)\n[![Coverage Status](https://coveralls.io/repos/github/bobg/merkle/badge.svg?branch=master)](https://coveralls.io/github/bobg/merkle?branch=master)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\nThis is merkle,\na Go package for computing the Merkle root hash of a sequence of byte strings,\nor of their hashes.\nIt can also produce a compact proof that a given string belongs in a Merkle tree with a given root hash.\n\nThis implementation does not require holding all of the input in memory while computing a root hash or a proof.\nInstead, it is able to operate on a stream of input strings of unbounded length,\nholding incremental state that is only logarithmic [O(log N)] in the size of the input.\n\nFor more about Merkle trees,\nsee [the Wikipedia article](https://en.wikipedia.org/wiki/Merkle_tree).\n\nCreating a merkle root hash:\n\n```go\nvar ch \u003c-chan []byte  // Represents some source of byte strings\ntree := merkle.NewTree(sha256.New())\nfor str := range ch {\n  tree.Add(str)\n}\nfmt.Printf(\"merkle root hash is %x\\n\", tree.Root())\n```\n\nCreating a merkle proof that `ref` belongs in the tree,\nthen verifying the proof:\n\n```go\nvar (\n  ch       \u003c-chan []byte  // Represents some source of byte strings\n  rootHash []byte         // Represents a previously computed merkle root hash (held by someone wishing to verify that ref is in the tree)\n  ref      []byte         // Represents the string to prove is a member of the tree with the given root hash\n)\ntree := merkle.NewProofTree(sha256.New(), ref)\nfor str := range ch {\n  tree.Add(str)\n}\nproof := tree.Proof()  // This is a compact object. For verification purposes, tree can now be discarded.\n\n// Verification:\nif bytes.Equal(rootHash, proof.Hash(sha256.New(), ref)) {\n  fmt.Println(\"Verified!\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobg%2Fmerkle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobg%2Fmerkle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobg%2Fmerkle/lists"}