utils

package
v0.4.0-dev.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEDASeparatorDataRequest byte = iota
	SEDASeparatorSecp256k1
)

SEDA domain separators

View Source
const SEDAKeyFileName = "seda_keys.json"

SEDAKeyFileName defines the SEDA key file name.

Variables

This section is empty.

Functions

func DisplayInfo

func DisplayInfo(info PrintInfo) error

func GenerateSEDAKeys

func GenerateSEDAKeys(dirPath string) ([]pubkeytypes.IndexedPubKey, error)

GenerateSEDAKeys generates SEDA keys given a list of private key generators, saves them to the SEDA key file, and returns the resulting index-public key pairs. Index is assigned incrementally in the order of the given private key generators. The key file is stored in the directory given by dirPath.

func GetProof

func GetProof(entries [][]byte, index int) ([][]byte, error)

GetProof returns the merkle proof for the entry at the given index.

func LoadSEDAPubKeys

func LoadSEDAPubKeys(loadPath string) ([]pubkeytypes.IndexedPubKey, error)

LoadSEDAPubKeys loads the SEDA key file from the given path and returns a list of index-public key pairs.

func PubKeyToEthAddress

func PubKeyToEthAddress(pubKey []byte) ([]byte, error)

PubKeyToAddress converts a public key in the 33-byte compressed format into the Ethereum address format, which is defined as the rightmost 160 bits of a Keccak hash of an ECDSA public key.

func RootFromEntries

func RootFromEntries(entries [][]byte) []byte

RootFromEntries computes the root of a merkle tree whose leaves are the hashes of the given entries.

  • It uses Keccak-256 hashing algorithm.
  • The leaves are sorted.
  • Each hash pair is sorted to make proofs more succinct.

func RootFromLeaves

func RootFromLeaves(leaves [][]byte) []byte

RootFromLeaves computes the root of a merkle tree with the given leaves.

func VerifyProof

func VerifyProof(proof [][]byte, root, entry []byte) bool

Types

type PrintInfo added in v0.0.6

type PrintInfo struct {
	Moniker string `json:"moniker" yaml:"moniker"`
	ChainID string `json:"chain_id" yaml:"chain_id"`
	NodeID  string `json:"node_id" yaml:"node_id"`
	Seeds   string `json:"seeds" yaml:"seeds"`
}

func NewPrintInfo

func NewPrintInfo(moniker, chainID, nodeID, seeds string) PrintInfo

type SEDAKeyIndex

type SEDAKeyIndex uint32

SEDAKeyIndex enumerates the SEDA key indices.

const (
	SEDAKeyIndexSecp256k1 SEDAKeyIndex = iota
)

type SEDASigner

type SEDASigner interface {
	Sign(input []byte, index SEDAKeyIndex) (signature []byte, err error)
}

func LoadSEDASigner

func LoadSEDASigner(loadPath string) (SEDASigner, error)

LoadSEDASigner loads the SEDA keys from a given file and returns a SEDASigner interface.

Jump to

Keyboard shortcuts

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