traits icon indicating copy to clipboard operation
traits copied to clipboard

Does `elliptic-curve` with only the `serde` feature enabled still require `alloc`?

Open datdenkikniet opened this issue 6 months ago • 4 comments

Hi,

We're trying to use some primitives from the p256 crate on an embedded target and would like to rely on the serde impls it provides, but sadly this transitively pulls in an alloc requirement that we cannot and do not want to satisfy.

Preliminary checks suggest that the problem is that p256/serde activates elliptic-curve/serde, which in turn unconditionally activates its alloc feature.

Is there a way to get rid of this requirement so that we can use the generated serde impls for Signature without being forced to draw in alloc?

Thanks,

Jona

datdenkikniet avatar Aug 18 '25 15:08 datdenkikniet

Hmm, everything still compiles with the alloc feature removed. I think it may be a mistake.

tarcieri avatar Aug 18 '25 17:08 tarcieri

We did a bit more digging, and it turns out that --no-default-features --features serde,arithmetic no longer compiles :( It seemed that working around that requirement/annoyingness was more difficult than anticipated, since it effectively requires that serde + arithmetic activates alloc, which didn't seem possible yet.

datdenkikniet avatar Aug 18 '25 17:08 datdenkikniet

Aah yeah, just noticed that in #535:

https://github.com/RustCrypto/traits/actions/runs/17048198855/job/48329236948?pr=1962#step:20:16

I can look into encoding that into a static buffer.

tarcieri avatar Aug 18 '25 17:08 tarcieri

For reference: I think it's #1962 which isn't actually merged yet :P (#535 is, and a little different)

datdenkikniet avatar Aug 18 '25 20:08 datdenkikniet