mt

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const TreeHeight = 16

Variables

This section is empty.

Functions

This section is empty.

Types

type ITreap

type ITreap interface {
	Remove(key []byte)
	Insert(key []byte, priority uint64)
	MerklePath(key []byte) [][]byte
	MerkleRoot() []byte
}

func New

func New() ITreap

type Node

type Node struct {
	Hash        []byte
	Priority    uint64
	MerkleHash  []byte
	Left, Right *Node
}

type Proof

type Proof struct {
	// Siblings is a list of non-empty sibling hashes.
	Siblings [][]byte `json:"siblings"`
}

Proof is a standard Merkle proof. If len(Siblings) == 0, this is proof of non-existence.

type Treap

type Treap struct {
	Root *Node
}

func (*Treap) Insert

func (t *Treap) Insert(key []byte, priority uint64)

func (*Treap) MerklePath

func (t *Treap) MerklePath(key []byte) [][]byte

func (*Treap) MerkleRoot

func (t *Treap) MerkleRoot() []byte

func (*Treap) Remove

func (t *Treap) Remove(key []byte)

type TreapTree

type TreapTree struct {
	// contains filtered or unexported fields
}

func BuildFromCosmos

func BuildFromCosmos(addr string, isSecure bool) (*TreapTree, error)

BuildFromCosmos builds a new dynamic Merkle tree with treap data structure by getting elements directly from the Cosmos. It requires GRPC Cosmos address with secure flag.

func BuildFromRaw

func BuildFromRaw(leaves []string) (*TreapTree, error)

BuildFromRaw builds a new dynamic Merkle tree with treap data structure tree from raw data, directly hashing the leaves. It is assumed to use 256|384|512 byte public keys as input.

func BuildTreeFromCollection

func BuildTreeFromCollection(data []byte) (*TreapTree, error)

BuildTreeFromCollection builds a new dynamic Merkle tree with treap data structure from raw pem certificates, that looks like: -----BEGIN CERTIFICATE----- ... QLIlpAZJZAlpPxwCIFlPFYmq4UcD6I5HJzTUvTRR1oMlYqwBC7SjwtwyspKc ... -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- ... MIIDKzCCAtCgAwIBAgIII+3Lgsfb3yUwCgYIKoZIzj0EAwIweTEUMBIGA1UEAwwL

func BuildTreeFromMarshalled

func BuildTreeFromMarshalled(elements []byte) (*TreapTree, error)

BuildTreeFromMarshalled builds a new dynamic Merkle tree with treap data structure from raw pem certificates array marshalled in JSON,

func (*TreapTree) GenerateInclusionProof

func (it *TreapTree) GenerateInclusionProof(rawPemCert string) (*Proof, error)

GenerateInclusionProof generates inclusion proof for the given pem certificate, returns marshalled inclusion proof type with a byte array of siblings

func (*TreapTree) IsExists

func (it *TreapTree) IsExists() bool

IsExists checks if the tree exists

func (*TreapTree) Root

func (it *TreapTree) Root() []byte

Root returns merkle tree root, if there is no tree empty string returned

Jump to

Keyboard shortcuts

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