crypto

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedCurve = errors.New("unsupported curve")
)

Functions

func GenerateNewKeyPair

func GenerateNewKeyPair() (PrivateKey, PublicKey, error)

func MarshalPrivateKey

func MarshalPrivateKey(key PrivateKey) ([]byte, error)

func MarshalPublicKey

func MarshalPublicKey(key PublicKey) ([]byte, error)

Types

type ECDSAPrivateKey

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

ECDSAPrivateKey is the ECDSA private key that implements crypto/PrivateKey

func (ECDSAPrivateKey) GetCurve

func (privateKey ECDSAPrivateKey) GetCurve() proto.KeyCurve

GetCurve returns the curve for this key

func (ECDSAPrivateKey) GetPublic

func (privateKey ECDSAPrivateKey) GetPublic() (PublicKey, error)

GetPublic returns the public key component associated with this key.

func (ECDSAPrivateKey) Sign

func (privateKey ECDSAPrivateKey) Sign(data []byte) ([]byte, error)

Sign Hashes this data and signs it.

func (ECDSAPrivateKey) ToBytes

func (privateKey ECDSAPrivateKey) ToBytes() ([]byte, error)

ToBytes serializes this key

type ECDSAPublicKey

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

ECDSAPublicKey is the ECDSA public key that implements crypto/PublicKey

func (ECDSAPublicKey) GetCurve

func (publicKey ECDSAPublicKey) GetCurve() proto.KeyCurve

GetCurve returns the curve for this key

func (*ECDSAPublicKey) ToBytes

func (publicKey *ECDSAPublicKey) ToBytes() ([]byte, error)

ToBytes serializes this key

func (*ECDSAPublicKey) VerifySignature

func (publicKey *ECDSAPublicKey) VerifySignature(data []byte, sig []byte) (bool, error)

VerifySignature hashes the data and verifies the signature.

type ECDSASig

type ECDSASig struct {
	R, S *big.Int
}

ECDSASig holds the r and s values of an ECDSA signature

type PrivateKey

type PrivateKey interface {
	// GetCurve returns the Key curve for this key
	GetCurve() proto.KeyCurve
	// ToBytes Serializes the key
	ToBytes() ([]byte, error)
	// Sign signs the data
	Sign(data []byte) ([]byte, error)
	// GetPublic returns the public component of this key
	GetPublic() (PublicKey, error)
}

PrivateKey is the Private key type

func EcdsaPrivateKeyFromRawBytes

func EcdsaPrivateKeyFromRawBytes(bytes []byte) (PrivateKey, error)

EcdsaPrivateKeyFromRawBytes - from raw bytes, assembles a private key

func UnMarshallPrivateKey

func UnMarshallPrivateKey(b []byte) (PrivateKey, error)

type PublicKey

type PublicKey interface {
	// GetCurve returns the Key curve for this key
	GetCurve() proto.KeyCurve
	// ToBytes Serializes the key
	ToBytes() ([]byte, error)
	// VerifySignature verifies whether the data was signed
	// by this key's private counterpart.
	VerifySignature(data []byte, sig []byte) (bool, error)
}

PublicKey is the Public key type

func PubKeyFromRawBytes

func PubKeyFromRawBytes(bytes []byte) (PublicKey, error)

PubKeyFromRawBytes - Bytes to PublicKey

func UnMarshallPublicKey

func UnMarshallPublicKey(b []byte) (PublicKey, error)

Jump to

Keyboard shortcuts

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