crypto

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 12 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
)

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 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.

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.

Jump to

Keyboard shortcuts

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