Documentation ¶
Index ¶
- Constants
- type Kyber
- func (k *Kyber) Decaps(packedSK, c []byte) []byte
- func (k *Kyber) Decrypt(packedSK, c []byte) []byte
- func (k *Kyber) Encaps(packedPK, coins []byte) ([]byte, []byte)
- func (k *Kyber) Encrypt(packedPK, msg, r []byte) []byte
- func (k *Kyber) KeyGen(seed []byte) ([]byte, []byte)
- func (k *Kyber) PKEKeyGen(seed []byte) ([]byte, []byte)
- func (k *Kyber) PackPK(pk *PublicKey) []byte
- func (k *Kyber) PackPKESK(sk *PKEPrivateKey) []byte
- func (k *Kyber) PackSK(sk *PrivateKey) []byte
- func (k *Kyber) SIZEC() int
- func (k *Kyber) SIZEPK() int
- func (k *Kyber) SIZEPKESK() int
- func (k *Kyber) SIZESK() int
- func (k *Kyber) UnpackPK(packedPK []byte) *PublicKey
- func (k *Kyber) UnpackPKESK(psk []byte) *PKEPrivateKey
- func (k *Kyber) UnpackSK(psk []byte) *PrivateKey
- type Mat
- type PKEPrivateKey
- type Poly
- type PrivateKey
- type PublicKey
- type Vec
Constants ¶
const ( SIZEZ = 32 SEEDBYTES = 32 Kyber512SizePK = 800 Kyber512SizeSK = 1632 Kyber512SizePKESK = 768 Kyber512SizeC = 768 //2*320 + 128 Kyber768SizePK = 1184 Kyber768SizeSK = 2400 Kyber768SizePKESK = 1152 Kyber768SizeC = 1088 //3*320 + 128 Kyber1024SizePK = 1568 Kyber1024SizeSK = 3168 Kyber1024SizePKESK = 1536 Kyber1024SizeC = 1568 //4*352 + 160 )
The first block of constants define internal parameters. SEEDBYTES holds the lenght in byte of the random number to give as input, if wanted. The remaining constants are exported to allow for fixed-lenght array instantiation. For a given security level, the consts are the same as the output of the k.SIZEX() functions defined in keys.go
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kyber ¶
type Kyber struct { Name string // contains filtered or unexported fields }
Kyber struct defines the internal parameters to be used given a security level
func NewKyber1024 ¶
func NewKyber1024() *Kyber
NewKyber1024 defines a kyber instance with a very high security level.
func NewKyber512 ¶
func NewKyber512() *Kyber
NewKyber512 defines a kyber instance with a light security level.
func NewKyber768 ¶
func NewKyber768() *Kyber
NewKyber768 defines a kyber instance with a medium security level.
func NewKyberUnsafe ¶
NewKyberUnsafe is a skeleton function to be used for research purposes when wanting to use a kyber instance with parameters that differ from the recommended ones.
func (*Kyber) Decaps ¶
Decaps decryps a ciphertext given a secret key and checks its validity. The secret key and ciphertext must be give as packed byte array. The recovered shared secret is returned as byte array. If an error occurs durirng the decapsulation process, a nil shared secret is returned.
func (*Kyber) Decrypt ¶
Decrypt decrypts a ciphertext given a secret key. The secret key and ciphertext must be give as packed byte array. The recovered message is returned as byte array. If an error occurs durirng the decryption process (wrong key format for example), a nil message is returned.
func (*Kyber) Encaps ¶
Encaps generates a shared secret and the encryption of said shared secret using a given public key. A 32 byte long seed can be given as argument (coins). If a nil seed is given, the seed is generated using Go crypto's random number generator. The shared secret and ciphertext returned are packed into byte arrays. If an error occurs during the encaps process, nil arrays are returned.
func (*Kyber) Encrypt ¶
Encrypt generates the encryption of a message using a public key. A 32 byte long seed can be given as argument (r). If a nil seed is given, the seed is generated using Go crypto's random number generator. The ciphertext returned is packed into a byte array. If an error occurs during the encrpytion process, a nil array is returned.
func (*Kyber) KeyGen ¶
KeyGen creates a public and private key pair. A 64 byte long seed can be given as argument. If a nil seed is given, the seed is generated using Go crypto's random number generator. The keys returned are packed into byte arrays.
func (*Kyber) PKEKeyGen ¶
PKEKeyGen creates a public and private key pair. A 32 byte long seed can be given as argument. If a nil seed is given, the seed is generated using Go crypto's random number generator. The keys returned are packed into byte arrays.
func (*Kyber) PackPKESK ¶
func (k *Kyber) PackPKESK(sk *PKEPrivateKey) []byte
PackPKESK packs a PKE PrivateKey into a byte array
func (*Kyber) PackSK ¶
func (k *Kyber) PackSK(sk *PrivateKey) []byte
PackSK packs a PrivateKey into a byte array
func (*Kyber) SIZEPKESK ¶
SIZEPKESK returns the size in bytes of the PKE secret key of a kyber instance
func (*Kyber) UnpackPKESK ¶
func (k *Kyber) UnpackPKESK(psk []byte) *PKEPrivateKey
UnpackPKESK reverses the packing operation and outputs a PKEPrivateKey struct
func (*Kyber) UnpackSK ¶
func (k *Kyber) UnpackSK(psk []byte) *PrivateKey
UnpackSK reverses the packing operation and outputs a PrivateKey struct
type PKEPrivateKey ¶
type PKEPrivateKey struct {
S Vec //NTT(s)
}
PKEPrivateKey holds the ak strct for Kyber's PKE scheme
type PrivateKey ¶
PrivateKey holds the sk struct