Skip to content

Conversation

@drorr-cr
Copy link

No description provided.

@drorr-cr drorr-cr requested a review from NoamK-CR December 16, 2025 15:56

namespace lbcrypto {

inline std::vector<uint32_t> GenerateRandomSeed(size_t size) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use the existing implementation if it isn't too difficult.


// 2. Absorb the seed (inject entropy)
// We cast the vector to bytes for absorption
if (!seed.empty()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to assert seed.length() == 32

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

for (uint16_t seg_i = 0; seg_i < 2048; ++seg_i){
std::unique_ptr<PRNG> shake128engine = std::make_unique<Shake128Engine>(m_seed,m_salt,qIndex,seg_i);

std::uniform_int_distribution<uint32_t> dist(DUG_CHUNK_MIN, DUG_CHUNK_MAX);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 174 to 178
// Convert 32-bit word to 4 bytes (little-endian)
digest[4*i] = static_cast<uint8_t>(word & 0xFF);
digest[4*i + 1] = static_cast<uint8_t>((word >> 8) & 0xFF);
digest[4*i + 2] = static_cast<uint8_t>((word >> 16) & 0xFF);
digest[4*i + 3] = static_cast<uint8_t>((word >> 24) & 0xFF);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, you can do rejection here, or directly construct 42 words

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// -----------------------------------------------------------------------------
// Function: extract_32_words_from_digest
// -----------------------------------------------------------------------------
inline std::array<int32_t, 32> extract_32_words_from_digest(const std::array<uint8_t, 168>& digest, uint32_t q) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if this works:

Suggested change
inline std::array<int32_t, 32> extract_32_words_from_digest(const std::array<uint8_t, 168>& digest, uint32_t q) {
template <typename VecType>
inline std::array<int32_t, 32> extract_32_words_from_digest(const std::array<uint8_t, 168>& digest, VecType::Integer &q) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

private:

protected:
typename VecType::Integer m_modulus{};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this protected, others private

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 56 to 57
template <typename VecType>
class DiscreteUniformGeneratorCRImpl : public DiscreteUniformGeneratorImpl<VecType> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <typename VecType>
class DiscreteUniformGeneratorCRImpl : public DiscreteUniformGeneratorImpl<VecType> {
class DiscreteUniformGeneratorCRImpl : public DiscreteUniformGeneratorImpl<NativeVector> {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants