-
Notifications
You must be signed in to change notification settings - Fork 31
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
Use const generics where feasible #18
Comments
It turns out I misunderstood this post: const generics are stable and generally available in Rust 1.51, so we could investigate adopting this now. |
I think we should keep type Field32 = GenericField<FP32>;
type Field64 = GenericField<FP64>;
type Field80 = GenericField<FP80>;
type Field126 = GenericField<FP126>; |
Const generics supports only primitive types, like integers. As such, we can't use them for FieldElement in this way. An area where const generics would be very helpful is in the gadget implementations ( pub struct PolyEval<F: FieldElement> {
poly: Vec<F>,
/// Size of buffer for FFT operations.
n: usize,
/// Inverse of `n` in `F`.
n_inv: F,
} Usually pub struct PolyEval<F: FieldElement, const L: usize> {
poly: [F; L],
/// Size of buffer for FFT operations.
n: usize,
/// Inverse of `n` in `F`.
n_inv: F,
} |
We've tried a couple times now to use const generics in this library (#85) and it hasn't worked out. @cjpatton and I agree we can't be taken seriously as a Rust cryptography project until we manage to use this language feature, so we will figure out a way to to adopt it! One promising candidate would be to make |
I'm now less certain that this is a good idea. The downside, of course, is the number of shares needs to be known at compile time. If there is no obvious benefit other than aesthetics, then I don't think it's worth doing. My main takeaway from this side quest so far is that const generics aren't mature enough to use the way we imagine they're intended to be used. |
FieldElement
We now use |
As const generics continue to evolve in the language, we'll keep trying to use them as appropriate, but this issue doesn't track any specific work or problem so I'm closing it. |
Once const generics (1 2) are out of beta, we might consider them to implement
FieldElement
as a generic over values ofFieldParameter
.The text was updated successfully, but these errors were encountered: