crypto

package
v0.0.4-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Libp2pKeyTypeCurve25519  = pb.KeyType(4)
	Curve25519PrivateKeySize = 32
	Curve25519PublicKeySize  = 32
)
View Source
const (
	// Length of nacl nonce
	NonceBytes = 24

	// Length of nacl ephemeral public key
	EphemeralPublicKeyBytes = 32
)
View Source
const (
	Libp2pKeyTypeNova  = pb.KeyType(5)
	NovaPrivateKeySize = 32
	NovaPublicKeySize  = 32
)

Variables

View Source
var ErrBoxDecryption = errors.New("failed to decrypt curve25519")

ErrBoxDecryption Nacl box decryption failed

View Source
var ErrSigNoop = errors.New("curve25519 keys cannot do signing or verification")

Functions

func Curve25519PrivateKeyFromEd25519

func Curve25519PrivateKeyFromEd25519(privKey crypto.PrivKey) (crypto.PrivKey, error)

func Curve25519PublicKeyFromEd25519

func Curve25519PublicKeyFromEd25519(pubKey crypto.PubKey) (crypto.PubKey, error)

func Decrypt

func Decrypt(privKey crypto.PrivKey, ciphertext []byte) ([]byte, error)

Decrypt decrypts an output using a private key.

func Encrypt

func Encrypt(pubKey crypto.PubKey, plaintext []byte) ([]byte, error)

Encrypt encrypts an output with the public key.

func GenerateCurve25519Key

func GenerateCurve25519Key(src io.Reader) (crypto.PrivKey, crypto.PubKey, error)

GenerateCurve25519Key generates a new Curve25519 private and public key pair.

func GenerateNovaKey

func GenerateNovaKey(src io.Reader) (crypto.PrivKey, crypto.PubKey, error)

GenerateNovaKey generates a new Nova private and public key pair.

func NewCurve25519KeyFromSeed

func NewCurve25519KeyFromSeed(seed [32]byte) (crypto.PrivKey, crypto.PubKey, error)

func NewNovaKeyFromSeed

func NewNovaKeyFromSeed(seed [32]byte) (crypto.PrivKey, crypto.PubKey, error)

NewNovaKeyFromSeed deterministically derives a nova private key from a seed

func UnmarshalCurve25519PrivateKey

func UnmarshalCurve25519PrivateKey(data []byte) (crypto.PrivKey, error)

UnmarshalCurve25519PrivateKey returns a private key from input bytes.

func UnmarshalCurve25519PublicKey

func UnmarshalCurve25519PublicKey(data []byte) (crypto.PubKey, error)

UnmarshalCurve25519PublicKey returns a public key from input bytes.

func UnmarshalNovaPrivateKey

func UnmarshalNovaPrivateKey(data []byte) (crypto.PrivKey, error)

UnmarshalNovaPrivateKey returns a private key from input bytes.

func UnmarshalNovaPublicKey

func UnmarshalNovaPublicKey(data []byte) (crypto.PubKey, error)

UnmarshalNovaPublicKey returns a public key from input bytes.

Types

type Curve25519PrivateKey

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

Curve25519PrivateKey is a Curve25519 private key.

func (*Curve25519PrivateKey) Decrypt

func (k *Curve25519PrivateKey) Decrypt(cipherText []byte) ([]byte, error)

Decrypt attempts to decrypt ciphertext using the private key.

func (*Curve25519PrivateKey) Equals

func (k *Curve25519PrivateKey) Equals(o crypto.Key) bool

Equals compares two Curve25519 private keys.

func (*Curve25519PrivateKey) GetPublic

func (k *Curve25519PrivateKey) GetPublic() crypto.PubKey

GetPublic returns an Curve25519 public key from a private key.

func (*Curve25519PrivateKey) Raw

func (k *Curve25519PrivateKey) Raw() ([]byte, error)

Raw private key bytes.

func (*Curve25519PrivateKey) Sign

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

Sign returns a signature from an input message. This is a noop.

func (*Curve25519PrivateKey) Type

func (k *Curve25519PrivateKey) Type() pb.KeyType

Type of the private key (Curve25519).

type Curve25519PublicKey

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

Curve25519PublicKey is a Curve25519 public key.

func (*Curve25519PublicKey) Encrypt

func (k *Curve25519PublicKey) Encrypt(plaintext []byte) ([]byte, error)

Encrypt encrypts the plaintext using the public key and returns the ciphertext.

func (*Curve25519PublicKey) Equals

func (k *Curve25519PublicKey) Equals(o crypto.Key) bool

Equals compares two Curve25519 public keys.

func (*Curve25519PublicKey) Raw

func (k *Curve25519PublicKey) Raw() ([]byte, error)

Raw public key bytes.

func (*Curve25519PublicKey) Type

func (k *Curve25519PublicKey) Type() pb.KeyType

Type of the public key (Curve25519).

func (*Curve25519PublicKey) Verify

func (k *Curve25519PublicKey) Verify(data []byte, sig []byte) (bool, error)

Verify checks a signature agains the input data. This is a noop.

type NovaPrivateKey

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

NovaPrivateKey is a Vesta curve private key in the nova proving system.

func (*NovaPrivateKey) Equals

func (k *NovaPrivateKey) Equals(o crypto.Key) bool

Equals compares two Nova private keys.

func (*NovaPrivateKey) GetPublic

func (k *NovaPrivateKey) GetPublic() crypto.PubKey

GetPublic returns an Nova public key from a private key.

func (*NovaPrivateKey) Raw

func (k *NovaPrivateKey) Raw() ([]byte, error)

Raw private key bytes.

func (*NovaPrivateKey) Sign

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

Sign returns a signature from an input message.

func (*NovaPrivateKey) Type

func (k *NovaPrivateKey) Type() pb.KeyType

Type of the private key (Curve25519).

type NovaPublicKey

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

NovaPublicKey is a Vesta curve public key in the nova proving system.

func (*NovaPublicKey) Equals

func (k *NovaPublicKey) Equals(o crypto.Key) bool

Equals compares two Nova public keys.

func (*NovaPublicKey) Raw

func (k *NovaPublicKey) Raw() ([]byte, error)

Raw public key bytes.

func (*NovaPublicKey) Type

func (k *NovaPublicKey) Type() pb.KeyType

Type of the public key (Nova).

func (*NovaPublicKey) Verify

func (k *NovaPublicKey) Verify(data []byte, sig []byte) (bool, error)

Verify checks a signature agains the input data.

Jump to

Keyboard shortcuts

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