crypt

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 16 Imported by: 20

Documentation

Overview

Package crypt is a wrapper around standard and 3rd party signature algorithms which adds a support of Tezos encodings of keys and signatures

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedKeyType = errors.New("crypt: unsupported key type")
	ErrInvalidPublicKey   = errors.New("crypt: invalid public key")
	ErrInvalidPrivateKey  = errors.New("crypt: invalid private key")
)

Functions

This section is empty.

Types

type BLSPrivateKey

type BLSPrivateKey minpk.PrivateKey

func (*BLSPrivateKey) Equal

func (priv *BLSPrivateKey) Equal(other PrivateKey) bool

func (*BLSPrivateKey) MarshalText

func (priv *BLSPrivateKey) MarshalText() (text []byte, err error)

func (*BLSPrivateKey) Public

func (priv *BLSPrivateKey) Public() PublicKey

func (*BLSPrivateKey) Sign

func (priv *BLSPrivateKey) Sign(message []byte) (signature Signature, err error)

func (*BLSPrivateKey) String

func (priv *BLSPrivateKey) String() string

func (*BLSPrivateKey) ToBase58

func (priv *BLSPrivateKey) ToBase58() []byte

func (*BLSPrivateKey) ToProtocol

func (priv *BLSPrivateKey) ToProtocol() tz.PrivateKey

func (*BLSPrivateKey) Unwrap

func (priv *BLSPrivateKey) Unwrap() crypto.PrivateKey

type BLSPublicKey

type BLSPublicKey minpk.PublicKey

func (*BLSPublicKey) Equal

func (pub *BLSPublicKey) Equal(other PublicKey) bool

func (*BLSPublicKey) Hash

func (pub *BLSPublicKey) Hash() PublicKeyHash

func (*BLSPublicKey) MarshalText

func (pub *BLSPublicKey) MarshalText() (text []byte, err error)

func (*BLSPublicKey) String

func (pub *BLSPublicKey) String() string

func (*BLSPublicKey) ToBase58

func (pub *BLSPublicKey) ToBase58() []byte

func (*BLSPublicKey) ToProtocol

func (pub *BLSPublicKey) ToProtocol() tz.PublicKey

func (*BLSPublicKey) Unwrap

func (pub *BLSPublicKey) Unwrap() crypto.PublicKey

func (*BLSPublicKey) VerifySignature

func (pub *BLSPublicKey) VerifySignature(sig Signature, message []byte) bool

type BLSSignature

type BLSSignature minpk.Signature

func (*BLSSignature) MarshalText

func (sig *BLSSignature) MarshalText() (text []byte, err error)

func (*BLSSignature) String

func (sig *BLSSignature) String() string

func (*BLSSignature) ToBase58

func (sig *BLSSignature) ToBase58() []byte

func (*BLSSignature) ToProtocol

func (sig *BLSSignature) ToProtocol() tz.Signature

func (*BLSSignature) Verify

func (sig *BLSSignature) Verify(pub PublicKey, message []byte) bool

type Digest

type Digest [32]byte

func DigestFunc

func DigestFunc(data []byte) Digest

type ECDSAPrivateKey

type ECDSAPrivateKey ecdsa.PrivateKey

func (*ECDSAPrivateKey) Equal

func (priv *ECDSAPrivateKey) Equal(other PrivateKey) bool

func (*ECDSAPrivateKey) MarshalText

func (priv *ECDSAPrivateKey) MarshalText() (text []byte, err error)

func (*ECDSAPrivateKey) Public

func (priv *ECDSAPrivateKey) Public() PublicKey

func (*ECDSAPrivateKey) Sign

func (priv *ECDSAPrivateKey) Sign(message []byte) (signature Signature, err error)

func (*ECDSAPrivateKey) String

func (priv *ECDSAPrivateKey) String() string

func (*ECDSAPrivateKey) ToBase58

func (priv *ECDSAPrivateKey) ToBase58() []byte

func (*ECDSAPrivateKey) ToProtocol

func (priv *ECDSAPrivateKey) ToProtocol() tz.PrivateKey

func (*ECDSAPrivateKey) Unwrap

func (priv *ECDSAPrivateKey) Unwrap() crypto.PrivateKey

type ECDSAPublicKey

type ECDSAPublicKey ecdsa.PublicKey

func (*ECDSAPublicKey) Equal

func (pub *ECDSAPublicKey) Equal(other PublicKey) bool

func (*ECDSAPublicKey) Hash

func (pub *ECDSAPublicKey) Hash() PublicKeyHash

func (*ECDSAPublicKey) MarshalText

func (pub *ECDSAPublicKey) MarshalText() (text []byte, err error)

func (*ECDSAPublicKey) String

func (pub *ECDSAPublicKey) String() string

func (*ECDSAPublicKey) ToBase58

func (pub *ECDSAPublicKey) ToBase58() []byte

func (*ECDSAPublicKey) ToProtocol

func (pub *ECDSAPublicKey) ToProtocol() tz.PublicKey

func (*ECDSAPublicKey) Unwrap

func (pub *ECDSAPublicKey) Unwrap() crypto.PublicKey

func (*ECDSAPublicKey) VerifySignature

func (pub *ECDSAPublicKey) VerifySignature(sig Signature, message []byte) bool

type ECDSASignature

type ECDSASignature struct {
	R     *big.Int
	S     *big.Int
	Curve elliptic.Curve
}

func (*ECDSASignature) MarshalText

func (sig *ECDSASignature) MarshalText() (text []byte, err error)

func (*ECDSASignature) String

func (sig *ECDSASignature) String() string

func (*ECDSASignature) ToBase58

func (sig *ECDSASignature) ToBase58() []byte

func (*ECDSASignature) ToProtocol

