aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ecc.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/ecc.hs b/ecc.hs
index 8146711..390bbb3 100644
--- a/ecc.hs
+++ b/ecc.hs
@@ -25,6 +25,10 @@ instance Num FieldElement where
negate (FieldElement a b) = FieldElement (mod (b - a) b) b
fromInteger _ = error "can't transform"
+instance Fractional FieldElement where
+ recip a = a ^ (prime a - 2)
+ fromRational _ = error "can't transform"
+
aa =
let a = FieldElement 2 31
b = FieldElement 15 31