Conversation
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.
661cbb5 to
5402e71
Compare
|
Note: trying to find somewhere to extract this. If Also not wild about the name, but I can't think of a better one. |
newpavlov
left a comment
There was a problem hiding this comment.
The type itself looks fine to me, but I am not sure it's worth to keep it as part of crypto-common. It would've been a bit better if we already had the alloc feature. So I would prefer to keep it elsewhere for now.
Also not wild about the name, but I can't think of a better one.
How about CondBox (i.e. conditionally Box)?
|
I can start with I do agree adding an |
|
We also could put it into a separate utils crate. |
Adds a type which is always available, but when the newly added
allocfeature is enabled, provides opportunistic heap allocation withBox, falling back on stack allocation if it is not.Originally added to the
ml-dsacrate in RustCrypto/signatures#1320 to address the large size of post-quantum keys and signatures while still retainingno_allocsupport.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.