tendermint

package
v0.0.0-...-c4e539a Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Size      = sha256.Size
	BlockSize = sha256.BlockSize
)
View Source
const (
	PrivKeyAminoName = "tendermint/PrivKeySecp256k1"
	PubKeyAminoName  = "tendermint/PubKeySecp256k1"
)

-------------------------------------

View Source
const PubKeySecp256k1Size = 33

PubKeySecp256k1Size is comprised of 32 bytes for one field element (the x-coordinate), plus one byte for the parity of the y-coordinate.

View Source
const (
	TruncatedSize = 20
)

Variables

This section is empty.

Functions

func New

func New() hash.Hash

New returns a new hash.Hash.

func NewTruncated

func NewTruncated() hash.Hash

NewTruncated returns a new hash.Hash.

func RegisterCodec

func RegisterCodec(cdc *amino.Codec)

RegisterAmino registers all crypto related types in the given (amino) codec.

func Sum

func Sum(bz []byte) []byte

Sum returns the SHA256 of the bz.

func SumTruncated

func SumTruncated(bz []byte) []byte

SumTruncated returns the first 20 bytes of SHA256 of the bz.

Types

type Address

type Address = HexBytes

An address is a []byte, but hex-encoded even in JSON. []byte leaves us the option to change the address length. Use an alias so Unmarshal methods (with ptr receivers) are available too.

type HexBytes

type HexBytes []byte

The main purpose of HexBytes is to enable HEX-encoding for json/encoding.

func (HexBytes) Bytes

func (bz HexBytes) Bytes() []byte

Allow it to fulfill various interfaces in light-client, etc...

func (HexBytes) Format

func (bz HexBytes) Format(s fmt.State, verb rune)

func (HexBytes) Marshal

func (bz HexBytes) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (HexBytes) MarshalJSON

func (bz HexBytes) MarshalJSON() ([]byte, error)

This is the point of Bytes.

func (HexBytes) String

func (bz HexBytes) String() string

func (*HexBytes) Unmarshal

func (bz *HexBytes) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*HexBytes) UnmarshalJSON

func (bz *HexBytes) UnmarshalJSON(data []byte) error

This is the point of Bytes.

type PrivKey

type PrivKey interface {
	Bytes() []byte
	PubKey() PubKey
	Equals(PrivKey) bool
}

type PrivKeySecp256k1

type PrivKeySecp256k1 [32]byte

PrivKeySecp256k1 implements PrivKey.

func (PrivKeySecp256k1) Bytes

func (privKey PrivKeySecp256k1) Bytes() []byte

Bytes marshalls the private key using amino encoding.

func (PrivKeySecp256k1) Equals

func (privKey PrivKeySecp256k1) Equals(other PrivKey) bool

Equals - you probably don't need to use this. Runs in constant time based on length of the keys.

func (PrivKeySecp256k1) PubKey

func (privKey PrivKeySecp256k1) PubKey() PubKey

PubKey performs the point-scalar multiplication from the privKey on the generator point to get the pubkey.

type PubKey

type PubKey interface {
	Address() Address
	Bytes() []byte
	Equals(PubKey) bool
}

type PubKeySecp256k1

type PubKeySecp256k1 [PubKeySecp256k1Size]byte

PubKeySecp256k1 implements crypto.PubKey. It is the compressed form of the pubkey. The first byte depends is a 0x02 byte if the y-coordinate is the lexicographically largest of the two associated with the x-coordinate. Otherwise the first byte is a 0x03. This prefix is followed with the x-coordinate.

func (PubKeySecp256k1) Address

func (pubKey PubKeySecp256k1) Address() Address

Address returns a Bitcoin style addresses: RIPEMD160(SHA256(pubkey))

func (PubKeySecp256k1) AminoSize

func (pubKey PubKeySecp256k1) AminoSize(_ *amino.Codec) int

func (PubKeySecp256k1) Bytes

func (pubKey PubKeySecp256k1) Bytes() []byte

Bytes returns the pubkey marshalled with amino encoding.

func (PubKeySecp256k1) Equals

func (pubKey PubKeySecp256k1) Equals(other PubKey) bool

func (PubKeySecp256k1) String

func (pubKey PubKeySecp256k1) String() string

Jump to

Keyboard shortcuts

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