Botan 3.6.1
Crypto and TLS for C&
|
std::pair< DilithiumSeedRho, DilithiumPolyVec > Botan::Dilithium_Algos::decode_public_key | ( | StrongSpan< const DilithiumSerializedPublicKey > | pk, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 23 (pkDecode)
Definition at line 345 of file dilithium_algos.cpp.
References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::copy(), Botan::BufferSlicer::empty(), Botan::DilithiumConstants::k(), Botan::DilithiumConstants::public_key_bytes(), Botan::rho(), Botan::DilithiumConstants::SEED_RHO_BYTES, and Botan::StrongSpan< T >::size().
Referenced by Botan::Dilithium_PublicKeyInternal::decode().
std::optional< std::tuple< DilithiumCommitmentHash, DilithiumPolyVec, DilithiumPolyVec > > Botan::Dilithium_Algos::decode_signature | ( | StrongSpan< const DilithiumSerializedSignature > | sig, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 27 (sigDecode)
Definition at line 493 of file dilithium_algos.cpp.
References BOTAN_ASSERT_NOMSG, Botan::DilithiumConstants::commitment_hash_full_bytes(), Botan::BufferSlicer::copy(), Botan::BufferSlicer::empty(), Botan::DilithiumConstants::k(), Botan::DilithiumConstants::l(), Botan::DilithiumConstants::omega(), Botan::BufferSlicer::remaining(), and Botan::DilithiumConstants::signature_bytes().
std::pair< DilithiumPolyVec, DilithiumPolyVec > Botan::Dilithium_Algos::decompose | ( | const DilithiumPolyVec & | vec, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 36 (Decompose) on a polynomial vector
Algorithms 37 (HighBits) and 38 (LowBits) are not implemented explicitly, simply use the first (HighBits) and second (LowBits) element of the result.
Definition at line 819 of file dilithium_algos.cpp.
References BOTAN_ASSERT_UNREACHABLE, and Botan::DilithiumConstants::gamma2().
DilithiumSerializedCommitment Botan::Dilithium_Algos::encode_commitment | ( | const DilithiumPolyVec & | w1, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 28 (w1Encode)
Definition at line 518 of file dilithium_algos.cpp.
References Botan::DilithiumConstants::serialized_commitment_bytes().
DilithiumSerializedPublicKey Botan::Dilithium_Algos::encode_public_key | ( | StrongSpan< const DilithiumSeedRho > | rho, |
const DilithiumPolyVec & | t1, | ||
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 22 (pkEncode)
Definition at line 327 of file dilithium_algos.cpp.
References Botan::BufferStuffer::append(), BOTAN_ASSERT_NOMSG, Botan::BufferStuffer::full(), Botan::DilithiumConstants::public_key_bytes(), and Botan::rho().
Referenced by Botan::Dilithium_PublicKeyInternal::raw_pk().
DilithiumSerializedSignature Botan::Dilithium_Algos::encode_signature | ( | StrongSpan< const DilithiumCommitmentHash > | c, |
const DilithiumPolyVec & | response, | ||
const DilithiumPolyVec & | hint, | ||
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 26 (sigEncode)
Definition at line 474 of file dilithium_algos.cpp.
References Botan::BufferStuffer::append(), and Botan::DilithiumConstants::signature_bytes().
DilithiumPolyMatNTT Botan::Dilithium_Algos::expand_A | ( | StrongSpan< const DilithiumSeedRho > | rho, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 32 (ExpandA)
Note that the actual concatenation of rho, s and r is done downstream in the sampling function.
Definition at line 695 of file dilithium_algos.cpp.
References Botan::DilithiumConstants::k(), Botan::DilithiumConstants::l(), Botan::load_le(), and Botan::rho().
Referenced by expand_keypair().
DilithiumInternalKeypair Botan::Dilithium_Algos::expand_keypair | ( | DilithiumSeedRandomness | xi, |
DilithiumConstants | mode ) |
NIST FIPS 204, Algorithm 6 (ML-DSA.KeyGen_internal)
Lines 5-7 are extracted into a separate function, see above. The key encoding is deferred until the user explicitly invokes the encoding.
Definition at line 665 of file dilithium_algos.cpp.
References expand_A(), expand_s(), Botan::CT::poison(), Botan::rho(), Botan::DilithiumConstants::symmetric_primitives(), and Botan::CT::unpoison().
Referenced by Botan::ML_DSA_Expanding_Keypair_Codec::decode_keypair(), and Botan::Dilithium_PrivateKey::Dilithium_PrivateKey().
DilithiumPolyVec Botan::Dilithium_Algos::expand_mask | ( | StrongSpan< const DilithiumSeedRhoPrime > | rhoprime, |
uint16_t | nonce, | ||
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 34 (ExpandMask)
Definition at line 728 of file dilithium_algos.cpp.
References Botan::Dilithium_Symmetric_Primitives_Base::H(), Botan::DilithiumConstants::l(), and Botan::DilithiumConstants::symmetric_primitives().
std::pair< DilithiumPolyVec, DilithiumPolyVec > Botan::Dilithium_Algos::expand_s | ( | StrongSpan< const DilithiumSeedRhoPrime > | rhoprime, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 33 (ExpandS)
Definition at line 708 of file dilithium_algos.cpp.
References Botan::DilithiumConstants::k(), and Botan::DilithiumConstants::l().
Referenced by expand_keypair().
bool Botan::Dilithium_Algos::infinity_norm_within_bound | ( | const DilithiumPolyVec & | vec, |
size_t | bound ) |
Definition at line 936 of file dilithium_algos.cpp.
References BOTAN_DEBUG_ASSERT, Botan::CT::driveby_unpoison(), and Botan::DilithiumConstants::Q.
DilithiumPolyVec Botan::Dilithium_Algos::make_hint | ( | const DilithiumPolyVec & | z, |
const DilithiumPolyVec & | r, | ||
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 39 (MakeHint)
MakeHint is specified per value in FIPS 204. This implements the algorithm for the entire polynomial vector. The specified algorithm is equivalent to the inner lambda.
TODO: This is taken from the reference implementation. We should implement it as specified in the spec, and see if that has any performance impact.
Definition at line 843 of file dilithium_algos.cpp.
References BOTAN_DEBUG_ASSERT, Botan::CRYSTALS::PolynomialVector< Trait, D >::ct_validate_value_range(), Botan::DilithiumConstants::gamma2(), make_hint(), Botan::DilithiumConstants::Q, and Botan::CRYSTALS::PolynomialVector< Trait, D >::size().
Referenced by make_hint().
std::pair< DilithiumPolyVec, DilithiumPolyVec > Botan::Dilithium_Algos::power2round | ( | const DilithiumPolyVec & | vec | ) |
NIST FIPS 204, Algorithm 35 (Power2Round)
In contrast to the spec, this function takes a polynomial vector and performs the power2round operation on each coefficient in the vector. The actual Algorithm 35 as specified is actually just the inner lambda.
Definition at line 746 of file dilithium_algos.cpp.
References Botan::DilithiumConstants::D, power2round(), and Botan::CRYSTALS::PolynomialVector< Trait, D >::size().
Referenced by power2round().
DilithiumPoly Botan::Dilithium_Algos::sample_in_ball | ( | StrongSpan< const DilithiumCommitmentHash > | seed, |
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 29 (SampleInBall)
Definition at line 532 of file dilithium_algos.cpp.
References BOTAN_DEBUG_ASSERT, Botan::CRYSTALS::Polynomial< Trait, D >::ct_validate_value_range(), Botan::Dilithium_Symmetric_Primitives_Base::H(), Botan::CRYSTALS::Polynomial< Trait, D >::hamming_weight(), Botan::load_le(), Botan::CRYSTALS::Polynomial< Trait, D >::size(), Botan::DilithiumConstants::symmetric_primitives(), and Botan::DilithiumConstants::tau().
void Botan::Dilithium_Algos::use_hint | ( | DilithiumPolyVec & | vec, |
const DilithiumPolyVec & | hints, | ||
const DilithiumConstants & | mode ) |
NIST FIPS 204, Algorithm 40 (UseHint)
UseHint is specified per value in FIPS 204. This implements the algorithm for the entire polynomial vector. The specified algorithm is equivalent to the inner lambdas of 'use_hint_with_coefficients'.
Definition at line 918 of file dilithium_algos.cpp.
References BOTAN_DEBUG_ASSERT, Botan::CRYSTALS::PolynomialVector< Trait, D >::ct_validate_value_range(), Botan::DilithiumConstants::gamma2(), Botan::DilithiumConstants::Q, and Botan::CRYSTALS::PolynomialVector< Trait, D >::size().