Dilithium#

Caution

Currently, crypto-condor uses test vectors for version 3.1 of Dilithium, which is the latest release of the reference implementation. This version differs slightly from the one submitted to the third round of the NIST competition. It also differs from the draft for ML-DSA, the NIST standard. The test vectors are not compatible between versions.

As 3.1 is the latest release, we do not intend to support version 3. Regarding ML-DSA, it is currently a draft, so it is subject to change, and NIST hasn’t released test vectors for it. Once the final version is published with accompanying vectors it will integrated into crypto-condor.

Supported parameters#

Dilithium has three parameter sets: these are supported and defined by Paramset.

enum crypto_condor.primitives.Dilithium.Paramset(value)#

Available parameter sets.

Member Type:

str

Valid values are as follows:

DILITHIUM2 = <Paramset.DILITHIUM2: 'Dilithium2'>#
DILITHIUM3 = <Paramset.DILITHIUM3: 'Dilithium3'>#
DILITHIUM5 = <Paramset.DILITHIUM5: 'Dilithium5'>#

Test a signing function#

crypto_condor.primitives.Dilithium.test_sign(sign, parameter_set)#

Tests a function that signs with Dilithium.

Signs messages with the given function and compares to the expected signature.

Parameters:
  • sign (Sign) – The function to test, must behave like Sign.

  • parameter_set (Paramset) – The parameter set to test the implementation on.

Returns:

The results of testing the given implementation with test vectors generated for the NIST submission.

Return type:

Results

Test a verifying function#

crypto_condor.primitives.Dilithium.test_verify(verify, parameter_set)#

Tests a function that verifies Dilithium signatures.

Parameters:
  • verify (Verify) – The function to test, must behave like Verify.

  • parameter_set (Paramset) – The parameter set to test the implementation on.

Returns:

The results of testing the given implementation with test vectors generated for the NIST submission.

Return type:

Results

Run a wrapper#

Note

Available wrappers are defined by Wrapper.

crypto_condor.primitives.Dilithium.run_wrapper(language, parameter_set, run_sign, run_verify)#

Runs the corresponding wrapper.

Parameters:
  • language (Wrapper) – The language of the wrapper to run.

  • parameter_set (Paramset) – The parameter set to use.

  • run_sign (bool) – Whether to run the signing function.

  • run_verify (bool) – Whether to run the verifying function.

Returns:

A dictionary of results, one for sign, one for verify. The keys are sign and verify.

Return type:

ResultsDict

enum crypto_condor.primitives.Dilithium.Wrapper(value)#

Available wrappers.

Member Type:

str

Valid values are as follows:

PYTHON = <Wrapper.PYTHON: 'Python'>#

Protocols#

protocol crypto_condor.primitives.Dilithium.Sign#

Represents a function that signs messages with Dilithium.

The function to test must conform to __call__().

Classes that implement this protocol must have the following methods / attributes:

__call__(secret_key, message)#

Signs a message with Dilithium.

Parameters:
  • secret_key (bytes) – The key to use for signing.

  • message (bytes) – The message to sign.

Returns:

The signed message, i.e. the concatenation of the signature and message.

Return type:

bytes

protocol crypto_condor.primitives.Dilithium.Verify#

Represents a function that verifies Dilithium signatures.

The function to test must conform to __call__().

Classes that implement this protocol must have the following methods / attributes:

__call__(public_key, signature, message)#

Verifies a Dilithium signature.

Parameters:
  • public_key (bytes) – The public part of the key used to sign the message.

  • signature (bytes) – The signature to verify.

  • message (bytes) – The message that was signed.

Returns:

True if the signature is valid for the given key and message.

Return type:

bool