Skip to content

PathToLeaf1

ratranqu edited this page Apr 7, 2021 · 2 revisions

PathToLeaf1

PathToLeaf represents an inner path to a leaf node. Note that the nodes are ordered such that the last one is closest to the root of the tree.

public struct PathToLeaf1<Node: NodeProtocol>: Codable

Inheritance

Codable

Nested Type Aliases

Hash

public typealias Hash = Node.Hasher.Hash

Initializers

init(_:)

public init(_ array: [ProofInnerNode<Node>] = [])

Properties

isLeftmost

var isLeftmost: Bool

isRightmost

var isRightmost: Bool

count

var count: Int

last

var last: ProofInnerNode<Node>?

index

var index: Int64

Methods

verify(_:_:)

verify checks that the leaf node's hash + the inner nodes merkle-izes to the given root. If it returns an error, it means the leafHash or the PathToLeaf is incorrect.

public func verify(_ leafHash: Hash, _ root: Node) -> Bool

computeRootHash(_:)

computeRootHash computes the root hash assuming some leaf hash. Does not verify the root hash.

public func computeRootHash(_ leafHash: Hash) -> Hash

dropLast()

public func dropLast() -> PathToLeaf1

append(_:)

public mutating func append(_ element: ProofInnerNode<Node>)

dropRoot()

public func dropRoot() throws -> PathToLeaf1

hasCommonRoot(_:)

public func hasCommonRoot(_ with: Self) -> Bool

isLeftAdjacent(_:)

public func isLeftAdjacent(_: PathToLeaf1) throws -> Bool