crypto

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: BSD-3-Clause Imports: 15 Imported by: 1

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
)

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)

NewPrivateKey implements the Factory interface

func (*FactoryED25519) ToPrivateKey

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

ToPrivateKey implements the Factory interface

func (*FactoryED25519) ToPublicKey

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

ToPublicKey implements the Factory interface

type FactoryRSA

type FactoryRSA struct{}

func (*FactoryRSA) NewPrivateKey

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

NewPrivateKey implements the Factory interface

func (*FactoryRSA) ToPrivateKey

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

ToPrivateKey implements the Factory interface

func (*FactoryRSA) ToPublicKey

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

ToPublicKey implements the Factory interface

type FactoryRSAPSS

type FactoryRSAPSS struct{}

func (*FactoryRSAPSS) NewPrivateKey

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

NewPrivateKey implements the Factory interface

func (*FactoryRSAPSS) ToPrivateKey

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

ToPrivateKey implements the Factory interface

func (*FactoryRSAPSS) ToPublicKey

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

ToPublicKey implements the Factory interface

type FactorySECP256K1R

type FactorySECP256K1R struct{ Cache cache.LRU }

func (*FactorySECP256K1R) NewPrivateKey

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

NewPrivateKey implements the Factory interface

func (*FactorySECP256K1R) RecoverHashPublicKey

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

RecoverHashPublicKey returns the public key from a 65 byte signature

func (*FactorySECP256K1R) RecoverPublicKey

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

RecoverPublicKey returns the public key from a 65 byte signature

func (*FactorySECP256K1R) ToPrivateKey

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

ToPrivateKey implements the Factory interface

func (*FactorySECP256K1R) ToPublicKey

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

ToPublicKey implements the Factory interface

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

Bytes implements the PrivateKey interface

func (*PrivateKeyED25519) PublicKey

func (k *PrivateKeyED25519) PublicKey() PublicKey

PublicKey implements the PrivateKey interface

func (*PrivateKeyED25519) Sign

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

Sign implements the PrivateKey interface

func (PrivateKeyED25519) SignHash

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

SignHash implements the PrivateKey interface

type PrivateKeyRSA

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

func (*PrivateKeyRSA) Bytes

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

Bytes implements the PrivateKey interface

func (*PrivateKeyRSA) PublicKey

func (k *PrivateKeyRSA) PublicKey() PublicKey

PublicKey implements the PrivateKey interface

func (*PrivateKeyRSA) Sign

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

Sign implements the PrivateKey interface

func (*PrivateKeyRSA) SignHash

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

SignHash implements the PrivateKey interface

type PrivateKeyRSAPSS

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

func (*PrivateKeyRSAPSS) Bytes

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

Bytes implements the PrivateKey interface

func (*PrivateKeyRSAPSS) PublicKey

func (k *PrivateKeyRSAPSS) PublicKey() PublicKey

PublicKey implements the PrivateKey interface

func (*PrivateKeyRSAPSS) Sign

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

Sign implements the PrivateKey interface

func (*PrivateKeyRSAPSS) SignHash

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

SignHash implements the PrivateKey interface

type PrivateKeySECP256K1R

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

func (*PrivateKeySECP256K1R) Bytes

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

Bytes implements the PrivateKey interface

func (*PrivateKeySECP256K1R) PublicKey

func (k *PrivateKeySECP256K1R) PublicKey() PublicKey

PublicKey implements the PrivateKey interface

func (*PrivateKeySECP256K1R) Sign

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

Sign implements the PrivateKey interface

func (*PrivateKeySECP256K1R) SignHash

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

SignHash implements the PrivateKey interface

func (*PrivateKeySECP256K1R) ToECDSA

ToECDSA returns the ecdsa representation of this private key

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

Address implements the PublicKey interface

func (*PublicKeyED25519) Bytes

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

Bytes implements the PublicKey interface

func (*PublicKeyED25519) Verify

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

Verify implements the PublicKey interface

func (*PublicKeyED25519) VerifyHash

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

VerifyHash implements the PublicKey interface

type PublicKeyRSA

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

func (*PublicKeyRSA) Address

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

Address implements the PublicKey interface

func (*PublicKeyRSA) Bytes

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

Bytes implements the PublicKey interface

func (*PublicKeyRSA) Verify

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

Verify implements the PublicKey interface

func (*PublicKeyRSA) VerifyHash

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

VerifyHash implements the PublicKey interface

type PublicKeyRSAPSS

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

func (*PublicKeyRSAPSS) Address

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

Address implements the PublicKey interface

func (*PublicKeyRSAPSS) Bytes

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

Bytes implements the PublicKey interface

func (*PublicKeyRSAPSS) Verify

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

Verify implements the PublicKey interface

func (*PublicKeyRSAPSS) VerifyHash

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

VerifyHash implements the PublicKey interface

type PublicKeySECP256K1R

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

func (*PublicKeySECP256K1R) Address

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

Address implements the PublicKey interface

func (*PublicKeySECP256K1R) Bytes

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

Bytes implements the PublicKey interface

func (*PublicKeySECP256K1R) ToECDSA

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

Verify implements the PublicKey interface

func (*PublicKeySECP256K1R) VerifyHash

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

VerifyHash implements the PublicKey interface

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