crypto

package
v0.0.0-...-db2f6b3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpLHash = 0
	OpRHash = 1
)
View Source
const HashSize = 32

HashSize is the size of a hash-checksum in bytes.

View Source
const PublicKeySize = ed25519.PublicKeySize
View Source
const SignatureSize = ed25519.SignatureSize

Variables

This section is empty.

Functions

func Hash

func Hash(vv ...[]byte) []byte

Hash returns the SHA256 checksum of concatenated arguments.

func MakeMerkleProof

func MakeMerkleProof(hashes [][]byte, i int) (buf []byte)

func MakeMerkleRoot

func MakeMerkleRoot(n int, itemHash func(int) []byte) []byte

func MerkleProofAppend

func MerkleProofAppend(proof []byte, op byte, hash []byte) []byte

func MerkleRoot

func MerkleRoot(hash ...[]byte) []byte

func NewHash

func NewHash() hash.Hash

NewHash returns a new hash.Hash computing the SHA256 checksum.

func VerifyMerkleProof

func VerifyMerkleProof(hash, root, proof []byte) bool

Types

type MerkleHash

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

func NewMerkleHash

func NewMerkleHash(partSize int64) *MerkleHash

func (*MerkleHash) Leaves

func (h *MerkleHash) Leaves() [][]byte

func (*MerkleHash) Root

func (h *MerkleHash) Root() []byte

func (*MerkleHash) Write

func (h *MerkleHash) Write(data []byte) (n int, err error)

func (*MerkleHash) Written

func (h *MerkleHash) Written() int64

type PrivateKey

type PrivateKey []byte

func NewPrivateKeyFromSeed

func NewPrivateKeyFromSeed(seed string) PrivateKey

func (PrivateKey) Encode

func (prv PrivateKey) Encode() string

func (PrivateKey) PublicKey

func (prv PrivateKey) PublicKey() PublicKey

func (PrivateKey) Sign

func (prv PrivateKey) Sign(message []byte) []byte

func (PrivateKey) String

func (prv PrivateKey) String() string

func (PrivateKey) SubKey

func (prv PrivateKey) SubKey(name string) PrivateKey

type PublicKey

type PublicKey []byte

func DecodePublicKey

func DecodePublicKey(s string) PublicKey

func (PublicKey) Encode

func (pub PublicKey) Encode() string

func (PublicKey) Equal

func (pub PublicKey) Equal(p PublicKey) bool

func (PublicKey) String

func (pub PublicKey) String() string

func (PublicKey) Verify

func (pub PublicKey) Verify(message, signature []byte) bool

Jump to

Keyboard shortcuts

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