Skip to content
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

Tracking issue for additional array size support: error[E0277]: the trait bound UInt<...>: ArraySize is not satisfied #66

Open
tarcieri opened this issue Mar 17, 2024 · 3 comments

Comments

@tarcieri
Copy link
Member

tarcieri commented Mar 17, 2024

hybrid-array relies on impls of ArraySize on individual typenum::Unsigned types, e.g. U1, U2, U3, which is a deliberate tradeoff versus generic-array which is able to support any array size.

These ArraySize impls are the linkage between typenum types and core arrays, which provide the underlying storage used by hybrid-array, and with it const generic linkage and significantly less unsafe code.

Unfortunately, you will encounter the rustc error message in the issue title if you attempt to use an unsupported array size.

Per #57, we are attempting to handle such cases as one-off requests for sizes which can be granted on a case-by-case basis, and gating them under the extra-sizes. It's unclear how well this will work in practice, but we are attempting it for now.

The main reason to constrain the number of supported sizes is a compile time cost as we add more impls of ArraySize/AssocArraySize. Compile times are not currently too significant but get worse as we add support for more array sizes.

@tarcieri tarcieri changed the title Tracking issue for additional array size support: error[E0277]: the trait bound UInt<...>: ArraySize is not satisfied Tracking issue for additional array size support: error[E0277]: the trait bound UInt<...>: ArraySize is not satisfied Mar 17, 2024
@oddcoder
Copy link

As per my proposal in #78, I will need sizes for NTRU-prime which are U653, U761, U857, U953, U1013, U1277. I will also need to add the type U1277 itself. I am not fully aware if I will need more sizes, since I am not fully familiar with the mathematics behind NTRU but unless there is an objection, Kindly expect a PR for those very soon.

@tarcieri
Copy link
Member Author

@oddcoder see how sizes are defined here:

https://github.com/RustCrypto/hybrid-array/blob/master/src/sizes.rs#L617-L811

It shouldn't be too hard to add.

@tarcieri
Copy link
Member Author

#81 provides a solution for user-defined types, however it requires removing the supertrait bound on typenum::Unsigned which seems like it will cause additional breakages beyond what hybrid-array will already entail.

For the v0.2.0 release I'd like to punt on that for now, but it's something we can consider for v0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants