crypto

package
v0.9.7-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: Apache-2.0, MIT Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const (
	SigTypeSecp256k1 = crypto.SigTypeSecp256k1
	SigTypeBLS       = crypto.SigTypeBLS
)
View Source
const PrivateKeyBytes = 32

PrivateKeyBytes is the size of a serialized private key.

Variables

This section is empty.

Functions

func EcRecover

func EcRecover(msg, signature []byte) ([]byte, error)

EcRecover recovers the public key from a message, signature pair.

func PublicKeyForSecpSecretKey

func PublicKeyForSecpSecretKey(sk []byte) []byte

PublicKeyForSecpSecretKey returns the public key for this private key.

func SignBLS

func SignBLS(sk, msg []byte) ([]byte, error)

SignBLS signs the given message with BLS.

func SignSecp

func SignSecp(sk, msg []byte) ([]byte, error)

SignSecp signs the given message using secp256k1 based cryptography, which must be 32 bytes long.

func ValidateBlsSignature

func ValidateBlsSignature(data []byte, addr address.Address, signature []byte) error

func ValidateSecpSignature

func ValidateSecpSignature(data []byte, addr address.Address, signature []byte) error

func ValidateSignature

func ValidateSignature(data []byte, addr address.Address, sig Signature) error

ValidateSignature cryptographically verifies that 'sig' is the signed hash of 'data' with the public key belonging to `addr`.

func VerifyBLS

func VerifyBLS(pubKey, msg, signature []byte) bool

VerifyBLS checks the given signature is valid using BLS cryptography.

func VerifyBLSAggregate

func VerifyBLSAggregate(pubKeys, msgs [][]byte, signature []byte) bool

VerifyBLSAggregate checks the given signature is a valid aggregate signature over all messages and public keys

func VerifySecp

func VerifySecp(pk, msg, signature []byte) bool

VerifySecp checks the given signature is a secp256k1 signature and returns true if it is valid.

Types

type KeyInfo

type KeyInfo struct {
	// Private key.
	PrivateKey []byte `json:"privateKey"`
	// Cryptographic system used to generate private key.
	SigType SigType `json:"type"`
}

KeyInfo is a key and its type used for signing.

func NewBLSKeyFromSeed

func NewBLSKeyFromSeed(seed io.Reader) (KeyInfo, error)

func NewSecpKeyFromSeed

func NewSecpKeyFromSeed(seed io.Reader) (KeyInfo, error)

NewSecpKeyFromSeed generates a new key from the given reader.

func (*KeyInfo) Address

func (ki *KeyInfo) Address() (address.Address, error)

Address returns the address for this keyinfo

func (*KeyInfo) Equals

func (ki *KeyInfo) Equals(other *KeyInfo) bool

Equals returns true if the KeyInfo is equal to other.

func (*KeyInfo) Key

func (ki *KeyInfo) Key() []byte

Key returns the private key of KeyInfo

func (*KeyInfo) MarshalCBOR

func (t *KeyInfo) MarshalCBOR(w io.Writer) error

func (*KeyInfo) MarshalJSON

func (ki *KeyInfo) MarshalJSON() ([]byte, error)

func (*KeyInfo) PublicKey

func (ki *KeyInfo) PublicKey() []byte

Returns the public key part as uncompressed bytes.

func (*KeyInfo) Type

func (ki *KeyInfo) Type() SigType

Type returns the type of curve used to generate the private key

func (*KeyInfo) UnmarshalCBOR

func (t *KeyInfo) UnmarshalCBOR(r io.Reader) error

func (*KeyInfo) UnmarshalJSON

func (ki *KeyInfo) UnmarshalJSON(data []byte) error

type SigType

type SigType = crypto.SigType

type Signature

type Signature = crypto.Signature

func Sign

func Sign(data []byte, secretKey []byte, sigtype SigType) (*Signature, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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