sntrup

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

This package provide the Streamlined NTRU Prime KEM.

Index

Constants

View Source
const (
	// PublicKeySize is the public key size in bytes.
	PublicKeySize = sntrup.PublicKeySize

	// PrivateKeySize is the private key size in bytes.
	PrivateKeySize = sntrup.PrivateKeySize

	// SharedKeySize is the size of the shared key in bytes.
	SharedKeySize = sntrup.SharedKeySize

	// CiphertextSize is the size of the ciphertext in bytes.
	CiphertextSize = sntrup.CiphertextSize

	// KeySeedSize is currently set to 32 but should be adjusted
	// to our security bits.
	KeySeedSize = 32

	// EncapsulationSeedSize is currently set to 32 but should be adjusted
	// to our security bits.
	EncapsulationSeedSize = 32
)

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair(rng io.Reader) (*PublicKey, *PrivateKey, error)

GenerateKeyPair generates public and private keys using entropy from rand. If rand is nil, hpqc/rand.Reader will be used.

func NewKeyFromSeed

func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)

NewKeyFromSeed derives a public/private keypair deterministically from the given seed.

Panics if seed is not of length KeySeedSize.

func Scheme

func Scheme() kem.Scheme

Scheme returns a KEM interface.

Types

type PrivateKey

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

Private key of a hybrid KEM.

func (*PrivateKey) DecapsulateTo

func (sk *PrivateKey) DecapsulateTo(ss, ct []byte)

DecapsulateTo computes the shared key which is encapsulated in ct for the private key.

Panics if ct or ss are not of length CiphertextSize and SharedKeySize respectively.

func (*PrivateKey) Equal

func (sk *PrivateKey) Equal(other kem.PrivateKey) bool

func (*PrivateKey) MarshalBinary

func (sk *PrivateKey) MarshalBinary() (data []byte, err error)

func (*PrivateKey) Public

func (sk *PrivateKey) Public() kem.PublicKey

func (*PrivateKey) Scheme

func (sk *PrivateKey) Scheme() kem.Scheme

type PublicKey

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

Public key of a hybrid KEM.

func (*PublicKey) EncapsulateTo

func (pk *PublicKey) EncapsulateTo(ct, ss []byte, seed []byte)

EncapsulateTo generates a shared key and ciphertext that contains it for the public key using randomness from seed and writes the shared key to ss and ciphertext to ct.

Panics if ss, ct or seed are not of length SharedKeySize, CiphertextSize and EncapsulationSeedSize respectively.

seed may be nil, in which case hpqc/rand.Reader is used to generate one.

func (*PublicKey) Equal

func (pk *PublicKey) Equal(other kem.PublicKey) bool

func (*PublicKey) MarshalBinary

func (pk *PublicKey) MarshalBinary() (data []byte, err error)

func (*PublicKey) MarshalText added in v0.0.3

func (pk *PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) Scheme

func (pk *PublicKey) Scheme() kem.Scheme

Jump to

Keyboard shortcuts

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