starknet-io / types-rs

🐺 Starknet Rust types 🦀
MIT License
66 stars 41 forks source link

feat(zeroize): added zeorizing to `Felt` #100

Open Trantorian1 opened 1 month ago

Trantorian1 commented 1 month ago

This is feature-gated behind the zeroing flag

Pull Request type

What is the current behavior?

Felt provides no option to zeroize its memory, which can be an issue when dealing with sensitive cryptographic information such as private keys.

Resolves: #99

What is the new behavior?

[!NOTE] Contrarily to zeroize, this is done using safe rust by leveraging core::mem::take to replace the in-memory representation of a felt with its default value of Felt::ZERO.

Does this introduce a breaking change?

No. While the zeroing feature has been added to default, zeroing has not been implemented on drop, both because this would interfere with the Copy trait of Felt but also because it seems like it should be up to the end user to determine when they are dealing with sensitive information.