-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefer the Pow trait #179
base: master
Are you sure you want to change the base?
Prefer the Pow trait #179
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #179 +/- ##
==========================================
+ Coverage 92.46% 92.47% +0.01%
==========================================
Files 35 35
Lines 7030 7031 +1
==========================================
+ Hits 6500 6502 +2
+ Misses 530 529 -1 ☔ View full report in Codecov by Sentry. |
+ Pow<SecretUnsigned<Self::Uint>> | ||
+ Pow<PublicSigned<Self::Uint>> | ||
+ Pow<PublicSigned<Self::WideUint>> | ||
+ Pow<PublicSigned<Self::ExtraWideUint>> | ||
+ Pow<SecretSigned<Self::Uint>> | ||
+ Pow<SecretSigned<Self::WideUint>> | ||
+ Pow<SecretSigned<Self::ExtraWideUint>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit nasty. :/
@@ -23,7 +23,7 @@ use crate::{ | |||
/// - Safe `Clone` implementation (without needing to impl `CloneableSecret`) | |||
/// - Safe `Debug` implementation | |||
/// - Safe serialization/deserialization (down to `serde` API; what happens there we cannot control) | |||
pub(crate) struct Secret<T: Zeroize>(SecretBox<T>); | |||
pub struct Secret<T: Zeroize>(SecretBox<T>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to make the wrapper types pub is unfortunate.
synedrion/src/paillier/encryption.rs
Outdated
@@ -294,7 +294,9 @@ impl<P: PaillierParams> Ciphertext<P> { | |||
// To isolate `rho`, calculate `(rho^N)^(N^(-1)) mod N`. | |||
// The order of `Z_N` is `phi(N)`, so the inversion in the exponent is modulo `phi(N)`. | |||
let sk_inv_modulus = sk.inv_modulus(); | |||
let randomizer_mod = Secret::init_with(|| ciphertext_mod_n.pow(sk_inv_modulus)); | |||
let randomizer_mod = Secret::init_with(|| { | |||
ciphertext_mod_n.pow_bounded_exp(sk_inv_modulus.expose_secret(), sk_inv_modulus.bound()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't pow()
work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, good catch. This was a left-over from early experimentation.
Is it actually helpful? I think that's the crucial thing here. I would say that using macros and making internal types public is a downside, so what are we getting for it? |
Indeed, I'm not convinced myself. I think it is useful (or even required) to have this to make using the I'll put this back as draft and collect some more info on how/if it's useful. |
dc4ed8a
to
43d6bf7
Compare
This PR removes the
Exponentiable
trait and its implementations forSecretSigned
,SecretUnsigned
andPublicSigned
. It's up for debate whether this is actually better, but I think it's a little bit cleaner and may be helpful for tricks like "exponentiation with known totient"? The downside is that now the wrapper types are public.EDIT: Rebased this on top of #173 t to be able to check for regressions (looks good).