From bc0120183d4d3852af87deb58f81c6c31c3d6388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20N=C3=A1jera?= Date: Mon, 5 Apr 2021 19:24:51 +0200 Subject: Implement division --- ecc.hs | 4 ++++ 1 file changed, 4 insertions(+) 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 -- cgit v1.2.3