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:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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 ¶
- func HashEmptyTree() [sha256.Size]byte
- func HashInteriorNode(left, right [sha256.Size]byte) (hash [sha256.Size]byte)
- func HashLeafNode(data []byte) (hash [sha256.Size]byte)
- func TreeHeadFromRangeProof(leafHashes [][sha256.Size]byte, index uint64, proof [][sha256.Size]byte) (root [sha256.Size]byte, err error)
- func VerifyConsistency(oldSize, newSize uint64, oldRoot, newRoot [sha256.Size]byte, ...) error
- func VerifyInclusion(data []byte, index, size uint64, root [sha256.Size]byte, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashEmptyTree ¶
HashEmptyTree computes the hash of an empty tree. See RFC 6162, §2.1:
MTH({}) = SHA-256()
func HashInteriorNode ¶
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 ¶
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.
Types ¶
This section is empty.