kem

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeySize           = errors.New("invalid key size")
	ErrSeedSize          = errors.New("invalid seed size")
	ErrCiphertext        = errors.New("invalid ciphertext size")
	ErrEncapsulationSeed = errors.New("invalid encapsulation seed size")
)

errors.

Functions

func Generate

func Generate(s Scheme, rand io.Reader) (PrivateKey, PublicKey, error)

Generate derives a key-pair from a seed generated by provided rand.

If rand is nil, crypto/rand is used.

Types

type PrivateKey

type PrivateKey interface {
	Scheme() Scheme

	Equal(PrivateKey) bool

	// Bytes allocates a new slice of bytes with Scheme().PrivateKeySize() length
	// and writes the private key to it.
	Bytes() []byte

	// Decapsulate decapsulates the shared secret from the provided ciphertext.
	Decapsulate(ciphertext []byte) ([]byte, error)
}

PrivateKey represents a KEM private key.

type PublicKey

type PublicKey interface {
	Scheme() Scheme

	Equal(PublicKey) bool

	// Bytes allocates a new slice of bytes with Scheme().PublicKeySize() length
	// and writes the public key to it.
	Bytes() []byte

	// Encapsulate encapsulates a shared secret generated from provided seed.
	Encapsulate(seed []byte) (ciphertext, secret []byte, err error)
}

PublicKey represents a KEM public key.

type Scheme

type Scheme interface {
	// DeriveKey derives a key-pair from a seed.
	DeriveKey(seed []byte) (PrivateKey, PublicKey, error)

	// Unpacks a PublicKey from the provided bytes.
	UnpackPublic(key []byte) (PublicKey, error)

	// Unpacks a PrivateKey from the provided bytes.
	UnpackPrivate(key []byte) (PrivateKey, error)

	// Size of packed public keys.
	PublicKeySize() int

	// Size of packed private keys.
	PrivateKeySize() int

	// Size of encapsulated shared secret.
	CiphertextSize() int

	// Size of shared secret.
	SharedSecretSize() int

	// Size of encapsulation seed.
	EncapsulationSeedSize() int

	// Size of seed.
	SeedSize() int
}

Scheme represents a KEM scheme.

func Frodo640Shake added in v0.2.0

func Frodo640Shake() Scheme

Frodo640Shake returns the variant FrodoKEM-640 with SHAKE.

func Kyber1024 added in v0.2.0

func Kyber1024() Scheme

Kyber1024 returns the Kyber1024 scheme.

func Kyber512 added in v0.2.0

func Kyber512() Scheme

Kyber512 returns the Kyber512 scheme.

func Kyber768 added in v0.2.0

func Kyber768() Scheme

Kyber768 returns the Kyber768 scheme.

Jump to

Keyboard shortcuts

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