mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-05 20:10:35 +00:00
Implement Identity for MontgomeryPoint.
This can be used in checks for non-contributory behaviour in protocols where that is a concern.
This commit is contained in:
parent
032a14cfa5
commit
0d8f33153c
1 changed files with 15 additions and 0 deletions
|
|
@ -94,6 +94,13 @@ impl PartialEq for MontgomeryPoint {
|
|||
|
||||
impl Eq for MontgomeryPoint {}
|
||||
|
||||
impl Identity for MontgomeryPoint {
|
||||
/// Return the group identity element, which has order 4.
|
||||
fn identity() -> MontgomeryPoint {
|
||||
MontgomeryPoint([0u8; 32])
|
||||
}
|
||||
}
|
||||
|
||||
impl Zeroize for MontgomeryPoint {
|
||||
fn zeroize(&mut self) {
|
||||
self.0.zeroize();
|
||||
|
|
@ -351,6 +358,14 @@ mod test {
|
|||
|
||||
use rand_core::OsRng;
|
||||
|
||||
#[test]
|
||||
fn identity_in_different_coordinates() {
|
||||
let id_projective = ProjectivePoint::identity();
|
||||
let id_montgomery = id_projective.to_affine();
|
||||
|
||||
assert!(id_montgomery == MontgomeryPoint::identity());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn serde_bincode_basepoint_roundtrip() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue