crypto

package
v1.7.14-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SECP256K1RSigLen is the number of bytes in a secp2561k recoverable
	// signature
	SECP256K1RSigLen = 65

	// SECP256K1RSKLen is the number of bytes in a secp2561k recoverable private
	// key
	SECP256K1RSKLen = 32

	// SECP256K1RPKLen is the number of bytes in a secp2561k recoverable public
	// key
	SECP256K1RPKLen = 33

	PrivateKeyPrefix = "PrivateKey-"
)

Variables

This section is empty.

Functions

func IsSortedAndUniqueSECP2561RSigs

func IsSortedAndUniqueSECP2561RSigs(sigs [][SECP256K1RSigLen]byte) bool

IsSortedAndUniqueSECP2561RSigs returns true if [sigs] is sorted

func SortSECP2561RSigs

func SortSECP2561RSigs(lst [][SECP256K1RSigLen]byte)

SortSECP2561RSigs sorts a slice of SECP2561R signatures

Types

type Factory

type Factory interface {
	NewPrivateKey() (PrivateKey, error)

	ToPublicKey([]byte) (PublicKey, error)
	ToPrivateKey([]byte) (PrivateKey, error)
}

type FactoryED25519

type FactoryED25519 struct{}

func (*FactoryED25519) NewPrivateKey

func (*FactoryED25519) NewPrivateKey() (PrivateKey, error)

func (*FactoryED25519) ToPrivateKey

func (*FactoryED25519) ToPrivateKey(b []byte) (PrivateKey, error)

func (*FactoryED25519) ToPublicKey

func (*FactoryED25519) ToPublicKey(b []byte) (PublicKey, error)

type FactoryRSA

type FactoryRSA struct{}

func (*FactoryRSA) NewPrivateKey

func (*FactoryRSA) NewPrivateKey() (PrivateKey, error)

func (*FactoryRSA) ToPrivateKey

func (*FactoryRSA) ToPrivateKey(b []byte) (PrivateKey, error)

func (*FactoryRSA) ToPublicKey

func (*FactoryRSA) ToPublicKey(b []byte) (PublicKey, error)

type FactoryRSAPSS

type FactoryRSAPSS struct{}

func (*FactoryRSAPSS) NewPrivateKey

func (*FactoryRSAPSS) NewPrivateKey() (PrivateKey, error)

func (*FactoryRSAPSS) ToPrivateKey

func (*FactoryRSAPSS) ToPrivateKey(b []byte) (PrivateKey, error)

func (*FactoryRSAPSS) ToPublicKey

func (*FactoryRSAPSS) ToPublicKey(b []byte) (PublicKey, error)

type FactorySECP256K1R

type FactorySECP256K1R struct{ Cache cache.LRU }

func (*FactorySECP256K1R) NewPrivateKey

func (*FactorySECP256K1R) NewPrivateKey() (PrivateKey, error)

func (*FactorySECP256K1R) RecoverHashPublicKey

func (f *FactorySECP256K1R) RecoverHashPublicKey(hash, sig []byte) (PublicKey, error)

func (*FactorySECP256K1R) RecoverPublicKey

func (f *FactorySECP256K1R) RecoverPublicKey(msg, sig []byte) (PublicKey, error)

func (*FactorySECP256K1R) ToPrivateKey

func (*FactorySECP256K1R) ToPrivateKey(b []byte) (PrivateKey, error)

func (*FactorySECP256K1R) ToPublicKey

func (*FactorySECP256K1R) ToPublicKey(b []byte) (PublicKey, error)

type PrivateKey

type PrivateKey interface {
	PublicKey() PublicKey

	Sign(message []byte) ([]byte, error)
	SignHash(hash []byte) ([]byte, error)

	Bytes() []byte
}

type PrivateKeyED25519

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

func (PrivateKeyED25519) Bytes

func (k PrivateKeyED25519) Bytes() []byte

func (*PrivateKeyED25519) PublicKey

func (k *PrivateKeyED25519) PublicKey() PublicKey

func (*PrivateKeyED25519) Sign

func (k *PrivateKeyED25519) Sign(msg []byte) ([]byte, error)

func (PrivateKeyED25519) SignHash

func (k PrivateKeyED25519) SignHash(hash []byte) ([]byte, error)

type PrivateKeyRSA

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

func (*PrivateKeyRSA) Bytes

func (k *PrivateKeyRSA) Bytes() []byte

func (*PrivateKeyRSA) PublicKey

func (k *PrivateKeyRSA) PublicKey() PublicKey

func (*PrivateKeyRSA) Sign

func (k *PrivateKeyRSA) Sign(msg []byte) ([]byte, error)

func (*PrivateKeyRSA) SignHash

func (k *PrivateKeyRSA) SignHash(hash []byte) ([]byte, error)

type PrivateKeyRSAPSS

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

func (*PrivateKeyRSAPSS) Bytes

