From bdf1a7a133aada008b3627a871f4a4aba99bed10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Ch=C3=A9ron?= Date: Sun, 22 Sep 2019 09:29:50 +0200 Subject: [PATCH] Require point equality in EllipticCurveArith This is an incompatible API change but is very useful to test properties and algorithms derived from the primitives. An ECC instance sufficiently advanced to have math primitives should implement equality too. --- Crypto/ECC.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Crypto/ECC.hs b/Crypto/ECC.hs index 8391b5a..0d4b186 100644 --- a/Crypto/ECC.hs +++ b/Crypto/ECC.hs @@ -8,6 +8,7 @@ -- Elliptic Curve Cryptography -- {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -98,7 +99,7 @@ class EllipticCurve curve => EllipticCurveDH curve where -- value or an exception. ecdh :: proxy curve -> Scalar curve -> Point curve -> CryptoFailable SharedSecret -class EllipticCurve curve => EllipticCurveArith curve where +class (EllipticCurve curve, Eq (Point curve)) => EllipticCurveArith curve where -- | Add points on a curve pointAdd :: proxy curve -> Point curve -> Point curve -> Point curve