Documentation ¶
Overview ¶
mode2aes implements the CRYSTALS-Dilithium signature scheme Dilithium2-AES as submitted to round2 of the NIST PQC competition and described in
https://pq-crystals.org/dilithium/data/dilithium-specification-round2.pdf
Index ¶
- Constants
- func GenerateKey(rand io.Reader) (*PublicKey, *PrivateKey, error)
- func NewKeyFromExpandedSeed(seed *[96]byte) (*PublicKey, *PrivateKey)
- func NewKeyFromSeed(seed *[SeedSize]byte) (*PublicKey, *PrivateKey)
- func SignTo(sk *PrivateKey, msg []byte, signature []byte)
- func Verify(pk *PublicKey, msg []byte, signature []byte) bool
- type PrivateKey
- func (sk *PrivateKey) Bytes() []byte
- func (sk *PrivateKey) Equal(other crypto.PrivateKey) bool
- func (sk *PrivateKey) MarshalBinary() ([]byte, error)
- func (sk *PrivateKey) Pack(buf *[PrivateKeySize]byte)
- func (sk *PrivateKey) Public() crypto.PublicKey
- func (sk *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error)
- func (sk *PrivateKey) UnmarshalBinary(data []byte) error
- func (sk *PrivateKey) Unpack(buf *[PrivateKeySize]byte)
- type PublicKey
- func (pk *PublicKey) Bytes() []byte
- func (pk *PublicKey) Equal(other crypto.PublicKey) bool
- func (pk *PublicKey) MarshalBinary() ([]byte, error)
- func (pk *PublicKey) Pack(buf *[PublicKeySize]byte)
- func (pk *PublicKey) UnmarshalBinary(data []byte) error
- func (pk *PublicKey) Unpack(buf *[PublicKeySize]byte)
Constants ¶
const ( // Size of seed for NewKeyFromSeed SeedSize = common.SeedSize // Size of a packed PublicKey PublicKeySize = internal.PublicKeySize // Size of a packed PrivateKey PrivateKeySize = internal.PrivateKeySize // Size of a signature SignatureSize = internal.SignatureSize )
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 NewKeyFromExpandedSeed ¶
func NewKeyFromExpandedSeed(seed *[96]byte) (*PublicKey, *PrivateKey)
NewKeyFromExpandedSeed derives a public/private key pair using the given expanded seed.
Use NewKeyFromSeed instead of this function. This function is only exposed to generate the NIST KAT test vectors.
func NewKeyFromSeed ¶
func NewKeyFromSeed(seed *[SeedSize]byte) (*PublicKey, *PrivateKey)
NewKeyFromSeed derives a public/private key pair using the given seed.
func SignTo ¶
func SignTo(sk *PrivateKey, msg []byte, signature []byte)
SignTo signs the given message and writes the signature into signature. It will panic if signature is not of length at least SignatureSize.
Types ¶
type PrivateKey ¶
type PrivateKey internal.PrivateKey
PrivateKey is the type of Dilithium2-AES private key
func (*PrivateKey) Equal ¶
func (sk *PrivateKey) Equal(other crypto.PrivateKey) bool
Equal returns whether the two private keys equal.
func (*PrivateKey) MarshalBinary ¶
func (sk *PrivateKey) MarshalBinary() ([]byte, error)
Packs the private key.
func (*PrivateKey) Pack ¶
func (sk *PrivateKey) Pack(buf *[PrivateKeySize]byte)
Packs the private key into buf.
func (*PrivateKey) Public ¶
func (sk *PrivateKey) Public() crypto.PublicKey
Computes the public key corresponding to this private key.
Returns a *PublicKey. The type crypto.PublicKey is used to make PrivateKey implement the crypto.Signer interface.
func (*PrivateKey) Sign ¶
func (sk *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ( signature []byte, err error)
Sign signs the given message.
opts.HashFunc() must return zero, which can be achieved by passing crypto.Hash(0) for opts. rand is ignored. Will only return an error if opts.HashFunc() is non-zero.
This function is used to make PrivateKey implement the crypto.Signer interface. The package-level SignTo function might be more convenient to use.
func (*PrivateKey) UnmarshalBinary ¶
func (sk *PrivateKey) UnmarshalBinary(data []byte) error
Unpacks the private key from data.
func (*PrivateKey) Unpack ¶
func (sk *PrivateKey) Unpack(buf *[PrivateKeySize]byte)
Sets sk to the private key encoded in buf.
type PublicKey ¶
PublicKey is the type of Dilithium2-AES public key
func (*PublicKey) MarshalBinary ¶
Packs the public key.
func (*PublicKey) Pack ¶
func (pk *PublicKey) Pack(buf *[PublicKeySize]byte)
Packs the public key into buf.
func (*PublicKey) UnmarshalBinary ¶
Unpacks the public key from data.
func (*PublicKey) Unpack ¶
func (pk *PublicKey) Unpack(buf *[PublicKeySize]byte)
Sets pk to the public key encoded in buf.