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.
The methods
from_seedandgenerate_keypairboth return aKem::DecapsulationKeyandKem::EncapsulationKey. However,DecapsulationKeyalready must implDecapsulator, which returns a&Kem::EncapsulationKey. Meaning the decap key already owns a copy of the encapsulation key! In other words: the encapsulation key output offrom_seedandgenerate_keypairis guaranteed to be redundant. Since this value is measured in the kilobytes, this is no small overhead.Proposed fix:
from_seedshould just return aDecapsulationKey. And it's less clear what to do aboutgenerate_keypair. Maybe it gets deleted and replaced withgenerate_decapsulation_key? Seems invasive.