cryptoutils

package
v1.0.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSignature error returned by Verify if signature is invalid
	ErrSignature = errors.New("invalid signature")
)

Functions

func MarshalPKCS8PrivateKey

func MarshalPKCS8PrivateKey(key interface{}) ([]byte, error)

MarshalPKCS8PrivateKey converts a private key to PKCS#8, ASN.1 DER form.

func NamedCurve

func NamedCurve(name string) elliptic.Curve

NamedCurve returns curve by its standard name or nil

func ParsePKIXPublicKey

func ParsePKIXPublicKey(derBytes []byte) (pub any, err error)

func PublicKeySuitableForTezos

func PublicKeySuitableForTezos(pub crypto.PublicKey) bool

PublicKeySuitable returns true if the key is Tezos compatible

func S256

func S256() elliptic.Curve

S256 returns a Curve which implements secp256k1

func Verify

func Verify(pub crypto.PublicKey, hash []byte, sig Signature) error

Verify verifies the signature

Types

type ECDSASignature

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

ECDSASignature is a type representing an ecdsa signature.

func CanonizeECDSASignature

func CanonizeECDSASignature(sig *ECDSASignature) *ECDSASignature

CanonizeECDSASignature returns the canonical versions of the signature the canonical version enforce low S values if S is above order / 2 it negating the S (modulo the order (N))

func (*ECDSASignature) String

func (e *ECDSASignature) String() string

type ED25519Signature

type ED25519Signature []byte

ED25519Signature is a type representing an Ed25519 signature

func (ED25519Signature) String

func (e ED25519Signature) String() string

type PrivateKey

type PrivateKey interface {
	Public() crypto.PublicKey
}

PrivateKey is implemented by private key types

type Signature

type Signature interface {
	String() string
}

Signature is a type representing a digital signature.

func CanonizeSignature

func CanonizeSignature(sig Signature) Signature

CanonizeSignature returns the canonical versions of the ECDSA signature if one is given

func Sign

func Sign(priv PrivateKey, hash []byte) (Signature, error)

Sign sign a hash using this private key

Jump to

Keyboard shortcuts

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