aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorÓscar Nájera <hi@oscarnajera.com>2021-04-05 20:50:24 +0200
committerÓscar Nájera <hi@oscarnajera.com>2021-04-05 20:50:24 +0200
commit224f0cc6d59c45abe67bbcef4d76b2dc1c99effd (patch)
tree6ef46e41506bb34918a2d76a273eff30944c9620
parentbc0120183d4d3852af87deb58f81c6c31c3d6388 (diff)
downloadprogrammingbitcoin-224f0cc6d59c45abe67bbcef4d76b2dc1c99effd.tar.gz
programmingbitcoin-224f0cc6d59c45abe67bbcef4d76b2dc1c99effd.tar.bz2
programmingbitcoin-224f0cc6d59c45abe67bbcef4d76b2dc1c99effd.zip
organize
-rw-r--r--ecc.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/ecc.hs b/ecc.hs
index 390bbb3..282817f 100644
--- a/ecc.hs
+++ b/ecc.hs
@@ -2,17 +2,13 @@
data FieldElement =
FieldElement
{ number :: Int
- , prime :: Int
+ , prime :: Int
}
deriving (Eq)
instance Show FieldElement where
show a = "FieldElement_" ++ show (prime a) ++ " " ++ show (number a)
-assert :: Bool -> Bool
-assert False = error "WRONG"
-assert x = x
-
instance Num FieldElement where
(FieldElement a b) + (FieldElement c d)
| b /= d = error "Distinct Fields"
@@ -29,6 +25,10 @@ instance Fractional FieldElement where
recip a = a ^ (prime a - 2)
fromRational _ = error "can't transform"
+assert :: Bool -> Bool
+assert False = error "WRONG"
+assert x = x
+
aa =
let a = FieldElement 2 31
b = FieldElement 15 31