Documentation ¶
Index ¶
- Constants
- type Dilithium
- func (d *Dilithium) KeyGen(seed []byte) ([]byte, []byte)
- func (d *Dilithium) PackPK(pk PublicKey) []byte
- func (d *Dilithium) PackSK(sk PrivateKey) []byte
- func (d *Dilithium) PackSig(z Vec, h Vec, hc []byte) []byte
- func (d *Dilithium) SIZEPK() int
- func (d *Dilithium) SIZESIG() int
- func (d *Dilithium) SIZESK() int
- func (d *Dilithium) Sign(packedSK, msg []byte) []byte
- func (d *Dilithium) UnpackPK(packedPK []byte) PublicKey
- func (d *Dilithium) UnpackSK(packedSK []byte) PrivateKey
- func (d *Dilithium) UnpackSig(sig []byte) (Vec, Vec, []byte)
- func (d *Dilithium) Verify(packedPK, msg, sig []byte) bool
- type Mat
- type Poly
- type PrivateKey
- type PublicKey
- type Vec
Constants ¶
const ( SEEDBYTES = 32 Dilithium2SizePK = 1312 Dilihtium2SizeSK = 2528 Dilithium2SizeSig = 2420 Dilithium3SizePK = 1952 Dilihtium3SizeSK = 4000 Dilithium3SizeSig = 3293 Dilithium5SizePK = 2592 Dilihtium5SizeSK = 4864 Dilithium5SizeSig = 4595 )
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 d.SIZEX() functions defined in keys.go
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dilithium ¶
type Dilithium struct { Name string // contains filtered or unexported fields }
Dilithium struct defines the internal parameters to be used given a security level
func NewDilithium2 ¶
NewDilithium2 defines a dilithium instance with a light security level. The signature is randomized expect if a false boolean is given as argument.
func NewDilithium3 ¶
NewDilithium3 defines a dilithium instance with a medium security level. The signature is randomized expect if a false boolean is given as argument.
func NewDilithium5 ¶
NewDilithium5 defines a dilithium instance with a very high security level. The signature is randomized expect if a false boolean is given as argument.
func NewDilithiumUnsafe ¶
NewDilithiumUnsafe is a skeleton function to be used for research purposes when wanting to use a dilithium instance with parameters that differ from the recommended ones.
func (*Dilithium) KeyGen ¶
KeyGen 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 (*Dilithium) PackSK ¶
func (d *Dilithium) PackSK(sk PrivateKey) []byte
PackSK packs a PrivateKey into a byte array
func (*Dilithium) SIZEPK ¶
SIZEPK returns the size in bytes of the public key of a dilithium instance
func (*Dilithium) SIZESIG ¶
SIZESIG returns the size in bytes of the signature of a dilithium instance
func (*Dilithium) SIZESK ¶
SIZESK returns the size in bytes of the secret key of a dilithium instance
func (*Dilithium) Sign ¶
Sign produces a signature on the given msg using the secret signing key. The signing key must be given as packed byte array. The message should also be a byte array. The returned signature is packed into a byte array. If an error occurs during the signature process, a nil signature is returned.
func (*Dilithium) UnpackSK ¶
func (d *Dilithium) UnpackSK(packedSK []byte) PrivateKey
UnpackSK reverses the packing operation and outputs a PrivateKey struct
func (*Dilithium) UnpackSig ¶
UnpackSig unpacks a byte array into a signature. If the format is incorrect, nil objects are returned.
func (*Dilithium) Verify ¶
Verify uses the verification key to verify a signature given a msg. The public key and signature must be given as packed byte arrays. The message should be a byte array. The result of the verificatino is returned as a boolean, true is the verificatino succeeded, false otherwise. If an error occurs during the verification, a false is returned.
type PrivateKey ¶
type PrivateKey struct { S1 Vec //L S2 Vec //K Rho [SEEDBYTES]byte Key [SEEDBYTES]byte Tr [SEEDBYTES]byte T0 Vec //K }
PrivateKey holds the sk struct