...

Package kyber1024

import "github.com/cloudflare/circl/pke/kyber/kyber1024"
Overview
Index
Subdirectories

Overview ▾

kyber1024 implements the IND-CPA-secure Public Key Encryption scheme Kyber1024.CPAPKE as submitted to round 3 of the NIST PQC competition and described in

https://pq-crystals.org/kyber/data/kyber-specification-round3.pdf

Constants

const (
    // Size of seed for NewKeyFromSeed
    KeySeedSize = internal.SeedSize

    // Size of seed for EncryptTo
    EncryptionSeedSize = internal.SeedSize

    // Size of a packed PublicKey
    PublicKeySize = internal.PublicKeySize

    // Size of a packed PrivateKey
    PrivateKeySize = internal.PrivateKeySize

    // Size of a ciphertext
    CiphertextSize = internal.CiphertextSize

    // Size of a plaintext
    PlaintextSize = internal.PlaintextSize
)

func GenerateKey

func GenerateKey(rand io.Reader) (*PublicKey, *PrivateKey, error)

GenerateKey generates a public/private key pair using entropy from rand. If rand is nil, crypto/rand.Reader will be used.

func NewKeyFromSeed

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

NewKeyFromSeed derives a public/private key pair using the given seed.

Panics if seed is not of length KeySeedSize.

type PrivateKey

PrivateKey is the type of Kyber1024.CPAPKE private key

type PrivateKey internal.PrivateKey

func (*PrivateKey) DecryptTo

func (sk *PrivateKey) DecryptTo(pt []byte, ct []byte)

DecryptTo decrypts message ct for the private key and writes the plaintext to pt.

This function panics if the lengths of ct and pt are not CiphertextSize and PlaintextSize respectively.

func (*PrivateKey) Equal

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

Returns whether the two private keys are equal.

func (*PrivateKey) Pack

func (sk *PrivateKey) Pack(buf []byte)

Packs sk into the given buffer.

Panics if buf is not of length PrivateKeySize.

func (*PrivateKey) Unpack

func (sk *PrivateKey) Unpack(buf []byte)

Unpacks sk from the given buffer.

Panics if buf is not of length PrivateKeySize.

type PublicKey

PublicKey is the type of Kyber1024.CPAPKE public key

type PublicKey internal.PublicKey

func (*PublicKey) EncryptTo

func (pk *PublicKey) EncryptTo(ct []byte, pt []byte, seed []byte)

EncryptTo encrypts message pt for the public key and writes the ciphertext to ct using randomness from seed.

This function panics if the lengths of pt, seed, and ct are not PlaintextSize, EncryptionSeedSize, and CiphertextSize respectively.

func (*PublicKey) Pack

func (pk *PublicKey) Pack(buf []byte)

Packs pk into the given buffer.

Panics if buf is not of length PublicKeySize.

func (*PublicKey) Unpack

func (pk *PublicKey) Unpack(buf []byte)

Unpacks pk from the given buffer.

Panics if buf is not of length PublicKeySize.

Subdirectories

Name Synopsis
..