crypt

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 17 Imported by: 29

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

func S256 added in v2.2.3

func S256() *secp256k1.KoblitzCurve

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) ProvePossession added in v2.3.4

func (priv *BLSPrivateKey) ProvePossession() *BLSSignature

func (*BLSPrivateKey) Public

func (priv *BLSPrivateKey) Public() PublicKey

func (*BLSPrivateKey) Sign

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

func (*BLSPrivateKey) SignAugmented added in v2.3.13

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

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

func (*BLSPublicKey) VerifySignatureAugmented added in v2.3.13

func (pub *BLSPublicKey) VerifySignatureAugmented(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

func (*BLSSignature) VerifyAugmented added in v2.3.13

func (sig *BLSSignature) VerifyAugmented(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) 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 UnmarshalECDSAPublicKey added in v2.2.2

func UnmarshalECDSAPublicKey(data []byte, curve elliptic.Curve) (*ECDSAPublicKey, error)

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 NewECDSASignature added in v2.3.18

func NewECDSASignature(r, s *big.Int, curve elliptic.Curve) *ECDSASignature

NewECDSASignature creates an ECDSA signature from R, S values and curve. Use this instead of directly constructing ECDSASignature when receiving signatures from external sources (e.g., cloud KMS providers).

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) 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 MLDSA44PrivateKey added in v2.4.0

type MLDSA44PrivateKey mldsa44.PrivateKey

func (*MLDSA44PrivateKey) Equal added in v2.4.0

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

func (*MLDSA44PrivateKey) MarshalText added in v2.4.0

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

func (*MLDSA44PrivateKey) Public added in v2.4.0

func (priv *MLDSA44PrivateKey) Public() PublicKey

func (*MLDSA44PrivateKey) Sign added in v2.4.0

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

func (*MLDSA44PrivateKey) ToBase58 added in v2.4.0

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

func (*MLDSA44PrivateKey) ToProtocol added in v2.4.0

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

func (*MLDSA44PrivateKey) Unwrap added in v2.4.0

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

type MLDSA44PublicKey added in v2.4.0

type MLDSA44PublicKey mldsa44.PublicKey

func (*MLDSA44PublicKey) Equal added in v2.4.0

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

func (*MLDSA44PublicKey) Hash added in v2.4.0

func (pub *MLDSA44PublicKey) Hash() PublicKeyHash

func (*MLDSA44PublicKey) MarshalText added in v2.4.0

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

func (*MLDSA44PublicKey) String added in v2.4.0

func (pub *MLDSA44PublicKey) String() string

func (*MLDSA44PublicKey) ToBase58 added in v2.4.0

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

func (*MLDSA44PublicKey) ToProtocol added in v2.4.0

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

func (*MLDSA44PublicKey) Unwrap added in v2.4.0

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

func (*MLDSA44PublicKey) VerifySignature added in v2.4.0

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

type MLDSA44Signature added in v2.4.0

type MLDSA44Signature []byte

func (MLDSA44Signature) MarshalText added in v2.4.0

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

func (MLDSA44Signature) String added in v2.4.0

func (sig MLDSA44Signature) String() string

func (MLDSA44Signature) ToBase58 added in v2.4.0

func (sig MLDSA44Signature) ToBase58() []byte

func (MLDSA44Signature) ToProtocol added in v2.4.0

func (sig MLDSA44Signature) ToProtocol() tz.Signature

func (MLDSA44Signature) Verify added in v2.4.0

func (sig MLDSA44Signature) 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
	String() string
	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
	String() string
	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