func (k *PrivateKeyRSAPSS) Bytes() []byte

func (*PrivateKeyRSAPSS) PublicKey

func (k *PrivateKeyRSAPSS) PublicKey() PublicKey

func (*PrivateKeyRSAPSS) Sign

func (k *PrivateKeyRSAPSS) Sign(msg []byte) ([]byte, error)

func (*PrivateKeyRSAPSS) SignHash

func (k *PrivateKeyRSAPSS) SignHash(hash []byte) ([]byte, error)

type PrivateKeySECP256K1R

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

func BuildTestKeys added in v1.7.11

func BuildTestKeys() []*PrivateKeySECP256K1R

func (*PrivateKeySECP256K1R) Bytes

func (k *PrivateKeySECP256K1R) Bytes() []byte

func (*PrivateKeySECP256K1R) MarshalJSON added in v1.7.11

func (k *PrivateKeySECP256K1R) MarshalJSON() ([]byte, error)

func (*PrivateKeySECP256K1R) MarshalText added in v1.7.11

func (k *PrivateKeySECP256K1R) MarshalText() ([]byte, error)

func (*PrivateKeySECP256K1R) PublicKey

func (k *PrivateKeySECP256K1R) PublicKey() PublicKey

func (*PrivateKeySECP256K1R) Sign

func (k *PrivateKeySECP256K1R) Sign(msg []byte) ([]byte, error)

func (*PrivateKeySECP256K1R) SignHash

func (k *PrivateKeySECP256K1R) SignHash(hash []byte) ([]byte, error)

func (*PrivateKeySECP256K1R) String added in v1.7.11

func (k *PrivateKeySECP256K1R) String() string

func (*PrivateKeySECP256K1R) ToECDSA added in v0.8.0

ToECDSA returns the ecdsa representation of this private key

func (*PrivateKeySECP256K1R) UnmarshalJSON added in v1.7.11

func (k *PrivateKeySECP256K1R) UnmarshalJSON(b []byte) error

func (*PrivateKeySECP256K1R) UnmarshalText added in v1.7.11

func (k *PrivateKeySECP256K1R) UnmarshalText(text []byte) error

type PublicKey

type PublicKey interface {
	Verify(message, signature []byte) bool
	VerifyHash(hash, signature []byte) bool

	Address() ids.ShortID
	Bytes() []byte
}

type PublicKeyED25519

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

func (*PublicKeyED25519) Address

func (k *PublicKeyED25519) Address() ids.ShortID

func (*PublicKeyED25519) Bytes

func (k *PublicKeyED25519) Bytes() []byte

func (*PublicKeyED25519) Verify

func (k *PublicKeyED25519) Verify(msg, sig []byte) bool

func (*PublicKeyED25519) VerifyHash

func (k *PublicKeyED25519) VerifyHash(hash, sig []byte) bool

type PublicKeyRSA

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

func (*PublicKeyRSA) Address

func (k *PublicKeyRSA) Address() ids.ShortID

func (*PublicKeyRSA) Bytes

func (k *PublicKeyRSA) Bytes() []byte

func (*PublicKeyRSA) Verify

func (k *PublicKeyRSA) Verify(msg, sig []byte) bool

func (*PublicKeyRSA) VerifyHash

func (k *PublicKeyRSA) VerifyHash(hash, sig []byte) bool

type PublicKeyRSAPSS

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

func (*PublicKeyRSAPSS) Address

func (k *PublicKeyRSAPSS) Address() ids.ShortID

func (*PublicKeyRSAPSS) Bytes

func (k *PublicKeyRSAPSS) Bytes() []byte

func (*PublicKeyRSAPSS) Verify

func (k *PublicKeyRSAPSS) Verify(msg, sig []byte) bool

func (*PublicKeyRSAPSS) VerifyHash

func (k *PublicKeyRSAPSS) VerifyHash(hash, sig []byte) bool

type PublicKeySECP256K1R

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

func (*PublicKeySECP256K1R) Address

func (k *PublicKeySECP256K1R) Address() ids.ShortID

func (*PublicKeySECP256K1R) Bytes

func (k *PublicKeySECP256K1R) Bytes() []byte

func (*PublicKeySECP256K1R) ToECDSA added in v0.8.0

func (k *PublicKeySECP256K1R) ToECDSA() *stdecdsa.PublicKey

ToECDSA returns the ecdsa representation of this public key

func (*PublicKeySECP256K1R) Verify

func (k *PublicKeySECP256K1R) Verify(msg, sig []byte) bool

func (*PublicKeySECP256K1R) VerifyHash

func (k *PublicKeySECP256K1R) VerifyHash(hash, sig []byte) bool

type RecoverableFactory

type RecoverableFactory interface {
	Factory

	RecoverPublicKey(message, signature []byte) (PublicKey, error)
	RecoverHashPublicKey(hash, signature []byte) (PublicKey, error)
}

Jump to

Keyboard shortcuts

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