packages feed

elliptic-curve (empty) → 0.1.0

raw patch · 96 files changed

+7644/−0 lines, 96 filesdep +MonadRandomdep +arithmoidep +base

Dependencies added: MonadRandom, arithmoi, base, criterion, galois-field, protolude, tasty, tasty-hunit, tasty-quickcheck, wl-pprint-text

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Change log for elliptic-curve++## 0.1.0++* Initial release.
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2019 Adjoint Inc.++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE+OR OTHER DEALINGS IN THE SOFTWARE.
+ README.md view
@@ -0,0 +1,265 @@+<p align="center">+  <a href="http://www.adjoint.io">+    <img width="250" src="./.assets/adjoint.png" alt="Adjoint Logo" />+  </a>+</p>++# Elliptic Curve++An extensible library of elliptic curves used in cryptography research.++## Curve representations++An [**elliptic curve**](src/Curve.hs) E(K) over a field K is a *smooth projective plane algebraic cubic curve* with a specified base point `O`, and the *points* on E(K) form an *algebraic group* with identity point `O`. By the *Riemann-Roch theorem*, any elliptic curve is isomorphic to a cubic curve of the form+```+E(K) = {(x, y) | y^2 + a1xy + a3y = x^3 + a2x^2 + a4x + a6} U {O}+```+where `O` is the *point at infinity*, and `a1, a2, a3, a4, a6` are *K-rational coefficients* that satisfy a *non-zero discriminant* condition. For cryptographic computational purposes, elliptic curves are represented in several different forms.++### Weierstrass curves++A (short) [**Weierstrass curve**](src/Curve/Weierstrass.hs) is an elliptic curve over GF(p) for some prime p, and is of the form+```+E(GF(p)) = {(x, y) | y^2 = x^3 + Ax^2 + B} U {O}+```+where `A` and `B` are K-rational coefficients such that `4A^3 + 27B^2` is non-zero. Weierstrass curves are the most common representations of elliptic curves, as any elliptic curve over a field of characteristic greater than 3 is isomorphic to a Weierstrass curve.++### Binary curves++A (short Weierstrass) [**binary curve**](src/Curve/Binary.hs) is an elliptic curve over GF(2^m) for some positive m, and is of the form+```+E(GF(2^m)) = {(x, y) | y^2 = x^3 + Ax + B} U {O}+```+where `A` and `B` are K-rational coefficients such that `B` is non-zero. Binary curves have field elements represented by binary integers for efficient arithmetic, and are special cases of *long Weierstrass curves* over a field of characteristic 2.++### Montgomery curves++A [**Montgomery curve**](src/Curve/Montgomery.hs) is an elliptic curve over GF(p) for some prime p, and is of the form+```+E(GF(p)) = {(x, y) | By^2 = x^3 + Ax^2 + x} U {O}+```+where `A` and `B` are K-rational coefficients such that `B(A^2 - 4)` is non-zero. Montgomery curves only use the first affine coordinate for computations, and can utilise the Montgomery ladder for efficient multiplication.++### Edwards curves++A (twisted) [**Edwards curve**](src/Curve/Edwards.hs) is an elliptic curve over GF(p) for some prime p, and is of the form+```+E(GF(p)) = {(x, y) | Ax^2 + y^2 = 1 + Dx^2y^2}+```+where `A` and `D` are K-rational coefficients such that `D(1 - D)` is non-zero. Edwards curves have no point at infinity, and their addition and doubling formulae converge.++## Curve usage++This library is open for new curve representations and curve implementations through pull requests. These should ideally be executed by replicating and modifying existing curve files, for ease, quickcheck testing, and formatting consistency, but a short description of the file organisation is provided here for clarity. Note that it also has a dependency on the [Galois field library](https://github.com/adjoint-io/galois-field) and its required language extensions.++### Representing a new curve using the curve class++Import the following modules.+```haskell+import Curve (Curve(..))+import GaloisField (GaloisField)+```+Create a phantom representation of Weierstrass curves.+```haskell+data W+```+Create a synonym for the points on Weierstrass curves.+```haskell+type WPoint = Point W+```+Create a class for Weierstrass curves and their parameters.+```haskell+class Curve W c k => WCurve c k where+  a_ :: c -> k+  b_ :: c -> k+  g_ :: WPoint c k+```+Create an instance of Weierstrass curves with their operations.+```haskell+instance (GaloisField k, WCurve c k) => Curve W c k where++  data instance Point W c k = A k k+                            | O+    deriving (Eq, Show)++  def O       = True+  def (A x y) = y * y == x ^ 3 + a * x ^ 2 + b+    where+      a = a_ (undefined :: c)+      b = b_ (undefined :: c)++  ...+```+Export the following data types.+```haskell+module Weierstrass+  ( Point(..)+  , WCurve(..)+  , WPoint+  ) where+```++### Implementing a new curve using a curve representation++Import a curve representation and a suitable Galois field.+```haskell+import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import PrimeField (PrimeField)+```+Create a phantom representation of the Anomalous curve.+```haskell+data Anomalous+```+Create a synonym for the field of the Anomalous curve.+```haskell+type Fp = PrimeField 0xb0000000000000000000000953000000000000000000001f9d7+```+Create a synonym for the points on the Anomalous curve.+```haskell+type P = WPoint Anomalous Fp+```+Create constants for the parameters of the Anomalous curve.+```haskell+_a :: Fp+_a = 0x98d0fac687d6343eb1a1f595283eb1a1f58d0fac687d635f5e4++_b :: Fp+_b = 0x4a1f58d0fac687d6343eb1a5e2d6343eb1a1f58d0fac688ab3f++_g :: P+_g = A+     0x101efb35fd1963c4871a2d17edaafa7e249807f58f8705126c6+     0x22389a3954375834304ba1d509a97de6c07148ea7f5951b20e7++...+```+Create an instance of the Anomalous curve with its parameters.+```haskell+instance WCurve Anomalous Fp where+  a_ = const _a+  b_ = const _b+  g_ = _g+```+Export the following data types and constants.+```haskell+module Curve.Weierstrass.Anomalous+  ( Fp+  , P+  , _a+  , _b+  , _g+  , ...+  ) where+```++### Using an implemented curve++Import the curve class and a curve implementation.+```haskell+import Curve+import qualified Curve.Weierstrass.Anomalous as Anomalous+```+The data types and constants can then be accessed readily as `Anomalous.P` and `Anomalous._g`.++## Curve implementations++The following curves have already been implemented.++### Binary curves++* SECT (NIST) curves+  * [SECT113R1](src/Curve/Binary/SECT113R1.hs)+  * [SECT113R2](src/Curve/Binary/SECT113R2.hs)+  * [SECT131R1](src/Curve/Binary/SECT131R1.hs)+  * [SECT131R2](src/Curve/Binary/SECT131R2.hs)+  * [SECT163K1](src/Curve/Binary/SECT163K1.hs)+  * [SECT163R1](src/Curve/Binary/SECT163R1.hs)+  * [SECT163R2](src/Curve/Binary/SECT163R2.hs)+  * [SECT193R1](src/Curve/Binary/SECT193R1.hs)+  * [SECT193R2](src/Curve/Binary/SECT193R2.hs)+  * [SECT233K1](src/Curve/Binary/SECT233K1.hs)+  * [SECT233R1](src/Curve/Binary/SECT233R1.hs)+  * [SECT239K1](src/Curve/Binary/SECT239K1.hs)+  * [SECT283K1](src/Curve/Binary/SECT283K1.hs)+  * [SECT283R1](src/Curve/Binary/SECT283R1.hs)+  * [SECT409K1](src/Curve/Binary/SECT409K1.hs)+  * [SECT409R1](src/Curve/Binary/SECT409R1.hs)+  * [SECT571K1](src/Curve/Binary/SECT571K1.hs)+  * [SECT571R1](src/Curve/Binary/SECT571R1.hs)++### Edwards curves++* Edwards curves+  * [Curve1174](src/Curve/Edwards/Curve1174.hs)+  * [Curve41417](src/Curve/Edwards/Curve41417.hs)+  * [E-222](src/Curve/Edwards/E222.hs)+  * [E-382](src/Curve/Edwards/E382.hs)+  * [E-521](src/Curve/Edwards/E521.hs)+  * [Ed25519 (Curve25519)](src/Curve/Edwards/Ed25519.hs)+  * [Ed3363 (HighFive)](src/Curve/Edwards/Ed3363.hs)+  * [Ed448 (Goldilocks)](src/Curve/Edwards/Ed448.hs)+  * [JubJub](src/Curve/Edwards/JubJub.hs)++### Montgomery curves++* Montgomery curves+  * [Curve25519 (Ed25519)](src/Curve/Montgomery/Curve25519.hs)+  * [Curve383187](src/Curve/Montgomery/Curve383187.hs)+  * [Curve448 (Goldilocks)](src/Curve/Montgomery/Curve448.hs)+  * [M-221](src/Curve/Montgomery/M221.hs)+  * [M-383](src/Curve/Montgomery/M383.hs)+  * [M-511](src/Curve/Montgomery/M511.hs)++### Weierstrass curves++* [Anomalous](src/Curve/Weierstrass/Anomalous.hs)+* [ANSSI-FRP256V1](src/Curve/Weierstrass/ANSSIFRP256V1.hs)+* Barreto-Lynn-Scott (BLS) curves+  * [BLS12-381](src/Curve/Weierstrass/BLS12_381.hs)+  * [BLS12-381T](src/Curve/Weierstrass/BLS12_381T.hs)+  * [BLS48-581](src/Curve/Weierstrass/BLS48_581.hs)+  * [BLS48-581T](src/Curve/Weierstrass/BLS48_581T.hs)+* Barreto-Naehrig (BN) curves+  * [BN224 (Fp224BN)](src/Curve/Weierstrass/BN224.hs)+  * [BN254 (CurveSNARK)](src/Curve/Weierstrass/BN254.hs)+  * [BN254T (CurveSNARKn2)](src/Curve/Weierstrass/BN254T.hs)+  * [BN254A (Fp254BNa)](src/Curve/Weierstrass/BN254A.hs)+  * [BN254AT (Fp254n2BNa)](src/Curve/Weierstrass/BN254AT.hs)+  * [BN254B (Fp254BNb)](src/Curve/Weierstrass/BN254B.hs)+  * [BN254BT (Fp254n2BNb)](src/Curve/Weierstrass/BN254BT.hs)+  * [BN256 (Fp256BN)](src/Curve/Weierstrass/BN256.hs)+  * [BN384 (Fp384BN)](src/Curve/Weierstrass/BN384.hs)+  * [BN462 (Fp462BN)](src/Curve/Weierstrass/BN462.hs)+  * [BN462T (Fp462n2BN)](src/Curve/Weierstrass/BN462T.hs)+  * [BN512 (Fp512BN)](src/Curve/Weierstrass/BN512.hs)+* Brainpool curves+  * [Brainpool-P160R1](src/Curve/Weierstrass/BrainpoolP160R1.hs)+  * [Brainpool-P160T1](src/Curve/Weierstrass/BrainpoolP160T1.hs)+  * [Brainpool-P192R1](src/Curve/Weierstrass/BrainpoolP192R1.hs)+  * [Brainpool-P192T1](src/Curve/Weierstrass/BrainpoolP192T1.hs)+  * [Brainpool-P224R1](src/Curve/Weierstrass/BrainpoolP224R1.hs)+  * [Brainpool-P224T1](src/Curve/Weierstrass/BrainpoolP224T1.hs)+  * [Brainpool-P256R1](src/Curve/Weierstrass/BrainpoolP256R1.hs)+  * [Brainpool-P256T1](src/Curve/Weierstrass/BrainpoolP256T1.hs)+  * [Brainpool-P320R1](src/Curve/Weierstrass/BrainpoolP320R1.hs)+  * [Brainpool-P320T1](src/Curve/Weierstrass/BrainpoolP320T1.hs)+  * [Brainpool-P384R1](src/Curve/Weierstrass/BrainpoolP384R1.hs)+  * [Brainpool-P384T1](src/Curve/Weierstrass/BrainpoolP384T1.hs)+  * [Brainpool-P512R1](src/Curve/Weierstrass/BrainpoolP512R1.hs)+  * [Brainpool-P512T1](src/Curve/Weierstrass/BrainpoolP512T1.hs)+* SECP (NIST) curves+  * [SECP112R1](src/Curve/Weierstrass/SECP112R1.hs)+  * [SECP112R2](src/Curve/Weierstrass/SECP112R2.hs)+  * [SECP128R1](src/Curve/Weierstrass/SECP128R1.hs)+  * [SECP128R2](src/Curve/Weierstrass/SECP128R2.hs)+  * [SECP160K1](src/Curve/Weierstrass/SECP160K1.hs)+  * [SECP160R1](src/Curve/Weierstrass/SECP160R1.hs)+  * [SECP160R2](src/Curve/Weierstrass/SECP160R2.hs)+  * [SECP192K1](src/Curve/Weierstrass/SECP192K1.hs)+  * [SECP192R1](src/Curve/Weierstrass/SECP192R1.hs)+  * [SECP224K1](src/Curve/Weierstrass/SECP224K1.hs)+  * [SECP224R1](src/Curve/Weierstrass/SECP224R1.hs)+  * [SECP256K1](src/Curve/Weierstrass/SECP256K1.hs)+  * [SECP256R1](src/Curve/Weierstrass/SECP256R1.hs)+  * [SECP384R1](src/Curve/Weierstrass/SECP384R1.hs)+  * [SECP521R1](src/Curve/Weierstrass/SECP521R1.hs)
+ benchmarks/Main.hs view
@@ -0,0 +1,182 @@+module Main where++import Protolude++import Criterion.Main+import Curve+import qualified Curve.Binary.SECT113R1            as SECT113R1+import qualified Curve.Binary.SECT113R2            as SECT113R2+import qualified Curve.Binary.SECT131R1            as SECT131R1+import qualified Curve.Binary.SECT131R2            as SECT131R2+import qualified Curve.Binary.SECT163K1            as SECT163K1+import qualified Curve.Binary.SECT163R1            as SECT163R1+import qualified Curve.Binary.SECT163R2            as SECT163R2+import qualified Curve.Binary.SECT193R1            as SECT193R1+import qualified Curve.Binary.SECT193R2            as SECT193R2+import qualified Curve.Binary.SECT233K1            as SECT233K1+import qualified Curve.Binary.SECT233R1            as SECT233R1+import qualified Curve.Binary.SECT239K1            as SECT239K1+import qualified Curve.Binary.SECT283K1            as SECT283K1+import qualified Curve.Binary.SECT283R1            as SECT283R1+import qualified Curve.Binary.SECT409K1            as SECT409K1+import qualified Curve.Binary.SECT409R1            as SECT409R1+import qualified Curve.Binary.SECT571K1            as SECT571K1+import qualified Curve.Binary.SECT571R1            as SECT571R1+import qualified Curve.Edwards.Curve1174           as Curve1174+import qualified Curve.Edwards.Curve41417          as Curve41417+import qualified Curve.Edwards.E222                as E222+import qualified Curve.Edwards.E382                as E382+import qualified Curve.Edwards.E521                as E521+import qualified Curve.Edwards.Ed448               as Ed448+import qualified Curve.Edwards.Ed3363              as Ed3363+import qualified Curve.Edwards.Ed25519             as Ed25519+import qualified Curve.Edwards.JubJub              as JubJub+import qualified Curve.Montgomery.Curve448         as Curve448+import qualified Curve.Montgomery.Curve25519       as Curve25519+import qualified Curve.Montgomery.Curve383187      as Curve383187+import qualified Curve.Montgomery.M221             as M221+import qualified Curve.Montgomery.M383             as M383+import qualified Curve.Montgomery.M511             as M511+import qualified Curve.Weierstrass.Anomalous       as Anomalous+import qualified Curve.Weierstrass.ANSSIFRP256V1   as ANSSIFRP256V1+import qualified Curve.Weierstrass.BLS12_381       as BLS12_381+import qualified Curve.Weierstrass.BLS12_381T      as BLS12_381T+import qualified Curve.Weierstrass.BLS48_581       as BLS48_581+import qualified Curve.Weierstrass.BLS48_581T      as BLS48_581T+import qualified Curve.Weierstrass.BN224           as BN224+import qualified Curve.Weierstrass.BN254           as BN254+import qualified Curve.Weierstrass.BN254T          as BN254T+import qualified Curve.Weierstrass.BN254A          as BN254A+import qualified Curve.Weierstrass.BN254AT         as BN254AT+import qualified Curve.Weierstrass.BN254B          as BN254B+import qualified Curve.Weierstrass.BN254BT         as BN254BT+import qualified Curve.Weierstrass.BN256           as BN256+import qualified Curve.Weierstrass.BN384           as BN384+import qualified Curve.Weierstrass.BN462           as BN462+import qualified Curve.Weierstrass.BN462T          as BN462T+import qualified Curve.Weierstrass.BN512           as BN512+import qualified Curve.Weierstrass.BrainpoolP160R1 as BrainpoolP160R1+import qualified Curve.Weierstrass.BrainpoolP160T1 as BrainpoolP160T1+import qualified Curve.Weierstrass.BrainpoolP192R1 as BrainpoolP192R1+import qualified Curve.Weierstrass.BrainpoolP192T1 as BrainpoolP192T1+import qualified Curve.Weierstrass.BrainpoolP224R1 as BrainpoolP224R1+import qualified Curve.Weierstrass.BrainpoolP224T1 as BrainpoolP224T1+import qualified Curve.Weierstrass.BrainpoolP256R1 as BrainpoolP256R1+import qualified Curve.Weierstrass.BrainpoolP256T1 as BrainpoolP256T1+import qualified Curve.Weierstrass.BrainpoolP320R1 as BrainpoolP320R1+import qualified Curve.Weierstrass.BrainpoolP320T1 as BrainpoolP320T1+import qualified Curve.Weierstrass.BrainpoolP384R1 as BrainpoolP384R1+import qualified Curve.Weierstrass.BrainpoolP384T1 as BrainpoolP384T1+import qualified Curve.Weierstrass.BrainpoolP512R1 as BrainpoolP512R1+import qualified Curve.Weierstrass.BrainpoolP512T1 as BrainpoolP512T1+import qualified Curve.Weierstrass.SECP112R1       as SECP112R1+import qualified Curve.Weierstrass.SECP112R2       as SECP112R2+import qualified Curve.Weierstrass.SECP128R1       as SECP128R1+import qualified Curve.Weierstrass.SECP128R2       as SECP128R2+import qualified Curve.Weierstrass.SECP160K1       as SECP160K1+import qualified Curve.Weierstrass.SECP160R1       as SECP160R1+import qualified Curve.Weierstrass.SECP160R2       as SECP160R2+import qualified Curve.Weierstrass.SECP192K1       as SECP192K1+import qualified Curve.Weierstrass.SECP192R1       as SECP192R1+import qualified Curve.Weierstrass.SECP224K1       as SECP224K1+import qualified Curve.Weierstrass.SECP224R1       as SECP224R1+import qualified Curve.Weierstrass.SECP256K1       as SECP256K1+import qualified Curve.Weierstrass.SECP256R1       as SECP256R1+import qualified Curve.Weierstrass.SECP384R1       as SECP384R1+import qualified Curve.Weierstrass.SECP521R1       as SECP521R1+import GHC.Base++benchmark :: forall r c k . Curve r c k => String -> Point r c k -> Benchmark+benchmark = (. whnf (mul (6 :: Int))) . bench++main :: IO ()+main = defaultMain+  [ bgroup "Binary"+    [ benchmark        "SECT113R1"       SECT113R1._g+    , benchmark        "SECT113R2"       SECT113R2._g+    , benchmark        "SECT131R1"       SECT131R1._g+    , benchmark        "SECT131R2"       SECT131R2._g+    , benchmark        "SECT163K1"       SECT163K1._g+    , benchmark        "SECT163R1"       SECT163R1._g+    , benchmark        "SECT163R2"       SECT163R2._g+    , benchmark        "SECT193R1"       SECT193R1._g+    , benchmark        "SECT193R2"       SECT193R2._g+    , benchmark        "SECT233K1"       SECT233K1._g+    , benchmark        "SECT233R1"       SECT233R1._g+    , benchmark        "SECT239K1"       SECT239K1._g+    , benchmark        "SECT283K1"       SECT283K1._g+    , benchmark        "SECT283R1"       SECT283R1._g+    , benchmark        "SECT409K1"       SECT409K1._g+    , benchmark        "SECT409R1"       SECT409R1._g+    , benchmark        "SECT571K1"       SECT571K1._g+    , benchmark        "SECT571R1"       SECT571R1._g+    ]+  , bgroup "Edwards"+    [ benchmark        "Curve1174"       Curve1174._g+    , benchmark       "Curve41417"      Curve41417._g+    , benchmark            "E-222"            E222._g+    , benchmark            "E-382"            E382._g+    , benchmark            "E-521"            E521._g+    , benchmark            "Ed448"           Ed448._g+    , benchmark           "Ed3363"          Ed3363._g+    , benchmark          "Ed25519"         Ed25519._g+    , benchmark           "JubJub"          JubJub._g+    ]+  , bgroup "Montgomery"+    [ benchmark         "Curve448"        Curve448._g+    , benchmark       "Curve25519"      Curve25519._g+    , benchmark      "Curve383187"     Curve383187._g+    , benchmark            "M-221"            M221._g+    , benchmark            "M-383"            M383._g+    , benchmark            "M-511"            M511._g+    ]+  , bgroup "Weierstrass"+    [ benchmark        "Anomalous"       Anomalous._g+    , benchmark   "ANSSI-FRP256V1"   ANSSIFRP256V1._g+    , benchmark        "BLS12-381"       BLS12_381._g+    , benchmark       "BLS12-381T"      BLS12_381T._g+    , benchmark        "BLS48-581"       BLS48_581._g+    , benchmark       "BLS48-581T"      BLS48_581T._g+    , benchmark            "BN224"           BN224._g+    , benchmark            "BN254"           BN254._g+    , benchmark           "BN254T"          BN254T._g+    , benchmark           "BN254A"          BN254A._g+    , benchmark          "BN254AT"         BN254AT._g+    , benchmark           "BN254B"          BN254B._g+    , benchmark          "BN254BT"         BN254BT._g+    , benchmark            "BN256"           BN256._g+    , benchmark            "BN384"           BN384._g+    , benchmark            "BN462"           BN462._g+    , benchmark           "BN462T"          BN462T._g+    , benchmark            "BN512"           BN512._g+    , benchmark "Brainpool-P160R1" BrainpoolP160R1._g+    , benchmark "Brainpool-P160T1" BrainpoolP160T1._g+    , benchmark "Brainpool-P192R1" BrainpoolP192R1._g+    , benchmark "Brainpool-P192T1" BrainpoolP192T1._g+    , benchmark "Brainpool-P224R1" BrainpoolP224R1._g+    , benchmark "Brainpool-P224T1" BrainpoolP224T1._g+    , benchmark "Brainpool-P256R1" BrainpoolP256R1._g+    , benchmark "Brainpool-P256T1" BrainpoolP256T1._g+    , benchmark "Brainpool-P320R1" BrainpoolP320R1._g+    , benchmark "Brainpool-P320T1" BrainpoolP320T1._g+    , benchmark "Brainpool-P384R1" BrainpoolP384R1._g+    , benchmark "Brainpool-P384T1" BrainpoolP384T1._g+    , benchmark "Brainpool-P512R1" BrainpoolP512R1._g+    , benchmark "Brainpool-P512T1" BrainpoolP512T1._g+    , benchmark        "SECP112R1"       SECP112R1._g+    , benchmark        "SECP112R2"       SECP112R2._g+    , benchmark        "SECP128R1"       SECP128R1._g+    , benchmark        "SECP128R2"       SECP128R2._g+    , benchmark        "SECP160K1"       SECP160K1._g+    , benchmark        "SECP160R1"       SECP160R1._g+    , benchmark        "SECP160R2"       SECP160R2._g+    , benchmark        "SECP192K1"       SECP192K1._g+    , benchmark        "SECP192R1"       SECP192R1._g+    , benchmark        "SECP224K1"       SECP224K1._g+    , benchmark        "SECP224R1"       SECP224R1._g+    , benchmark        "SECP256K1"       SECP256K1._g+    , benchmark        "SECP256R1"       SECP256R1._g+    , benchmark        "SECP384R1"       SECP384R1._g+    , benchmark        "SECP521R1"       SECP521R1._g+    ]+  ]
+ elliptic-curve.cabal view
@@ -0,0 +1,345 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: bdbd38917d50ccd9f993f22110c962321da59072497a327bb80a0309791e767b++name:           elliptic-curve+version:        0.1.0+synopsis:       Elliptic curve library+description:    An extensible library of elliptic curves used in cryptography research+category:       Cryptography+homepage:       https://github.com/adjoint-io/elliptic-curve#readme+bug-reports:    https://github.com/adjoint-io/elliptic-curve/issues+maintainer:     Adjoint Inc (info@adjoint.io)+license:        MIT+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    ChangeLog.md++source-repository head+  type: git+  location: https://github.com/adjoint-io/elliptic-curve++library+  exposed-modules:+      Curve+      Curve.Binary+      Curve.Binary.SECT113R1+      Curve.Binary.SECT113R2+      Curve.Binary.SECT131R1+      Curve.Binary.SECT131R2+      Curve.Binary.SECT163K1+      Curve.Binary.SECT163R1+      Curve.Binary.SECT163R2+      Curve.Binary.SECT193R1+      Curve.Binary.SECT193R2+      Curve.Binary.SECT233K1+      Curve.Binary.SECT233R1+      Curve.Binary.SECT239K1+      Curve.Binary.SECT283K1+      Curve.Binary.SECT283R1+      Curve.Binary.SECT409K1+      Curve.Binary.SECT409R1+      Curve.Binary.SECT571K1+      Curve.Binary.SECT571R1+      Curve.Edwards+      Curve.Edwards.Curve1174+      Curve.Edwards.Curve41417+      Curve.Edwards.E222+      Curve.Edwards.E382+      Curve.Edwards.E521+      Curve.Edwards.Ed448+      Curve.Edwards.Ed3363+      Curve.Edwards.Ed25519+      Curve.Edwards.JubJub+      Curve.Montgomery+      Curve.Montgomery.Curve448+      Curve.Montgomery.Curve25519+      Curve.Montgomery.Curve383187+      Curve.Montgomery.M221+      Curve.Montgomery.M383+      Curve.Montgomery.M511+      Curve.Weierstrass+      Curve.Weierstrass.Anomalous+      Curve.Weierstrass.ANSSIFRP256V1+      Curve.Weierstrass.BLS12_381+      Curve.Weierstrass.BLS12_381T+      Curve.Weierstrass.BLS48_581+      Curve.Weierstrass.BLS48_581T+      Curve.Weierstrass.BN224+      Curve.Weierstrass.BN254+      Curve.Weierstrass.BN254T+      Curve.Weierstrass.BN254A+      Curve.Weierstrass.BN254AT+      Curve.Weierstrass.BN254B+      Curve.Weierstrass.BN254BT+      Curve.Weierstrass.BN256+      Curve.Weierstrass.BN384+      Curve.Weierstrass.BN462+      Curve.Weierstrass.BN462T+      Curve.Weierstrass.BN512+      Curve.Weierstrass.SECP112R1+      Curve.Weierstrass.SECP112R2+      Curve.Weierstrass.SECP128R1+      Curve.Weierstrass.SECP128R2+      Curve.Weierstrass.SECP160K1+      Curve.Weierstrass.SECP160R1+      Curve.Weierstrass.SECP160R2+      Curve.Weierstrass.SECP192K1+      Curve.Weierstrass.SECP192R1+      Curve.Weierstrass.SECP224K1+      Curve.Weierstrass.SECP224R1+      Curve.Weierstrass.SECP256K1+      Curve.Weierstrass.SECP256R1+      Curve.Weierstrass.SECP384R1+      Curve.Weierstrass.SECP521R1+      Curve.Weierstrass.BrainpoolP160R1+      Curve.Weierstrass.BrainpoolP160T1+      Curve.Weierstrass.BrainpoolP192R1+      Curve.Weierstrass.BrainpoolP192T1+      Curve.Weierstrass.BrainpoolP224R1+      Curve.Weierstrass.BrainpoolP224T1+      Curve.Weierstrass.BrainpoolP256R1+      Curve.Weierstrass.BrainpoolP256T1+      Curve.Weierstrass.BrainpoolP320R1+      Curve.Weierstrass.BrainpoolP320T1+      Curve.Weierstrass.BrainpoolP384R1+      Curve.Weierstrass.BrainpoolP384T1+      Curve.Weierstrass.BrainpoolP512R1+      Curve.Weierstrass.BrainpoolP512T1+  other-modules:+      Paths_elliptic_curve+  hs-source-dirs:+      src+  default-extensions: LambdaCase RecordWildCards OverloadedStrings NoImplicitPrelude FlexibleInstances FlexibleContexts ScopedTypeVariables RankNTypes DataKinds DeriveAnyClass DeriveGeneric MultiParamTypeClasses TypeFamilyDependencies UndecidableInstances+  ghc-options: -O2 -Wall -fno-warn-orphans+  build-depends:+      MonadRandom+    , base >=4.7 && <5+    , galois-field+    , protolude >=0.2+    , tasty-quickcheck+    , wl-pprint-text+  default-language: Haskell2010++test-suite elliptic-curve-tests+  type: exitcode-stdio-1.0+  main-is: Main.hs+  other-modules:+      BinaryTests+      CurveTests+      EdwardsTests+      MontgomeryTests+      WeierstrassTests+      Curve+      Curve.Binary+      Curve.Binary.SECT113R1+      Curve.Binary.SECT113R2+      Curve.Binary.SECT131R1+      Curve.Binary.SECT131R2+      Curve.Binary.SECT163K1+      Curve.Binary.SECT163R1+      Curve.Binary.SECT163R2+      Curve.Binary.SECT193R1+      Curve.Binary.SECT193R2+      Curve.Binary.SECT233K1+      Curve.Binary.SECT233R1+      Curve.Binary.SECT239K1+      Curve.Binary.SECT283K1+      Curve.Binary.SECT283R1+      Curve.Binary.SECT409K1+      Curve.Binary.SECT409R1+      Curve.Binary.SECT571K1+      Curve.Binary.SECT571R1+      Curve.Edwards+      Curve.Edwards.Curve1174+      Curve.Edwards.Curve41417+      Curve.Edwards.E222+      Curve.Edwards.E382+      Curve.Edwards.E521+      Curve.Edwards.Ed25519+      Curve.Edwards.Ed3363+      Curve.Edwards.Ed448+      Curve.Edwards.JubJub+      Curve.Montgomery+      Curve.Montgomery.Curve25519+      Curve.Montgomery.Curve383187+      Curve.Montgomery.Curve448+      Curve.Montgomery.M221+      Curve.Montgomery.M383+      Curve.Montgomery.M511+      Curve.Weierstrass+      Curve.Weierstrass.Anomalous+      Curve.Weierstrass.ANSSIFRP256V1+      Curve.Weierstrass.BLS12_381+      Curve.Weierstrass.BLS12_381T+      Curve.Weierstrass.BLS48_581+      Curve.Weierstrass.BLS48_581T+      Curve.Weierstrass.BN224+      Curve.Weierstrass.BN254+      Curve.Weierstrass.BN254A+      Curve.Weierstrass.BN254AT+      Curve.Weierstrass.BN254B+      Curve.Weierstrass.BN254BT+      Curve.Weierstrass.BN254T+      Curve.Weierstrass.BN256+      Curve.Weierstrass.BN384+      Curve.Weierstrass.BN462+      Curve.Weierstrass.BN462T+      Curve.Weierstrass.BN512+      Curve.Weierstrass.BrainpoolP160R1+      Curve.Weierstrass.BrainpoolP160T1+      Curve.Weierstrass.BrainpoolP192R1+      Curve.Weierstrass.BrainpoolP192T1+      Curve.Weierstrass.BrainpoolP224R1+      Curve.Weierstrass.BrainpoolP224T1+      Curve.Weierstrass.BrainpoolP256R1+      Curve.Weierstrass.BrainpoolP256T1+      Curve.Weierstrass.BrainpoolP320R1+      Curve.Weierstrass.BrainpoolP320T1+      Curve.Weierstrass.BrainpoolP384R1+      Curve.Weierstrass.BrainpoolP384T1+      Curve.Weierstrass.BrainpoolP512R1+      Curve.Weierstrass.BrainpoolP512T1+      Curve.Weierstrass.SECP112R1+      Curve.Weierstrass.SECP112R2+      Curve.Weierstrass.SECP128R1+      Curve.Weierstrass.SECP128R2+      Curve.Weierstrass.SECP160K1+      Curve.Weierstrass.SECP160R1+      Curve.Weierstrass.SECP160R2+      Curve.Weierstrass.SECP192K1+      Curve.Weierstrass.SECP192R1+      Curve.Weierstrass.SECP224K1+      Curve.Weierstrass.SECP224R1+      Curve.Weierstrass.SECP256K1+      Curve.Weierstrass.SECP256R1+      Curve.Weierstrass.SECP384R1+      Curve.Weierstrass.SECP521R1+      Paths_elliptic_curve+  hs-source-dirs:+      tests+      src+  default-extensions: LambdaCase RecordWildCards OverloadedStrings NoImplicitPrelude FlexibleInstances FlexibleContexts ScopedTypeVariables RankNTypes DataKinds DeriveAnyClass DeriveGeneric MultiParamTypeClasses TypeFamilyDependencies UndecidableInstances+  ghc-options: -O2 -Wall -main-is Main+  build-depends:+      MonadRandom+    , arithmoi+    , base >=4.7 && <5+    , galois-field+    , protolude >=0.2+    , tasty+    , tasty-hunit+    , tasty-quickcheck+    , wl-pprint-text+  default-language: Haskell2010++benchmark elliptic-curve-benchmarks+  type: exitcode-stdio-1.0+  main-is: Main.hs+  other-modules:+      Curve+      Curve.Binary+      Curve.Binary.SECT113R1+      Curve.Binary.SECT113R2+      Curve.Binary.SECT131R1+      Curve.Binary.SECT131R2+      Curve.Binary.SECT163K1+      Curve.Binary.SECT163R1+      Curve.Binary.SECT163R2+      Curve.Binary.SECT193R1+      Curve.Binary.SECT193R2+      Curve.Binary.SECT233K1+      Curve.Binary.SECT233R1+      Curve.Binary.SECT239K1+      Curve.Binary.SECT283K1+      Curve.Binary.SECT283R1+      Curve.Binary.SECT409K1+      Curve.Binary.SECT409R1+      Curve.Binary.SECT571K1+      Curve.Binary.SECT571R1+      Curve.Edwards+      Curve.Edwards.Curve1174+      Curve.Edwards.Curve41417+      Curve.Edwards.E222+      Curve.Edwards.E382+      Curve.Edwards.E521+      Curve.Edwards.Ed25519+      Curve.Edwards.Ed3363+      Curve.Edwards.Ed448+      Curve.Edwards.JubJub+      Curve.Montgomery+      Curve.Montgomery.Curve25519+      Curve.Montgomery.Curve383187+      Curve.Montgomery.Curve448+      Curve.Montgomery.M221+      Curve.Montgomery.M383+      Curve.Montgomery.M511+      Curve.Weierstrass+      Curve.Weierstrass.Anomalous+      Curve.Weierstrass.ANSSIFRP256V1+      Curve.Weierstrass.BLS12_381+      Curve.Weierstrass.BLS12_381T+      Curve.Weierstrass.BLS48_581+      Curve.Weierstrass.BLS48_581T+      Curve.Weierstrass.BN224+      Curve.Weierstrass.BN254+      Curve.Weierstrass.BN254A+      Curve.Weierstrass.BN254AT+      Curve.Weierstrass.BN254B+      Curve.Weierstrass.BN254BT+      Curve.Weierstrass.BN254T+      Curve.Weierstrass.BN256+      Curve.Weierstrass.BN384+      Curve.Weierstrass.BN462+      Curve.Weierstrass.BN462T+      Curve.Weierstrass.BN512+      Curve.Weierstrass.BrainpoolP160R1+      Curve.Weierstrass.BrainpoolP160T1+      Curve.Weierstrass.BrainpoolP192R1+      Curve.Weierstrass.BrainpoolP192T1+      Curve.Weierstrass.BrainpoolP224R1+      Curve.Weierstrass.BrainpoolP224T1+      Curve.Weierstrass.BrainpoolP256R1+      Curve.Weierstrass.BrainpoolP256T1+      Curve.Weierstrass.BrainpoolP320R1+      Curve.Weierstrass.BrainpoolP320T1+      Curve.Weierstrass.BrainpoolP384R1+      Curve.Weierstrass.BrainpoolP384T1+      Curve.Weierstrass.BrainpoolP512R1+      Curve.Weierstrass.BrainpoolP512T1+      Curve.Weierstrass.SECP112R1+      Curve.Weierstrass.SECP112R2+      Curve.Weierstrass.SECP128R1+      Curve.Weierstrass.SECP128R2+      Curve.Weierstrass.SECP160K1+      Curve.Weierstrass.SECP160R1+      Curve.Weierstrass.SECP160R2+      Curve.Weierstrass.SECP192K1+      Curve.Weierstrass.SECP192R1+      Curve.Weierstrass.SECP224K1+      Curve.Weierstrass.SECP224R1+      Curve.Weierstrass.SECP256K1+      Curve.Weierstrass.SECP256R1+      Curve.Weierstrass.SECP384R1+      Curve.Weierstrass.SECP521R1+      Paths_elliptic_curve+  hs-source-dirs:+      benchmarks+      src+  default-extensions: LambdaCase RecordWildCards OverloadedStrings NoImplicitPrelude FlexibleInstances FlexibleContexts ScopedTypeVariables RankNTypes DataKinds DeriveAnyClass DeriveGeneric MultiParamTypeClasses TypeFamilyDependencies UndecidableInstances+  ghc-options: -O2 -Wall -main-is Main+  build-depends:+      MonadRandom+    , base >=4.7 && <5+    , criterion+    , galois-field+    , protolude >=0.2+    , tasty-quickcheck+    , wl-pprint-text+  default-language: Haskell2010
+ src/Curve.hs view
@@ -0,0 +1,65 @@+module Curve+  ( Curve(..)+  ) where++import Protolude++import Control.Monad.Random (MonadRandom)+import GaloisField (GaloisField)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Elliptic curves over Galois fields.+class GaloisField k => Curve r c k where+  {-# MINIMAL id, inv, add, def, disc, point, rnd #-}++  -- | Curve point.+  data family Point r c k :: *++  -- | Point identity.+  id :: Point r c k++  -- | Point inversion.+  inv :: Point r c k -> Point r c k++  -- | Point addition.+  add :: Point r c k -> Point r c k -> Point r c k++  -- | Point doubling.+  double :: Point r c k -> Point r c k+  double = join add+  {-# INLINE double #-}++  -- | Point multiplication.+  mul :: Integral n => n -> Point r c k -> Point r c k+  mul n p+    | n < 0     = inv (mul (-n) p)+    | n == 0    = id+    | n == 1    = p+    | even n    = p'+    | otherwise = add p p'+    where+      p' = mul (div n 2) (double p)+  {-# INLINE mul #-}++  -- | Point is well-defined.+  def :: Point r c k -> Bool++  -- | Get curve discriminant.+  disc :: Point r c k -> k++  -- | Get point from x coordinate.+  point :: k -> Maybe (Point r c k)++  -- | Get random point.+  rnd :: MonadRandom m => m (Point r c k)++-- Elliptic curves are semigroups.+instance Curve r c k => Semigroup (Point r c k) where+  (<>) = add++-- Elliptic curves are monoids.+instance Curve r c k => Monoid (Point r c k) where+  mempty = id
+ src/Curve/Binary.hs view
@@ -0,0 +1,112 @@+module Curve.Binary+  ( BCurve(..)+  , BPoint+  , Point(..)+  ) where++import Protolude++import Control.Monad.Random (Random(..), getRandom)+import GaloisField (GaloisField(..))+import Test.Tasty.QuickCheck (Arbitrary(..))+import Text.PrettyPrint.Leijen.Text (Pretty(..))++import Curve (Curve(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Binary curve representation.+data B++-- | Binary curve points.+type BPoint = Point B++-- | Binary curves @y^2 + xy = x^3 + Ax^2 + B@.+class Curve B c k => BCurve c k where+  a_ :: c -> k     -- ^ Coefficient @A@.+  b_ :: c -> k     -- ^ Coefficient @B@.+  g_ :: BPoint c k -- ^ Curve generator.++-- Binary points are arbitrary.+instance (GaloisField k, BCurve c k) => Arbitrary (Point B c k) where+  arbitrary = return g_+  -- arbitrary = flip mul g_ <$> (arbitrary :: Gen Int)+  -- arbitrary = suchThatMap arbitrary point++-- Binary points are pretty.+instance (GaloisField k, BCurve c k) => Pretty (Point B c k) where+  pretty (A x y) = pretty (x, y)+  pretty O       = "O"++-- Binary points are random.+instance (GaloisField k, BCurve c k) => Random (Point B c k) where+  random g = case point x of+    Just p -> (p, g')+    _      -> random g'+    where+      (x, g') = random g+  {-# INLINE random #-}+  randomR  = panic "not implemented."++-------------------------------------------------------------------------------+-- Operations+-------------------------------------------------------------------------------++-- Binary curves are elliptic curves.+instance (GaloisField k, BCurve c k) => Curve B c k where++  data instance Point B c k = A k k -- ^ Affine point.+                            | O     -- ^ Infinite point.+    deriving (Eq, Generic, NFData, Read, Show)++  id = O+  {-# INLINE id #-}++  inv O       = O+  inv (A x y) = A x (x + y)+  {-# INLINE inv #-}++  add p O          = p+  add O q          = q+  add p@(A x1 y1) (A x2 y2)+    | xx /= 0      = A x3 y3+    | yy + x2 /= 0 = double p+    | otherwise    = O+    where+      xx = x1 + x2+      yy = y1 + y2+      l  = yy / xx+      x3 = l * (l + 1) + xx + a_ (witness :: c)+      y3 = l * (x1 + x3) + x3 + y1+  {-# INLINE add #-}++  double O       = O+  double (A x y) = A x' y'+    where+      l  = x + y / x+      l' = l + 1+      x' = l * l' + a_ (witness :: c)+      y' = x * x + l' * x'+  {-# INLINE double #-}++  def O       = True+  def (A x y) = ((x + a) * x + y) * x + b + y * y == 0+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE def #-}++  disc _ = b_ (witness :: c)+  {-# INLINE disc #-}++  point 0 = A 0 <$> sr (b_ (witness :: c))+  point x = A x <$> quad 1 x ((x + a) * x * x + b)+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE point #-}++  rnd = getRandom+  {-# INLINE rnd #-}
+ src/Curve/Binary/SECT113R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT113R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT113R1 curve+data SECT113R1++-- | Field of SECT113R1 curve+type F2m = BinaryField 0x20000000000000000000000000201++-- | SECT113R1 curve is a binary curve+instance BCurve SECT113R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT113R1 curve+type P = BPoint SECT113R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT113R1 curve+_a :: F2m+_a = 0x3088250ca6e7c7fe649ce85820f7+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT113R1 curve+_b :: F2m+_b = 0xe8bee4d3e2260744188be0e9c723+{-# INLINE _b #-}++-- | Polynomial of SECT113R1 curve+_f :: Integer+_f = 0x20000000000000000000000000201+{-# INLINE _f #-}++-- | Generator of SECT113R1 curve+_g :: P+_g = A+     0x9d73616f35f4ab1407d73562c10f+     0xa52830277958ee84d1315ed31886+{-# INLINE _g #-}++-- | Cofactor of SECT113R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT113R1 curve+_n :: Integer+_n = 0x100000000000000d9ccec8a39e56f+{-# INLINE _n #-}
+ src/Curve/Binary/SECT113R2.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT113R2+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT113R2 curve+data SECT113R2++-- | Field of SECT113R2 curve+type F2m = BinaryField 0x20000000000000000000000000201++-- | SECT113R2 curve is a binary curve+instance BCurve SECT113R2 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT113R2 curve+type P = BPoint SECT113R2 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT113R2 curve+_a :: F2m+_a = 0x689918dbec7e5a0dd6dfc0aa55c7+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT113R2 curve+_b :: F2m+_b = 0x95e9a9ec9b297bd4bf36e059184f+{-# INLINE _b #-}++-- | Polynomial of SECT113R2 curve+_f :: Integer+_f = 0x20000000000000000000000000201+{-# INLINE _f #-}++-- | Generator of SECT113R2 curve+_g :: P+_g = A+     0x1a57a6a7b26ca5ef52fcdb8164797+     0xb3adc94ed1fe674c06e695baba1d+{-# INLINE _g #-}++-- | Cofactor of SECT113R2 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT113R2 curve+_n :: Integer+_n = 0x10000000000000108789b2496af93+{-# INLINE _n #-}
+ src/Curve/Binary/SECT131R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT131R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT131R1 curve+data SECT131R1++-- | Field of SECT131R1 curve+type F2m = BinaryField 0x80000000000000000000000000000010d++-- | SECT131R1 curve is a binary curve+instance BCurve SECT131R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT131R1 curve+type P = BPoint SECT131R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT131R1 curve+_a :: F2m+_a = 0x7a11b09a76b562144418ff3ff8c2570b8+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT131R1 curve+_b :: F2m+_b = 0x217c05610884b63b9c6c7291678f9d341+{-# INLINE _b #-}++-- | Polynomial of SECT131R1 curve+_f :: Integer+_f = 0x80000000000000000000000000000010d+{-# INLINE _f #-}++-- | Generator of SECT131R1 curve+_g :: P+_g = A+     0x81baf91fdf9833c40f9c181343638399+     0x78c6e7ea38c001f73c8134b1b4ef9e150+{-# INLINE _g #-}++-- | Cofactor of SECT131R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT131R1 curve+_n :: Integer+_n = 0x400000000000000023123953a9464b54d+{-# INLINE _n #-}
+ src/Curve/Binary/SECT131R2.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT131R2+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT131R2 curve+data SECT131R2++-- | Field of SECT131R2 curve+type F2m = BinaryField 0x80000000000000000000000000000010d++-- | SECT131R2 curve is a binary curve+instance BCurve SECT131R2 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT131R2 curve+type P = BPoint SECT131R2 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT131R2 curve+_a :: F2m+_a = 0x3e5a88919d7cafcbf415f07c2176573b2+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT131R2 curve+_b :: F2m+_b = 0x4b8266a46c55657ac734ce38f018f2192+{-# INLINE _b #-}++-- | Polynomial of SECT131R2 curve+_f :: Integer+_f = 0x80000000000000000000000000000010d+{-# INLINE _f #-}++-- | Generator of SECT131R2 curve+_g :: P+_g = A+     0x356dcd8f2f95031ad652d23951bb366a8+     0x648f06d867940a5366d9e265de9eb240f+{-# INLINE _g #-}++-- | Cofactor of SECT131R2 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT131R2 curve+_n :: Integer+_n = 0x400000000000000016954a233049ba98f+{-# INLINE _n #-}
+ src/Curve/Binary/SECT163K1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT163K1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT163K1 curve+data SECT163K1++-- | Field of SECT163K1 curve+type F2m = BinaryField 0x800000000000000000000000000000000000000c9++-- | SECT163K1 curve is a binary curve+instance BCurve SECT163K1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT163K1 curve+type P = BPoint SECT163K1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT163K1 curve+_a :: F2m+_a = 1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT163K1 curve+_b :: F2m+_b = 1+{-# INLINE _b #-}++-- | Polynomial of SECT163K1 curve+_f :: Integer+_f = 0x800000000000000000000000000000000000000c9+{-# INLINE _f #-}++-- | Generator of SECT163K1 curve+_g :: P+_g = A+     0x2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8+     0x289070fb05d38ff58321f2e800536d538ccdaa3d9+{-# INLINE _g #-}++-- | Cofactor of SECT163K1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT163K1 curve+_n :: Integer+_n = 0x4000000000000000000020108a2e0cc0d99f8a5ef+{-# INLINE _n #-}
+ src/Curve/Binary/SECT163R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT163R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT163R1 curve+data SECT163R1++-- | Field of SECT163R1 curve+type F2m = BinaryField 0x800000000000000000000000000000000000000c9++-- | SECT163R1 curve is a binary curve+instance BCurve SECT163R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT163R1 curve+type P = BPoint SECT163R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT163R1 curve+_a :: F2m+_a = 0x7b6882caaefa84f9554ff8428bd88e246d2782ae2+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT163R1 curve+_b :: F2m+_b = 0x713612dcddcb40aab946bda29ca91f73af958afd9+{-# INLINE _b #-}++-- | Polynomial of SECT163R1 curve+_f :: Integer+_f = 0x800000000000000000000000000000000000000c9+{-# INLINE _f #-}++-- | Generator of SECT163R1 curve+_g :: P+_g = A+     0x369979697ab43897789566789567f787a7876a654+     0x435edb42efafb2989d51fefce3c80988f41ff883+{-# INLINE _g #-}++-- | Cofactor of SECT163R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT163R1 curve+_n :: Integer+_n = 0x3ffffffffffffffffffff48aab689c29ca710279b+{-# INLINE _n #-}
+ src/Curve/Binary/SECT163R2.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT163R2+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT163R2 curve+data SECT163R2++-- | Field of SECT163R2 curve+type F2m = BinaryField 0x800000000000000000000000000000000000000c9++-- | SECT163R2 curve is a binary curve+instance BCurve SECT163R2 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT163R2 curve+type P = BPoint SECT163R2 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT163R2 curve+_a :: F2m+_a = 1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT163R2 curve+_b :: F2m+_b = 0x20a601907b8c953ca1481eb10512f78744a3205fd+{-# INLINE _b #-}++-- | Polynomial of SECT163R2 curve+_f :: Integer+_f = 0x800000000000000000000000000000000000000c9+{-# INLINE _f #-}++-- | Generator of SECT163R2 curve+_g :: P+_g = A+     0x3f0eba16286a2d57ea0991168d4994637e8343e36+     0xd51fbc6c71a0094fa2cdd545b11c5c0c797324f1+{-# INLINE _g #-}++-- | Cofactor of SECT163R2 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT163R2 curve+_n :: Integer+_n = 0x40000000000000000000292fe77e70c12a4234c33+{-# INLINE _n #-}
+ src/Curve/Binary/SECT193R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT193R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT193R1 curve+data SECT193R1++-- | Field of SECT193R1 curve+type F2m = BinaryField 0x2000000000000000000000000000000000000000000008001++-- | SECT193R1 curve is a binary curve+instance BCurve SECT193R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT193R1 curve+type P = BPoint SECT193R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT193R1 curve+_a :: F2m+_a = 0x17858feb7a98975169e171f77b4087de098ac8a911df7b01+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT193R1 curve+_b :: F2m+_b = 0xfdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814+{-# INLINE _b #-}++-- | Polynomial of SECT193R1 curve+_f :: Integer+_f = 0x2000000000000000000000000000000000000000000008001+{-# INLINE _f #-}++-- | Generator of SECT193R1 curve+_g :: P+_g = A+     0x1f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1+     0x25e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05+{-# INLINE _g #-}++-- | Cofactor of SECT193R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT193R1 curve+_n :: Integer+_n = 0x1000000000000000000000000c7f34a778f443acc920eba49+{-# INLINE _n #-}
+ src/Curve/Binary/SECT193R2.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT193R2+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT193R2 curve+data SECT193R2++-- | Field of SECT193R2 curve+type F2m = BinaryField 0x2000000000000000000000000000000000000000000008001++-- | SECT193R2 curve is a binary curve+instance BCurve SECT193R2 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT193R2 curve+type P = BPoint SECT193R2 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT193R2 curve+_a :: F2m+_a = 0x163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT193R2 curve+_b :: F2m+_b = 0xc9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae+{-# INLINE _b #-}++-- | Polynomial of SECT193R2 curve+_f :: Integer+_f = 0x2000000000000000000000000000000000000000000008001+{-# INLINE _f #-}++-- | Generator of SECT193R2 curve+_g :: P+_g = A+     0xd9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f+     0x1ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c+{-# INLINE _g #-}++-- | Cofactor of SECT193R2 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT193R2 curve+_n :: Integer+_n = 0x10000000000000000000000015aab561b005413ccd4ee99d5+{-# INLINE _n #-}
+ src/Curve/Binary/SECT233K1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT233K1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT233K1 curve+data SECT233K1++-- | Field of SECT233K1 curve+type F2m = BinaryField 0x20000000000000000000000000000000000000004000000000000000001++-- | SECT233K1 curve is a binary curve+instance BCurve SECT233K1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT233K1 curve+type P = BPoint SECT233K1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT233K1 curve+_a :: F2m+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT233K1 curve+_b :: F2m+_b = 1+{-# INLINE _b #-}++-- | Polynomial of SECT233K1 curve+_f :: Integer+_f = 0x20000000000000000000000000000000000000004000000000000000001+{-# INLINE _f #-}++-- | Generator of SECT233K1 curve+_g :: P+_g = A+     0x17232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126+     0x1db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3+{-# INLINE _g #-}++-- | Cofactor of SECT233K1 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECT233K1 curve+_n :: Integer+_n = 0x8000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf+{-# INLINE _n #-}
+ src/Curve/Binary/SECT233R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT233R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT233R1 curve+data SECT233R1++-- | Field of SECT233R1 curve+type F2m = BinaryField 0x20000000000000000000000000000000000000004000000000000000001++-- | SECT233R1 curve is a binary curve+instance BCurve SECT233R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT233R1 curve+type P = BPoint SECT233R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT233R1 curve+_a :: F2m+_a = 1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT233R1 curve+_b :: F2m+_b = 0x66647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad+{-# INLINE _b #-}++-- | Polynomial of SECT233R1 curve+_f :: Integer+_f = 0x20000000000000000000000000000000000000004000000000000000001+{-# INLINE _f #-}++-- | Generator of SECT233R1 curve+_g :: P+_g = A+     0xfac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b+     0x1006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052+{-# INLINE _g #-}++-- | Cofactor of SECT233R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT233R1 curve+_n :: Integer+_n = 0x1000000000000000000000000000013e974e72f8a6922031d2603cfe0d7+{-# INLINE _n #-}
+ src/Curve/Binary/SECT239K1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT239K1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT239K1 curve+data SECT239K1++-- | Field of SECT239K1 curve+type F2m = BinaryField 0x800000000000000000004000000000000000000000000000000000000001++-- | SECT239K1 curve is a binary curve+instance BCurve SECT239K1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT239K1 curve+type P = BPoint SECT239K1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT239K1 curve+_a :: F2m+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT239K1 curve+_b :: F2m+_b = 1+{-# INLINE _b #-}++-- | Polynomial of SECT239K1 curve+_f :: Integer+_f = 0x800000000000000000004000000000000000000000000000000000000001+{-# INLINE _f #-}++-- | Generator of SECT239K1 curve+_g :: P+_g = A+     0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc+     0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca+{-# INLINE _g #-}++-- | Cofactor of SECT239K1 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECT239K1 curve+_n :: Integer+_n = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5+{-# INLINE _n #-}
+ src/Curve/Binary/SECT283K1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT283K1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT283K1 curve+data SECT283K1++-- | Field of SECT283K1 curve+type F2m = BinaryField 0x800000000000000000000000000000000000000000000000000000000000000000010a1++-- | SECT283K1 curve is a binary curve+instance BCurve SECT283K1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT283K1 curve+type P = BPoint SECT283K1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT283K1 curve+_a :: F2m+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT283K1 curve+_b :: F2m+_b = 1+{-# INLINE _b #-}++-- | Polynomial of SECT283K1 curve+_f :: Integer+_f = 0x800000000000000000000000000000000000000000000000000000000000000000010a1+{-# INLINE _f #-}++-- | Generator of SECT283K1 curve+_g :: P+_g = A+     0x503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836+     0x1ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259+{-# INLINE _g #-}++-- | Cofactor of SECT283K1 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECT283K1 curve+_n :: Integer+_n = 0x1ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61+{-# INLINE _n #-}
+ src/Curve/Binary/SECT283R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT283R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT283R1 curve+data SECT283R1++-- | Field of SECT283R1 curve+type F2m = BinaryField 0x800000000000000000000000000000000000000000000000000000000000000000010a1++-- | SECT283R1 curve is a binary curve+instance BCurve SECT283R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT283R1 curve+type P = BPoint SECT283R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT283R1 curve+_a :: F2m+_a = 1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT283R1 curve+_b :: F2m+_b = 0x27b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5+{-# INLINE _b #-}++-- | Polynomial of SECT283R1 curve+_f :: Integer+_f = 0x800000000000000000000000000000000000000000000000000000000000000000010a1+{-# INLINE _f #-}++-- | Generator of SECT283R1 curve+_g :: P+_g = A+     0x5f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053+     0x3676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4+{-# INLINE _g #-}++-- | Cofactor of SECT283R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT283R1 curve+_n :: Integer+_n = 0x3ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307+{-# INLINE _n #-}
+ src/Curve/Binary/SECT409K1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT409K1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT409K1 curve+data SECT409K1++-- | Field of SECT409K1 curve+type F2m = BinaryField 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001++-- | SECT409K1 curve is a binary curve+instance BCurve SECT409K1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT409K1 curve+type P = BPoint SECT409K1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT409K1 curve+_a :: F2m+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT409K1 curve+_b :: F2m+_b = 1+{-# INLINE _b #-}++-- | Polynomial of SECT409K1 curve+_f :: Integer+_f = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+{-# INLINE _f #-}++-- | Generator of SECT409K1 curve+_g :: P+_g = A+     0x60f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746+     0x1e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b+{-# INLINE _g #-}++-- | Cofactor of SECT409K1 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECT409K1 curve+_n :: Integer+_n = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf+{-# INLINE _n #-}
+ src/Curve/Binary/SECT409R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT409R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT409R1 curve+data SECT409R1++-- | Field of SECT409R1 curve+type F2m = BinaryField 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001++-- | SECT409R1 curve is a binary curve+instance BCurve SECT409R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT409R1 curve+type P = BPoint SECT409R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT409R1 curve+_a :: F2m+_a = 1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT409R1 curve+_b :: F2m+_b = 0x21a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f+{-# INLINE _b #-}++-- | Polynomial of SECT409R1 curve+_f :: Integer+_f = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+{-# INLINE _f #-}++-- | Generator of SECT409R1 curve+_g :: P+_g = A+     0x15d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7+     0x61b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706+{-# INLINE _g #-}++-- | Cofactor of SECT409R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT409R1 curve+_n :: Integer+_n = 0x10000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173+{-# INLINE _n #-}
+ src/Curve/Binary/SECT571K1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT571K1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT571K1 curve+data SECT571K1++-- | Field of SECT571K1 curve+type F2m = BinaryField 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425++-- | SECT571K1 curve is a binary curve+instance BCurve SECT571K1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT571K1 curve+type P = BPoint SECT571K1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT571K1 curve+_a :: F2m+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT571K1 curve+_b :: F2m+_b = 1+{-# INLINE _b #-}++-- | Polynomial of SECT571K1 curve+_f :: Integer+_f = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+{-# INLINE _f #-}++-- | Generator of SECT571K1 curve+_g :: P+_g = A+     0x26eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972+     0x349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3+{-# INLINE _g #-}++-- | Cofactor of SECT571K1 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECT571K1 curve+_n :: Integer+_n = 0x20000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001+{-# INLINE _n #-}
+ src/Curve/Binary/SECT571R1.hs view
@@ -0,0 +1,74 @@+module Curve.Binary.SECT571R1+  ( F2m+  , P+  , _a+  , _b+  , _f+  , _g+  , _h+  , _n+  ) where++import Protolude++import BinaryField (BinaryField)++import Curve.Binary (BCurve(..), BPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECT571R1 curve+data SECT571R1++-- | Field of SECT571R1 curve+type F2m = BinaryField 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425++-- | SECT571R1 curve is a binary curve+instance BCurve SECT571R1 F2m where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECT571R1 curve+type P = BPoint SECT571R1 F2m++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECT571R1 curve+_a :: F2m+_a = 1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECT571R1 curve+_b :: F2m+_b = 0x2f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a+{-# INLINE _b #-}++-- | Polynomial of SECT571R1 curve+_f :: Integer+_f = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+{-# INLINE _f #-}++-- | Generator of SECT571R1 curve+_g :: P+_g = A+     0x303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19+     0x37bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b+{-# INLINE _g #-}++-- | Cofactor of SECT571R1 curve+_h :: Integer+_h = 2+{-# INLINE _h #-}++-- | Order of SECT571R1 curve+_n :: Integer+_n = 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47+{-# INLINE _n #-}
+ src/Curve/Edwards.hs view
@@ -0,0 +1,100 @@+module Curve.Edwards+  ( ECurve(..)+  , EPoint+  , Point(..)+  ) where++import Protolude++import Control.Monad.Random (Random(..), getRandom)+import GaloisField (GaloisField(..))+import Test.Tasty.QuickCheck (Arbitrary(..), suchThatMap)+import Text.PrettyPrint.Leijen.Text (Pretty(..))++import Curve (Curve(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Edwards curve representation.+data E++-- | Edwards curve points.+type EPoint = Point E++-- | Edwards curves @Ax^2 + y^2 = 1 + Dx^2y^2@.+class Curve E c k => ECurve c k where+  a_ :: c -> k     -- ^ Coefficient @A@.+  d_ :: c -> k     -- ^ Coefficient @D@.+  g_ :: EPoint c k -- ^ Curve generator.++-- Edwards points are arbitrary.+instance (GaloisField k, ECurve c k) => Arbitrary (Point E c k) where+  arbitrary = suchThatMap arbitrary point++-- Edwards points are pretty.+instance (GaloisField k, ECurve c k) => Pretty (Point E c k) where+  pretty (A x y) = pretty (x, y)++-- Edwards points are random.+instance (GaloisField k, ECurve c k) => Random (Point E c k) where+  random g = case point x of+    Just p -> (p, g')+    _      -> random g'+    where+      (x, g') = random g+  {-# INLINE random #-}+  randomR  = panic "not implemented."++-------------------------------------------------------------------------------+-- Operations+-------------------------------------------------------------------------------++-- Edwards curves are elliptic curves.+instance (GaloisField k, ECurve c k) => Curve E c k where++  data instance Point E c k = A k k -- ^ Affine point.+    deriving (Eq, Generic, NFData, Read, Show)++  id = A 0 1+  {-# INLINE id #-}++  inv (A x y) = A (-x) y+  {-# INLINE inv #-}++  add (A x1 y1) (A x2 y2) = A x3 y3+    where+      a    = a_ (witness :: c)+      d    = d_ (witness :: c)+      x1x2 = x1 * x2+      y1y2 = y1 * y2+      x1y2 = x1 * y2+      x2y1 = x2 * y1+      dxy  = d * x1x2 * y1y2+      x3   = (x1y2 + x2y1) / (1 + dxy)+      y3   = (y1y2 - a * x1x2) / (1 - dxy)+  {-# INLINE add #-}++  def (A x y) = a * xx + yy == 1 + d * xx * yy+    where+      a  = a_ (witness :: c)+      d  = d_ (witness :: c)+      xx = x * x+      yy = y * y+  {-# INLINE def #-}++  disc _ = d * (1 - d)+    where+      d = d_ (witness :: c)+  {-# INLINE disc #-}++  point x = A x <$> sr ((1 - a * xx) / (1 - d * xx))+    where+      a  = a_ (witness :: c)+      d  = d_ (witness :: c)+      xx = x * x+  {-# INLINE point #-}++  rnd = getRandom+  {-# INLINE rnd #-}
+ src/Curve/Edwards/Curve1174.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.Curve1174+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Curve1174 curve+data Curve1174++-- | Field of Curve1174 curve+type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7++-- | Curve1174 curve is an Edwards curve+instance ECurve Curve1174 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Curve1174 curve+type P = EPoint Curve1174 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Curve1174 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of Curve1174 curve+_d :: Fp+_d = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb61+{-# INLINE _d #-}++-- | Generator of Curve1174 curve+_g :: P+_g = A+     0x37fbb0cea308c479343aee7c029a190c021d96a492ecd6516123f27bce29eda+     0x6b72f82d47fb7cc6656841169840e0c4fe2dee2af3f976ba4ccb1bf9b46360e+{-# INLINE _g #-}++-- | Cofactor of Curve1174 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of Curve1174 curve+_n :: Integer+_n = 0x1fffffffffffffffffffffffffffffff77965c4dfd307348944d45fd166c971+{-# INLINE _n #-}++-- | Characteristic of Curve1174 curve+_p :: Integer+_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7+{-# INLINE _p #-}
+ src/Curve/Edwards/Curve41417.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.Curve41417+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Curve41417 curve+data Curve41417++-- | Field of Curve41417 curve+type Fp = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef++-- | Curve41417 curve is an Edwards curve+instance ECurve Curve41417 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Curve41417 curve+type P = EPoint Curve41417 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Curve41417 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of Curve41417 curve+_d :: Fp+_d = 0xe21+{-# INLINE _d #-}++-- | Generator of Curve41417 curve+_g :: P+_g = A+     0x1a334905141443300218c0631c326e5fcd46369f44c03ec7f57ff35498a4ab4d6d6ba111301a73faa8537c64c4fd3812f3cbc595+     0x22+{-# INLINE _g #-}++-- | Cofactor of Curve41417 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of Curve41417 curve+_n :: Integer+_n = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffeb3cc92414cf706022b36f1c0338ad63cf181b0e71a5e106af79+{-# INLINE _n #-}++-- | Characteristic of Curve41417 curve+_p :: Integer+_p = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef+{-# INLINE _p #-}
+ src/Curve/Edwards/E222.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.E222+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | E-222 curve+data E222++-- | Field of E-222 curve+type Fp = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b++-- | E-222 curve is an Edwards curve+instance ECurve E222 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of E-222 curve+type P = EPoint E222 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of E-222 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of E-222 curve+_d :: Fp+_d = 0x27166+{-# INLINE _d #-}++-- | Generator of E-222 curve+_g :: P+_g = A+     0x19b12bb156a389e55c9768c303316d07c23adab3736eb2bc3eb54e51+     0x1c+{-# INLINE _g #-}++-- | Cofactor of E-222 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of E-222 curve+_n :: Integer+_n = 0xffffffffffffffffffffffffffff70cbc95e932f802f31423598cbf+{-# INLINE _n #-}++-- | Characteristic of E-222 curve+_p :: Integer+_p = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b+{-# INLINE _p #-}
+ src/Curve/Edwards/E382.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.E382+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | E-382 curve+data E382++-- | Field of E-382 curve+type Fp = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97++-- | E-382 curve is an Edwards curve+instance ECurve E382 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of E-382 curve+type P = EPoint E382 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of E-382 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of E-382 curve+_d :: Fp+_d = 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef8e1+{-# INLINE _d #-}++-- | Generator of E-382 curve+_g :: P+_g = A+     0x196f8dd0eab20391e5f05be96e8d20ae68f840032b0b64352923bab85364841193517dbce8105398ebc0cc9470f79603+     0x11+{-# INLINE _g #-}++-- | Cofactor of E-382 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of E-382 curve+_n :: Integer+_n = 0xfffffffffffffffffffffffffffffffffffffffffffffffd5fb21f21e95eee17c5e69281b102d2773e27e13fd3c9719+{-# INLINE _n #-}++-- | Characteristic of E-382 curve+_p :: Integer+_p = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97+{-# INLINE _p #-}
+ src/Curve/Edwards/E521.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.E521+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | E-521 curve+data E521++-- | Field of E-521 curve+type Fp = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff++-- | E-521 curve is an Edwards curve+instance ECurve E521 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of E-521 curve+type P = EPoint E521 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of E-521 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of E-521 curve+_d :: Fp+_d = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa4331+{-# INLINE _d #-}++-- | Generator of E-521 curve+_g :: P+_g = A+     0x752cb45c48648b189df90cb2296b2878a3bfd9f42fc6c818ec8bf3c9c0c6203913f6ecc5ccc72434b1ae949d568fc99c6059d0fb13364838aa302a940a2f19ba6c+     0xc+{-# INLINE _g #-}++-- | Cofactor of E-521 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of E-521 curve+_n :: Integer+_n = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd15b6c64746fc85f736b8af5e7ec53f04fbd8c4569a8f1f4540ea2435f5180d6b+{-# INLINE _n #-}++-- | Characteristic of E-521 curve+_p :: Integer+_p = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Edwards/Ed25519.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.Ed25519+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Ed25519 curve+data Ed25519++-- | Field of Ed25519 curve+type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed++-- | Ed25519 curve is an Edwards curve+instance ECurve Ed25519 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Ed25519 curve+type P = EPoint Ed25519 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Ed25519 curve+_a :: Fp+_a = -1+{-# INLINE _a #-}++-- | Coefficient @D@ of Ed25519 curve+_d :: Fp+_d = 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3+{-# INLINE _d #-}++-- | Generator of Ed25519 curve+_g :: P+_g = A+     0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a+     0x6666666666666666666666666666666666666666666666666666666666666658+{-# INLINE _g #-}++-- | Cofactor of Ed25519 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of Ed25519 curve+_n :: Integer+_n = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+{-# INLINE _n #-}++-- | Characteristic of Ed25519 curve+_p :: Integer+_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+{-# INLINE _p #-}
+ src/Curve/Edwards/Ed3363.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.Ed3363+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Ed3363 curve+data Ed3363++-- | Field of Ed3363 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd++-- | Ed3363 curve is an Edwards curve+instance ECurve Ed3363 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Ed3363 curve+type P = EPoint Ed3363 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Ed3363 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of Ed3363 curve+_d :: Fp+_d = 0x2b67+{-# INLINE _d #-}++-- | Generator of Ed3363 curve+_g :: P+_g = A+     0xc+     0xc0dc616b56502e18e1c161d007853d1b14b46c3811c7ef435b6db5d5650ca0365db12bec68505fe8632+{-# INLINE _g #-}++-- | Cofactor of Ed3363 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of Ed3363 curve+_n :: Integer+_n = 0x200000000000000000000000000000000000000000071415fa9850c0bd6b87f93baa7b2f95973e9fa805+{-# INLINE _n #-}++-- | Characteristic of Ed3363 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd+{-# INLINE _p #-}
+ src/Curve/Edwards/Ed448.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.Ed448+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Ed448 curve+data Ed448++-- | Field of Ed448 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff++-- | Ed448 curve is an Edwards curve+instance ECurve Ed448 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Ed448 curve+type P = EPoint Ed448 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Ed448 curve+_a :: Fp+_a = 1+{-# INLINE _a #-}++-- | Coefficient @D@ of Ed448 curve+_d :: Fp+_d = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffff6756+{-# INLINE _d #-}++-- | Generator of Ed448 curve+_g :: P+_g = A+     0x297ea0ea2692ff1b4faff46098453a6a26adf733245f065c3c59d0709cecfa96147eaaf3932d94c63d96c170033f4ba0c7f0de840aed939f+     0x13+{-# INLINE _g #-}++-- | Cofactor of Ed448 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of Ed448 curve+_n :: Integer+_n = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+{-# INLINE _n #-}++-- | Characteristic of Ed448 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Edwards/JubJub.hs view
@@ -0,0 +1,74 @@+module Curve.Edwards.JubJub+  ( Fp+  , P+  , _a+  , _d+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Edwards (ECurve(..), EPoint, Point(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | JubJub curve+data JubJub++-- | Field of JubJub curve+type Fp = PrimeField 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001++-- | JubJub curve is an Edwards curve+instance ECurve JubJub Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  d_ = const _d+  {-# INLINE d_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of JubJub curve+type P = EPoint JubJub Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of JubJub curve+_a :: Fp+_a = -1+{-# INLINE _a #-}++-- | Coefficient @D@ of JubJub curve+_d :: Fp+_d = 0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1+{-# INLINE _d #-}++-- | Generator of JubJub curve+_g :: P+_g = A+     0x5183972af8eff38ca624b4df00384882000c546bf2f39ede7f4ecf1a74f976c4+     0x3b43f8472ca2fc2c9e8fcc5abd9dc308096c8707ffa6833b146bad709349702e+{-# INLINE _g #-}++-- | Cofactor of JubJub curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of JubJub curve+_n :: Integer+_n = 0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7+{-# INLINE _n #-}++-- | Characteristic of JubJub curve+_p :: Integer+_p = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+{-# INLINE _p #-}
+ src/Curve/Montgomery.hs view
@@ -0,0 +1,114 @@+module Curve.Montgomery+  ( Point(..)+  , MCurve(..)+  , MPoint+  ) where++import Protolude++import Control.Monad.Random (Random(..), getRandom)+import GaloisField (GaloisField(..))+import Test.Tasty.QuickCheck (Arbitrary(..), suchThatMap)+import Text.PrettyPrint.Leijen.Text (Pretty(..))++import Curve (Curve(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Montgomery curve representation.+data M++-- | Montgomery curve points.+type MPoint = Point M++-- | Montgomery curves @By^2 = x^3 + Ax^2 + x@.+class Curve M c k => MCurve c k where+  a_ :: c -> k     -- ^ Coefficient @A@.+  b_ :: c -> k     -- ^ Coefficient @B@.+  g_ :: MPoint c k -- ^ Curve generator.++-- Montgomery points are arbitrary.+instance (GaloisField k, MCurve c k) => Arbitrary (Point M c k) where+  arbitrary = suchThatMap arbitrary point++-- Montgomery points are pretty.+instance (GaloisField k, MCurve c k) => Pretty (Point M c k) where+  pretty (A x y) = pretty (x, y)+  pretty O       = "O"++-- Montgomery points are random.+instance (GaloisField k, MCurve c k) => Random (Point M c k) where+  random g = case point x of+    Just p -> (p, g')+    _      -> random g'+    where+      (x, g') = random g+  {-# INLINE random #-}+  randomR  = panic "not implemented."++-------------------------------------------------------------------------------+-- Operations+-------------------------------------------------------------------------------++-- Montgomery curves are elliptic curves.+instance (GaloisField k, MCurve c k) => Curve M c k where++  data instance Point M c k = A k k -- ^ Affine point.+                            | O     -- ^ Infinite point.+    deriving (Eq, Generic, NFData, Read, Show)++  id = O+  {-# INLINE id #-}++  inv O       = O+  inv (A x y) = A x (-y)+  {-# INLINE inv #-}++  add p O          = p+  add O q          = q+  add p@(A x1 y1) (A x2 y2)+    | x1 /= x2     = A x3 y3+    | y1 + y2 == 0 = O+    | otherwise    = double p+    where+      a  = a_ (witness :: c)+      b  = b_ (witness :: c)+      l  = (y2 - y1) / (x2 - x1)+      x3 = b * l * l - a - x1 - x2+      y3 = l * (x1 - x3) - y1+  {-# INLINE add #-}++  double O       = O+  double (A _ 0) = O+  double (A x y) = A x' y'+    where+      a  = a_ (witness :: c)+      b  = b_ (witness :: c)+      l  = (x * (3 * x + 2 * a) + 1) / (2 * b * y)+      x' = b * l * l - a - 2 * x+      y' = l * (x - x') - y+  {-# INLINE double #-}++  def O       = True+  def (A x y) = b * y * y == (((x + a) * x) + 1) * x+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE def #-}++  disc _ = b * (a * a - 4)+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE disc #-}++  point x = A x <$> sr ((((x + a) * x) + 1) * x / b)+    where+      a  = a_ (witness :: c)+      b  = b_ (witness :: c)+  {-# INLINE point #-}++  rnd = getRandom+  {-# INLINE rnd #-}
+ src/Curve/Montgomery/Curve25519.hs view
@@ -0,0 +1,74 @@+module Curve.Montgomery.Curve25519+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Montgomery (Point(..), MCurve(..), MPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Curve25519 curve+data Curve25519++-- | Field of Curve25519 curve+type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed++-- | Curve25519 curve is a Montgomery curve+instance MCurve Curve25519 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Curve25519 curve+type P = MPoint Curve25519 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Curve25519 curve+_a :: Fp+_a = 0x76d06+{-# INLINE _a #-}++-- | Coefficient @B@ of Curve25519 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of Curve25519 curve+_g :: P+_g = A+     9+     0x20ae19a1b8a086b4e01edd2c7748d14c923d4d7e6d7c61b229e9c5a27eced3d9+{-# INLINE _g #-}++-- | Cofactor of Curve25519 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of Curve25519 curve+_n :: Integer+_n = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+{-# INLINE _n #-}++-- | Characteristic of Curve25519 curve+_p :: Integer+_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+{-# INLINE _p #-}
+ src/Curve/Montgomery/Curve383187.hs view
@@ -0,0 +1,74 @@+module Curve.Montgomery.Curve383187+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Montgomery (Point(..), MCurve(..), MPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Curve383187 curve+data Curve383187++-- | Field of Curve383187 curve+type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45++-- | Curve383187 curve is a Montgomery curve+instance MCurve Curve383187 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Curve383187 curve+type P = MPoint Curve383187 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Curve383187 curve+_a :: Fp+_a = 0x38251+{-# INLINE _a #-}++-- | Coefficient @B@ of Curve383187 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of Curve383187 curve+_g :: P+_g = A+     5+     0x1eebe07dc1871896732b12d5504a32370471965c7a11f2c89865f855ab3cbd7c224e3620c31af3370788457dd5ce46df+{-# INLINE _g #-}++-- | Cofactor of Curve383187 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of Curve383187 curve+_n :: Integer+_n = 0x1000000000000000000000000000000000000000000000000e85a85287a1488acd41ae84b2b7030446f72088b00a0e21+{-# INLINE _n #-}++-- | Characteristic of Curve383187 curve+_p :: Integer+_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+{-# INLINE _p #-}
+ src/Curve/Montgomery/Curve448.hs view
@@ -0,0 +1,74 @@+module Curve.Montgomery.Curve448+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Montgomery (Point(..), MCurve(..), MPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Curve448 curve+data Curve448++-- | Field of Curve448 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff++-- | Curve448 curve is a Montgomery curve+instance MCurve Curve448 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Curve448 curve+type P = MPoint Curve448 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Curve448 curve+_a :: Fp+_a = 0x262a6+{-# INLINE _a #-}++-- | Coefficient @B@ of Curve448 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of Curve448 curve+_g :: P+_g = A+     5+     0x7d235d1295f5b1f66c98ab6e58326fcecbae5d34f55545d060f75dc28df3f6edb8027e2346430d211312c4b150677af76fd7223d457b5b1a+{-# INLINE _g #-}++-- | Cofactor of Curve448 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of Curve448 curve+_n :: Integer+_n = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+{-# INLINE _n #-}++-- | Characteristic of Curve448 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Montgomery/M221.hs view
@@ -0,0 +1,74 @@+module Curve.Montgomery.M221+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Montgomery (Point(..), MCurve(..), MPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | M-221 curve+data M221++-- | Field of M-221 curve+type Fp = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd++-- | M-221 curve is a Montgomery curve+instance MCurve M221 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of M-221 curve+type P = MPoint M221 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of M-221 curve+_a :: Fp+_a = 0x1c93a+{-# INLINE _a #-}++-- | Coefficient @B@ of M-221 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of M-221 curve+_g :: P+_g = A+     4+     0xf7acdd2a4939571d1cef14eca37c228e61dbff10707dc6c08c5056d+{-# INLINE _g #-}++-- | Cofactor of M-221 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of M-221 curve+_n :: Integer+_n = 0x40000000000000000000000000015a08ed730e8a2f77f005042605b+{-# INLINE _n #-}++-- | Characteristic of M-221 curve+_p :: Integer+_p = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd+{-# INLINE _p #-}
+ src/Curve/Montgomery/M383.hs view
@@ -0,0 +1,74 @@+module Curve.Montgomery.M383+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Montgomery (Point(..), MCurve(..), MPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | M-383 curve+data M383++-- | Field of M-383 curve+type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45++-- | M-383 curve is a Montgomery curve+instance MCurve M383 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of M-383 curve+type P = MPoint M383 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of M-383 curve+_a :: Fp+_a = 0x1f82fe+{-# INLINE _a #-}++-- | Coefficient @B@ of M-383 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of M-383 curve+_g :: P+_g = A+     0xc+     0x1ec7ed04aaf834af310e304b2da0f328e7c165f0e8988abd3992861290f617aa1f1b2e7d0b6e332e969991b62555e77e+{-# INLINE _g #-}++-- | Cofactor of M-383 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of M-383 curve+_n :: Integer+_n = 0x10000000000000000000000000000000000000000000000006c79673ac36ba6e7a32576f7b1b249e46bbc225be9071d7+{-# INLINE _n #-}++-- | Characteristic of M-383 curve+_p :: Integer+_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+{-# INLINE _p #-}
+ src/Curve/Montgomery/M511.hs view
@@ -0,0 +1,74 @@+module Curve.Montgomery.M511+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Montgomery (Point(..), MCurve(..), MPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | M-511 curve+data M511++-- | Field of M-511 curve+type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45++-- | M-511 curve is a Montgomery curve+instance MCurve M511 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of M-511 curve+type P = MPoint M511 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of M-511 curve+_a :: Fp+_a = 0x81806+{-# INLINE _a #-}++-- | Coefficient @B@ of M-511 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of M-511 curve+_g :: P+_g = A+     5+     0x2fbdc0ad8530803d28fdbad354bb488d32399ac1cf8f6e01ee3f96389b90c809422b9429e8a43dbf49308ac4455940abe9f1dbca542093a895e30a64af056fa5+{-# INLINE _g #-}++-- | Cofactor of M-511 curve+_h :: Integer+_h = 8+{-# INLINE _h #-}++-- | Order of M-511 curve+_n :: Integer+_n = 0x100000000000000000000000000000000000000000000000000000000000000017b5feff30c7f5677ab2aeebd13779a2ac125042a6aa10bfa54c15bab76baf1b+{-# INLINE _n #-}++-- | Characteristic of M-511 curve+_p :: Integer+_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+{-# INLINE _p #-}
+ src/Curve/Weierstrass.hs view
@@ -0,0 +1,117 @@+module Curve.Weierstrass+  ( Point(..)+  , WCurve(..)+  , WPoint+  ) where++import Protolude++import Control.Monad.Random (Random(..), RandomGen, getRandom)+import ExtensionField (ExtensionField, IrreducibleMonic)+import GaloisField (GaloisField(..))+import PrimeField (PrimeField)+import Test.Tasty.QuickCheck (Arbitrary(..), Gen, suchThatMap)+import Text.PrettyPrint.Leijen.Text (Pretty(..))++import Curve (Curve(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Weierstrass curve representation.+data W++-- | Weierstrass curve points.+type WPoint = Point W++-- | Weierstrass curves @y^2 = x^3 + Ax + B@.+class Curve W c k => WCurve c k where+  a_ :: c -> k     -- ^ Coefficient @A@.+  b_ :: c -> k     -- ^ Coefficient @B@.+  g_ :: WPoint c k -- ^ Curve generator.++-- Weierstrass points are arbitrary.+instance (GaloisField k, IrreducibleMonic k im, WCurve c (ExtensionField k im))+  => Arbitrary (Point W c (ExtensionField k im)) where+  arbitrary = flip mul g_ <$> (arbitrary :: Gen Int) -- TODO+instance (KnownNat p, WCurve c (PrimeField p))+  => Arbitrary (Point W c (PrimeField p)) where+  arbitrary = suchThatMap arbitrary point++-- Weierstrass points are pretty.+instance (GaloisField k, WCurve c k) => Pretty (Point W c k) where+  pretty (A x y) = pretty (x, y)+  pretty O       = "O"++-- Weierstrass points are random.+instance (GaloisField k, WCurve c k) => Random (Point W c k) where+  random = first (flip mul g_) . (random :: RandomGen g => g -> (Int, g)) -- TODO+  -- random g = case point x of+  --   Just p -> (p, g')+  --   _      -> random g'+  --   where+  --     (x, g') = random g+  {-# INLINE random #-}+  randomR  = panic "not implemented."++-------------------------------------------------------------------------------+-- Operations+-------------------------------------------------------------------------------++-- Weierstrass curves are elliptic curves.+instance (GaloisField k, WCurve c k) => Curve W c k where++  data instance Point W c k = A k k -- ^ Affine point.+                            | O     -- ^ Infinite point.+    deriving (Eq, Generic, NFData, Read, Show)++  id = O+  {-# INLINE id #-}++  inv O       = O+  inv (A x y) = A x (-y)+  {-# INLINE inv #-}++  add p O          = p+  add O q          = q+  add p@(A x1 y1) (A x2 y2)+    | x1 /= x2     = A x3 y3+    | y1 + y2 == 0 = O+    | otherwise    = double p+    where+      l  = (y1 - y2) / (x1 - x2)+      x3 = l * l - x1 - x2+      y3 = l * (x1 - x3) - y1+  {-# INLINE add #-}++  double O       = O+  double (A _ 0) = O+  double (A x y) = A x' y'+    where+      l  = (3 * x * x + a_ (witness :: c)) / (2 * y)+      x' = l * l - 2 * x+      y' = l * (x - x') - y+  {-# INLINE double #-}++  def O       = True+  def (A x y) = y * y == (x * x + a) * x + b+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE def #-}++  disc _ = 4 * a * a * a + 27 * b * b+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE disc #-}++  point x = A x <$> sr (((x * x + a) * x) + b)+    where+      a = a_ (witness :: c)+      b = b_ (witness :: c)+  {-# INLINE point #-}++  rnd = getRandom+  {-# INLINE rnd #-}
+ src/Curve/Weierstrass/ANSSIFRP256V1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.ANSSIFRP256V1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | ANSSI-FRP256V1 curve+data ANSSIFRP256V1++-- | Field of ANSSI-FRP256V1 curve+type Fp = PrimeField 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03++-- | ANSSI-FRP256V1 curve is a Weierstrass curve+instance WCurve ANSSIFRP256V1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of ANSSI-FRP256V1 curve+type P = WPoint ANSSIFRP256V1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of ANSSI-FRP256V1 curve+_a :: Fp+_a = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c00+{-# INLINE _a #-}++-- | Coefficient @B@ of ANSSI-FRP256V1 curve+_b :: Fp+_b = 0xee353fca5428a9300d4aba754a44c00fdfec0c9ae4b1a1803075ed967b7bb73f+{-# INLINE _b #-}++-- | Generator of ANSSI-FRP256V1 curve+_g :: P+_g = A+     0xb6b3d4c356c139eb31183d4749d423958c27d2dcaf98b70164c97a2dd98f5cff+     0x6142e0f7c8b204911f9271f0f3ecef8c2701c307e8e4c9e183115a1554062cfb+{-# INLINE _g #-}++-- | Cofactor of ANSSI-FRP256V1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of ANSSI-FRP256V1 curve+_n :: Integer+_n = 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1+{-# INLINE _n #-}++-- | Characteristic of ANSSI-FRP256V1 curve+_p :: Integer+_p = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03+{-# INLINE _p #-}
+ src/Curve/Weierstrass/Anomalous.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.Anomalous+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Anomalous curve+data Anomalous++-- | Field of Anomalous curve+type Fp = PrimeField 0xb0000000000000000000000953000000000000000000001f9d7++-- | Anomalous curve is a Weierstrass curve+instance WCurve Anomalous Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Anomalous curve+type P = WPoint Anomalous Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Anomalous curve+_a :: Fp+_a = 0x98d0fac687d6343eb1a1f595283eb1a1f58d0fac687d635f5e4+{-# INLINE _a #-}++-- | Coefficient @B@ of Anomalous curve+_b :: Fp+_b = 0x4a1f58d0fac687d6343eb1a5e2d6343eb1a1f58d0fac688ab3f+{-# INLINE _b #-}++-- | Generator of Anomalous curve+_g :: P+_g = A+     0x101efb35fd1963c4871a2d17edaafa7e249807f58f8705126c6+     0x22389a3954375834304ba1d509a97de6c07148ea7f5951b20e7+{-# INLINE _g #-}++-- | Cofactor of Anomalous curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Anomalous curve+_n :: Integer+_n = 0xb0000000000000000000000953000000000000000000001f9d7+{-# INLINE _n #-}++-- | Characteristic of Anomalous curve+_p :: Integer+_p = 0xb0000000000000000000000953000000000000000000001f9d7+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BLS12_381.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BLS12_381+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS12-381 curve+data BLS12_381++-- | Field of BLS12-381 curve+type Fp = PrimeField 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab++-- | BLS12-381 curve is a Weierstrass curve+instance WCurve BLS12_381 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BLS12-381 curve+type P = WPoint BLS12_381 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS12-381 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BLS12-381 curve+_b :: Fp+_b = 4+{-# INLINE _b #-}++-- | Generator of BLS12-381 curve+_g :: P+_g = A+     0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb+     0x8b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1+{-# INLINE _g #-}++-- | Cofactor of BLS12-381 curve+_h :: Integer+_h = 0x396c8c005555e1568c00aaab0000aaab+{-# INLINE _h #-}++-- | Order of BLS12-381 curve+_n :: Integer+_n = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+{-# INLINE _n #-}++-- | Characteristic of BLS12-381 curve+_p :: Integer+_p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BLS12_381T.hs view
@@ -0,0 +1,86 @@+module Curve.Weierstrass.BLS12_381T+  ( Fp2+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass.BLS12_381 (Fp)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS12-381T curve+data BLS12_381T++-- | Field of BLS12-381T curve+data PolynomialU+instance IrreducibleMonic Fp PolynomialU where+  split _ = x ^ (2 :: Int) + 1+type Fp2 = ExtensionField Fp PolynomialU++-- | BLS12-381T curve is a Weierstrass curve+instance WCurve BLS12_381T Fp2 where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BLS12-381T curve+type P = WPoint BLS12_381T Fp2++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS12-381T curve+_a :: Fp2+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BLS12-381T curve+_b :: Fp2+_b = fromList [4, 4]+{-# INLINE _b #-}++-- | Generator of BLS12-381T curve+_g :: P+_g = A+  ( fromList+   [ 0x24aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8+   , 0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e+   ]+  )+  ( fromList+   [ 0xce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801+   , 0x606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be+   ]+  )+{-# INLINE _g #-}++-- | Cofactor of BLS12-381T curve+_h :: Integer+_h = 0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5+{-# INLINE _h #-}++-- | Order of BLS12-381T curve+_n :: Integer+_n = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+{-# INLINE _n #-}++-- | Characteristic of BLS12-381T curve+_p :: Integer+_p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BLS48_581.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BLS48_581+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS48-581 curve+data BLS48_581++-- | Field of BLS48-581 curve+type Fp = PrimeField 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b++-- | BLS48-581 curve is a Weierstrass curve+instance WCurve BLS48_581 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BLS48-581 curve+type P = WPoint BLS48_581 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS48-581 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BLS48-581 curve+_b :: Fp+_b = 1+{-# INLINE _b #-}++-- | Generator of BLS48-581 curve+_g :: P+_g = A+     0x2af59b7ac340f2baf2b73df1e93f860de3f257e0e86868cf61abdbaedffb9f7544550546a9df6f9645847665d859236ebdbc57db368b11786cb74da5d3a1e6d8c3bce8732315af640+     0xcefda44f6531f91f86b3a2d1fb398a488a553c9efeb8a52e991279dd41b720ef7bb7beffb98aee53e80f678584c3ef22f487f77c2876d1b2e35f37aef7b926b576dbb5de3e2587a70+{-# INLINE _g #-}++-- | Cofactor of BLS48-581 curve+_h :: Integer+_h = 0x85555841aaaec4ac+{-# INLINE _h #-}++-- | Order of BLS48-581 curve+_n :: Integer+_n = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+{-# INLINE _n #-}++-- | Characteristic of BLS48-581 curve+_p :: Integer+_p = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BLS48_581T.hs view
@@ -0,0 +1,130 @@+module Curve.Weierstrass.BLS48_581T+  ( Fp8+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, t, x)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass.BLS48_581 (Fp)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS48-581T curve+data BLS48_581T++-- | Field of BLS48-581T curve+data PolynomialU+instance IrreducibleMonic Fp PolynomialU where+  split _ = x ^ (2 :: Int) + 1+type Fp2 = ExtensionField Fp PolynomialU+data PolynomialV+instance IrreducibleMonic Fp2 PolynomialV where+  split _ = x ^ (2 :: Int) + 1 + t x+type Fp4 = ExtensionField Fp2 PolynomialV+data PolynomialW+instance IrreducibleMonic Fp4 PolynomialW where+  split _ = x ^ (2 :: Int) + t x+type Fp8 = ExtensionField Fp4 PolynomialW++-- | BLS48-581T curve is a Weierstrass curve+instance WCurve BLS48_581T Fp8 where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BLS48-581T curve+type P = WPoint BLS48_581T Fp8++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS48-581T curve+_a :: Fp8+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BLS48-581T curve+_b :: Fp8+_b = -1 / fromList [0, 1]+{-# INLINE _b #-}++-- | Generator of BLS48-581T curve+_g :: P+_g = A+  ( fromList+   [ fromList+    [ fromList+     [ 0x5d615d9a7871e4a38237fa45a2775debabbefc70344dbccb7de64db3a2ef156c46ff79baad1a8c42281a63ca0612f400503004d80491f510317b79766322154dec34fd0b4ace8bfab+     , 0x7c4973ece2258512069b0e86abc07e8b22bb6d980e1623e9526f6da12307f4e1c3943a00abfedf16214a76affa62504f0c3c7630d979630ffd75556a01afa143f1669b36676b47c57+     ]+    , fromList+     [ 0x1fccc70198f1334e1b2ea1853ad83bc73a8a6ca9ae237ca7a6d6957ccbab5ab6860161c1dbd19242ffae766f0d2a6d55f028cbdfbb879d5fea8ef4cded6b3f0b46488156ca55a3e6a+     , 0xbe2218c25ceb6185c78d8012954d4bfe8f5985ac62f3e5821b7b92a393f8be0cc218a95f63e1c776e6ec143b1b279b9468c31c5257c200ca52310b8cb4e80bc3f09a7033cbb7feafe+     ]+    ]+   , fromList+    [ fromList+     [ 0x38b91c600b35913a3c598e4caa9dd63007c675d0b1642b5675ff0e7c5805386699981f9e48199d5ac10b2ef492ae589274fad55fc1889aa80c65b5f746c9d4cbb739c3a1c53f8cce5+     , 0xc96c7797eb0738603f1311e4ecda088f7b8f35dcef0977a3d1a58677bb037418181df63835d28997eb57b40b9c0b15dd7595a9f177612f097fc7960910fce3370f2004d914a3c093a+     ]+    , fromList+     [ 0xb9b7951c6061ee3f0197a498908aee660dea41b39d13852b6db908ba2c0b7a449cef11f293b13ced0fd0caa5efcf3432aad1cbe4324c22d63334b5b0e205c3354e41607e60750e057+     , 0x827d5c22fb2bdec5282624c4f4aaa2b1e5d7a9defaf47b5211cf741719728a7f9f8cfca93f29cff364a7190b7e2b0d4585479bd6aebf9fc44e56af2fc9e97c3f84e19da00fbc6ae34+     ]+    ]+   ]+  )+  ( fromList+   [ fromList+    [ fromList+     [ 0xeb53356c375b5dfa497216452f3024b918b4238059a577e6f3b39ebfc435faab0906235afa27748d90f7336d8ae5163c1599abf77eea6d659045012ab12c0ff323edd3fe4d2d7971+     , 0x284dc75979e0ff144da6531815fcadc2b75a422ba325e6fba01d72964732fcbf3afb096b243b1f192c5c3d1892ab24e1dd212fa097d760e2e588b423525ffc7b111471db936cd5665+     ]+    , fromList+     [ 0xb36a201dd008523e421efb70367669ef2c2fc5030216d5b119d3a480d370514475f7d5c99d0e90411515536ca3295e5e2f0c1d35d51a652269cbc7c46fc3b8fde68332a526a2a8474+     , 0xaec25a4621edc0688223fbbd478762b1c2cded3360dcee23dd8b0e710e122d2742c89b224333fa40dced2817742770ba10d67bda503ee5e578fb3d8b8a1e5337316213da92841589d+     ]+    ]+   , fromList+    [ fromList+     [ 0xd209d5a223a9c46916503fa5a88325a2554dc541b43dd93b5a959805f1129857ed85c77fa238cdce8a1e2ca4e512b64f59f430135945d137b08857fdddfcf7a43f47831f982e50137+     , 0x7d0d03745736b7a513d339d5ad537b90421ad66eb16722b589d82e2055ab7504fa83420e8c270841f6824f47c180d139e3aafc198caa72b679da59ed8226cf3a594eedc58cf90bee4+     ]+    , fromList+     [ 0x896767811be65ea25c2d05dfdd17af8a006f364fc0841b064155f14e4c819a6df98f425ae3a2864f22c1fab8c74b2618b5bb40fa639f53dccc9e884017d9aa62b3d41faeafeb23986+     , 0x35e2524ff89029d393a5c07e84f981b5e068f1406be8e50c87549b6ef8eca9a9533a3f8e69c31e97e1ad0333ec719205417300d8c4ab33f748e5ac66e84069c55d667ffcb732718b6+     ]+    ]+   ]+  )+{-# INLINE _g #-}++-- | Cofactor of BLS48-581T curve+_h :: Integer+_h = 0x170e915cb0a6b7406b8d94042317f811d6bc3fc6e211ada42e58ccfcb3ac076a7e4499d700a0c23dc4b0c078f92def8c87b7fe63e1eea270db353a4ef4d38b5998ad8f0d042ea24c8f02be1c0c83992fe5d7725227bb27123a949e0876c0a8ce0a67326db0e955dcb791b867f31d6bfa62fbdd5f44a00504df04e186fae033f1eb43c1b1a08b6e086eff03c8fee9ebdd1e191a8a4b0466c90b389987de5637d5dd13dab33196bd2e5afa6cd19cf0fc3fc7db7ece1f3fac742626b1b02fcee04043b2ea96492f6afa51739597c54bb78aa6b0b99319fef9d09f768831018ee6564c68d054c62f2e0b4549426fec24ab26957a669dba2a2b6945ce40c9aec6afdeda16c79e15546cd7771fa544d5364236690ea06832679562a68731420ae52d0d35a90b8d10b688e31b6aee45f45b7a5083c71732105852decc888f64839a4de33b99521f0984a418d20fc7b0609530e454f0696fa2a8075ac01cc8ae3869e8d0fe1f3788ffac4c01aa2720e431da333c83d9663bfb1fb7a1a7b90528482c6be7892299030bb51a51dc7e91e9156874416bf4c26f1ea7ec578058563960ef92bbbb8632d3a1b695f954af10e9a78e40acffc13b06540aae9da5287fc4429485d44e6289d8c0d6a3eb2ece35012452751839fb48bc14b515478e2ff412d930ac20307561f3a5c998e6bcbfebd97effc6433033a2361bfcdc4fc74ad379a16c6dea49c209b1+{-# INLINE _h #-}++-- | Order of BLS48-581T curve+_n :: Integer+_n = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+{-# INLINE _n #-}++-- | Characteristic of BLS48-581T curve+_p :: Integer+_p = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN224.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN224+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN224 curve+data BN224++-- | Field of BN224 curve+type Fp = PrimeField 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833++-- | BN224 curve is a Weierstrass curve+instance WCurve BN224 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN224 curve+type P = WPoint BN224 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN224 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN224 curve+_b :: Fp+_b = 3+{-# INLINE _b #-}++-- | Generator of BN224 curve+_g :: P+_g = A+     1+     2+{-# INLINE _g #-}++-- | Cofactor of BN224 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN224 curve+_n :: Integer+_n = 0xfffffffffff107288ec29e602c4420db4218082b36c2accff76c58ed+{-# INLINE _n #-}++-- | Characteristic of BN224 curve+_p :: Integer+_p = 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN254.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN254+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN254 curve+data BN254++-- | Field of BN254 curve+type Fp = PrimeField 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47++-- | BN254 curve is a Weierstrass curve+instance WCurve BN254 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN254 curve+type P = WPoint BN254 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN254 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN254 curve+_b :: Fp+_b = 3+{-# INLINE _b #-}++-- | Generator of BN254 curve+_g :: P+_g = A+     1+     2+{-# INLINE _g #-}++-- | Cofactor of BN254 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN254 curve+_n :: Integer+_n = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+{-# INLINE _n #-}++-- | Characteristic of BN254 curve+_p :: Integer+_p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN254A.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN254A+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN254A curve+data BN254A++-- | Field of BN254A curve+type Fp = PrimeField 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001++-- | BN254A curve is a Weierstrass curve+instance WCurve BN254A Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN254A curve+type P = WPoint BN254A Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN254A curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN254A curve+_b :: Fp+_b = 5+{-# INLINE _b #-}++-- | Generator of BN254A curve+_g :: P+_g = A+     1+     0xd45589b158faaf6ab0e4ad38d998e9982e7ff63964ee1460342a592677cccb0+{-# INLINE _g #-}++-- | Cofactor of BN254A curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN254A curve+_n :: Integer+_n = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+{-# INLINE _n #-}++-- | Characteristic of BN254A curve+_p :: Integer+_p = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN254AT.hs view
@@ -0,0 +1,86 @@+module Curve.Weierstrass.BN254AT+  ( Fp2+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass.BN254A (Fp)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN254AT curve+data BN254AT++-- | Field of BN254AT curve+data PolynomialU+instance IrreducibleMonic Fp PolynomialU where+  split _ = x ^ (2 :: Int) + 5+type Fp2 = ExtensionField Fp PolynomialU++-- | BN254AT curve is a Weierstrass curve+instance WCurve BN254AT Fp2 where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN254AT curve+type P = WPoint BN254AT Fp2++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN254AT curve+_a :: Fp2+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN254AT curve+_b :: Fp2+_b = fromList [0, -1]+{-# INLINE _b #-}++-- | Generator of BN254AT curve+_g :: P+_g = A+  ( fromList+   [ 0x19b0bea4afe4c330da93cc3533da38a9f430b471c6f8a536e81962ed967909b5+   , 0xa1cf585585a61c6e9880b1f2a5c539f7d906fff238fa6341e1de1a2e45c3f72+   ]+  )+  ( fromList+   [ 0x17abd366ebbd65333e49c711a80a0cf6d24adf1b9b3990eedcc91731384d2627+   , 0xee97d6de9902a27d00e952232a78700863bc9aa9be960C32f5bf9fd0a32d345+   ]+  )+{-# INLINE _g #-}++-- | Cofactor of BN254AT curve+_h :: Integer+_h = 0x2370fb049d410fbe4e761a9886e50241dc42cf101e0000017e80600000000001+{-# INLINE _h #-}++-- | Order of BN254AT curve+_n :: Integer+_n = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+{-# INLINE _n #-}++-- | Characteristic of BN254AT curve+_p :: Integer+_p = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN254B.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN254B+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN254B curve+data BN254B++-- | Field of BN254B curve+type Fp = PrimeField 0x2523648240000001ba344d80000000086121000000000013a700000000000013++-- | BN254B curve is a Weierstrass curve+instance WCurve BN254B Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN254B curve+type P = WPoint BN254B Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN254B curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN254B curve+_b :: Fp+_b = 2+{-# INLINE _b #-}++-- | Generator of BN254B curve+_g :: P+_g = A+     0x2523648240000001ba344d80000000086121000000000013a700000000000012+     1+{-# INLINE _g #-}++-- | Cofactor of BN254B curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN254B curve+_n :: Integer+_n = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+{-# INLINE _n #-}++-- | Characteristic of BN254B curve+_p :: Integer+_p = 0x2523648240000001ba344d80000000086121000000000013a700000000000013+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN254BT.hs view
@@ -0,0 +1,86 @@+module Curve.Weierstrass.BN254BT+  ( Fp2+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass.BN254B (Fp)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN254BT curve+data BN254BT++-- | Field of BN254BT curve+data PolynomialU+instance IrreducibleMonic Fp PolynomialU where+  split _ = x ^ (2 :: Int) + 1+type Fp2 = ExtensionField Fp PolynomialU++-- | BN254BT curve is a Weierstrass curve+instance WCurve BN254BT Fp2 where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN254BT curve+type P = WPoint BN254BT Fp2++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN254BT curve+_a :: Fp2+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN254BT curve+_b :: Fp2+_b = fromList [1, -1]+{-# INLINE _b #-}++-- | Generator of BN254BT curve+_g :: P+_g = A+  ( fromList+   [ 0x61a10bb519eb62feb8d8c7e8c61edb6a4648bbb4898bf0d91ee4224c803fb2b+   , 0x516aaf9ba737833310aa78c5982aa5b1f4d746bae3784b70d8c34c1e7d54cf3+   ]+  )+  ( fromList+   [ 0x21897a06baf93439a90e096698c822329bd0ae6bdbe09bd19f0e07891cd2b9a+   , 0xebb2b0e7c8b15268f6d4456f5f38d37b09006ffd739c9578a2d1aec6b3ace9b+   ]+  )+{-# INLINE _g #-}++-- | Cofactor of BN254BT curve+_h :: Integer+_h = 0x2523648240000001ba344d8000000008c2a2800000000016ad00000000000019+{-# INLINE _h #-}++-- | Order of BN254BT curve+_n :: Integer+_n = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+{-# INLINE _n #-}++-- | Characteristic of BN254BT curve+_p :: Integer+_p = 0x2523648240000001ba344d80000000086121000000000013a700000000000013+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN254T.hs view
@@ -0,0 +1,86 @@+module Curve.Weierstrass.BN254T+  ( Fp2+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass.BN254 (Fp)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN254T curve+data BN254T++-- | Field of BN254T curve+data PolynomialU+instance IrreducibleMonic Fp PolynomialU where+  split _ = x ^ (2 :: Int) + 1+type Fp2 = ExtensionField Fp PolynomialU++-- | BN254T curve is a Weierstrass curve+instance WCurve BN254T Fp2 where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN254T curve+type P = WPoint BN254T Fp2++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN254T curve+_a :: Fp2+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN254T curve+_b :: Fp2+_b = 3 / fromList [9, 1]+{-# INLINE _b #-}++-- | Generator of BN254T curve+_g :: P+_g = A+  ( fromList+   [ 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed+   , 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2+   ]+  )+  ( fromList+   [ 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa+   , 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b+   ]+  )+{-# INLINE _g #-}++-- | Cofactor of BN254T curve+_h :: Integer+_h = 0x30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d+{-# INLINE _h #-}++-- | Order of BN254T curve+_n :: Integer+_n = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+{-# INLINE _n #-}++-- | Characteristic of BN254T curve+_p :: Integer+_p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN256.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN256+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN256 curve+data BN256++-- | Field of BN256 curve+type Fp = PrimeField 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013++-- | BN256 curve is a Weierstrass curve+instance WCurve BN256 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN256 curve+type P = WPoint BN256 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN256 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN256 curve+_b :: Fp+_b = 3+{-# INLINE _b #-}++-- | Generator of BN256 curve+_g :: P+_g = A+     1+     2+{-# INLINE _g #-}++-- | Cofactor of BN256 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN256 curve+_n :: Integer+_n = 0xfffffffffffcf0cd46e5f25eee71a49e0cdc65fb1299921af62d536cd10b500d+{-# INLINE _n #-}++-- | Characteristic of BN256 curve+_p :: Integer+_p = 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN384.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN384+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN384 curve+data BN384++-- | Field of BN384 curve+type Fp = PrimeField 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b++-- | BN384 curve is a Weierstrass curve+instance WCurve BN384 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN384 curve+type P = WPoint BN384 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN384 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN384 curve+_b :: Fp+_b = 3+{-# INLINE _b #-}++-- | Generator of BN384 curve+_g :: P+_g = A+     1+     2+{-# INLINE _g #-}++-- | Cofactor of BN384 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN384 curve+_n :: Integer+_n = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca023c8fbe29531892c795356487d8ac63e4f4db17384341a5775+{-# INLINE _n #-}++-- | Characteristic of BN384 curve+_p :: Integer+_p = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN462.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN462+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN462 curve+data BN462++-- | Field of BN462 curve+type Fp = PrimeField 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013++-- | BN462 curve is a Weierstrass curve+instance WCurve BN462 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN462 curve+type P = WPoint BN462 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN462 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN462 curve+_b :: Fp+_b = 5+{-# INLINE _b #-}++-- | Generator of BN462 curve+_g :: P+_g = A+     0x21a6d67ef250191fadba34a0a30160b9ac9264b6f95f63b3edbec3cf4b2e689db1bbb4e69a416a0b1e79239c0372e5cd70113c98d91f36b6980d+     0x118ea0460f7f7abb82b33676a7432a490eeda842cccfa7d788c659650426e6af77df11b8ae40eb80f475432c66600622ecaa8a5734d36fb03de+{-# INLINE _g #-}++-- | Cofactor of BN462 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN462 curve+_n :: Integer+_n = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+{-# INLINE _n #-}++-- | Characteristic of BN462 curve+_p :: Integer+_p = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN462T.hs view
@@ -0,0 +1,86 @@+module Curve.Weierstrass.BN462T+  ( Fp2+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass.BN462 (Fp)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN462T curve+data BN462T++-- | Field of BN462T curve+data PolynomialU+instance IrreducibleMonic Fp PolynomialU where+  split _ = x ^ (2 :: Int) + 1+type Fp2 = ExtensionField Fp PolynomialU++-- | BN462T curve is a Weierstrass curve+instance WCurve BN462T Fp2 where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN462T curve+type P = WPoint BN462T Fp2++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN462T curve+_a :: Fp2+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN462T curve+_b :: Fp2+_b = fromList [2, -1]+{-# INLINE _b #-}++-- | Generator of BN462T curve+_g :: P+_g = A+  ( fromList+   [ 0x257ccc85b58dda0dfb38e3a8cbdc5482e0337e7c1cd96ed61c913820408208f9ad2699bad92e0032ae1f0aa6a8b48807695468e3d934ae1e4df+   , 0x1d2e4343e8599102af8edca849566ba3c98e2a354730cbed9176884058b18134dd86bae555b783718f50af8b59bf7e850e9b73108ba6aa8cd283+   ]+  )+  ( fromList+   [ 0xa0650439da22c1979517427a20809eca035634706e23c3fa7a6bb42fe810f1399a1f41c9ddae32e03695a140e7b11d7c3376e5b68df0db7154e+   , 0x73ef0cbd438cbe0172c8ae37306324d44d5e6b0c69ac57b393f1ab370fd725cc647692444a04ef87387aa68d53743493b9eba14cc552ca2a93a+   ]+  )+{-# INLINE _g #-}++-- | Cofactor of BN462T curve+_h :: Integer+_h = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908fa1ce0227fffffffff6ff66fc63f5f7f4c0000000002401b008a0168019+{-# INLINE _h #-}++-- | Order of BN462T curve+_n :: Integer+_n = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+{-# INLINE _n #-}++-- | Characteristic of BN462T curve+_p :: Integer+_p = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BN512.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BN512+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BN512 curve+data BN512++-- | Field of BN512 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33++-- | BN512 curve is a Weierstrass curve+instance WCurve BN512 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of BN512 curve+type P = WPoint BN512 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BN512 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of BN512 curve+_b :: Fp+_b = 3+{-# INLINE _b #-}++-- | Generator of BN512 curve+_g :: P+_g = A+     1+     2+{-# INLINE _g #-}++-- | Cofactor of BN512 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of BN512 curve+_n :: Integer+_n = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef445146cf1eacbe98b8e48c65deab2679a34a10313e04f9a2b406a64a5f519a09ed+{-# INLINE _n #-}++-- | Characteristic of BN512 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP160R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP160R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P160R1 curve+data BrainpoolP160R1++-- | Field of Brainpool-P160R1 curve+type Fp = PrimeField 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f++-- | Brainpool-P160R1 curve is a Weierstrass curve+instance WCurve BrainpoolP160R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P160R1 curve+type P = WPoint BrainpoolP160R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P160R1 curve+_a :: Fp+_a = 0x340e7be2a280eb74e2be61bada745d97e8f7c300+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P160R1 curve+_b :: Fp+_b = 0x1e589a8595423412134faa2dbdec95c8d8675e58+{-# INLINE _b #-}++-- | Generator of Brainpool-P160R1 curve+_g :: P+_g = A+     0xbed5af16ea3f6a4f62938c4631eb5af7bdbcdbc3+     0x1667cb477a1a8ec338f94741669c976316da6321+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P160R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P160R1 curve+_n :: Integer+_n = 0xe95e4a5f737059dc60df5991d45029409e60fc09+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P160R1 curve+_p :: Integer+_p = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP160T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP160T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P160T1 curve+data BrainpoolP160T1++-- | Field of Brainpool-P160T1 curve+type Fp = PrimeField 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f++-- | Brainpool-P160T1 curve is a Weierstrass curve+instance WCurve BrainpoolP160T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P160T1 curve+type P = WPoint BrainpoolP160T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P160T1 curve+_a :: Fp+_a = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620c+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P160T1 curve+_b :: Fp+_b = 0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380+{-# INLINE _b #-}++-- | Generator of Brainpool-P160T1 curve+_g :: P+_g = A+     0xb199b13b9b34efc1397e64baeb05acc265ff2378+     0xadd6718b7c7c1961f0991b842443772152c9e0ad+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P160T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P160T1 curve+_n :: Integer+_n = 0xe95e4a5f737059dc60df5991d45029409e60fc09+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P160T1 curve+_p :: Integer+_p = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP192R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP192R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P192R1 curve+data BrainpoolP192R1++-- | Field of Brainpool-P192R1 curve+type Fp = PrimeField 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297++-- | Brainpool-P192R1 curve is a Weierstrass curve+instance WCurve BrainpoolP192R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P192R1 curve+type P = WPoint BrainpoolP192R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P192R1 curve+_a :: Fp+_a = 0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28ef+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P192R1 curve+_b :: Fp+_b = 0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9+{-# INLINE _b #-}++-- | Generator of Brainpool-P192R1 curve+_g :: P+_g = A+     0xc0a0647eaab6a48753b033c56cb0f0900a2f5c4853375fd6+     0x14b690866abd5bb88b5f4828c1490002e6773fa2fa299b8f+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P192R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P192R1 curve+_n :: Integer+_n = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P192R1 curve+_p :: Integer+_p = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP192T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP192T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P192T1 curve+data BrainpoolP192T1++-- | Field of Brainpool-P192T1 curve+type Fp = PrimeField 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297++-- | Brainpool-P192T1 curve is a Weierstrass curve+instance WCurve BrainpoolP192T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P192T1 curve+type P = WPoint BrainpoolP192T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P192T1 curve+_a :: Fp+_a = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86294+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P192T1 curve+_b :: Fp+_b = 0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79+{-# INLINE _b #-}++-- | Generator of Brainpool-P192T1 curve+_g :: P+_g = A+     0x3ae9e58c82f63c30282e1fe7bbf43fa72c446af6f4618129+     0x97e2c5667c2223a902ab5ca449d0084b7e5b3de7ccc01c9+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P192T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P192T1 curve+_n :: Integer+_n = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P192T1 curve+_p :: Integer+_p = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP224R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP224R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P224R1 curve+data BrainpoolP224R1++-- | Field of Brainpool-P224R1 curve+type Fp = PrimeField 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff++-- | Brainpool-P224R1 curve is a Weierstrass curve+instance WCurve BrainpoolP224R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P224R1 curve+type P = WPoint BrainpoolP224R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P224R1 curve+_a :: Fp+_a = 0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P224R1 curve+_b :: Fp+_b = 0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400b+{-# INLINE _b #-}++-- | Generator of Brainpool-P224R1 curve+_g :: P+_g = A+     0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d+     0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P224R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P224R1 curve+_n :: Integer+_n = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P224R1 curve+_p :: Integer+_p = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP224T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP224T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P224T1 curve+data BrainpoolP224T1++-- | Field of Brainpool-P224T1 curve+type Fp = PrimeField 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff++-- | Brainpool-P224T1 curve is a Weierstrass curve+instance WCurve BrainpoolP224T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P224T1 curve+type P = WPoint BrainpoolP224T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P224T1 curve+_a :: Fp+_a = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fc+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P224T1 curve+_b :: Fp+_b = 0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888d+{-# INLINE _b #-}++-- | Generator of Brainpool-P224T1 curve+_g :: P+_g = A+     0x6ab1e344ce25ff3896424e7ffe14762ecb49f8928ac0c76029b4d580+     0x374e9f5143e568cd23f3f4d7c0d4b1e41c8cc0d1c6abd5f1a46db4c+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P224T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P224T1 curve+_n :: Integer+_n = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P224T1 curve+_p :: Integer+_p = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP256R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP256R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P256R1 curve+data BrainpoolP256R1++-- | Field of Brainpool-P256R1 curve+type Fp = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377++-- | Brainpool-P256R1 curve is a Weierstrass curve+instance WCurve BrainpoolP256R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P256R1 curve+type P = WPoint BrainpoolP256R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P256R1 curve+_a :: Fp+_a = 0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P256R1 curve+_b :: Fp+_b = 0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6+{-# INLINE _b #-}++-- | Generator of Brainpool-P256R1 curve+_g :: P+_g = A+     0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262+     0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P256R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P256R1 curve+_n :: Integer+_n = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P256R1 curve+_p :: Integer+_p = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP256T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP256T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P256T1 curve+data BrainpoolP256T1++-- | Field of Brainpool-P256T1 curve+type Fp = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377++-- | Brainpool-P256T1 curve is a Weierstrass curve+instance WCurve BrainpoolP256T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P256T1 curve+type P = WPoint BrainpoolP256T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P256T1 curve+_a :: Fp+_a = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P256T1 curve+_b :: Fp+_b = 0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04+{-# INLINE _b #-}++-- | Generator of Brainpool-P256T1 curve+_g :: P+_g = A+     0xa3e8eb3cc1cfe7b7732213b23a656149afa142c47aafbc2b79a191562e1305f4+     0x2d996c823439c56d7f7b22e14644417e69bcb6de39d027001dabe8f35b25c9be+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P256T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P256T1 curve+_n :: Integer+_n = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P256T1 curve+_p :: Integer+_p = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP320R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP320R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P320R1 curve+data BrainpoolP320R1++-- | Field of Brainpool-P320R1 curve+type Fp = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27++-- | Brainpool-P320R1 curve is a Weierstrass curve+instance WCurve BrainpoolP320R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P320R1 curve+type P = WPoint BrainpoolP320R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P320R1 curve+_a :: Fp+_a = 0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P320R1 curve+_b :: Fp+_b = 0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6+{-# INLINE _b #-}++-- | Generator of Brainpool-P320R1 curve+_g :: P+_g = A+     0x43bd7e9afb53d8b85289bcc48ee5bfe6f20137d10a087eb6e7871e2a10a599c710af8d0d39e20611+     0x14fdd05545ec1cc8ab4093247f77275e0743ffed117182eaa9c77877aaac6ac7d35245d1692e8ee1+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P320R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P320R1 curve+_n :: Integer+_n = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P320R1 curve+_p :: Integer+_p = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP320T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP320T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P320T1 curve+data BrainpoolP320T1++-- | Field of Brainpool-P320T1 curve+type Fp = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27++-- | Brainpool-P320T1 curve is a Weierstrass curve+instance WCurve BrainpoolP320T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P320T1 curve+type P = WPoint BrainpoolP320T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P320T1 curve+_a :: Fp+_a = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P320T1 curve+_b :: Fp+_b = 0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353+{-# INLINE _b #-}++-- | Generator of Brainpool-P320T1 curve+_g :: P+_g = A+     0x925be9fb01afc6fb4d3e7d4990010f813408ab106c4f09cb7ee07868cc136fff3357f624a21bed52+     0x63ba3a7a27483ebf6671dbef7abb30ebee084e58a0b077ad42a5a0989d1ee71b1b9bc0455fb0d2c3+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P320T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P320T1 curve+_n :: Integer+_n = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P320T1 curve+_p :: Integer+_p = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP384R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP384R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P384R1 curve+data BrainpoolP384R1++-- | Field of Brainpool-P384R1 curve+type Fp = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53++-- | Brainpool-P384R1 curve is a Weierstrass curve+instance WCurve BrainpoolP384R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P384R1 curve+type P = WPoint BrainpoolP384R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P384R1 curve+_a :: Fp+_a = 0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P384R1 curve+_b :: Fp+_b = 0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11+{-# INLINE _b #-}++-- | Generator of Brainpool-P384R1 curve+_g :: P+_g = A+     0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e+     0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P384R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P384R1 curve+_n :: Integer+_n = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P384R1 curve+_p :: Integer+_p = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP384T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP384T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Type+-------------------------------------------------------------------------------++-- | Brainpool-P384T1 curve+data BrainpoolP384T1++-- | Field of Brainpool-P384T1 curve+type Fp = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53++-- | Brainpool-P384T1 curve is a Weierstrass curve+instance WCurve BrainpoolP384T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P384T1 curve+type P = WPoint BrainpoolP384T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P384T1 curve+_a :: Fp+_a = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P384T1 curve+_b :: Fp+_b = 0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471ee+{-# INLINE _b #-}++-- | Generator of Brainpool-P384T1 curve+_g :: P+_g = A+     0x18de98b02db9a306f2afcd7235f72a819b80ab12ebd653172476fecd462aabffc4ff191b946a5f54d8d0aa2f418808cc+     0x25ab056962d30651a114afd2755ad336747f93475b7a1fca3b88f2b6a208ccfe469408584dc2b2912675bf5b9e582928+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P384T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P384T1 curve+_n :: Integer+_n = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P384T1 curve+_p :: Integer+_p = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP512R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP512R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P512R1 curve+data BrainpoolP512R1++-- | Field of Brainpool-P512R1 curve+type Fp = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3++-- | Brainpool-P512R1 curve is a Weierstrass curve+instance WCurve BrainpoolP512R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P512R1 curve+type P = WPoint BrainpoolP512R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P512R1 curve+_a :: Fp+_a = 0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P512R1 curve+_b :: Fp+_b = 0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723+{-# INLINE _b #-}++-- | Generator of Brainpool-P512R1 curve+_g :: P+_g = A+     0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822+     0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P512R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P512R1 curve+_n :: Integer+_n = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P512R1 curve+_p :: Integer+_p = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+{-# INLINE _p #-}
+ src/Curve/Weierstrass/BrainpoolP512T1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.BrainpoolP512T1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Brainpool-P512T1 curve+data BrainpoolP512T1++-- | Field of Brainpool-P512T1 curve+type Fp = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3++-- | Brainpool-P512T1 curve is a Weierstrass curve+instance WCurve BrainpoolP512T1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of Brainpool-P512T1 curve+type P = WPoint BrainpoolP512T1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of Brainpool-P512T1 curve+_a :: Fp+_a = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f0+{-# INLINE _a #-}++-- | Coefficient @B@ of Brainpool-P512T1 curve+_b :: Fp+_b = 0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423e+{-# INLINE _b #-}++-- | Generator of Brainpool-P512T1 curve+_g :: P+_g = A+     0x640ece5c12788717b9c1ba06cbc2a6feba85842458c56dde9db1758d39c0313d82ba51735cdb3ea499aa77a7d6943a64f7a3f25fe26f06b51baa2696fa9035da+     0x5b534bd595f5af0fa2c892376c84ace1bb4e3019b71634c01131159cae03cee9d9932184beef216bd71df2dadf86a627306ecff96dbb8bace198b61e00f8b332+{-# INLINE _g #-}++-- | Cofactor of Brainpool-P512T1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of Brainpool-P512T1 curve+_n :: Integer+_n = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+{-# INLINE _n #-}++-- | Characteristic of Brainpool-P512T1 curve+_p :: Integer+_p = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP112R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP112R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP112R1 curve+data SECP112R1++-- | Field of SECP112R1 curve+type Fp = PrimeField 0xdb7c2abf62e35e668076bead208b++-- | SECP112R1 curve is a Weierstrass curve+instance WCurve SECP112R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP112R1 curve+type P = WPoint SECP112R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP112R1 curve+_a :: Fp+_a = 0xdb7c2abf62e35e668076bead2088+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP112R1 curve+_b :: Fp+_b = 0x659ef8ba043916eede8911702b22+{-# INLINE _b #-}++-- | Generator of SECP112R1 curve+_g :: P+_g = A+     0x9487239995a5ee76b55f9c2f098+     0xa89ce5af8724c0a23e0e0ff77500+{-# INLINE _g #-}++-- | Cofactor of SECP112R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP112R1 curve+_n :: Integer+_n = 0xdb7c2abf62e35e7628dfac6561c5+{-# INLINE _n #-}++-- | Characteristic of SECP112R1 curve+_p :: Integer+_p = 0xdb7c2abf62e35e668076bead208b+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP112R2.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP112R2+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP112R2 curve+data SECP112R2++-- | Field of SECP112R2 curve+type Fp = PrimeField 0xdb7c2abf62e35e668076bead208b++-- | SECP112R2 curve is a Weierstrass curve+instance WCurve SECP112R2 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP112R2 curve+type P = WPoint SECP112R2 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP112R2 curve+_a :: Fp+_a = 0x6127c24c05f38a0aaaf65c0ef02c+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP112R2 curve+_b :: Fp+_b = 0x51def1815db5ed74fcc34c85d709+{-# INLINE _b #-}++-- | Generator of SECP112R2 curve+_g :: P+_g = A+     0x4ba30ab5e892b4e1649dd0928643+     0xadcd46f5882e3747def36e956e97+{-# INLINE _g #-}++-- | Cofactor of SECP112R2 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECP112R2 curve+_n :: Integer+_n = 0x36df0aafd8b8d7597ca10520d04b+{-# INLINE _n #-}++-- | Characteristic of SECP112R2 curve+_p :: Integer+_p = 0xdb7c2abf62e35e668076bead208b+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP128R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP128R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP128R1 curve+data SECP128R1++-- | Field of SECP128R1 curve+type Fp = PrimeField 0xfffffffdffffffffffffffffffffffff++-- | SECP128R1 curve is a Weierstrass curve+instance WCurve SECP128R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP128R1 curve+type P = WPoint SECP128R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP128R1 curve+_a :: Fp+_a = 0xfffffffdfffffffffffffffffffffffc+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP128R1 curve+_b :: Fp+_b = 0xe87579c11079f43dd824993c2cee5ed3+{-# INLINE _b #-}++-- | Generator of SECP128R1 curve+_g :: P+_g = A+     0x161ff7528b899b2d0c28607ca52c5b86+     0xcf5ac8395bafeb13c02da292dded7a83+{-# INLINE _g #-}++-- | Cofactor of SECP128R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP128R1 curve+_n :: Integer+_n = 0xfffffffe0000000075a30d1b9038a115+{-# INLINE _n #-}++-- | Characteristic of SECP128R1 curve+_p :: Integer+_p = 0xfffffffdffffffffffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP128R2.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP128R2+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP128R2 curve+data SECP128R2++-- | Field of SECP128R2 curve+type Fp = PrimeField 0xfffffffdffffffffffffffffffffffff++-- | SECP128R2 curve is a Weierstrass curve+instance WCurve SECP128R2 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP128R2 curve+type P = WPoint SECP128R2 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP128R2 curve+_a :: Fp+_a = 0xd6031998d1b3bbfebf59cc9bbff9aee1+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP128R2 curve+_b :: Fp+_b = 0x5eeefca380d02919dc2c6558bb6d8a5d+{-# INLINE _b #-}++-- | Generator of SECP128R2 curve+_g :: P+_g = A+     0x7b6aa5d85e572983e6fb32a7cdebc140+     0x27b6916a894d3aee7106fe805fc34b44+{-# INLINE _g #-}++-- | Cofactor of SECP128R2 curve+_h :: Integer+_h = 4+{-# INLINE _h #-}++-- | Order of SECP128R2 curve+_n :: Integer+_n = 0x3fffffff7fffffffbe0024720613b5a3+{-# INLINE _n #-}++-- | Characteristic of SECP128R2 curve+_p :: Integer+_p = 0xfffffffdffffffffffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP160K1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP160K1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP160K1 curve+data SECP160K1++-- | Field of SECP160K1 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffeffffac73++-- | SECP160K1 curve is a Weierstrass curve+instance WCurve SECP160K1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP160K1 curve+type P = WPoint SECP160K1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP160K1 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP160K1 curve+_b :: Fp+_b = 7+{-# INLINE _b #-}++-- | Generator of SECP160K1 curve+_g :: P+_g = A+     0x3b4c382ce37aa192a4019e763036f4f5dd4d7ebb+     0x938cf935318fdced6bc28286531733c3f03c4fee+{-# INLINE _g #-}++-- | Cofactor of SECP160K1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP160K1 curve+_n :: Integer+_n = 0x100000000000000000001b8fa16dfab9aca16b6b3+{-# INLINE _n #-}++-- | Characteristic of SECP160K1 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffeffffac73+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP160R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP160R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP160R1 curve+data SECP160R1++-- | Field of SECP160R1 curve+type Fp = PrimeField 0xffffffffffffffffffffffffffffffff7fffffff++-- | SECP160R1 curve is a Weierstrass curve+instance WCurve SECP160R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP160R1 curve+type P = WPoint SECP160R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP160R1 curve+_a :: Fp+_a = 0xffffffffffffffffffffffffffffffff7ffffffc+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP160R1 curve+_b :: Fp+_b = 0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45+{-# INLINE _b #-}++-- | Generator of SECP160R1 curve+_g :: P+_g = A+     0x4a96b5688ef573284664698968c38bb913cbfc82+     0x23a628553168947d59dcc912042351377ac5fb32+{-# INLINE _g #-}++-- | Cofactor of SECP160R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP160R1 curve+_n :: Integer+_n = 0x100000000000000000001f4c8f927aed3ca752257+{-# INLINE _n #-}++-- | Characteristic of SECP160R1 curve+_p :: Integer+_p = 0xffffffffffffffffffffffffffffffff7fffffff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP160R2.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP160R2+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP160R2 curve+data SECP160R2++-- | Field of SECP160R2 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffeffffac73++-- | SECP160R2 curve is a Weierstrass curve+instance WCurve SECP160R2 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP160R2 curve+type P = WPoint SECP160R2 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP160R2 curve+_a :: Fp+_a = 0xfffffffffffffffffffffffffffffffeffffac70+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP160R2 curve+_b :: Fp+_b = 0xb4e134d3fb59eb8bab57274904664d5af50388ba+{-# INLINE _b #-}++-- | Generator of SECP160R2 curve+_g :: P+_g = A+     0x52dcb034293a117e1f4ff11b30f7199d3144ce6d+     0xfeaffef2e331f296e071fa0df9982cfea7d43f2e+{-# INLINE _g #-}++-- | Cofactor of SECP160R2 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP160R2 curve+_n :: Integer+_n = 0x100000000000000000000351ee786a818f3a1a16b+{-# INLINE _n #-}++-- | Characteristic of SECP160R2 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffeffffac73+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP192K1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP192K1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP192K1 curve+data SECP192K1++-- | Field of SECP192K1 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffeffffee37++-- | SECP192K1 curve is a Weierstrass curve+instance WCurve SECP192K1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP192K1 curve+type P = WPoint SECP192K1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP192K1 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP192K1 curve+_b :: Fp+_b = 3+{-# INLINE _b #-}++-- | Generator of SECP192K1 curve+_g :: P+_g = A+     0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d+     0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d+{-# INLINE _g #-}++-- | Cofactor of SECP192K1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP192K1 curve+_n :: Integer+_n = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d+{-# INLINE _n #-}++-- | Characteristic of SECP192K1 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffeffffee37+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP192R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP192R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP192R1 curve+data SECP192R1++-- | Field of SECP192R1 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffeffffffffffffffff++-- | SECP192R1 curve is a Weierstrass curve+instance WCurve SECP192R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP192R1 curve+type P = WPoint SECP192R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP192R1 curve+_a :: Fp+_a = 0xfffffffffffffffffffffffffffffffefffffffffffffffc+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP192R1 curve+_b :: Fp+_b = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1+{-# INLINE _b #-}++-- | Generator of SECP192R1 curve+_g :: P+_g = A+     0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012+     0x7192b95ffc8da78631011ed6b24cdd573f977a11e794811+{-# INLINE _g #-}++-- | Cofactor of SECP192R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP192R1 curve+_n :: Integer+_n = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831+{-# INLINE _n #-}++-- | Characteristic of SECP192R1 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffeffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP224K1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP224K1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP224K1 curve+data SECP224K1++-- | Field of SECP224K1 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d++-- | SECP224K1 curve is a Weierstrass curve+instance WCurve SECP224K1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP224K1 curve+type P = WPoint SECP224K1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP224K1 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP224K1 curve+_b :: Fp+_b = 5+{-# INLINE _b #-}++-- | Generator of SECP224K1 curve+_g :: P+_g = A+     0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c+     0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5+{-# INLINE _g #-}++-- | Cofactor of SECP224K1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP224K1 curve+_n :: Integer+_n = 0x10000000000000000000000000001dce8d2ec6184caf0a971769fb1f7+{-# INLINE _n #-}++-- | Characteristic of SECP224K1 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP224R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP224R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP224R1 curve+data SECP224R1++-- | Field of SECP224R1 curve+type Fp = PrimeField 0xffffffffffffffffffffffffffffffff000000000000000000000001++-- | SECP224R1 curve is a Weierstrass curve+instance WCurve SECP224R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP224R1 curve+type P = WPoint SECP224R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP224R1 curve+_a :: Fp+_a = 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP224R1 curve+_b :: Fp+_b = 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4+{-# INLINE _b #-}++-- | Generator of SECP224R1 curve+_g :: P+_g = A+     0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21+     0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34+{-# INLINE _g #-}++-- | Cofactor of SECP224R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP224R1 curve+_n :: Integer+_n = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d+{-# INLINE _n #-}++-- | Characteristic of SECP224R1 curve+_p :: Integer+_p = 0xffffffffffffffffffffffffffffffff000000000000000000000001+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP256K1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP256K1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP256K1 curve+data SECP256K1++-- | Field of SECP256K1 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f++-- | SECP256K1 curve is a Weierstrass curve+instance WCurve SECP256K1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP256K1 curve+type P = WPoint SECP256K1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP256K1 curve+_a :: Fp+_a = 0+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP256K1 curve+_b :: Fp+_b = 7+{-# INLINE _b #-}++-- | Generator of SECP256K1 curve+_g :: P+_g = A+     0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798+     0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8+{-# INLINE _g #-}++-- | Cofactor of SECP256K1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP256K1 curve+_n :: Integer+_n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141+{-# INLINE _n #-}++-- | Characteristic of SECP256K1 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP256R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP256R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP256R1 curve+data SECP256R1++-- | Field of SECP256R1 curve+type Fp = PrimeField 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff++-- | SECP256R1 curve is a Weierstrass curve+instance WCurve SECP256R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP256R1 curve+type P = WPoint SECP256R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP256R1 curve+_a :: Fp+_a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP256R1 curve+_b :: Fp+_b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b+{-# INLINE _b #-}++-- | Generator of SECP256R1 curve+_g :: P+_g = A+     0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296+     0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5+{-# INLINE _g #-}++-- | Cofactor of SECP256R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP256R1 curve+_n :: Integer+_n = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551+{-# INLINE _n #-}++-- | Characteristic of SECP256R1 curve+_p :: Integer+_p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP384R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP384R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP384R1 curve+data SECP384R1++-- | Field of SECP384R1 curve+type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff++-- | SECP384R1 curve is a Weierstrass curve+instance WCurve SECP384R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP384R1 curve+type P = WPoint SECP384R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP384R1 curve+_a :: Fp+_a = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP384R1 curve+_b :: Fp+_b = 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef+{-# INLINE _b #-}++-- | Generator of SECP384R1 curve+_g :: P+_g = A+     0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7+     0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f+{-# INLINE _g #-}++-- | Cofactor of SECP384R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP384R1 curve+_n :: Integer+_n = 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973+{-# INLINE _n #-}++-- | Characteristic of SECP384R1 curve+_p :: Integer+_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff+{-# INLINE _p #-}
+ src/Curve/Weierstrass/SECP521R1.hs view
@@ -0,0 +1,74 @@+module Curve.Weierstrass.SECP521R1+  ( Fp+  , P+  , _a+  , _b+  , _g+  , _h+  , _n+  , _p+  ) where++import Protolude++import PrimeField (PrimeField)++import Curve.Weierstrass (Point(..), WCurve(..), WPoint)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | SECP521R1 curve+data SECP521R1++-- | Field of SECP521R1 curve+type Fp = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff++-- | SECP521R1 curve is a Weierstrass curve+instance WCurve SECP521R1 Fp where+  a_ = const _a+  {-# INLINE a_ #-}+  b_ = const _b+  {-# INLINE b_ #-}+  g_ = _g+  {-# INLINE g_ #-}++-- | Point of SECP521R1 curve+type P = WPoint SECP521R1 Fp++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of SECP521R1 curve+_a :: Fp+_a = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc+{-# INLINE _a #-}++-- | Coefficient @B@ of SECP521R1 curve+_b :: Fp+_b = 0x51953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00+{-# INLINE _b #-}++-- | Generator of SECP521R1 curve+_g :: P+_g = A+     0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66+     0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650+{-# INLINE _g #-}++-- | Cofactor of SECP521R1 curve+_h :: Integer+_h = 1+{-# INLINE _h #-}++-- | Order of SECP521R1 curve+_n :: Integer+_n = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409+{-# INLINE _n #-}++-- | Characteristic of SECP521R1 curve+_p :: Integer+_p = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINE _p #-}
+ tests/BinaryTests.hs view
@@ -0,0 +1,45 @@+module BinaryTests where++import Test.Tasty++import CurveTests+import qualified Curve.Binary.SECT113R1 as SECT113R1+import qualified Curve.Binary.SECT113R2 as SECT113R2+import qualified Curve.Binary.SECT131R1 as SECT131R1+import qualified Curve.Binary.SECT131R2 as SECT131R2+import qualified Curve.Binary.SECT163K1 as SECT163K1+import qualified Curve.Binary.SECT163R1 as SECT163R1+import qualified Curve.Binary.SECT163R2 as SECT163R2+import qualified Curve.Binary.SECT193R1 as SECT193R1+import qualified Curve.Binary.SECT193R2 as SECT193R2+import qualified Curve.Binary.SECT233K1 as SECT233K1+import qualified Curve.Binary.SECT233R1 as SECT233R1+import qualified Curve.Binary.SECT239K1 as SECT239K1+import qualified Curve.Binary.SECT283K1 as SECT283K1+import qualified Curve.Binary.SECT283R1 as SECT283R1+import qualified Curve.Binary.SECT409K1 as SECT409K1+import qualified Curve.Binary.SECT409R1 as SECT409R1+import qualified Curve.Binary.SECT571K1 as SECT571K1+import qualified Curve.Binary.SECT571R1 as SECT571R1++testBinary :: TestTree+testBinary = testGroup "Binary"+  [ test "SECT113R1" SECT113R1._g SECT113R1._h SECT113R1._n 2+  , test "SECT113R2" SECT113R2._g SECT113R2._h SECT113R2._n 2+  , test "SECT131R1" SECT131R1._g SECT131R1._h SECT131R1._n 2+  , test "SECT131R2" SECT131R2._g SECT131R2._h SECT131R2._n 2+  , test "SECT163K1" SECT163K1._g SECT163K1._h SECT163K1._n 2+  , test "SECT163R1" SECT163R1._g SECT163R1._h SECT163R1._n 2+  , test "SECT163R2" SECT163R2._g SECT163R2._h SECT163R2._n 2+  , test "SECT193R1" SECT193R1._g SECT193R1._h SECT193R1._n 2+  , test "SECT193R2" SECT193R2._g SECT193R2._h SECT193R2._n 2+  , test "SECT233K1" SECT233K1._g SECT233K1._h SECT233K1._n 2+  , test "SECT233R1" SECT233R1._g SECT233R1._h SECT233R1._n 2+  , test "SECT239K1" SECT239K1._g SECT239K1._h SECT239K1._n 2+  , test "SECT283K1" SECT283K1._g SECT283K1._h SECT283K1._n 2+  , test "SECT283R1" SECT283R1._g SECT283R1._h SECT283R1._n 2+  , test "SECT409K1" SECT409K1._g SECT409K1._h SECT409K1._n 2+  , test "SECT409R1" SECT409R1._g SECT409R1._h SECT409R1._n 2+  , test "SECT571K1" SECT571K1._g SECT571K1._h SECT571K1._n 2+  , test "SECT571R1" SECT571R1._g SECT571R1._h SECT571R1._n 2+  ]
+ tests/CurveTests.hs view
@@ -0,0 +1,74 @@+module CurveTests where++import Protolude++import Curve+import GaloisField+import Math.NumberTheory.Primes.Testing+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck++identities :: Eq a => (a -> a -> a) -> a -> a -> Bool+identities op e x = op x e == x && op e x == x++inverses :: Eq a => (a -> a -> a) -> (a -> a) -> a -> a -> Bool+inverses op neg e x = op x (neg x) == e && op (neg x) x == e++commutativity :: Eq a => (a -> a -> a) -> a -> a -> Bool+commutativity op x y = op x y == op y x++associativity :: Eq a => (a -> a -> a) -> a -> a -> a -> Bool+associativity op x y z = op x (op y z) == op (op x y) z++groupAxioms :: forall r c k .+  (Arbitrary (Point r c k), Curve r c k, Eq (Point r c k), GaloisField k, Show (Point r c k))+  => Point r c k -> TestTree+groupAxioms _ = testGroup "Group axioms"+  [ testCase "identity closure" $+    def (id :: Point r c k) @?= True+  , testProperty "point closure" $+    def . (identity :: Point r c k -> Point r c k)+  , testProperty "inversion closure" $+    def . (inv :: Point r c k -> Point r c k)+  , testProperty "addition closure" $+    (.) def . (add :: Point r c k -> Point r c k -> Point r c k)+  , testProperty "doubling closure" $+    def . (double :: Point r c k -> Point r c k)+  , testProperty "multiplication closure" $+    def . (mul (6 :: Int) :: Point r c k -> Point r c k)+  , testProperty "identity" $+    identities (add :: Point r c k -> Point r c k -> Point r c k) mempty+  , testProperty "inverses" $+    inverses (add :: Point r c k -> Point r c k -> Point r c k) inv mempty+  , testProperty "commutativity" $+    commutativity (add :: Point r c k -> Point r c k -> Point r c k)+  , testProperty "associativity" $+    associativity (add :: Point r c k -> Point r c k -> Point r c k)+  ]++hasse :: Integer -> Integer -> Integer -> Bool+hasse h n q = (h * n - q - 1) ^ (2 :: Int) <= 4 * q++curveParameters :: forall r c k .+  (Arbitrary (Point r c k), Curve r c k, Eq (Point r c k), GaloisField k, Show (Point r c k))+  => Point r c k -> Integer -> Integer -> Integer -> TestTree+curveParameters g h n p = testGroup "Curve parameters"+  [ testCase "characteristic is typed" $+    char (witness :: k) @?= p+  , testCase "characteristic is prime" $+    isPrime p @?= True+  , testCase "discriminant is nonzero" $+    disc (witness :: Point r c k) /= 0 @?= True+  , testCase "generator is in cyclic subgroup" $+    mul n g @?= id+  , testCase "cyclic subgroup has prime order" $+    isPrime n @?= True+  , testCase "hasse theorem holds" $+    hasse h n (order (witness :: k)) @?= True+  ]++test :: forall r c k .+  (Arbitrary (Point r c k), Curve r c k, Eq (Point r c k), GaloisField k, Show (Point r c k))+  => TestName -> Point r c k -> Integer -> Integer -> Integer -> TestTree+test s g h n p = testGroup s [groupAxioms g, curveParameters g h n p]
+ tests/EdwardsTests.hs view
@@ -0,0 +1,27 @@+module EdwardsTests where++import Test.Tasty++import CurveTests+import qualified Curve.Edwards.Curve1174  as Curve1174+import qualified Curve.Edwards.Curve41417 as Curve41417+import qualified Curve.Edwards.E222       as E222+import qualified Curve.Edwards.E382       as E382+import qualified Curve.Edwards.E521       as E521+import qualified Curve.Edwards.Ed448      as Ed448+import qualified Curve.Edwards.Ed3363     as Ed3363+import qualified Curve.Edwards.Ed25519    as Ed25519+import qualified Curve.Edwards.JubJub     as JubJub++testEdwards :: TestTree+testEdwards = testGroup "Edwards"+  [ test  "Curve1174"  Curve1174._g  Curve1174._h  Curve1174._n  Curve1174._p+  , test "Curve41417" Curve41417._g Curve41417._h Curve41417._n Curve41417._p+  , test      "E-222"       E222._g       E222._h       E222._n       E222._p+  , test      "E-382"       E382._g       E382._h       E382._n       E382._p+  , test      "E-521"       E521._g       E521._h       E521._n       E521._p+  , test      "Ed448"      Ed448._g      Ed448._h      Ed448._n      Ed448._p+  , test     "Ed3363"     Ed3363._g     Ed3363._h     Ed3363._n     Ed3363._p+  , test    "Ed25519"    Ed25519._g    Ed25519._h    Ed25519._n    Ed25519._p+  , test     "JubJub"     JubJub._g     JubJub._h     JubJub._n     JubJub._p+  ]
+ tests/Main.hs view
@@ -0,0 +1,14 @@+module Main where++import Protolude++import Test.Tasty++import BinaryTests+import EdwardsTests+import MontgomeryTests+import WeierstrassTests++main :: IO ()+main = defaultMain $+  testGroup "Tests" [testBinary, testEdwards, testMontgomery, testWeierstrass]
+ tests/MontgomeryTests.hs view
@@ -0,0 +1,21 @@+module MontgomeryTests where++import Test.Tasty++import CurveTests+import qualified Curve.Montgomery.Curve448         as Curve448+import qualified Curve.Montgomery.Curve25519       as Curve25519+import qualified Curve.Montgomery.Curve383187      as Curve383187+import qualified Curve.Montgomery.M221             as M221+import qualified Curve.Montgomery.M383             as M383+import qualified Curve.Montgomery.M511             as M511++testMontgomery :: TestTree+testMontgomery = testGroup "Montgomery"+  [ test    "Curve448"    Curve448._g    Curve448._h    Curve448._n    Curve448._p+  , test  "Curve25519"  Curve25519._g  Curve25519._h  Curve25519._n  Curve25519._p+  , test "Curve383187" Curve383187._g Curve383187._h Curve383187._n Curve383187._p+  , test       "M-221"        M221._g        M221._h        M221._n        M221._p+  , test       "M-383"        M383._g        M383._h        M383._n        M383._p+  , test       "M-511"        M511._g        M511._h        M511._n        M511._p+  ]
+ tests/WeierstrassTests.hs view
@@ -0,0 +1,103 @@+module WeierstrassTests where++import Test.Tasty++import CurveTests+import qualified Curve.Weierstrass.Anomalous       as Anomalous+import qualified Curve.Weierstrass.ANSSIFRP256V1   as ANSSIFRP256V1+import qualified Curve.Weierstrass.BLS12_381       as BLS12_381+import qualified Curve.Weierstrass.BLS12_381T      as BLS12_381T+import qualified Curve.Weierstrass.BLS48_581       as BLS48_581+import qualified Curve.Weierstrass.BLS48_581T      as BLS48_581T+import qualified Curve.Weierstrass.BN224           as BN224+import qualified Curve.Weierstrass.BN254           as BN254+import qualified Curve.Weierstrass.BN254T          as BN254T+import qualified Curve.Weierstrass.BN254A          as BN254A+import qualified Curve.Weierstrass.BN254AT         as BN254AT+import qualified Curve.Weierstrass.BN254B          as BN254B+import qualified Curve.Weierstrass.BN254BT         as BN254BT+import qualified Curve.Weierstrass.BN256           as BN256+import qualified Curve.Weierstrass.BN384           as BN384+import qualified Curve.Weierstrass.BN462           as BN462+import qualified Curve.Weierstrass.BN462T          as BN462T+import qualified Curve.Weierstrass.BN512           as BN512+import qualified Curve.Weierstrass.BrainpoolP160R1 as BrainpoolP160R1+import qualified Curve.Weierstrass.BrainpoolP160T1 as BrainpoolP160T1+import qualified Curve.Weierstrass.BrainpoolP192R1 as BrainpoolP192R1+import qualified Curve.Weierstrass.BrainpoolP192T1 as BrainpoolP192T1+import qualified Curve.Weierstrass.BrainpoolP224R1 as BrainpoolP224R1+import qualified Curve.Weierstrass.BrainpoolP224T1 as BrainpoolP224T1+import qualified Curve.Weierstrass.BrainpoolP256R1 as BrainpoolP256R1+import qualified Curve.Weierstrass.BrainpoolP256T1 as BrainpoolP256T1+import qualified Curve.Weierstrass.BrainpoolP320R1 as BrainpoolP320R1+import qualified Curve.Weierstrass.BrainpoolP320T1 as BrainpoolP320T1+import qualified Curve.Weierstrass.BrainpoolP384R1 as BrainpoolP384R1+import qualified Curve.Weierstrass.BrainpoolP384T1 as BrainpoolP384T1+import qualified Curve.Weierstrass.BrainpoolP512R1 as BrainpoolP512R1+import qualified Curve.Weierstrass.BrainpoolP512T1 as BrainpoolP512T1+import qualified Curve.Weierstrass.SECP112R1       as SECP112R1+import qualified Curve.Weierstrass.SECP112R2       as SECP112R2+import qualified Curve.Weierstrass.SECP128R1       as SECP128R1+import qualified Curve.Weierstrass.SECP128R2       as SECP128R2+import qualified Curve.Weierstrass.SECP160K1       as SECP160K1+import qualified Curve.Weierstrass.SECP160R1       as SECP160R1+import qualified Curve.Weierstrass.SECP160R2       as SECP160R2+import qualified Curve.Weierstrass.SECP192K1       as SECP192K1+import qualified Curve.Weierstrass.SECP192R1       as SECP192R1+import qualified Curve.Weierstrass.SECP224K1       as SECP224K1+import qualified Curve.Weierstrass.SECP224R1       as SECP224R1+import qualified Curve.Weierstrass.SECP256K1       as SECP256K1+import qualified Curve.Weierstrass.SECP256R1       as SECP256R1+import qualified Curve.Weierstrass.SECP384R1       as SECP384R1+import qualified Curve.Weierstrass.SECP521R1       as SECP521R1++testWeierstrass :: TestTree+testWeierstrass = testGroup "Weierstrass"+  [ test        "Anomalous"       Anomalous._g       Anomalous._h       Anomalous._n       Anomalous._p+  , test   "ANSSI-FRP256V1"   ANSSIFRP256V1._g   ANSSIFRP256V1._h   ANSSIFRP256V1._n   ANSSIFRP256V1._p+  , test        "BLS12-381"       BLS12_381._g       BLS12_381._h       BLS12_381._n       BLS12_381._p+  , test       "BLS12-381T"      BLS12_381T._g      BLS12_381T._h      BLS12_381T._n      BLS12_381T._p+  , test        "BLS48-581"       BLS48_581._g       BLS48_581._h       BLS48_581._n       BLS48_581._p+  , test       "BLS48-581T"      BLS48_581T._g      BLS48_581T._h      BLS48_581T._n      BLS48_581T._p+  , test            "BN224"           BN224._g           BN224._h           BN224._n           BN224._p+  , test            "BN254"           BN254._g           BN254._h           BN254._n           BN254._p+  , test           "BN254T"          BN254T._g          BN254T._h          BN254T._n          BN254T._p+  , test           "BN254A"          BN254A._g          BN254A._h          BN254A._n          BN254A._p+  , test          "BN254AT"         BN254AT._g         BN254AT._h         BN254AT._n         BN254AT._p+  , test           "BN254B"          BN254B._g          BN254B._h          BN254B._n          BN254B._p+  , test          "BN254BT"         BN254BT._g         BN254BT._h         BN254BT._n         BN254BT._p+  , test            "BN256"           BN256._g           BN256._h           BN256._n           BN256._p+  , test            "BN384"           BN384._g           BN384._h           BN384._n           BN384._p+  , test            "BN462"           BN462._g           BN462._h           BN462._n           BN462._p+  , test           "BN462T"          BN462T._g          BN462T._h          BN462T._n          BN462T._p+  , test            "BN512"           BN512._g           BN512._h           BN512._n           BN512._p+  , test "Brainpool-P160R1" BrainpoolP160R1._g BrainpoolP160R1._h BrainpoolP160R1._n BrainpoolP160R1._p+  , test "Brainpool-P160T1" BrainpoolP160T1._g BrainpoolP160T1._h BrainpoolP160T1._n BrainpoolP160T1._p+  , test "Brainpool-P192R1" BrainpoolP192R1._g BrainpoolP192R1._h BrainpoolP192R1._n BrainpoolP192R1._p+  , test "Brainpool-P192T1" BrainpoolP192T1._g BrainpoolP192T1._h BrainpoolP192T1._n BrainpoolP192T1._p+  , test "Brainpool-P224R1" BrainpoolP224R1._g BrainpoolP224R1._h BrainpoolP224R1._n BrainpoolP224R1._p+  , test "Brainpool-P224T1" BrainpoolP224T1._g BrainpoolP224T1._h BrainpoolP224T1._n BrainpoolP224T1._p+  , test "Brainpool-P256R1" BrainpoolP256R1._g BrainpoolP256R1._h BrainpoolP256R1._n BrainpoolP256R1._p+  , test "Brainpool-P256T1" BrainpoolP256T1._g BrainpoolP256T1._h BrainpoolP256T1._n BrainpoolP256T1._p+  , test "Brainpool-P320R1" BrainpoolP320R1._g BrainpoolP320R1._h BrainpoolP320R1._n BrainpoolP320R1._p+  , test "Brainpool-P320T1" BrainpoolP320T1._g BrainpoolP320T1._h BrainpoolP320T1._n BrainpoolP320T1._p+  , test "Brainpool-P384R1" BrainpoolP384R1._g BrainpoolP384R1._h BrainpoolP384R1._n BrainpoolP384R1._p+  , test "Brainpool-P384T1" BrainpoolP384T1._g BrainpoolP384T1._h BrainpoolP384T1._n BrainpoolP384T1._p+  , test "Brainpool-P512R1" BrainpoolP512R1._g BrainpoolP512R1._h BrainpoolP512R1._n BrainpoolP512R1._p+  , test "Brainpool-P512T1" BrainpoolP512T1._g BrainpoolP512T1._h BrainpoolP512T1._n BrainpoolP512T1._p+  , test        "SECP112R1"       SECP112R1._g       SECP112R1._h       SECP112R1._n       SECP112R1._p+  , test        "SECP112R2"       SECP112R2._g       SECP112R2._h       SECP112R2._n       SECP112R2._p+  , test        "SECP128R1"       SECP128R1._g       SECP128R1._h       SECP128R1._n       SECP128R1._p+  , test        "SECP128R2"       SECP128R2._g       SECP128R2._h       SECP128R2._n       SECP128R2._p+  , test        "SECP160K1"       SECP160K1._g       SECP160K1._h       SECP160K1._n       SECP160K1._p+  , test        "SECP160R1"       SECP160R1._g       SECP160R1._h       SECP160R1._n       SECP160R1._p+  , test        "SECP160R2"       SECP160R2._g       SECP160R2._h       SECP160R2._n       SECP160R2._p+  , test        "SECP192K1"       SECP192K1._g       SECP192K1._h       SECP192K1._n       SECP192K1._p+  , test        "SECP192R1"       SECP192R1._g       SECP192R1._h       SECP192R1._n       SECP192R1._p+  , test        "SECP224K1"       SECP224K1._g       SECP224K1._h       SECP224K1._n       SECP224K1._p+  , test        "SECP224R1"       SECP224R1._g       SECP224R1._h       SECP224R1._n       SECP224R1._p+  , test        "SECP256K1"       SECP256K1._g       SECP256K1._h       SECP256K1._n       SECP256K1._p+  , test        "SECP256R1"       SECP256R1._g       SECP256R1._h       SECP256R1._n       SECP256R1._p+  , test        "SECP384R1"       SECP384R1._g       SECP384R1._h       SECP384R1._n       SECP384R1._p+  , test        "SECP521R1"       SECP521R1._g       SECP521R1._h       SECP521R1._n       SECP521R1._p+  ]