crypto

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0, MIT Imports: 6 Imported by: 39

README

go-crypto

Crypto utility functions used in filecoin

License

This repository is dual-licensed under Apache 2.0 and MIT terms.

Copyright 2019. Protocol Labs, Inc.

Documentation

Index

Constants

View Source
const PrivateKeyBytes = 32

PrivateKeyBytes is the size of a serialized private key.

View Source
const PublicKeyBytes = 65

PublicKeyBytes is the size of a serialized public key.

Variables

View Source
var (
	ErrInvalidMsgLength = errors.New("filecoin/go-crypto: invalid message length")
)

Functions

func EcRecover

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

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

func Equals

func Equals(sk, other []byte) bool

Equals compares two private key for equality and returns true if they are the same.

func GenerateKey

func GenerateKey() ([]byte, error)

GenerateKey creates a new key using secure randomness from crypto.rand.

func GenerateKeyFromSeed

func GenerateKeyFromSeed(io.Reader) ([]byte, error)

GenerateKeyFromSeed generates a new key from the given reader. Deprecated: use GenerateKey instead - the given reader is no longer used.

func PublicKey

func PublicKey(sk []byte) []byte

PublicKey returns the public key for this private key.

func Sign

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

Sign signs the given message, which must be 32 bytes long.

func Verify

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

Verify checks the given signature and returns true if it is valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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