aboutsummaryrefslogtreecommitdiffstats
path: root/ecc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ecc.hs')
-rw-r--r--ecc.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/ecc.hs b/ecc.hs
index 0bdbf02..5bc5d8a 100644
--- a/ecc.hs
+++ b/ecc.hs
@@ -104,6 +104,12 @@ binaryExpansion m value result | m == 0 = result
scalarProduct :: (Eq a, Fractional a) => Integer -> ECPoint a -> ECPoint a
scalarProduct m ec = binaryExpansion m ec Infinity
+instance (Eq a, Fractional a) => Semigroup (ECPoint a) where
+ (<>) = add
+
+instance (Eq a, Fractional a) => Monoid (ECPoint a) where
+ mempty = Infinity
+
tre = FieldElement 3 :: FieldElement 31
cc =
let a = ECPoint tre (-7) 5 7
@@ -133,6 +139,7 @@ aPoint = ECPoint 192 105 0 7 :: ECPoint (FieldElement 223)
total = add aPoint $ add aPoint $ add aPoint $ add aPoint aPoint
totalfold=foldr add Infinity $ replicate 5 aPoint
+totalmconcat = mconcat $ replicate 5 aPoint
type S256Field = FieldElement (2 ^ 256- 2^ 32 - 977)
type S256Point = ECPoint S256Field