merkle

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

BSD 2-Clause License

Copyright (c) 2022, the ct authors All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

From: https://gitlab.torproject.org/rgdd/ct/-/tree/main/pkg/merkle

The only difference is that leaf hashes rather than leaf data are passed as input to TreeHeadFromRangeProof, thus also changing the nodes() helper.

BSD 2-Clause License

Copyright (c) 2022, the ct authors All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

From: https://gitlab.torproject.org/rgdd/ct/-/tree/main/pkg/merkle

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashEmptyTree

func HashEmptyTree() [sha256.Size]byte

HashEmptyTree computes the hash of an empty tree. See RFC 6162, §2.1:

MTH({}) = SHA-256()

func HashInteriorNode

func HashInteriorNode(left, right [sha256.Size]byte) (hash [sha256.Size]byte)

HashInteriorNode computes the hash of an interior node. See RFC 6962, §2.1:

MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n])

func HashLeafNode

func HashLeafNode(data []byte) (hash [sha256.Size]byte)

HashLeafNode computes the hash of a leaf's data. See RFC 6162, §2.1:

MTH({d(0)}) = SHA-256(0x00 || d(0))

func TreeHeadFromRangeProof

func TreeHeadFromRangeProof(leafHashes [][sha256.Size]byte, index uint64, proof [][sha256.Size]byte) (root [sha256.Size]byte, err error)

TreeHeadFromRangeProof computes a tree head at size n=len(leafHashes)+index if given a list of leaf hashes at indices index,...,n-1 as well as an inclusion proof for the first leaf in the tree of size n. This allows a verifier to check inclusion of one or more log entries with a single inclusion proof.

func VerifyConsistency

func VerifyConsistency(oldSize, newSize uint64, oldRoot, newRoot [sha256.Size]byte, proof [][sha256.Size]byte) error

VerifyConsistency verifies that an an old tree is consistent with a new tree

func VerifyInclusion

func VerifyInclusion(data []byte, index, size uint64, root [sha256.Size]byte, proof [][sha256.Size]byte) error

VerifyInclusion verifies that a leaf's data is commited at a given index in a reference tree

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL