Extend NTTShoup handling to add, sub, and neg operations#352
Conversation
Implemented handling for Representation::NttShoup in Add, Sub, and Neg traits in crates/fhe-math/src/rq/ops.rs. When performing these operations on an NttShoup polynomial, it is now automatically converted to Ntt representation. Also updated AddAssign and SubAssign to allow operations between Ntt and NttShoup representations. Added regression tests in crates/fhe-math/tests/ntt_shoup_ops.rs. Co-authored-by: tlepoint <1345502+tlepoint@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38cf3d0850
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| impl Add<&Poly> for &Poly { | ||
| type Output = Poly; | ||
| fn add(self, p: &Poly) -> Poly { | ||
| let mut q = self.clone(); | ||
| q += p; | ||
| q | ||
| match self.representation { | ||
| Representation::NttShoup => { |
There was a problem hiding this comment.
Make owned
Poly + Poly handle NttShoup RHS
This new conversion only runs in the &Poly + &Poly implementation. The owned impl Add for Poly still does p += &self, and AddAssign continues to forbid NttShoup on the LHS, so a + b will still panic when b is Representation::NttShoup even though &a + &b now works. That makes behavior depend on ownership and breaks the intended NttShoup support for owned additions; consider routing the owned Add through the borrowed implementation or converting the RHS when it is NttShoup.
Useful? React with 👍 / 👎.
Implemented handling for Representation::NttShoup in Add, Sub, and Neg traits in crates/fhe-math/src/rq/ops.rs. When performing these operations on an NttShoup polynomial, it is now automatically converted to Ntt representation. Also updated AddAssign and SubAssign to allow operations between Ntt and NttShoup representations. Added regression tests in crates/fhe-math/tests/ntt_shoup_ops.rs. Fixed clippy warnings regarding wildcard enum matches. Co-authored-by: tlepoint <1345502+tlepoint@users.noreply.github.com>
Implemented handling for Representation::NttShoup in Add, Sub, and Neg traits in crates/fhe-math/src/rq/ops.rs. When performing these operations on an NttShoup polynomial, it is now automatically converted to Ntt representation. Updated AddAssign and SubAssign to handle NttShoup on LHS by converting to Ntt, which enables owned operations (p + q, p - q) to work correctly when RHS is NttShoup. Implemented Sub for Poly to support owned subtraction. Added regression tests in crates/fhe-math/tests/ntt_shoup_ops.rs covering borrowed and owned operations. Fixed clippy warnings regarding wildcard enum matches. Co-authored-by: tlepoint <1345502+tlepoint@users.noreply.github.com>
Implemented handling for Representation::NttShoup in Add, Sub, and Neg traits in crates/fhe-math/src/rq/ops.rs. When performing these operations on an NttShoup polynomial, it is now automatically converted to Ntt representation (as linear operations invalidate Shoup precomputations or don't benefit from them). Also updated AddAssign and SubAssign to allow operations between Ntt and NttShoup representations. Added regression tests.
PR created automatically by Jules for task 6421348099083632485 started by @tlepoint