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

Further expand array size support #49

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Further expand array size support #49

merged 1 commit into from
Feb 16, 2024

Conversation

tarcieri
Copy link
Member

This adds support for sizes identified as needed for post-quantum KEM/DSA use cases, namely the ones from this comment:

RustCrypto/KEMs#2 (comment)

These should ideally get expanded into some consistent multiples above 1024, e.g. multiples of 32, and generated in a purely automated manner (e.g. by a script that can break down the bit representation and build the generic syntax), but this should at least be sufficient to unblock these use cases.

Note that UInt<UInt<..<UTerm, B#>, B#... aliases expressing the explicit bits for a given number are used instead of e.g. <U1024 as Add<U32>>::Output because when the latter is used it causes similar errors for conflicting trait impls as we saw with typenum::U<N> for whatever reason:

error[E0119]: conflicting implementations of trait `traits::ArraySize` for type `UTerm`
   --> src/sizes.rs:82:13
    |
82  |               unsafe impl ArraySize for $ty {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |               |
    |               first implementation here
    |               conflicting implementation for `UTerm`

This adds support for sizes identified as needed for post-quantum
KEM/DSA use cases, namely the ones from this comment:

RustCrypto/KEMs#2 (comment)

These should ideally get expanded into some consistent multiples above
1024, e.g. multiples of 32, and generated in a purely automated manner
(e.g. by a script that can break down the bit representation and build
the generic syntax), but this should at least be sufficient to unblock
these use cases.

Note that `UInt<UInt<..<UTerm, B#>, B#...` aliases expressing the
explicit bits for a given number are used instead of e.g.
`<U1024 as Add<U32>>::Output` because when the latter is used it causes
similar errors for conflicting trait impls as we saw with
`typenum::U<N>` for whatever reason:

    error[E0119]: conflicting implementations of trait `traits::ArraySize` for type `UTerm`
       --> src/sizes.rs:82:13
        |
    82  |               unsafe impl ArraySize for $ty {
        |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |               |
        |               first implementation here
        |               conflicting implementation for `UTerm`
@tarcieri tarcieri merged commit 7ac59a4 into master Feb 16, 2024
14 checks passed
@tarcieri tarcieri deleted the extra-sizes branch February 16, 2024 15:47
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

Successfully merging this pull request may close these issues.

1 participant