Documentation ¶
Index ¶
- Constants
- func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)
- func PolyDotHat(p *common.Poly, a, b *Vec)
- type Mat
- type PrivateKey
- type PublicKey
- 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 = 2 Eta1 = 3 DU = 10 DV = 4 PublicKeySize = 32 + K*common.PolySize PrivateKeySize = K * common.PolySize PlaintextSize = common.PlaintextSize SeedSize = 32 CiphertextSize = 768 )
Variables ¶
This section is empty.
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 ¶
A k by k matrix of polynomials.
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) 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.
type Vec ¶
A vector of K polynomials
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}.