ed25519local

package
v0.0.0-...-da2935b Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ed25519PrivKeyAminoRoute = "tendermint/PrivKeyEd25519"
	Ed25519PubKeyAminoRoute  = "tendermint/PubKeyEd25519"
	// Size of an Edwards25519 signature. Namely the size of a compressed
	// Edwards25519 point, and a field element. Both of which are 32 bytes.
	SignatureSize  = 64
	PrivateKeySize = 64
	PublicKeySize  = 32
)

Variables

This section is empty.

Functions

func MakePublicKey

func MakePublicKey(privateKey *[64]byte) (publicKey *[32]byte)

MakePublicKey makes a publicKey from the first half of privateKey.

func Sha256

func Sha256(bytes []byte) []byte

func Sign

func Sign(privateKey *[PrivateKeySize]byte, message []byte) *[SignatureSize]byte

Sign signs the message with privateKey and returns a signature.

func Sum

func Sum(bz []byte) []byte

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

func Verify

func Verify(publicKey *[PublicKeySize]byte, message []byte, sig *[SignatureSize]byte) bool

Verify returns true iff sig is a valid signature of message by publicKey.

Types

type Address

type Address = HexBytes

type HexBytes

type HexBytes []byte

func (HexBytes) Bytes

func (bz HexBytes) Bytes() []byte

type PrivKey

type PrivKey interface {
	Bytes() []byte
	Sign(msg []byte) ([]byte, error)
	PubKey() PubKey
}

type PrivKeyEd25519

type PrivKeyEd25519 [64]byte

PrivKeyEd25519 implements crypto.PrivKey.

func GenPrivKeyFromSecret

func GenPrivKeyFromSecret(secret []byte) PrivKeyEd25519

GenPrivKeyFromSecret hashes the secret with SHA2, and uses that 32 byte output to create the private key. NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.

func (PrivKeyEd25519) Bytes

func (privKey PrivKeyEd25519) Bytes() []byte

Bytes marshals the privkey using amino encoding.

func (PrivKeyEd25519) PubKey

func (privKey PrivKeyEd25519) PubKey() PubKey

PubKey gets the corresponding public key from the private key.

func (PrivKeyEd25519) Sign

func (privKey PrivKeyEd25519) Sign(msg []byte) ([]byte, error)

Sign produces a signature on the provided message.

type PubKey

type PubKey interface {
	Address() Address
	Bytes() []byte
	VerifyBytes(msg []byte, sig []byte) bool
}

type PubKeyEd25519

type PubKeyEd25519 [32]byte

PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme.

func (PubKeyEd25519) Address

func (pubKey PubKeyEd25519) Address() Address

Address is the SHA256-20 of the raw pubkey bytes.

func (PubKeyEd25519) Bytes

func (pubKey PubKeyEd25519) Bytes() []byte

Bytes marshals the PubKey using amino encoding.

func (PubKeyEd25519) VerifyBytes

func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ []byte) bool

Jump to

Keyboard shortcuts

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