-
Notifications
You must be signed in to change notification settings - Fork 56
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
[RFC] Is it possible to be both const generic and dynamic size #29
Comments
It sounds like you want heap-backed, arbitrary precision integers in addition to the fixed-sized const generic ones? If so, I'd say there aren't any plans to add that sort of thing any time soon. Maybe down the road, but it isn't on the radar right now. I'd also point out that if this is really what you want, there are many, many libraries in the Rust ecosystem to select from which provide heap-backed arbitrary precision big integers.
If you want to select from different sizes at runtime, use an enum with variants for your acceptable alternatives. This is a solution that works not just for different sizes of RSA, but for whatever ciphers happen to fulfill a particular role. |
Well, even when using a heap based arbitrary precision integer, I'd want it to have a specific size determined in runtime, and not allow it to alloc any more than that. it's possible now if you prealloc + only use modular operations, but I'd rather have in enforced in the type system. |
If that's all you want, it sounds like |
Not quite, it doesn't allow you to write the follwing: fn get_integer(moduli: &str) -> Box<Uint> (such that it will determine the size of the uint depending on the moduli) It can probably also be done with a custom allocator that prohibits the reallocation. |
Then you really need something like an enum to provide the type-level glue between a const-generic
|
Const generics and no-std are great features, both for performance and for interoperability.
The down side is that some protocols require a dynamic moduli, and maybe even dynamic sizes, for example RSA sizes(2048/3072/4096/8192 etc), or DSA moduli sizes, and more.
This gets more obvious with something like #28, which makes the type generic over the field, then you have to support a dynamic field to be able to support RSA, dynamic DSA moduli, groups with unknown order etc.
My question is is it possible to win both worlds, and somehow both allow const generics for arrays, but also allow dynamic generation over vectors?
The text was updated successfully, but these errors were encountered: