Skip to content

module-lattice: add MaybeBox#309

Merged
tarcieri merged 1 commit intomasterfrom
module-lattice/maybe-box
May 10, 2026
Merged

module-lattice: add MaybeBox#309
tarcieri merged 1 commit intomasterfrom
module-lattice/maybe-box

Conversation

@tarcieri
Copy link
Copy Markdown
Member

Adds a type which is always available, but when the newly added alloc feature is enabled, provides opportunistic heap allocation with Box, falling back on stack allocation if it is not.

Originally added to the ml-dsa crate in RustCrypto/signatures#1320 to address the large size of post-quantum keys and signatures while still retaining no_alloc support.

However, it is generally useful anywhere we work with secret values to e.g. prevent moves from making copies of them on the stack, even if they aren't excessively large.

@tarcieri tarcieri merged commit e171ace into master May 10, 2026
18 checks passed
@tarcieri tarcieri deleted the module-lattice/maybe-box branch May 10, 2026 18:24
tarcieri added a commit that referenced this pull request May 10, 2026
Uses the `MaybeBox` type added in #309 to offload large values onto the
heap when the `alloc` feature of the crate has been enabled.
tarcieri added a commit that referenced this pull request May 10, 2026
Uses the `MaybeBox` type added in #309 to offload large values onto the
heap when the `alloc` feature of the crate has been enabled.
tarcieri added a commit that referenced this pull request May 10, 2026
Uses the `MaybeBox` type added in #309 to offload large values onto the
heap when the `alloc` feature of the crate has been enabled.
@tarcieri tarcieri mentioned this pull request May 10, 2026
tarcieri added a commit that referenced this pull request May 10, 2026
## Added
- `MaybeBox` type (#309)
tarcieri added a commit to RustCrypto/signatures that referenced this pull request May 10, 2026
The `MaybeBox` type was moved to `module-lattice` so it could also be
used with the `ml-kem` crate.

See RustCrypto/KEMs#309
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