keypair

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

README

The purpose of this package is to provide functionality for working with public and private key cryptography in Casper. This includes generating keys, working with PEM files, and generating and verifying signatures using both the ed25519 and secp256k1 algorithms. However, for ease of use, this implementation is hidden behind the common PublicKey and PrivateKey structs. (See documentation for more information.)

Documentation

Index

Constants

View Source
const (
	ED25519   keyAlgorithm = 1
	SECP256K1 keyAlgorithm = 2
)

Variables

View Source
var (
	ErrEmptySignature       = errors.New("empty signature")
	ErrInvalidPublicKeyAlgo = errors.New("invalid public key algorithm")
	ErrInvalidSignature     = errors.New("invalid signature")
	ErrEmptyPublicKey       = errors.New("empty public key")
)
View Source
var KeySettings = map[keyAlgorithm]KeyAlgorithmSetting{
	ED25519: {
		// contains filtered or unexported fields
	},
	SECP256K1: {
		// contains filtered or unexported fields
	},
}

Functions

This section is empty.

Types

type KeyAlgorithmSetting

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

type PrivateKey

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

func GeneratePrivateKey

func GeneratePrivateKey(algorithm keyAlgorithm) (PrivateKey, error)

func NewPrivateKeyED25518

func NewPrivateKeyED25518(path string) (PrivateKey, error)

func NewPrivateKeyFromFile

func NewPrivateKeyFromFile(path string, algorithm keyAlgorithm) (PrivateKey, error)

func NewPrivateKeyFromPEM added in v1.4.3

func NewPrivateKeyFromPEM(content []byte, algorithm keyAlgorithm) (PrivateKey, error)

func NewPrivateKeySECP256K1

func NewPrivateKeySECP256K1(path string) (PrivateKey, error)

func (PrivateKey) PublicKey

func (v PrivateKey) PublicKey() PublicKey

func (PrivateKey) RawSign added in v0.9.8

func (v PrivateKey) RawSign(mes []byte) ([]byte, error)

RawSign returns raw bytes of signature to sign off chain data Deprecated: won't work with Casper node, use Sign method instead

func (PrivateKey) Sign

func (v PrivateKey) Sign(msg []byte) ([]byte, error)

Sign creates a Casper compatible cryptographic signature, including the algorithm tag prefix

func (PrivateKey) ToPem added in v1.4.3

func (v PrivateKey) ToPem() ([]byte, error)

type PrivateKeyInternal

type PrivateKeyInternal interface {
	PublicKeyBytes() []byte
	Sign(mes []byte) ([]byte, error)
	ToPem() ([]byte, error)
}

type PublicKey

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

func NewPublicKey

func NewPublicKey(source string) (PublicKey, error)

func NewPublicKeyFromBuffer

func NewPublicKeyFromBuffer(buf *bytes.Buffer) (PublicKey, error)

func NewPublicKeyFromBytes

func NewPublicKeyFromBytes(source []byte) (PublicKey, error)

func (PublicKey) AccountHash

func (v PublicKey) AccountHash() key.AccountHash

func (PublicKey) Bytes

func (v PublicKey) Bytes() []byte

func (PublicKey) Equals

func (v PublicKey) Equals(target PublicKey) bool

func (*PublicKey) GobDecode

func (v *PublicKey) GobDecode(i []byte) error

func (PublicKey) GobEncode

func (v PublicKey) GobEncode() ([]byte, error)

func (PublicKey) MarshalJSON

func (v PublicKey) MarshalJSON() ([]byte, error)

func (*PublicKey) Scan

func (v *PublicKey) Scan(value interface{}) error

func (PublicKey) String

func (v PublicKey) String() string

func (PublicKey) ToHex

func (v PublicKey) ToHex() string

func (*PublicKey) UnmarshalJSON

func (v *PublicKey) UnmarshalJSON(data []byte) error

func (PublicKey) Value

func (v PublicKey) Value() (driver.Value, error)

func (PublicKey) VerifyRawSignature added in v0.9.8

func (v PublicKey) VerifyRawSignature(message []byte, sig []byte) error

VerifyRawSignature verifies message using raw signature Deprecated: won't work with Casper node, use VerifySignature method to achieve compatibility

func (PublicKey) VerifySignature

func (v PublicKey) VerifySignature(message []byte, sig []byte) error

VerifySignature verifies message using Casper compatible cryptographic signature, including the algorithm tag prefix

type PublicKeyInternal

type PublicKeyInternal interface {
	Bytes() []byte
	VerifySignature(message []byte, sig []byte) bool
}

type PublicKeyList

type PublicKeyList []PublicKey

func (PublicKeyList) Contains

func (p PublicKeyList) Contains(target PublicKey) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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