aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorÓscar Nájera <hi@oscarnajera.com>2021-04-05 19:24:51 +0200
committerÓscar Nájera <hi@oscarnajera.com>2021-04-05 19:24:51 +0200
commitbc0120183d4d3852af87deb58f81c6c31c3d6388 (patch)
tree31b8a96eac6d2425e109511a478a3f2c33118409
parentc9d3b981cd56d14450c2078980861153dd4920cc (diff)
downloadprogrammingbitcoin-bc0120183d4d3852af87deb58f81c6c31c3d6388.tar.gz
programmingbitcoin-bc0120183d4d3852af87deb58f81c6c31c3d6388.tar.bz2
programmingbitcoin-bc0120183d4d3852af87deb58f81c6c31c3d6388.zip
Implement division
-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