-
Notifications
You must be signed in to change notification settings - Fork 58
Filip/secret felt implementation #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filip/secret felt implementation #144
Conversation
ProjectivePoints have 3 coordinates (x,y,z) and the AffinePoint incorrectly expose just the (x, y) coordinate without converting the representation from projective to affine.
…ng secrets by zeroizing the memory at the end Remove the zeroized implementation for the Felt
So yes haha ;) |
…e is a must. Add `inner_value` function that returnes a safe copy of the inner felt. The value will be zeroized automatically when is out of scope.
@FilipLaurentiu CI is failing |
@FilipLaurentiu ok we have this secret felt now. But we can't do much with it. Just move it around in memory safely. What operations can we safely implement on this type? Arithmetic (Add, Mul, and so on) seems out of reach due to the way the internal representation of /// Field addition. Never overflows/underflows.
impl ops::Add<Felt> for Felt {
type Output = Felt;
fn add(self, rhs: Felt) -> Self::Output {
Self(self.0 + rhs.0)
}
}
/// Field addition. Never overflows/underflows.
impl ops::Add<&Felt> for Felt {
type Output = Felt;
fn add(self, rhs: &Felt) -> Self::Output {
Self(self.0 + rhs.0)
}
} A copy of the internal value will be created if I don't mistake. We could add a constant time comparison for the secret felt, to add one more security measure against timing attacks. |
…le` crate. - Implement `from_random` for `SecretFelt` to generate a secret Felt using a CSPRNG - Improve the `from_hex_string` example - Change `from_bytes_be`, `from_bytes_le` function signature to accept a `[u8; 32]` instead of `Vec<u8>`. No conversion needed and the function can't fail anymore.
I manage to implement a constant time comparison function for the One big usage for |
@FilipLaurentiu I think once you add |
Done, ready to go 👍 |
Pull Request type
Please add the labels corresponding to the type of changes your PR introduces:
What is the current behavior?
Felt
implement the Copy trait and it could leak the secret information into memory.Felt
is not zeroized on drop, it need to be manually zeroized.Resolves: #NA
What is the new behavior?
New type
SecretFelt
is introduced for this specific purpose. This type could be used to represent sensible information that will not be leaked into memory at the end of the programDoes this introduce a breaking change?
No - Only if a project use the
zeroize
function onFelt
and upgrade to the latest version of this library, but from what I know, nobody use it (starknet-rs doesn't use it)