Check at compile time that the packing moduli are odd
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- cryptography
Research direction
Read the modulus constants in src/rings.rs and the existing compile time assertions in src/cs.rs. Add oddness assertions for CS_MODULUS and KAHE_MODULUS in src/rings.rs, plus HVC_MODULUS in src/cs.rs; done when all three checks compile and reject an even modulus with the stated message.
Written by the indexing model from the issue text.
Description
Since #24, polynomials are packed as centered representatives in [-(m-1)/2, (m-1)/2], and poly_packed_len/poly_packed_len64 compute the bound as modulus / 2. Both are only exact for an odd modulus, as their doc comments say, but nothing checks it.
With an even modulus, packing still round-trips, but every coefficient takes ⌈log₂(m+1)⌉ bits, which is one bit more than needed when m is a power of two. The tests would catch that for the real moduli. A compile-time check next to the constants in src/rings.rs would document the precondition and reject such a change with a clear message:
const _: () = assert!(CS_MODULUS % 2 == 1, "centered packing needs an odd modulus");
const _: () = assert!(KAHE_MODULUS % 2 == 1, "centered packing needs an odd modulus");
plus the same for HVC_MODULUS, which comes from chipmunk_code, in src/cs.rs.
Related checks:
src/cs.rsalready asserts at compile time thatCS_MODULUSandHVC_MODULUSare prime, for the batch soundness argument. That rules out every even modulus except 2, but it says nothing about packing and doesn't coverKAHE_MODULUS.- #41 adds a compile-time check that
KAHE_MODULUSfits the 56-bit packers. The oddness check could go next to it. - #45, making items
pub(crate), would keep outside callers from passing other moduli topoly_packed_len. This one is about the crate's own constants.
Prompt:
report an issue to add the const _: () = assert!(CS_MODULUS % 2 == 1) check
Created together with Claude Opus 5.5 🧮✅
- Dominant language
- Rust
- Stars
- 1
- Forks
- 2
- Avg merge
- 6d 14h
- Merged PRs (30d)
- 11
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from flashbots/panetiere
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
flashbots/panetiere#31 · 1 comment ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
flashbots/panetiere#29 · 2 comments ·
Maintainers usually reply within 5 days
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 5 days
-
warning
Difficulty 1/5 Under an hour Newbie friendliness 78/100
flashbots/panetiere#2 · 1 comment ·
Maintainers usually reply within 5 days
-
warning
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
flashbots/panetiere#1 · 1 comment ·
Maintainers usually reply within 5 days
All issues in flashbots/panetiere
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
tinystream-dev/tinystream#132 ·
-
contract good first issue testing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Emmyt24/nova-launch#2436 ·
Maintainers usually reply within 1 day