func (sig *ECDSASignature) ToProtocol() tz.Signature

func (*ECDSASignature) Verify

func (sig *ECDSASignature) Verify(pub PublicKey, message []byte) bool

type Ed25519PrivateKey

type Ed25519PrivateKey ed25519.PrivateKey

func (Ed25519PrivateKey) Equal

func (priv Ed25519PrivateKey) Equal(other PrivateKey) bool

func (Ed25519PrivateKey) MarshalText

func (priv Ed25519PrivateKey) MarshalText() (text []byte, err error)

func (Ed25519PrivateKey) Public

func (priv Ed25519PrivateKey) Public() PublicKey

func (Ed25519PrivateKey) Seed

func (priv Ed25519PrivateKey) Seed() []byte

func (Ed25519PrivateKey) Sign

func (priv Ed25519PrivateKey) Sign(message []byte) (signature Signature, err error)

func (Ed25519PrivateKey) String

func (priv Ed25519PrivateKey) String() string

func (Ed25519PrivateKey) ToBase58

func (priv Ed25519PrivateKey) ToBase58() []byte

func (Ed25519PrivateKey) ToProtocol

func (priv Ed25519PrivateKey) ToProtocol() tz.PrivateKey

func (Ed25519PrivateKey) Unwrap

func (priv Ed25519PrivateKey) Unwrap() crypto.PrivateKey

type Ed25519PublicKey

type Ed25519PublicKey ed25519.PublicKey

func (Ed25519PublicKey) Equal

func (pub Ed25519PublicKey) Equal(other PublicKey) bool

func (Ed25519PublicKey) Hash

func (pub Ed25519PublicKey) Hash() PublicKeyHash

func (Ed25519PublicKey) MarshalText

func (pub Ed25519PublicKey) MarshalText() (text []byte, err error)

func (Ed25519PublicKey) String

func (pub Ed25519PublicKey) String() string

func (Ed25519PublicKey) ToBase58

func (pub Ed25519PublicKey) ToBase58() []byte

func (Ed25519PublicKey) ToProtocol

func (pub Ed25519PublicKey) ToProtocol() tz.PublicKey

func (Ed25519PublicKey) Unwrap

func (pub Ed25519PublicKey) Unwrap() crypto.PublicKey

func (Ed25519PublicKey) VerifySignature

func (pub Ed25519PublicKey) VerifySignature(sig Signature, message []byte) bool

type Ed25519Signature

type Ed25519Signature []byte

func NewEd25519Signature

func NewEd25519Signature(sig *tz.Ed25519Signature) Ed25519Signature

func (Ed25519Signature) MarshalText

func (sig Ed25519Signature) MarshalText() (text []byte, err error)

func (Ed25519Signature) String

func (sig Ed25519Signature) String() string

func (Ed25519Signature) ToBase58

func (sig Ed25519Signature) ToBase58() []byte

func (Ed25519Signature) ToProtocol

func (sig Ed25519Signature) ToProtocol() tz.Signature

func (Ed25519Signature) Verify

func (sig Ed25519Signature) Verify(pub PublicKey, message []byte) bool

type GenericSignature

type GenericSignature tz.GenericSignature

func (*GenericSignature) String

func (sig *GenericSignature) String() string

func (*GenericSignature) ToBase58

func (sig *GenericSignature) ToBase58() []byte

func (*GenericSignature) ToProtocol

func (sig *GenericSignature) ToProtocol() tz.Signature

func (*GenericSignature) Verify

func (sig *GenericSignature) Verify(pub PublicKey, message []byte) bool

type PrivateKey

type PrivateKey interface {
	tz.Base58Encoder
	ToProtocol() tz.PrivateKey
	Sign(message []byte) (signature Signature, err error)
	Public() PublicKey
	Equal(PrivateKey) bool
	Unwrap() crypto.PrivateKey
}

func NewPrivateKey

func NewPrivateKey(priv tz.PrivateKey) (PrivateKey, error)

func NewPrivateKeyFrom

func NewPrivateKeyFrom(priv crypto.PrivateKey) (PrivateKey, error)

NewPrivateKeyFrom tries to make PrivateKey from a raw one. It returns ErrUnsupportedKeyType if the key is of unsupported type

func ParsePrivateKey

func ParsePrivateKey(src []byte) (PrivateKey, error)

type PublicKey

type PublicKey interface {
	tz.Base58Encoder
	ToProtocol() tz.PublicKey
	VerifySignature(sig Signature, message []byte) bool
	Hash() PublicKeyHash
	Equal(PublicKey) bool
	Unwrap() crypto.PublicKey
}

func NewPublicKey

func NewPublicKey(pub tz.PublicKey) (PublicKey, error)

func NewPublicKeyFrom

func NewPublicKeyFrom(pub crypto.PublicKey) (PublicKey, error)

NewPublicKeyFrom tries to make PublicKey from a raw one. It returns ErrUnsupportedKeyType if the key is of unsupported type

func ParsePublicKey

func ParsePublicKey(src []byte) (PublicKey, error)

type PublicKeyHash

type PublicKeyHash = tz.PublicKeyHash

type Signature

type Signature interface {
	tz.Base58Encoder
	ToProtocol() tz.Signature
	Verify(pub PublicKey, message []byte) bool
}

func NewSignature

func NewSignature(sig tz.Signature) (Signature, error)

func NewSignatureFromBytes

func NewSignatureFromBytes(sig []byte, pub PublicKey) (Signature, error)

NewSignatureFromBytes tries to parse signature coming from a third party. It makes an assumption about signature type base on the public key. For ECDSA it expects the signature to be serialized to ASN.1

func ParseSignature

func ParseSignature(src []byte) (Signature, error)

Jump to

Keyboard shortcuts

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