HQC¶
How to use the crypto_condor.primitives.HQC module to test implementations of
HQC.
Test encapsulation¶
Attention
Testing encapsulation requires a reference implementation to decapsulate the ciphertexts, as encapsulation is a non-deterministic operation. We are working on integrating one.
Test decapsulation¶
- crypto_condor.primitives.HQC.test_decaps(decaps, paramset, *, compliance=True, resilience=False)¶
- Tests decapsulation. - Uses the given function to decapsulate ciphertexts and compares the resulting shared secret with the test vectors. The test passes if the secrets match. - Parameters:
- Keyword Arguments:
- compliance – Whether to use compliance test vectors. 
- resilience – Whether to use resilience test vectors. 
 
- Returns:
- A dictionary of results, with one - Resultsper test vectors file.
- Return type:
 
Test the encapsulation-decapsulation invariant¶
- crypto_condor.primitives.HQC.test_invariant(encaps, decaps, paramset)¶
- Tests the encapsulate then decapsulate invariant. - Encapsulating to a public key then decapsulating with the corresponding secret key should always yield the same share secret. To test this invariant, crypto-condor uses key pairs from test vectors to perform both operations. The test passes if the shared secrets match. - Parameters:
- Returns:
- A dictionary of results with one - Resultsper test vectors file.
- Return type:
 - Notes - Only valid keys from compliance test vectors are used. 
Parameters¶
- enum crypto_condor.primitives.HQC.Paramset(value)¶
- HQC parameter sets. - Member Type:
- str
 - Valid values are as follows: - HQC128 = <Paramset.HQC128: 'HQC-128'>¶
 - HQC192 = <Paramset.HQC192: 'HQC-192'>¶
 - HQC256 = <Paramset.HQC256: 'HQC-256'>¶
 - The - Enumand its members also have the following methods:- property pk_size¶
- The size of the public key in bytes. 
 - property sk_size¶
- The size of the secret key in bytes. 
 - property ct_size¶
- The size of the ciphertext in bytes. 
 - property ss_size¶
- The size of the shared secret in bytes. 
 
Protocols¶
- protocol crypto_condor.primitives.HQC.Encaps¶
- Represents an HQC encapsulation function. - Classes that implement this protocol must have the following methods / attributes: - __call__(pk)¶
- Generates and encapsulates a shared secret. - Parameters:
- pk (bytes) – The public key to encapsulate the secret with. 
- Returns:
- A tuple (ct, ss) containing the shared secret (ss) and ciphertext (ct). 
- Return type:
- tuple[bytes, bytes] 
 
 
- protocol crypto_condor.primitives.HQC.Decaps¶
- Represents an HQC decapsulation function. - Classes that implement this protocol must have the following methods / attributes: - __call__(sk, ct)¶
- Decapsulates a shared secret. - Parameters:
- sk (bytes) – The secret key to use. 
- ct (bytes) – The ciphertext to decapsulate. 
 
- Returns:
- The decapsulated shared secret. 
- Return type:
- bytes