...

Source file src/github.com/transparency-dev/merkle/hasher.go

Documentation: github.com/transparency-dev/merkle

     1  // Copyright 2017 Google LLC. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package merkle provides Merkle tree interfaces and implementation.
    16  package merkle
    17  
    18  // TODO(pavelkalinnikov): Remove this root package. The only interface provided
    19  // here does not have to exist, and can be [re-]defined on the user side, such
    20  // as in compact or proof package.
    21  
    22  // LogHasher provides the hash functions needed to compute dense merkle trees.
    23  type LogHasher interface {
    24  	// EmptyRoot supports returning a special case for the root of an empty tree.
    25  	EmptyRoot() []byte
    26  	// HashLeaf computes the hash of a leaf that exists.
    27  	HashLeaf(leaf []byte) []byte
    28  	// HashChildren computes interior nodes.
    29  	HashChildren(l, r []byte) []byte
    30  	// Size returns the number of bytes the Hash* functions will return.
    31  	Size() int
    32  }
    33  

View as plain text