Skip to content

ml-dsa: activate MaybeBox with alloc feature#1370

Closed
baloo wants to merge 1 commit into
RustCrypto:masterfrom
baloo:baloo/push-prxvszmnstvy
Closed

ml-dsa: activate MaybeBox with alloc feature#1370
baloo wants to merge 1 commit into
RustCrypto:masterfrom
baloo:baloo/push-prxvszmnstvy

Conversation

@baloo

@baloo baloo commented Jun 5, 2026

Copy link
Copy Markdown
Member

When the matrices were pushed on the stack in #1344 and #1345, it relies on the MaybeBox implementation of module-lattice.

MaybeBox will push the matrix on the heap only if alloc is enabled.

Because alloc never got activated in ml-dsa this effectively reverted the optimization on the stack size made in #1261 and #1259.

This commit fixes that by enabling alloc on module-lattice when alloc is enabled on ml-dsa and restoring the expected behavior of MaybeBox.

When the matrices were pushed on the stack in RustCrypto#1344 and RustCrypto#1345, it relies
on the `MaybeBox` implementation of `module-lattice`.

`MaybeBox` will push the matrix on the heap only if `alloc` is enabled.

Because `alloc` never got activated in `ml-dsa` this effectively
reverted the optimization on the stack size made in RustCrypto#1261 and RustCrypto#1259.

This commit fixes that by enabling `alloc` on `module-lattice` when
`alloc` is enabled on `ml-dsa` and restoring the expected behavior of
`MaybeBox`.
@baloo

baloo commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

a workaround for a consumer crate until this makes into a release is to enable the feature on module-lattice manually:

[dependencies]
ml-dsa = { version = "0.1", features = ["alloc"] }
module-lattice = { version = "0.2.3", features = ["alloc"] }

@tarcieri

tarcieri commented Jun 5, 2026

Copy link
Copy Markdown
Member

This looks like a dup of #1365? I think if you rebase on master it won't have any changes.

@baloo

baloo commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

indeed, sorry for the noise.

@baloo baloo closed this Jun 5, 2026
@baloo baloo deleted the baloo/push-prxvszmnstvy branch June 5, 2026 18:01
@tarcieri

tarcieri commented Jun 5, 2026

Copy link
Copy Markdown
Member

I can cut a patch release with the fix

@baloo

baloo commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

I think we can use the workaround, if you have time that'd be appreciated, but it's fine otherwise.

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.

2 participants