RustCrypto / RustCrypto/traits
kem: `from_seed` and `generate_keypair` use unnecessary memory
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 755
- Forks
- 256
- Avg merge
- 1h 27m
- Merged PRs (30d)
- 2
Description
The methods from_seed and generate_keypair both return a Kem::DecapsulationKey and Kem::EncapsulationKey. However, DecapsulationKey already must impl Decapsulator, which returns a &Kem::EncapsulationKey. Meaning the decap key already owns a copy of the encapsulation key! In other words: the encapsulation key output of from_seed and generate_keypair is guaranteed to be redundant. Since this value is measured in the kilobytes, this is no small overhead.
Proposed fix: from_seed should just return a DecapsulationKey. And it's less clear what to do about generate_keypair. Maybe it gets deleted and replaced with generate_decapsulation_key? Seems invasive.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the definitions of from_seed, generate_keypair, Kem::DecapsulationKey, and the Decapsulator trait. Trace callers and tests to determine how the API can stop returning a redundant EncapsulationKey, especially whether generate_keypair should be replaced. Done means the public API and its callers/tests no longer require the unnecessary key copy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100