package internal
import "github.com/cloudflare/circl/pke/kyber/kyber768/internal"
Index ¶
- Constants
- func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)
- func PolyDotHat(p *common.Poly, a, b *Vec)
- type Mat
- type PrivateKey
- func (sk *PrivateKey) DecryptTo(pt, ct []byte)
- func (sk *PrivateKey) Equal(other *PrivateKey) bool
- func (sk *PrivateKey) Pack(buf []byte)
- func (sk *PrivateKey) Unpack(buf []byte)
- type PublicKey
- func (pk *PublicKey) EncryptTo(ct, pt, seed []byte)
- func (pk *PublicKey) Pack(buf []byte)
- func (pk *PublicKey) Unpack(buf []byte)
- func (pk *PublicKey) UnpackMLKEM(buf []byte) error
- type Vec
- func (v *Vec) Add(a, b *Vec)
- func (v *Vec) BarrettReduce()
- func (v *Vec) CompressTo(m []byte, d int)
- func (v *Vec) Decompress(m []byte, d int)
- func (v *Vec) DeriveNoise(seed []byte, nonce uint8, eta int)
- func (v *Vec) InvNTT()
- func (v *Vec) NTT()
- func (v *Vec) Normalize()
- func (v *Vec) Pack(buf []byte)
- func (v *Vec) Unpack(buf []byte)
Constants ¶
const ( K = 3 Eta1 = 2 DU = 10 DV = 4 PublicKeySize = 32 + K*common.PolySize PrivateKeySize = K * common.PolySize PlaintextSize = common.PlaintextSize SeedSize = 32 CiphertextSize = 1088 )
Functions ¶
func NewKeyFromSeed ¶
func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)
Derives a new Kyber.CPAPKE keypair from the given seed.
func PolyDotHat ¶
Sets p to the inner product of a and b using "pointwise" multiplication.
See MulHat() and NTT() for a description of the multiplication. Assumes a and b are in Montgomery form. p will be in Montgomery form, and its coefficients will be bounded in absolute value by 2kq. If a and b are not in Montgomery form, then the action is the same as "pointwise" multiplication followed by multiplying by R⁻¹, the inverse of the Montgomery factor.
Types ¶
type Mat ¶
type Mat [K]Vec
A k by k matrix of polynomials.
func (*Mat) Derive ¶
Expands the given seed to the corresponding matrix A or its transpose Aᵀ.
func (*Mat) Transpose ¶
func (m *Mat) Transpose()
Transposes A in place.
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
A Kyber.CPAPKE private key.
func (*PrivateKey) DecryptTo ¶
func (sk *PrivateKey) DecryptTo(pt, ct []byte)
Decrypts ciphertext ct meant for private key sk to plaintext pt.
func (*PrivateKey) Equal ¶
func (sk *PrivateKey) Equal(other *PrivateKey) bool
Returns whether sk equals other.
func (*PrivateKey) Pack ¶
func (sk *PrivateKey) Pack(buf []byte)
Packs the private key to buf.
func (*PrivateKey) Unpack ¶
func (sk *PrivateKey) Unpack(buf []byte)
Unpacks the private key from buf.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
A Kyber.CPAPKE public key.
func (*PublicKey) EncryptTo ¶
Encrypts message pt for the public key to ciphertext ct using randomness from seed.
seed has to be of length SeedSize, pt of PlaintextSize and ct of CiphertextSize.
func (*PublicKey) Pack ¶
Packs the public key to buf.
func (*PublicKey) Unpack ¶
Unpacks the public key from buf.
func (*PublicKey) UnpackMLKEM ¶
Unpacks the public key from buf. Checks if the public key is normalized.
type Vec ¶
A vector of K polynomials
func (*Vec) Add ¶
Sets v to a + b.
func (*Vec) BarrettReduce ¶
func (v *Vec) BarrettReduce()
Almost normalizes coefficients in-place.
Ensures each coefficient is in {0, …, q}.
func (*Vec) CompressTo ¶
Writes Compress_q(v, d) to m.
Assumes v is normalized and d is in {3, 4, 5, 10, 11}.
func (*Vec) Decompress ¶
Set v to Decompress_q(m, 1).
Assumes d is in {3, 4, 5, 10, 11}. v will be normalized.
func (*Vec) DeriveNoise ¶
Samples v[i] from a centered binomial distribution with given η, seed and nonce+i.
Essentially CBD_η(PRF(seed, nonce+i)) from the specification.
func (*Vec) InvNTT ¶
func (v *Vec) InvNTT()
Applies in-place inverse NTT(). See Poly.InvNTT() for assumptions.
func (*Vec) NTT ¶
func (v *Vec) NTT()
Applies in-place forward NTT(). See Poly.NTT() for assumptions.
func (*Vec) Normalize ¶
func (v *Vec) Normalize()
Normalizes coefficients in-place.
Ensures each coefficient is in {0, …, q-1}.
func (*Vec) Pack ¶
Packs v into buf, which must be of length K*PolySize.
func (*Vec) Unpack ¶
Unpacks v from buf which must be of length K*PolySize.
Source Files ¶
cpapke.go mat.go params.go vec.go
- Version
- v1.6.1 (latest)
- Published
- Apr 9, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 22 hours ago –
Tools for package owners.