From db17dc4b786d02917022174ef9dbe52d3cd9b3fc Mon Sep 17 00:00:00 2001 From: Henry & Isis Date: Mon, 20 Feb 2017 03:14:25 -0800 Subject: [PATCH] Add Eq implementation for DecafPoint --- src/decaf.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/decaf.rs b/src/decaf.rs index f549a78..f46e53d 100644 --- a/src/decaf.rs +++ b/src/decaf.rs @@ -156,6 +156,22 @@ impl DecafPoint { } } +// ------------------------------------------------------------------------ +// Equality +// ------------------------------------------------------------------------ + +/// XXX check whether there's a simple way to do equality checking +/// with cofactor 8, not just cofactor 4, and add a CT equality function? +impl PartialEq for DecafPoint { + fn eq(&self, other: &DecafPoint) -> bool { + let self_compressed = self.compress(); + let other_compressed = other.compress(); + self_compressed == other_compressed + } +} + +impl Eq for DecafPoint {} + // ------------------------------------------------------------------------ // Arithmetic // ------------------------------------------------------------------------