Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 1.11 KB

README.md

File metadata and controls

41 lines (34 loc) · 1.11 KB

Gomerkle

Build Status Coverage Status GoDoc Go Report Card

Golang Merkle tree implementation

Usage

package main

import (
    "crypto/sha256"

    "github.com/onrik/gomerkle"
)

func main() {
    data := [][]byte{
        []byte("Buzz"),
        []byte("Lenny"),
        []byte("Squeeze"),
        []byte("Wheezy"),
        []byte("Jessie"),
        []byte("Stretch"),
        []byte("Buster"),
    }
    tree := gomerkle.NewTree(sha256.New())
    tree.AddData(data...)

    err := tree.Generate()
    if err != nil {
        panic(err)
    }

    // Proof for Jessie
    proof := tree.GetProof(4)
    println(tree.VerifyProof(proof, tree.Root(), data[4]))
}