Documentation ¶
Overview ¶
kyber512 implements the IND-CPA-secure Public Key Encryption scheme Kyber512.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
https://pq-crystals.org/kyber/data/kyber-specification-round3.pdf
Index ¶
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 )
Variables ¶
This section is empty.
Functions ¶
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.
Types ¶
type PrivateKey ¶
type PrivateKey internal.PrivateKey
PrivateKey is the type of Kyber512.CPAPKE private key
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 Kyber512.CPAPKE public key
func (*PublicKey) EncryptTo ¶
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.