-
Notifications
You must be signed in to change notification settings - Fork 111
[cryptography] poly: add from_iter and new_with_constant fns #1877
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
base: main
Are you sure you want to change the base?
Conversation
f802a4a
to
7a731dd
Compare
Deploying monorepo with
|
Latest commit: |
38f3415
|
Status: | ✅ Deploy successful! |
Preview URL: | https://667401e3.monorepo-eu0.pages.dev |
Branch Preview URL: | https://cronokirby-new-poly-methods.monorepo-eu0.pages.dev |
pub fn new_with_constant( | ||
degree: u32, | ||
mut rng: impl CryptoRngCore, | ||
constant: Scalar, |
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.
nit: put constant
as the first argument
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.
I had it this way to respect the argument order of the other functions, for consistency ; I thought having this extend new_from
with an additional argument was best.
} | ||
|
||
/// Create a new scalar polynomial with a particular value for the constant coefficient. | ||
pub fn new_with_constant( |
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.
I wonder if it would be cleaner to accept Option<Scalar>
for this? May alleviate some cognitive overhead from dkg
.
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.
My thinking with the DKG logic is that, instead, you want to quickly transition from having no share to have a share that's been randomly generated, and always use that. Then, you'd just call this method.
bf9656d
to
0819011
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1877 +/- ##
=======================================
Coverage 92.20% 92.20%
=======================================
Files 308 308
Lines 81072 81087 +15
=======================================
+ Hits 74750 74765 +15
Misses 6322 6322
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
from_iter
is useful to avoid needing to call collect yourself, and enables a useful function, which sets the 0 value of the polynomial to a particular element, which is needed in a DKG reshare.I think there's enough value in the simple change to merit inclusion, even without propagating the change. (I'm working on a refactor of the DKG code which will use this method).