elliptic-curve 0.1.0 → 0.2.1
raw patch · 131 files changed
+11698/−4549 lines, 131 filesdep +textdep ~basedep ~galois-fielddep ~protolude
Dependencies added: text
Dependency ranges changed: base, galois-field, protolude
Files
- ChangeLog.md +33/−0
- README.md +22/−22
- benchmarks/BinaryBenchmarks.hs +50/−0
- benchmarks/EdwardsBenchmarks.hs +32/−0
- benchmarks/FieldBenchmarks.hs +11/−0
- benchmarks/GroupBenchmarks.hs +8/−0
- benchmarks/Main.hs +6/−173
- benchmarks/MontgomeryBenchmarks.hs +25/−0
- benchmarks/WeierstrassBenchmarks.hs +109/−0
- elliptic-curve.cabal +71/−31
- generate/Generate/Binary/Curve.hs +144/−0
- generate/Generate/Binary/Generate.hs +84/−0
- generate/Generate/Binary/Parameters.hs +379/−0
- generate/Generate/Binary/Types.hs +27/−0
- generate/Generate/Curve.hs +62/−0
- generate/Generate/Edwards/Curve.hs +144/−0
- generate/Generate/Edwards/Generate.hs +84/−0
- generate/Generate/Edwards/Parameters.hs +199/−0
- generate/Generate/Edwards/Types.hs +27/−0
- generate/Generate/Generate.hs +41/−0
- generate/Generate/Montgomery/Curve.hs +129/−0
- generate/Generate/Montgomery/Generate.hs +84/−0
- generate/Generate/Montgomery/Parameters.hs +139/−0
- generate/Generate/Montgomery/Types.hs +27/−0
- generate/Generate/Pretty.hs +40/−0
- generate/Generate/Types.hs +24/−0
- generate/Generate/Weierstrass/Curve.hs +159/−0
- generate/Generate/Weierstrass/Generate.hs +84/−0
- generate/Generate/Weierstrass/Parameters.hs +1035/−0
- generate/Generate/Weierstrass/Types.hs +27/−0
- generate/Main.hs +104/−0
- src/Curve.hs +78/−40
- src/Curve/Binary.hs +209/−71
- src/Curve/Binary/SECT113R1.hs +74/−42
- src/Curve/Binary/SECT113R2.hs +74/−42
- src/Curve/Binary/SECT131R1.hs +74/−42
- src/Curve/Binary/SECT131R2.hs +74/−42
- src/Curve/Binary/SECT163K1.hs +76/−44
- src/Curve/Binary/SECT163R1.hs +74/−42
- src/Curve/Binary/SECT163R2.hs +75/−43
- src/Curve/Binary/SECT193R1.hs +74/−42
- src/Curve/Binary/SECT193R2.hs +74/−42
- src/Curve/Binary/SECT233K1.hs +76/−44
- src/Curve/Binary/SECT233R1.hs +75/−43
- src/Curve/Binary/SECT239K1.hs +76/−44
- src/Curve/Binary/SECT283K1.hs +76/−44
- src/Curve/Binary/SECT283R1.hs +75/−43
- src/Curve/Binary/SECT409K1.hs +76/−44
- src/Curve/Binary/SECT409R1.hs +75/−43
- src/Curve/Binary/SECT571K1.hs +76/−44
- src/Curve/Binary/SECT571R1.hs +75/−43
- src/Curve/Edwards.hs +197/−55
- src/Curve/Edwards/Curve1174.hs +77/−46
- src/Curve/Edwards/Curve41417.hs +77/−46
- src/Curve/Edwards/E222.hs +77/−46
- src/Curve/Edwards/E382.hs +77/−46
- src/Curve/Edwards/E521.hs +77/−46
- src/Curve/Edwards/Ed25519.hs +77/−46
- src/Curve/Edwards/Ed3363.hs +77/−46
- src/Curve/Edwards/Ed448.hs +77/−46
- src/Curve/Edwards/JubJub.hs +77/−46
- src/Curve/Montgomery.hs +96/−74
- src/Curve/Montgomery/Curve25519.hs +64/−46
- src/Curve/Montgomery/Curve383187.hs +64/−46
- src/Curve/Montgomery/Curve448.hs +64/−46
- src/Curve/Montgomery/M221.hs +64/−46
- src/Curve/Montgomery/M383.hs +64/−46
- src/Curve/Montgomery/M511.hs +64/−46
- src/Curve/Weierstrass.hs +343/−76
- src/Curve/Weierstrass/ANSSIFRP256V1.hs +89/−45
- src/Curve/Weierstrass/Anomalous.hs +89/−45
- src/Curve/Weierstrass/BLS12381.hs +118/−0
- src/Curve/Weierstrass/BLS12381T.hs +130/−0
- src/Curve/Weierstrass/BLS12_381.hs +0/−74
- src/Curve/Weierstrass/BLS12_381T.hs +0/−86
- src/Curve/Weierstrass/BLS48581.hs +118/−0
- src/Curve/Weierstrass/BLS48581T.hs +168/−0
- src/Curve/Weierstrass/BLS48_581.hs +0/−74
- src/Curve/Weierstrass/BLS48_581T.hs +0/−130
- src/Curve/Weierstrass/BN224.hs +91/−47
- src/Curve/Weierstrass/BN254.hs +91/−47
- src/Curve/Weierstrass/BN254A.hs +91/−47
- src/Curve/Weierstrass/BN254AT.hs +101/−57
- src/Curve/Weierstrass/BN254B.hs +91/−47
- src/Curve/Weierstrass/BN254BT.hs +101/−57
- src/Curve/Weierstrass/BN254T.hs +101/−57
- src/Curve/Weierstrass/BN256.hs +91/−47
- src/Curve/Weierstrass/BN384.hs +91/−47
- src/Curve/Weierstrass/BN462.hs +91/−47
- src/Curve/Weierstrass/BN462T.hs +101/−57
- src/Curve/Weierstrass/BN512.hs +91/−47
- src/Curve/Weierstrass/BrainpoolP160R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP160T1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP192R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP192T1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP224R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP224T1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP256R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP256T1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP320R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP320T1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP384R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP384T1.hs +90/−46
- src/Curve/Weierstrass/BrainpoolP512R1.hs +89/−45
- src/Curve/Weierstrass/BrainpoolP512T1.hs +89/−45
- src/Curve/Weierstrass/SECP112R1.hs +89/−45
- src/Curve/Weierstrass/SECP112R2.hs +89/−45
- src/Curve/Weierstrass/SECP128R1.hs +89/−45
- src/Curve/Weierstrass/SECP128R2.hs +89/−45
- src/Curve/Weierstrass/SECP160K1.hs +91/−47
- src/Curve/Weierstrass/SECP160R1.hs +89/−45
- src/Curve/Weierstrass/SECP160R2.hs +89/−45
- src/Curve/Weierstrass/SECP192K1.hs +91/−47
- src/Curve/Weierstrass/SECP192R1.hs +89/−45
- src/Curve/Weierstrass/SECP224K1.hs +91/−47
- src/Curve/Weierstrass/SECP224R1.hs +89/−45
- src/Curve/Weierstrass/SECP256K1.hs +91/−47
- src/Curve/Weierstrass/SECP256R1.hs +89/−45
- src/Curve/Weierstrass/SECP384R1.hs +89/−45
- src/Curve/Weierstrass/SECP521R1.hs +89/−45
- src/Group.hs +56/−0
- src/Group/Field.hs +100/−0
- src/Group/Field/BN254TF.hs +85/−0
- tests/BinaryTests.hs +28/−20
- tests/CurveTests.hs +0/−74
- tests/EdwardsTests.hs +19/−11
- tests/FieldTests.hs +11/−0
- tests/GroupTests.hs +122/−0
- tests/Main.hs +2/−1
- tests/MontgomeryTests.hs +20/−13
- tests/WeierstrassTests.hs +62/−53
ChangeLog.md view
@@ -1,5 +1,38 @@ # Change log for elliptic-curve +## 0.2.1++* Fix dependency issue with `galois-field`.++## 0.2.0++* Add `Arbitrary` instances for elliptic curves.+* Add `Pretty` instances for elliptic curves.+* Add `Random` instances for elliptic curves.+* Add `Group` class for elliptic curves.+* Add `Field` group under the `Group` class.+* Add `BN254TF` field group under the `Field` form.+* Add `Projective` coordinates for `Binary` curves.+* Add `Projective` coordinates for `Edwards` curves.+* Add `Jacobian` coordinates for `Weierstrass` curves.+* Add `Projective` coordinates for `Weierstrass` curves.+* Add `char` function for elliptic curves.+* Add `cof` function for elliptic curves.+* Add `disc` function for elliptic curves.+* Add `def` function for groups.+* Add `gen` function for groups.+* Add `order` function for groups.+* Add `mul` function over exponent prime fields.+* Add `mul'` function over integers.+* Add `point` function for elliptic curves.+* Add `pointX` function for elliptic curves.+* Add `fromA` function for elliptic curves.+* Add `toA` function for elliptic curves.++## 0.1.1++* Fix dependency issue with `galois-field`.+ ## 0.1.0 * Initial release.
README.md view
@@ -206,19 +206,19 @@ * [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)+ * [M221](src/Curve/Montgomery/M221.hs)+ * [M383](src/Curve/Montgomery/M383.hs)+ * [M511](src/Curve/Montgomery/M511.hs) ### Weierstrass curves * [Anomalous](src/Curve/Weierstrass/Anomalous.hs)-* [ANSSI-FRP256V1](src/Curve/Weierstrass/ANSSIFRP256V1.hs)+* [ANSSIFRP256V1](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)+ * [BLS12381](src/Curve/Weierstrass/BLS12381.hs)+ * [BLS12381T](src/Curve/Weierstrass/BLS12381T.hs)+ * [BLS48581](src/Curve/Weierstrass/BLS48581.hs)+ * [BLS48581T](src/Curve/Weierstrass/BLS48581T.hs) * Barreto-Naehrig (BN) curves * [BN224 (Fp224BN)](src/Curve/Weierstrass/BN224.hs) * [BN254 (CurveSNARK)](src/Curve/Weierstrass/BN254.hs)@@ -233,20 +233,20 @@ * [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)+ * [BrainpoolP160R1](src/Curve/Weierstrass/BrainpoolP160R1.hs)+ * [BrainpoolP160T1](src/Curve/Weierstrass/BrainpoolP160T1.hs)+ * [BrainpoolP192R1](src/Curve/Weierstrass/BrainpoolP192R1.hs)+ * [BrainpoolP192T1](src/Curve/Weierstrass/BrainpoolP192T1.hs)+ * [BrainpoolP224R1](src/Curve/Weierstrass/BrainpoolP224R1.hs)+ * [BrainpoolP224T1](src/Curve/Weierstrass/BrainpoolP224T1.hs)+ * [BrainpoolP256R1](src/Curve/Weierstrass/BrainpoolP256R1.hs)+ * [BrainpoolP256T1](src/Curve/Weierstrass/BrainpoolP256T1.hs)+ * [BrainpoolP320R1](src/Curve/Weierstrass/BrainpoolP320R1.hs)+ * [BrainpoolP320T1](src/Curve/Weierstrass/BrainpoolP320T1.hs)+ * [BrainpoolP384R1](src/Curve/Weierstrass/BrainpoolP384R1.hs)+ * [BrainpoolP384T1](src/Curve/Weierstrass/BrainpoolP384T1.hs)+ * [BrainpoolP512R1](src/Curve/Weierstrass/BrainpoolP512R1.hs)+ * [BrainpoolP512T1](src/Curve/Weierstrass/BrainpoolP512T1.hs) * SECP (NIST) curves * [SECP112R1](src/Curve/Weierstrass/SECP112R1.hs) * [SECP112R2](src/Curve/Weierstrass/SECP112R2.hs)
+ benchmarks/BinaryBenchmarks.hs view
@@ -0,0 +1,50 @@+module BinaryBenchmarks where++import Criterion.Main+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 GroupBenchmarks++benchmarkBinary :: Benchmark+benchmarkBinary = bgroup "Binary"+ [ benchmarkBinary' "SECT113R1" SECT113R1.gA SECT113R1.gP+ , benchmarkBinary' "SECT113R2" SECT113R2.gA SECT113R2.gP+ , benchmarkBinary' "SECT131R1" SECT131R1.gA SECT131R1.gP+ , benchmarkBinary' "SECT131R2" SECT131R2.gA SECT131R2.gP+ , benchmarkBinary' "SECT163K1" SECT163K1.gA SECT163K1.gP+ , benchmarkBinary' "SECT163R1" SECT163R1.gA SECT163R1.gP+ , benchmarkBinary' "SECT163R2" SECT163R2.gA SECT163R2.gP+ , benchmarkBinary' "SECT193R1" SECT193R1.gA SECT193R1.gP+ , benchmarkBinary' "SECT193R2" SECT193R2.gA SECT193R2.gP+ , benchmarkBinary' "SECT233K1" SECT233K1.gA SECT233K1.gP+ , benchmarkBinary' "SECT233R1" SECT233R1.gA SECT233R1.gP+ , benchmarkBinary' "SECT239K1" SECT239K1.gA SECT239K1.gP+ , benchmarkBinary' "SECT283K1" SECT283K1.gA SECT283K1.gP+ , benchmarkBinary' "SECT283R1" SECT283R1.gA SECT283R1.gP+ , benchmarkBinary' "SECT409K1" SECT409K1.gA SECT409K1.gP+ , benchmarkBinary' "SECT409R1" SECT409R1.gA SECT409R1.gP+ , benchmarkBinary' "SECT571K1" SECT571K1.gA SECT571K1.gP+ , benchmarkBinary' "SECT571R1" SECT571R1.gA SECT571R1.gP+ ]+ where+ benchmarkBinary' curve affine projective = bgroup curve+ [ benchmark "Affine" affine+ , benchmark "Projective" projective+ ]
+ benchmarks/EdwardsBenchmarks.hs view
@@ -0,0 +1,32 @@+module EdwardsBenchmarks where++import Criterion.Main+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 GroupBenchmarks++benchmarkEdwards :: Benchmark+benchmarkEdwards = bgroup "Edwards"+ [ benchmarkEdwards' "Curve1174" Curve1174.gA Curve1174.gP+ , benchmarkEdwards' "Curve41417" Curve41417.gA Curve41417.gP+ , benchmarkEdwards' "E222" E222.gA E222.gP+ , benchmarkEdwards' "E382" E382.gA E382.gP+ , benchmarkEdwards' "E521" E521.gA E521.gP+ , benchmarkEdwards' "Ed448" Ed448.gA Ed448.gP+ , benchmarkEdwards' "Ed3363" Ed3363.gA Ed3363.gP+ , benchmarkEdwards' "Ed25519" Ed25519.gA Ed25519.gP+ , benchmarkEdwards' "JubJub" JubJub.gA JubJub.gP+ ]+ where+ benchmarkEdwards' curve affine projective = bgroup curve+ [ benchmark "Affine" affine+ , benchmark "Projective" projective+ ]
+ benchmarks/FieldBenchmarks.hs view
@@ -0,0 +1,11 @@+module FieldBenchmarks where++import Criterion.Main+import qualified Group.Field.BN254TF as BN254TF++import GroupBenchmarks++benchmarkField :: Benchmark+benchmarkField = bgroup "Field"+ [ benchmark "BN254TF" BN254TF._g+ ]
+ benchmarks/GroupBenchmarks.hs view
@@ -0,0 +1,8 @@+module GroupBenchmarks where++import Criterion.Main+import GHC.Base+import Group++benchmark :: Group g => String -> g -> Benchmark+benchmark = (. whnf (flip mul' 3)) . bench
benchmarks/Main.hs view
@@ -3,180 +3,13 @@ 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+import BinaryBenchmarks+import EdwardsBenchmarks+import MontgomeryBenchmarks+import WeierstrassBenchmarks+import FieldBenchmarks 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- ]- ]+ [benchmarkBinary, benchmarkEdwards, benchmarkMontgomery, benchmarkWeierstrass, benchmarkField]
+ benchmarks/MontgomeryBenchmarks.hs view
@@ -0,0 +1,25 @@+module MontgomeryBenchmarks where++import Criterion.Main+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 GroupBenchmarks++benchmarkMontgomery :: Benchmark+benchmarkMontgomery = bgroup "Montgomery"+ [ benchmarkMontgomery' "Curve448" Curve448.gA+ , benchmarkMontgomery' "Curve25519" Curve25519.gA+ , benchmarkMontgomery' "Curve383187" Curve383187.gA+ , benchmarkMontgomery' "M221" M221.gA+ , benchmarkMontgomery' "M383" M383.gA+ , benchmarkMontgomery' "M511" M511.gA+ ]+ where+ benchmarkMontgomery' curve affine = bgroup curve+ [ benchmark "Affine" affine+ ]
+ benchmarks/WeierstrassBenchmarks.hs view
@@ -0,0 +1,109 @@+module WeierstrassBenchmarks where++import Criterion.Main+import qualified Curve.Weierstrass.Anomalous as Anomalous+import qualified Curve.Weierstrass.ANSSIFRP256V1 as ANSSIFRP256V1+import qualified Curve.Weierstrass.BLS12381 as BLS12381+import qualified Curve.Weierstrass.BLS12381T as BLS12381T+import qualified Curve.Weierstrass.BLS48581 as BLS48581+import qualified Curve.Weierstrass.BLS48581T as BLS48581T+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 GroupBenchmarks++benchmarkWeierstrass :: Benchmark+benchmarkWeierstrass = bgroup "Weierstrass"+ [ benchmarkWeierstrass' "Anomalous" Anomalous.gA Anomalous.gJ Anomalous.gP+ , benchmarkWeierstrass' "ANSSIFRP256V1" ANSSIFRP256V1.gA ANSSIFRP256V1.gJ ANSSIFRP256V1.gP+ , benchmarkWeierstrass' "BLS12381" BLS12381.gA BLS12381.gJ BLS12381.gP+ , benchmarkWeierstrass' "BLS12381T" BLS12381T.gA BLS12381T.gJ BLS12381T.gP+ , benchmarkWeierstrass' "BLS48581" BLS48581.gA BLS48581.gJ BLS48581.gP+ , benchmarkWeierstrass' "BLS48581T" BLS48581T.gA BLS48581T.gJ BLS48581T.gP+ , benchmarkWeierstrass' "BN224" BN224.gA BN224.gJ BN224.gP+ , benchmarkWeierstrass' "BN254" BN254.gA BN254.gJ BN254.gP+ , benchmarkWeierstrass' "BN254T" BN254T.gA BN254T.gJ BN254T.gP+ , benchmarkWeierstrass' "BN254A" BN254A.gA BN254A.gJ BN254A.gP+ , benchmarkWeierstrass' "BN254AT" BN254AT.gA BN254AT.gJ BN254AT.gP+ , benchmarkWeierstrass' "BN254B" BN254B.gA BN254B.gJ BN254B.gP+ , benchmarkWeierstrass' "BN254BT" BN254BT.gA BN254BT.gJ BN254BT.gP+ , benchmarkWeierstrass' "BN256" BN256.gA BN256.gJ BN256.gP+ , benchmarkWeierstrass' "BN384" BN384.gA BN384.gJ BN384.gP+ , benchmarkWeierstrass' "BN462" BN462.gA BN462.gJ BN462.gP+ , benchmarkWeierstrass' "BN462T" BN462T.gA BN462T.gJ BN462T.gP+ , benchmarkWeierstrass' "BN512" BN512.gA BN512.gJ BN512.gP+ , benchmarkWeierstrass' "BrainpoolP160R1" BrainpoolP160R1.gA BrainpoolP160R1.gJ BrainpoolP160R1.gP+ , benchmarkWeierstrass' "BrainpoolP160T1" BrainpoolP160T1.gA BrainpoolP160T1.gJ BrainpoolP160T1.gP+ , benchmarkWeierstrass' "BrainpoolP192R1" BrainpoolP192R1.gA BrainpoolP192R1.gJ BrainpoolP192R1.gP+ , benchmarkWeierstrass' "BrainpoolP192T1" BrainpoolP192T1.gA BrainpoolP192T1.gJ BrainpoolP192T1.gP+ , benchmarkWeierstrass' "BrainpoolP224R1" BrainpoolP224R1.gA BrainpoolP224R1.gJ BrainpoolP224R1.gP+ , benchmarkWeierstrass' "BrainpoolP224T1" BrainpoolP224T1.gA BrainpoolP224T1.gJ BrainpoolP224T1.gP+ , benchmarkWeierstrass' "BrainpoolP256R1" BrainpoolP256R1.gA BrainpoolP256R1.gJ BrainpoolP256R1.gP+ , benchmarkWeierstrass' "BrainpoolP256T1" BrainpoolP256T1.gA BrainpoolP256T1.gJ BrainpoolP256T1.gP+ , benchmarkWeierstrass' "BrainpoolP320R1" BrainpoolP320R1.gA BrainpoolP320R1.gJ BrainpoolP320R1.gP+ , benchmarkWeierstrass' "BrainpoolP320T1" BrainpoolP320T1.gA BrainpoolP320T1.gJ BrainpoolP320T1.gP+ , benchmarkWeierstrass' "BrainpoolP384R1" BrainpoolP384R1.gA BrainpoolP384R1.gJ BrainpoolP384R1.gP+ , benchmarkWeierstrass' "BrainpoolP384T1" BrainpoolP384T1.gA BrainpoolP384T1.gJ BrainpoolP384T1.gP+ , benchmarkWeierstrass' "BrainpoolP512R1" BrainpoolP512R1.gA BrainpoolP512R1.gJ BrainpoolP512R1.gP+ , benchmarkWeierstrass' "BrainpoolP512T1" BrainpoolP512T1.gA BrainpoolP512T1.gJ BrainpoolP512T1.gP+ , benchmarkWeierstrass' "SECP112R1" SECP112R1.gA SECP112R1.gJ SECP112R1.gP+ , benchmarkWeierstrass' "SECP112R2" SECP112R2.gA SECP112R2.gJ SECP112R2.gP+ , benchmarkWeierstrass' "SECP128R1" SECP128R1.gA SECP128R1.gJ SECP128R1.gP+ , benchmarkWeierstrass' "SECP128R2" SECP128R2.gA SECP128R2.gJ SECP128R2.gP+ , benchmarkWeierstrass' "SECP160K1" SECP160K1.gA SECP160K1.gJ SECP160K1.gP+ , benchmarkWeierstrass' "SECP160R1" SECP160R1.gA SECP160R1.gJ SECP160R1.gP+ , benchmarkWeierstrass' "SECP160R2" SECP160R2.gA SECP160R2.gJ SECP160R2.gP+ , benchmarkWeierstrass' "SECP192K1" SECP192K1.gA SECP192K1.gJ SECP192K1.gP+ , benchmarkWeierstrass' "SECP192R1" SECP192R1.gA SECP192R1.gJ SECP192R1.gP+ , benchmarkWeierstrass' "SECP224K1" SECP224K1.gA SECP224K1.gJ SECP224K1.gP+ , benchmarkWeierstrass' "SECP224R1" SECP224R1.gA SECP224R1.gJ SECP224R1.gP+ , benchmarkWeierstrass' "SECP256K1" SECP256K1.gA SECP256K1.gJ SECP256K1.gP+ , benchmarkWeierstrass' "SECP256R1" SECP256R1.gA SECP256R1.gJ SECP256R1.gP+ , benchmarkWeierstrass' "SECP384R1" SECP384R1.gA SECP384R1.gJ SECP384R1.gP+ , benchmarkWeierstrass' "SECP521R1" SECP521R1.gA SECP521R1.gJ SECP521R1.gP+ ]+ where+ benchmarkWeierstrass' curve affine jacobian projective = bgroup curve+ [ benchmark "Affine" affine+ , benchmark "Jacobian" jacobian+ , benchmark "Projective" projective+ ]
elliptic-curve.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: bdbd38917d50ccd9f993f22110c962321da59072497a327bb80a0309791e767b+-- hash: 664a809970025f3cc9258b03d8eaed1d4a44189ed18d2cda5ffb313eb866a2ce name: elliptic-curve-version: 0.1.0+version: 0.2.1 synopsis: Elliptic curve library description: An extensible library of elliptic curves used in cryptography research category: Cryptography@@ -67,10 +67,10 @@ 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.BLS12381+ Curve.Weierstrass.BLS12381T+ Curve.Weierstrass.BLS48581+ Curve.Weierstrass.BLS48581T Curve.Weierstrass.BN224 Curve.Weierstrass.BN254 Curve.Weierstrass.BN254T@@ -112,18 +112,43 @@ Curve.Weierstrass.BrainpoolP384T1 Curve.Weierstrass.BrainpoolP512R1 Curve.Weierstrass.BrainpoolP512T1+ Group+ Group.Field+ Group.Field.BN254TF other-modules:- Paths_elliptic_curve+ Generate.Binary.Curve+ Generate.Binary.Generate+ Generate.Binary.Parameters+ Generate.Binary.Types+ Generate.Curve+ Generate.Edwards.Curve+ Generate.Edwards.Generate+ Generate.Edwards.Parameters+ Generate.Edwards.Types+ Generate.Generate+ Generate.Montgomery.Curve+ Generate.Montgomery.Generate+ Generate.Montgomery.Parameters+ Generate.Montgomery.Types+ Generate.Pretty+ Generate.Types+ Generate.Weierstrass.Curve+ Generate.Weierstrass.Generate+ Generate.Weierstrass.Parameters+ Generate.Weierstrass.Types+ Main 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+ generate+ default-extensions: LambdaCase RecordWildCards OverloadedStrings NoImplicitPrelude FlexibleInstances FlexibleContexts ScopedTypeVariables RankNTypes DataKinds DeriveAnyClass DeriveFunctor DeriveGeneric MultiParamTypeClasses PatternSynonyms PolyKinds TypeFamilyDependencies+ ghc-options: -Wall build-depends: MonadRandom- , base >=4.7 && <5- , galois-field- , protolude >=0.2+ , base >=4.10 && <5+ , galois-field >=0.4 && <0.5+ , protolude , tasty-quickcheck+ , text , wl-pprint-text default-language: Haskell2010 @@ -132,8 +157,9 @@ main-is: Main.hs other-modules: BinaryTests- CurveTests EdwardsTests+ FieldTests+ GroupTests MontgomeryTests WeierstrassTests Curve@@ -176,10 +202,10 @@ 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.BLS12381+ Curve.Weierstrass.BLS12381T+ Curve.Weierstrass.BLS48581+ Curve.Weierstrass.BLS48581T Curve.Weierstrass.BN224 Curve.Weierstrass.BN254 Curve.Weierstrass.BN254A@@ -221,21 +247,25 @@ Curve.Weierstrass.SECP256R1 Curve.Weierstrass.SECP384R1 Curve.Weierstrass.SECP521R1+ Group+ Group.Field+ Group.Field.BN254TF 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+ default-extensions: LambdaCase RecordWildCards OverloadedStrings NoImplicitPrelude FlexibleInstances FlexibleContexts ScopedTypeVariables RankNTypes DataKinds DeriveAnyClass DeriveFunctor DeriveGeneric MultiParamTypeClasses PatternSynonyms PolyKinds TypeFamilyDependencies+ ghc-options: -Wall -main-is Main build-depends: MonadRandom , arithmoi- , base >=4.7 && <5- , galois-field- , protolude >=0.2+ , base >=4.10 && <5+ , galois-field >=0.4 && <0.5+ , protolude , tasty , tasty-hunit , tasty-quickcheck+ , text , wl-pprint-text default-language: Haskell2010 @@ -243,6 +273,12 @@ type: exitcode-stdio-1.0 main-is: Main.hs other-modules:+ BinaryBenchmarks+ EdwardsBenchmarks+ FieldBenchmarks+ GroupBenchmarks+ MontgomeryBenchmarks+ WeierstrassBenchmarks Curve Curve.Binary Curve.Binary.SECT113R1@@ -283,10 +319,10 @@ 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.BLS12381+ Curve.Weierstrass.BLS12381T+ Curve.Weierstrass.BLS48581+ Curve.Weierstrass.BLS48581T Curve.Weierstrass.BN224 Curve.Weierstrass.BN254 Curve.Weierstrass.BN254A@@ -328,18 +364,22 @@ Curve.Weierstrass.SECP256R1 Curve.Weierstrass.SECP384R1 Curve.Weierstrass.SECP521R1+ Group+ Group.Field+ Group.Field.BN254TF 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+ default-extensions: LambdaCase RecordWildCards OverloadedStrings NoImplicitPrelude FlexibleInstances FlexibleContexts ScopedTypeVariables RankNTypes DataKinds DeriveAnyClass DeriveFunctor DeriveGeneric MultiParamTypeClasses PatternSynonyms PolyKinds TypeFamilyDependencies+ ghc-options: -Wall -main-is Main build-depends: MonadRandom- , base >=4.7 && <5+ , base >=4.10 && <5 , criterion- , galois-field- , protolude >=0.2+ , galois-field >=0.4 && <0.5+ , protolude , tasty-quickcheck+ , text , wl-pprint-text default-language: Haskell2010
+ generate/Generate/Binary/Curve.hs view
@@ -0,0 +1,144 @@+module Generate.Binary.Curve+ ( prettyCurve+ ) where++import Protolude++import Text.PrettyPrint.Leijen.Text++import Generate.Binary.Types+import Generate.Curve+import Generate.Pretty++-------------------------------------------------------------------------------+-- Curve+-------------------------------------------------------------------------------++prettyImports :: Types -> Doc+prettyImports Types{..}+ = "module Curve.Binary." <> pretty curve+ <$$> indent 2+ ( "( module Curve.Binary"+ <$$> ", module Curve.Binary." <> pretty curve+ <$$> ") where"+ )+ <> prettyBreak+ <$$> prettyImport field+ <> prettyBreak+ <$$> "import Curve.Binary"+ <$$> maybe mempty pretty imports++prettyTypes :: Types -> Doc+prettyTypes Types{..}+ = prettySection "Types"+ <$$> prettyDocumentation curve'+ <$$> "data" <+> pretty curve+ <> prettyBreak+ <$$> prettyDocumentation ("Field of points of" <+> curve')+ <$$> prettyType field+ <> prettyBreak+ <$$> prettyDocumentation ("Field of coefficients of" <+> curve')+ <$$> prettyType field'+ <> prettyBreak+ <$$> prettyDocumentation (curve' <+> "is a binary curve")+ <$$> "instance Curve 'Binary c" <+> pretty curve <+> prettyField field+ <+> "Fr => BCurve c" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "a_ = const _a"+ <$$> prettyInline "a_"+ <$$> "b_ = const _b"+ <$$> prettyInline "b_"+ <$$> "h_ = const _h"+ <$$> prettyInline "h_"+ <$$> "p_ = const _p"+ <$$> prettyInline "p_"+ <$$> "r_ = const _r"+ <$$> prettyInline "r_"+ <$$> "x_ = const _x"+ <$$> prettyInline "x_"+ <$$> "y_ = const _y"+ <$$> prettyInline "y_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "point")+ <$$> "type PA = BAPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "is a binary affine curve")+ <$$> "instance BACurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gA_ = gA"+ <$$> prettyInline "gA_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Projective" <+> pretty curve <+> "point")+ <$$> "type PP = BPPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Projective" <+> curve' <+> "is a binary projective curve")+ <$$> "instance BPCurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gP_ = gP"+ <$$> prettyInline "gP_"+ )+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyParameters :: Types -> Parameters -> Doc+prettyParameters Types{..} Parameters{..}+ = prettySection "Parameters"+ <$$> prettyDocumentation ("Coefficient @A@ of" <+> curve')+ <$$> "_a ::" <+> prettyField field+ <$$> "_a =" <+> prettyElement a+ <$$> prettyInline "_a"+ <> prettyBreak+ <$$> prettyDocumentation ("Coefficient @B@ of" <+> curve')+ <$$> "_b ::" <+> prettyField field+ <$$> "_b =" <+> prettyElement b+ <$$> prettyInline "_b"+ <> prettyBreak+ <$$> prettyDocumentation ("Cofactor of" <+> curve')+ <$$> "_h :: Integer"+ <$$> "_h =" <+> prettyInteger h+ <$$> prettyInline "_h"+ <> prettyBreak+ <$$> prettyDocumentation ("Polynomial of" <+> curve')+ <$$> "_p :: Integer"+ <$$> "_p =" <+> prettyInteger p+ <$$> prettyInline "_p"+ <> prettyBreak+ <$$> prettyDocumentation ("Order of" <+> curve')+ <$$> "_r :: Integer"+ <$$> "_r =" <+> prettyInteger r+ <$$> prettyInline "_r"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @X@ of" <+> curve')+ <$$> "_x ::" <+> prettyField field+ <$$> "_x =" <+> prettyElement x+ <$$> prettyInline "_x"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @Y@ of" <+> curve')+ <$$> "_y ::" <+> prettyField field+ <$$> "_y =" <+> prettyElement y+ <$$> prettyInline "_y"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of affine" <+> curve')+ <$$> "gA :: PA"+ <$$> "gA = A _x _y"+ <$$> prettyInline "gA"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of projective" <+> curve')+ <$$> "gP :: PP"+ <$$> "gP = P _x _y 1"+ <$$> prettyInline "gP"+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyCurve :: Curve -> Doc+prettyCurve (Curve types parameters)+ = prettyImports types+ <> prettyBreak+ <$$> prettyTypes types+ <> prettyBreak+ <$$> prettyParameters types parameters+ <> prettyBreak
+ generate/Generate/Binary/Generate.hs view
@@ -0,0 +1,84 @@+module Generate.Binary.Generate+ ( prettyGenerate+ ) where++import Protolude++import Data.Text (toLower)+import Text.PrettyPrint.Leijen.Text++import Generate.Binary.Types+import Generate.Generate+import Generate.Pretty++-------------------------------------------------------------------------------+-- Generate+-------------------------------------------------------------------------------++prettyImports :: Doc+prettyImports+ = "module Generate.Binary.Parameters"+ <$$> indent 2+ ( "( curves"+ <$$> ") where"+ )+ <> prettyBreak+ <$$> "import Protolude"+ <> prettyBreak+ <$$> "import Generate.Binary.Types"++prettyCurves :: [Curve] -> Doc+prettyCurves curves+ = prettySection "Curves"+ <$$> "curves :: [Curve]"+ <$$> "curves ="+ <$$> indent 2+ ( "[ "+ <> hcat (punctuate "\n, " (map prettyCurves' curves))+ <$$> "]"+ )+ where+ prettyCurves' :: Curve -> Doc+ prettyCurves' = pretty . toLower . curve . types++prettyParameters :: [Curve] -> Doc+prettyParameters curves+ = prettySection "Parameters"+ <$$> vcat (punctuate prettyBreak (map prettyParameters' curves))+ where+ prettyParameters' :: Curve -> Doc+ prettyParameters' (Curve Types{..} Parameters{..})+ = pretty (toLower curve) <+> ":: Curve"+ <$$> pretty (toLower curve) <+> "= Curve"+ <$$> indent 2+ ( "{ types = Types"+ <$$> indent 2+ ( "{ curve =" <+> prettyText curve+ <$$> ", field =" <+> prettyField field+ <$$> ", field' =" <+> prettyField field'+ <$$> ", imports = "+ <> maybe "Nothing" ((<>) "Just " . prettyText) imports+ <$$> "}"+ )+ <$$> ", parameters = Parameters"+ <$$> indent 2+ ( "{ a =" <+> prettyElement a+ <$$> ", b =" <+> prettyElement b+ <$$> ", h =" <+> prettyInteger h+ <$$> ", p =" <+> prettyInteger p+ <$$> ", r =" <+> prettyInteger r+ <$$> ", x =" <+> prettyElement x+ <$$> ", y =" <+> prettyElement y+ <$$> "}"+ )+ <$$> "}"+ )++prettyGenerate :: [Curve] -> Doc+prettyGenerate curves+ = prettyImports+ <> prettyBreak+ <$$> prettyCurves curves+ <> prettyBreak+ <$$> prettyParameters curves+ <> prettyBreak
+ generate/Generate/Binary/Parameters.hs view
@@ -0,0 +1,379 @@+module Generate.Binary.Parameters+ ( curves+ ) where++import Protolude++import Generate.Binary.Types++-------------------------------------------------------------------------------+-- Curves+-------------------------------------------------------------------------------++curves :: [Curve]+curves =+ [ sect113r1+ , sect113r2+ , sect131r1+ , sect131r2+ , sect163k1+ , sect163r1+ , sect163r2+ , sect193r1+ , sect193r2+ , sect233k1+ , sect233r1+ , sect239k1+ , sect283k1+ , sect283r1+ , sect409k1+ , sect409r1+ , sect571k1+ , sect571r1+ ]++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++sect113r1 :: Curve+sect113r1 = Curve+ { types = Types+ { curve = "SECT113R1"+ , field = BinaryField "F2m" 0x20000000000000000000000000201+ , field' = PrimeField "Fr" 0x100000000000000d9ccec8a39e56f+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x3088250ca6e7c7fe649ce85820f7+ , b = BF 0xe8bee4d3e2260744188be0e9c723+ , h = 0x2+ , p = 0x20000000000000000000000000201+ , r = 0x100000000000000d9ccec8a39e56f+ , x = BF 0x9d73616f35f4ab1407d73562c10f+ , y = BF 0xa52830277958ee84d1315ed31886+ }+ }++sect113r2 :: Curve+sect113r2 = Curve+ { types = Types+ { curve = "SECT113R2"+ , field = BinaryField "F2m" 0x20000000000000000000000000201+ , field' = PrimeField "Fr" 0x10000000000000108789b2496af93+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x689918dbec7e5a0dd6dfc0aa55c7+ , b = BF 0x95e9a9ec9b297bd4bf36e059184f+ , h = 0x2+ , p = 0x20000000000000000000000000201+ , r = 0x10000000000000108789b2496af93+ , x = BF 0x1a57a6a7b26ca5ef52fcdb8164797+ , y = BF 0xb3adc94ed1fe674c06e695baba1d+ }+ }++sect131r1 :: Curve+sect131r1 = Curve+ { types = Types+ { curve = "SECT131R1"+ , field = BinaryField "F2m" 0x80000000000000000000000000000010d+ , field' = PrimeField "Fr" 0x400000000000000023123953a9464b54d+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x7a11b09a76b562144418ff3ff8c2570b8+ , b = BF 0x217c05610884b63b9c6c7291678f9d341+ , h = 0x2+ , p = 0x80000000000000000000000000000010d+ , r = 0x400000000000000023123953a9464b54d+ , x = BF 0x81baf91fdf9833c40f9c181343638399+ , y = BF 0x78c6e7ea38c001f73c8134b1b4ef9e150+ }+ }++sect131r2 :: Curve+sect131r2 = Curve+ { types = Types+ { curve = "SECT131R2"+ , field = BinaryField "F2m" 0x80000000000000000000000000000010d+ , field' = PrimeField "Fr" 0x400000000000000016954a233049ba98f+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x3e5a88919d7cafcbf415f07c2176573b2+ , b = BF 0x4b8266a46c55657ac734ce38f018f2192+ , h = 0x2+ , p = 0x80000000000000000000000000000010d+ , r = 0x400000000000000016954a233049ba98f+ , x = BF 0x356dcd8f2f95031ad652d23951bb366a8+ , y = BF 0x648f06d867940a5366d9e265de9eb240f+ }+ }++sect163k1 :: Curve+sect163k1 = Curve+ { types = Types+ { curve = "SECT163K1"+ , field = BinaryField "F2m" 0x800000000000000000000000000000000000000c9+ , field' = PrimeField "Fr" 0x4000000000000000000020108a2e0cc0d99f8a5ef+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x1+ , b = BF 0x1+ , h = 0x2+ , p = 0x800000000000000000000000000000000000000c9+ , r = 0x4000000000000000000020108a2e0cc0d99f8a5ef+ , x = BF 0x2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8+ , y = BF 0x289070fb05d38ff58321f2e800536d538ccdaa3d9+ }+ }++sect163r1 :: Curve+sect163r1 = Curve+ { types = Types+ { curve = "SECT163R1"+ , field = BinaryField "F2m" 0x800000000000000000000000000000000000000c9+ , field' = PrimeField "Fr" 0x3ffffffffffffffffffff48aab689c29ca710279b+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x7b6882caaefa84f9554ff8428bd88e246d2782ae2+ , b = BF 0x713612dcddcb40aab946bda29ca91f73af958afd9+ , h = 0x2+ , p = 0x800000000000000000000000000000000000000c9+ , r = 0x3ffffffffffffffffffff48aab689c29ca710279b+ , x = BF 0x369979697ab43897789566789567f787a7876a654+ , y = BF 0x435edb42efafb2989d51fefce3c80988f41ff883+ }+ }++sect163r2 :: Curve+sect163r2 = Curve+ { types = Types+ { curve = "SECT163R2"+ , field = BinaryField "F2m" 0x800000000000000000000000000000000000000c9+ , field' = PrimeField "Fr" 0x40000000000000000000292fe77e70c12a4234c33+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x1+ , b = BF 0x20a601907b8c953ca1481eb10512f78744a3205fd+ , h = 0x2+ , p = 0x800000000000000000000000000000000000000c9+ , r = 0x40000000000000000000292fe77e70c12a4234c33+ , x = BF 0x3f0eba16286a2d57ea0991168d4994637e8343e36+ , y = BF 0xd51fbc6c71a0094fa2cdd545b11c5c0c797324f1+ }+ }++sect193r1 :: Curve+sect193r1 = Curve+ { types = Types+ { curve = "SECT193R1"+ , field = BinaryField "F2m" 0x2000000000000000000000000000000000000000000008001+ , field' = PrimeField "Fr" 0x1000000000000000000000000c7f34a778f443acc920eba49+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x17858feb7a98975169e171f77b4087de098ac8a911df7b01+ , b = BF 0xfdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814+ , h = 0x2+ , p = 0x2000000000000000000000000000000000000000000008001+ , r = 0x1000000000000000000000000c7f34a778f443acc920eba49+ , x = BF 0x1f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1+ , y = BF 0x25e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05+ }+ }++sect193r2 :: Curve+sect193r2 = Curve+ { types = Types+ { curve = "SECT193R2"+ , field = BinaryField "F2m" 0x2000000000000000000000000000000000000000000008001+ , field' = PrimeField "Fr" 0x10000000000000000000000015aab561b005413ccd4ee99d5+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b+ , b = BF 0xc9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae+ , h = 0x2+ , p = 0x2000000000000000000000000000000000000000000008001+ , r = 0x10000000000000000000000015aab561b005413ccd4ee99d5+ , x = BF 0xd9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f+ , y = BF 0x1ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c+ }+ }++sect233k1 :: Curve+sect233k1 = Curve+ { types = Types+ { curve = "SECT233K1"+ , field = BinaryField "F2m" 0x20000000000000000000000000000000000000004000000000000000001+ , field' = PrimeField "Fr" 0x8000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x0+ , b = BF 0x1+ , h = 0x4+ , p = 0x20000000000000000000000000000000000000004000000000000000001+ , r = 0x8000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf+ , x = BF 0x17232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126+ , y = BF 0x1db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3+ }+ }++sect233r1 :: Curve+sect233r1 = Curve+ { types = Types+ { curve = "SECT233R1"+ , field = BinaryField "F2m" 0x20000000000000000000000000000000000000004000000000000000001+ , field' = PrimeField "Fr" 0x1000000000000000000000000000013e974e72f8a6922031d2603cfe0d7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x1+ , b = BF 0x66647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad+ , h = 0x2+ , p = 0x20000000000000000000000000000000000000004000000000000000001+ , r = 0x1000000000000000000000000000013e974e72f8a6922031d2603cfe0d7+ , x = BF 0xfac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b+ , y = BF 0x1006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052+ }+ }++sect239k1 :: Curve+sect239k1 = Curve+ { types = Types+ { curve = "SECT239K1"+ , field = BinaryField "F2m" 0x800000000000000000004000000000000000000000000000000000000001+ , field' = PrimeField "Fr" 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x0+ , b = BF 0x1+ , h = 0x4+ , p = 0x800000000000000000004000000000000000000000000000000000000001+ , r = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5+ , x = BF 0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc+ , y = BF 0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca+ }+ }++sect283k1 :: Curve+sect283k1 = Curve+ { types = Types+ { curve = "SECT283K1"+ , field = BinaryField "F2m" 0x800000000000000000000000000000000000000000000000000000000000000000010a1+ , field' = PrimeField "Fr" 0x1ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x0+ , b = BF 0x1+ , h = 0x4+ , p = 0x800000000000000000000000000000000000000000000000000000000000000000010a1+ , r = 0x1ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61+ , x = BF 0x503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836+ , y = BF 0x1ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259+ }+ }++sect283r1 :: Curve+sect283r1 = Curve+ { types = Types+ { curve = "SECT283R1"+ , field = BinaryField "F2m" 0x800000000000000000000000000000000000000000000000000000000000000000010a1+ , field' = PrimeField "Fr" 0x3ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x1+ , b = BF 0x27b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5+ , h = 0x2+ , p = 0x800000000000000000000000000000000000000000000000000000000000000000010a1+ , r = 0x3ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307+ , x = BF 0x5f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053+ , y = BF 0x3676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4+ }+ }++sect409k1 :: Curve+sect409k1 = Curve+ { types = Types+ { curve = "SECT409K1"+ , field = BinaryField "F2m" 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+ , field' = PrimeField "Fr" 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x0+ , b = BF 0x1+ , h = 0x4+ , p = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+ , r = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf+ , x = BF 0x60f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746+ , y = BF 0x1e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b+ }+ }++sect409r1 :: Curve+sect409r1 = Curve+ { types = Types+ { curve = "SECT409R1"+ , field = BinaryField "F2m" 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+ , field' = PrimeField "Fr" 0x10000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x1+ , b = BF 0x21a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f+ , h = 0x2+ , p = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+ , r = 0x10000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173+ , x = BF 0x15d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7+ , y = BF 0x61b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706+ }+ }++sect571k1 :: Curve+sect571k1 = Curve+ { types = Types+ { curve = "SECT571K1"+ , field = BinaryField "F2m" 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+ , field' = PrimeField "Fr" 0x20000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x0+ , b = BF 0x1+ , h = 0x4+ , p = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+ , r = 0x20000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001+ , x = BF 0x26eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972+ , y = BF 0x349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3+ }+ }++sect571r1 :: Curve+sect571r1 = Curve+ { types = Types+ { curve = "SECT571R1"+ , field = BinaryField "F2m" 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+ , field' = PrimeField "Fr" 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47+ , imports = Nothing+ }+ , parameters = Parameters+ { a = BF 0x1+ , b = BF 0x2f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a+ , h = 0x2+ , p = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+ , r = 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47+ , x = BF 0x303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19+ , y = BF 0x37bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b+ }+ }
+ generate/Generate/Binary/Types.hs view
@@ -0,0 +1,27 @@+module Generate.Binary.Types+ ( module Generate.Binary.Types+ , module Generate.Types+ ) where++import Protolude++import Generate.Types++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++data Curve = Curve+ { types :: Types+ , parameters :: Parameters+ }++data Parameters = Parameters+ { a :: Element+ , b :: Element+ , h :: Integer+ , p :: Integer+ , r :: Integer+ , x :: Element+ , y :: Element+ }
+ generate/Generate/Curve.hs view
@@ -0,0 +1,62 @@+module Generate.Curve+ ( module Generate.Curve+ ) where++import Protolude++import Text.PrettyPrint.Leijen.Text++import Generate.Pretty+import Generate.Types++-------------------------------------------------------------------------------+-- Pretty+-------------------------------------------------------------------------------++prettyElement :: Element -> Doc+prettyElement (BF n)+ = prettyInteger n+prettyElement (EF ns)+ = "toField" <+> align+ ( (if null ns then "[" else "[ ")+ <> hcat (punctuate "\n, " (map prettyElement ns))+ <$$> "]"+ )+prettyElement (PF n)+ = prettyInteger n++prettyField :: Field -> Doc+prettyField (BinaryField f2m _)+ = pretty f2m+prettyField (ExtensionField fq' _ _ _ _)+ = pretty fq'+prettyField (PrimeField fq _)+ = pretty fq++prettyImport :: Field -> Doc+prettyImport k+ = "import Protolude"+ <> prettyBreak+ <$$> k'+ <$$> "import PrimeField"+ where+ k' = case k of+ BinaryField _ _ -> "import BinaryField"+ ExtensionField _ _ _ _ _ -> "import ExtensionField"+ _ -> mempty++prettyType :: Field -> Doc+prettyType (BinaryField f2m q)+ = "type" <+> pretty f2m <+> "= BinaryField" <+> prettyInteger q+prettyType (ExtensionField fq' fq q s k)+ = prettyType' k+ <$$> "data" <+> pretty q+ <$$> "instance IrreducibleMonic" <+> pretty fq <+> pretty q <+> "where"+ <$$> " split _ =" <+> pretty s+ <$$> "type" <+> pretty fq' <+> "= ExtensionField" <+> pretty fq <+> pretty q+ where+ prettyType' :: Maybe Field -> Doc+ prettyType' (Just f) = prettyType f+ prettyType' _ = mempty+prettyType (PrimeField fq q)+ = "type" <+> pretty fq <+> "= PrimeField" <+> prettyInteger q
+ generate/Generate/Edwards/Curve.hs view
@@ -0,0 +1,144 @@+module Generate.Edwards.Curve+ ( prettyCurve+ ) where++import Protolude++import Text.PrettyPrint.Leijen.Text++import Generate.Curve+import Generate.Edwards.Types+import Generate.Pretty++-------------------------------------------------------------------------------+-- Curve+-------------------------------------------------------------------------------++prettyImports :: Types -> Doc+prettyImports Types{..}+ = "module Curve.Edwards." <> pretty curve+ <$$> indent 2+ ( "( module Curve.Edwards"+ <$$> ", module Curve.Edwards." <> pretty curve+ <$$> ") where"+ )+ <> prettyBreak+ <$$> prettyImport field+ <> prettyBreak+ <$$> "import Curve.Edwards"+ <$$> maybe mempty pretty imports++prettyTypes :: Types -> Doc+prettyTypes Types{..}+ = prettySection "Types"+ <$$> prettyDocumentation curve'+ <$$> "data" <+> pretty curve+ <> prettyBreak+ <$$> prettyDocumentation ("Field of points of" <+> curve')+ <$$> prettyType field+ <> prettyBreak+ <$$> prettyDocumentation ("Field of coefficients of" <+> curve')+ <$$> prettyType field'+ <> prettyBreak+ <$$> prettyDocumentation (curve' <+> "is an Edwards curve")+ <$$> "instance Curve 'Edwards c" <+> pretty curve <+> prettyField field+ <+> "Fr => ECurve c" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "a_ = const _a"+ <$$> prettyInline "a_"+ <$$> "d_ = const _d"+ <$$> prettyInline "d_"+ <$$> "h_ = const _h"+ <$$> prettyInline "h_"+ <$$> "q_ = const _q"+ <$$> prettyInline "q_"+ <$$> "r_ = const _r"+ <$$> prettyInline "r_"+ <$$> "x_ = const _x"+ <$$> prettyInline "x_"+ <$$> "y_ = const _y"+ <$$> prettyInline "y_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "point")+ <$$> "type PA = EAPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "is an Edwards affine curve")+ <$$> "instance EACurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gA_ = gA"+ <$$> prettyInline "gA_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Projective" <+> pretty curve <+> "point")+ <$$> "type PP = EPPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Projective" <+> curve' <+> "is an Edwards projective curve")+ <$$> "instance EPCurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gP_ = gP"+ <$$> prettyInline "gP_"+ )+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyParameters :: Types -> Parameters -> Doc+prettyParameters Types{..} Parameters{..}+ = prettySection "Parameters"+ <$$> prettyDocumentation ("Coefficient @A@ of" <+> curve')+ <$$> "_a ::" <+> prettyField field+ <$$> "_a =" <+> prettyElement a+ <$$> prettyInline "_a"+ <> prettyBreak+ <$$> prettyDocumentation ("Coefficient @D@ of" <+> curve')+ <$$> "_d ::" <+> prettyField field+ <$$> "_d =" <+> prettyElement d+ <$$> prettyInline "_d"+ <> prettyBreak+ <$$> prettyDocumentation ("Cofactor of" <+> curve')+ <$$> "_h :: Integer"+ <$$> "_h =" <+> prettyInteger h+ <$$> prettyInline "_h"+ <> prettyBreak+ <$$> prettyDocumentation ("Characteristic of" <+> curve')+ <$$> "_q :: Integer"+ <$$> "_q =" <+> prettyInteger q+ <$$> prettyInline "_q"+ <> prettyBreak+ <$$> prettyDocumentation ("Order of" <+> curve')+ <$$> "_r :: Integer"+ <$$> "_r =" <+> prettyInteger r+ <$$> prettyInline "_r"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @X@ of" <+> curve')+ <$$> "_x ::" <+> prettyField field+ <$$> "_x =" <+> prettyElement x+ <$$> prettyInline "_x"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @Y@ of" <+> curve')+ <$$> "_y ::" <+> prettyField field+ <$$> "_y =" <+> prettyElement y+ <$$> prettyInline "_y"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of affine" <+> curve')+ <$$> "gA :: PA"+ <$$> "gA = A _x _y"+ <$$> prettyInline "gA"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of projective" <+> curve')+ <$$> "gP :: PP"+ <$$> "gP = P _x _y 1"+ <$$> prettyInline "gP"+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyCurve :: Curve -> Doc+prettyCurve (Curve types parameters)+ = prettyImports types+ <> prettyBreak+ <$$> prettyTypes types+ <> prettyBreak+ <$$> prettyParameters types parameters+ <> prettyBreak
+ generate/Generate/Edwards/Generate.hs view
@@ -0,0 +1,84 @@+module Generate.Edwards.Generate+ ( prettyGenerate+ ) where++import Protolude++import Data.Text (toLower)+import Text.PrettyPrint.Leijen.Text++import Generate.Edwards.Types+import Generate.Generate+import Generate.Pretty++-------------------------------------------------------------------------------+-- Generate+-------------------------------------------------------------------------------++prettyImports :: Doc+prettyImports+ = "module Generate.Edwards.Parameters"+ <$$> indent 2+ ( "( curves"+ <$$> ") where"+ )+ <> prettyBreak+ <$$> "import Protolude"+ <> prettyBreak+ <$$> "import Generate.Edwards.Types"++prettyCurves :: [Curve] -> Doc+prettyCurves curves+ = prettySection "Curves"+ <$$> "curves :: [Curve]"+ <$$> "curves ="+ <$$> indent 2+ ( "[ "+ <> hcat (punctuate "\n, " (map prettyCurves' curves))+ <$$> "]"+ )+ where+ prettyCurves' :: Curve -> Doc+ prettyCurves' = pretty . toLower . curve . types++prettyParameters :: [Curve] -> Doc+prettyParameters curves+ = prettySection "Parameters"+ <$$> vcat (punctuate prettyBreak (map prettyParameters' curves))+ where+ prettyParameters' :: Curve -> Doc+ prettyParameters' (Curve Types{..} Parameters{..})+ = pretty (toLower curve) <+> ":: Curve"+ <$$> pretty (toLower curve) <+> "= Curve"+ <$$> indent 2+ ( "{ types = Types"+ <$$> indent 2+ ( "{ curve =" <+> prettyText curve+ <$$> ", field =" <+> prettyField field+ <$$> ", field' =" <+> prettyField field'+ <$$> ", imports = "+ <> maybe "Nothing" ((<>) "Just " . prettyText) imports+ <$$> "}"+ )+ <$$> ", parameters = Parameters"+ <$$> indent 2+ ( "{ a =" <+> prettyElement a+ <$$> ", d =" <+> prettyElement d+ <$$> ", h =" <+> prettyInteger h+ <$$> ", q =" <+> prettyInteger q+ <$$> ", r =" <+> prettyInteger r+ <$$> ", x =" <+> prettyElement x+ <$$> ", y =" <+> prettyElement y+ <$$> "}"+ )+ <$$> "}"+ )++prettyGenerate :: [Curve] -> Doc+prettyGenerate curves+ = prettyImports+ <> prettyBreak+ <$$> prettyCurves curves+ <> prettyBreak+ <$$> prettyParameters curves+ <> prettyBreak
+ generate/Generate/Edwards/Parameters.hs view
@@ -0,0 +1,199 @@+module Generate.Edwards.Parameters+ ( curves+ ) where++import Protolude++import Generate.Edwards.Types++-------------------------------------------------------------------------------+-- Curves+-------------------------------------------------------------------------------++curves :: [Curve]+curves =+ [ curve1174+ , curve41417+ , e222+ , e382+ , e521+ , ed448+ , ed3363+ , ed25519+ , jubjub+ ]++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++curve1174 :: Curve+curve1174 = Curve+ { types = Types+ { curve = "Curve1174"+ , field = PrimeField "Fq" 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7+ , field' = PrimeField "Fr" 0x1fffffffffffffffffffffffffffffff77965c4dfd307348944d45fd166c971+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb61+ , h = 0x4+ , q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7+ , r = 0x1fffffffffffffffffffffffffffffff77965c4dfd307348944d45fd166c971+ , x = PF 0x37fbb0cea308c479343aee7c029a190c021d96a492ecd6516123f27bce29eda+ , y = PF 0x6b72f82d47fb7cc6656841169840e0c4fe2dee2af3f976ba4ccb1bf9b46360e+ }+ }++curve41417 :: Curve+curve41417 = Curve+ { types = Types+ { curve = "Curve41417"+ , field = PrimeField "Fq" 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef+ , field' = PrimeField "Fr" 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffeb3cc92414cf706022b36f1c0338ad63cf181b0e71a5e106af79+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0xe21+ , h = 0x8+ , q = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef+ , r = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffeb3cc92414cf706022b36f1c0338ad63cf181b0e71a5e106af79+ , x = PF 0x1a334905141443300218c0631c326e5fcd46369f44c03ec7f57ff35498a4ab4d6d6ba111301a73faa8537c64c4fd3812f3cbc595+ , y = PF 0x22+ }+ }++e222 :: Curve+e222 = Curve+ { types = Types+ { curve = "E222"+ , field = PrimeField "Fq" 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b+ , field' = PrimeField "Fr" 0xffffffffffffffffffffffffffff70cbc95e932f802f31423598cbf+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0x27166+ , h = 0x4+ , q = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b+ , r = 0xffffffffffffffffffffffffffff70cbc95e932f802f31423598cbf+ , x = PF 0x19b12bb156a389e55c9768c303316d07c23adab3736eb2bc3eb54e51+ , y = PF 0x1c+ }+ }++e382 :: Curve+e382 = Curve+ { types = Types+ { curve = "E382"+ , field = PrimeField "Fq" 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97+ , field' = PrimeField "Fr" 0xfffffffffffffffffffffffffffffffffffffffffffffffd5fb21f21e95eee17c5e69281b102d2773e27e13fd3c9719+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef8e1+ , h = 0x4+ , q = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97+ , r = 0xfffffffffffffffffffffffffffffffffffffffffffffffd5fb21f21e95eee17c5e69281b102d2773e27e13fd3c9719+ , x = PF 0x196f8dd0eab20391e5f05be96e8d20ae68f840032b0b64352923bab85364841193517dbce8105398ebc0cc9470f79603+ , y = PF 0x11+ }+ }++e521 :: Curve+e521 = Curve+ { types = Types+ { curve = "E521"+ , field = PrimeField "Fq" 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd15b6c64746fc85f736b8af5e7ec53f04fbd8c4569a8f1f4540ea2435f5180d6b+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa4331+ , h = 0x4+ , q = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , r = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd15b6c64746fc85f736b8af5e7ec53f04fbd8c4569a8f1f4540ea2435f5180d6b+ , x = PF 0x752cb45c48648b189df90cb2296b2878a3bfd9f42fc6c818ec8bf3c9c0c6203913f6ecc5ccc72434b1ae949d568fc99c6059d0fb13364838aa302a940a2f19ba6c+ , y = PF 0xc+ }+ }++ed448 :: Curve+ed448 = Curve+ { types = Types+ { curve = "Ed448"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffff6756+ , h = 0x4+ , q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , r = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+ , x = PF 0x297ea0ea2692ff1b4faff46098453a6a26adf733245f065c3c59d0709cecfa96147eaaf3932d94c63d96c170033f4ba0c7f0de840aed939f+ , y = PF 0x13+ }+ }++ed3363 :: Curve+ed3363 = Curve+ { types = Types+ { curve = "Ed3363"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd+ , field' = PrimeField "Fr" 0x200000000000000000000000000000000000000000071415fa9850c0bd6b87f93baa7b2f95973e9fa805+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1+ , d = PF 0x2b67+ , h = 0x8+ , q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd+ , r = 0x200000000000000000000000000000000000000000071415fa9850c0bd6b87f93baa7b2f95973e9fa805+ , x = PF 0xc+ , y = PF 0xc0dc616b56502e18e1c161d007853d1b14b46c3811c7ef435b6db5d5650ca0365db12bec68505fe8632+ }+ }++ed25519 :: Curve+ed25519 = Curve+ { types = Types+ { curve = "Ed25519"+ , field = PrimeField "Fq" 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+ , field' = PrimeField "Fr" 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec+ , d = PF 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3+ , h = 0x8+ , q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+ , r = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+ , x = PF 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a+ , y = PF 0x6666666666666666666666666666666666666666666666666666666666666658+ }+ }++jubjub :: Curve+jubjub = Curve+ { types = Types+ { curve = "JubJub"+ , field = PrimeField "Fq" 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+ , field' = PrimeField "Fr" 0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000+ , d = PF 0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1+ , h = 0x8+ , q = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+ , r = 0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7+ , x = PF 0x5183972af8eff38ca624b4df00384882000c546bf2f39ede7f4ecf1a74f976c4+ , y = PF 0x3b43f8472ca2fc2c9e8fcc5abd9dc308096c8707ffa6833b146bad709349702e+ }+ }
+ generate/Generate/Edwards/Types.hs view
@@ -0,0 +1,27 @@+module Generate.Edwards.Types+ ( module Generate.Edwards.Types+ , module Generate.Types+ ) where++import Protolude++import Generate.Types++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++data Curve = Curve+ { types :: Types+ , parameters :: Parameters+ }++data Parameters = Parameters+ { a :: Element+ , d :: Element+ , h :: Integer+ , q :: Integer+ , r :: Integer+ , x :: Element+ , y :: Element+ }
+ generate/Generate/Generate.hs view
@@ -0,0 +1,41 @@+module Generate.Generate+ ( module Generate.Generate+ ) where++import Protolude++import Text.PrettyPrint.Leijen.Text++import Generate.Pretty+import Generate.Types++-------------------------------------------------------------------------------+-- Pretty+-------------------------------------------------------------------------------++prettyElement :: Element -> Doc+prettyElement (BF n)+ = "BF" <+> prettyInteger n+prettyElement (EF ns)+ = "EF" <+> align+ ( (if null ns then "[" else "[ ")+ <> hcat (punctuate "\n, " (map prettyElement ns))+ <$$> "]"+ )+prettyElement (PF n)+ = "PF" <+> prettyInteger n++prettyField :: Field -> Doc+prettyField (BinaryField fp p)+ = "BinaryField" <+> prettyText fp <+> prettyInteger p+prettyField (ExtensionField fq fp p s k)+ = align+ ( "ExtensionField" <+> prettyText fq <+> prettyText fp+ <+> prettyText p <+> prettyText s <+> prettyField' k+ )+ where+ prettyField' :: Maybe Field -> Doc+ prettyField' (Just f) = "(Just" <$$> "(" <+> align (prettyField f) <$$> "))"+ prettyField' _ = "Nothing"+prettyField (PrimeField f2m p)+ = "PrimeField" <+> prettyText f2m <+> prettyInteger p
+ generate/Generate/Montgomery/Curve.hs view
@@ -0,0 +1,129 @@+module Generate.Montgomery.Curve+ ( prettyCurve+ ) where++import Protolude++import Text.PrettyPrint.Leijen.Text++import Generate.Curve+import Generate.Montgomery.Types+import Generate.Pretty++-------------------------------------------------------------------------------+-- Curve+-------------------------------------------------------------------------------++prettyImports :: Types -> Doc+prettyImports Types{..}+ = "module Curve.Montgomery." <> pretty curve+ <$$> indent 2+ ( "( module Curve.Montgomery"+ <$$> ", module Curve.Montgomery." <> pretty curve+ <$$> ") where"+ )+ <> prettyBreak+ <$$> prettyImport field+ <> prettyBreak+ <$$> "import Curve.Montgomery"+ <$$> maybe mempty pretty imports++prettyTypes :: Types -> Doc+prettyTypes Types{..}+ = prettySection "Types"+ <$$> prettyDocumentation curve'+ <$$> "data" <+> pretty curve+ <> prettyBreak+ <$$> prettyDocumentation ("Field of points of" <+> curve')+ <$$> prettyType field+ <> prettyBreak+ <$$> prettyDocumentation ("Field of coefficients of" <+> curve')+ <$$> prettyType field'+ <> prettyBreak+ <$$> prettyDocumentation (curve' <+> "is a Montgomery curve")+ <$$> "instance Curve 'Montgomery c" <+> pretty curve <+> prettyField field+ <+> "Fr => MCurve c" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "a_ = const _a"+ <$$> prettyInline "a_"+ <$$> "b_ = const _b"+ <$$> prettyInline "b_"+ <$$> "h_ = const _h"+ <$$> prettyInline "h_"+ <$$> "q_ = const _q"+ <$$> prettyInline "q_"+ <$$> "r_ = const _r"+ <$$> prettyInline "r_"+ <$$> "x_ = const _x"+ <$$> prettyInline "x_"+ <$$> "y_ = const _y"+ <$$> prettyInline "y_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "point")+ <$$> "type PA = MAPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "is a Montgomery affine curve")+ <$$> "instance MACurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gA_ = gA"+ <$$> prettyInline "gA_"+ )+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyParameters :: Types -> Parameters -> Doc+prettyParameters Types{..} Parameters{..}+ = prettySection "Parameters"+ <$$> prettyDocumentation ("Coefficient @A@ of" <+> curve')+ <$$> "_a ::" <+> prettyField field+ <$$> "_a =" <+> prettyElement a+ <$$> prettyInline "_a"+ <> prettyBreak+ <$$> prettyDocumentation ("Coefficient @B@ of" <+> curve')+ <$$> "_b ::" <+> prettyField field+ <$$> "_b =" <+> prettyElement b+ <$$> prettyInline "_b"+ <> prettyBreak+ <$$> prettyDocumentation ("Cofactor of" <+> curve')+ <$$> "_h :: Integer"+ <$$> "_h =" <+> prettyInteger h+ <$$> prettyInline "_h"+ <> prettyBreak+ <$$> prettyDocumentation ("Characteristic of" <+> curve')+ <$$> "_q :: Integer"+ <$$> "_q =" <+> prettyInteger q+ <$$> prettyInline "_q"+ <> prettyBreak+ <$$> prettyDocumentation ("Order of" <+> curve')+ <$$> "_r :: Integer"+ <$$> "_r =" <+> prettyInteger r+ <$$> prettyInline "_r"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @X@ of" <+> curve')+ <$$> "_x ::" <+> prettyField field+ <$$> "_x =" <+> prettyElement x+ <$$> prettyInline "_x"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @Y@ of" <+> curve')+ <$$> "_y ::" <+> prettyField field+ <$$> "_y =" <+> prettyElement y+ <$$> prettyInline "_y"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of affine" <+> curve')+ <$$> "gA :: PA"+ <$$> "gA = A _x _y"+ <$$> prettyInline "gA"+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyCurve :: Curve -> Doc+prettyCurve (Curve types parameters)+ = prettyImports types+ <> prettyBreak+ <$$> prettyTypes types+ <> prettyBreak+ <$$> prettyParameters types parameters+ <> prettyBreak
+ generate/Generate/Montgomery/Generate.hs view
@@ -0,0 +1,84 @@+module Generate.Montgomery.Generate+ ( prettyGenerate+ ) where++import Protolude++import Data.Text (toLower)+import Text.PrettyPrint.Leijen.Text++import Generate.Generate+import Generate.Montgomery.Types+import Generate.Pretty++-------------------------------------------------------------------------------+-- Generate+-------------------------------------------------------------------------------++prettyImports :: Doc+prettyImports+ = "module Generate.Montgomery.Parameters"+ <$$> indent 2+ ( "( curves"+ <$$> ") where"+ )+ <> prettyBreak+ <$$> "import Protolude"+ <> prettyBreak+ <$$> "import Generate.Montgomery.Types"++prettyCurves :: [Curve] -> Doc+prettyCurves curves+ = prettySection "Curves"+ <$$> "curves :: [Curve]"+ <$$> "curves ="+ <$$> indent 2+ ( "[ "+ <> hcat (punctuate "\n, " (map prettyCurves' curves))+ <$$> "]"+ )+ where+ prettyCurves' :: Curve -> Doc+ prettyCurves' = pretty . toLower . curve . types++prettyParameters :: [Curve] -> Doc+prettyParameters curves+ = prettySection "Parameters"+ <$$> vcat (punctuate prettyBreak (map prettyParameters' curves))+ where+ prettyParameters' :: Curve -> Doc+ prettyParameters' (Curve Types{..} Parameters{..})+ = pretty (toLower curve) <+> ":: Curve"+ <$$> pretty (toLower curve) <+> "= Curve"+ <$$> indent 2+ ( "{ types = Types"+ <$$> indent 2+ ( "{ curve =" <+> prettyText curve+ <$$> ", field =" <+> prettyField field+ <$$> ", field' =" <+> prettyField field'+ <$$> ", imports = "+ <> maybe "Nothing" ((<>) "Just " . prettyText) imports+ <$$> "}"+ )+ <$$> ", parameters = Parameters"+ <$$> indent 2+ ( "{ a =" <+> prettyElement a+ <$$> ", b =" <+> prettyElement b+ <$$> ", h =" <+> prettyInteger h+ <$$> ", q =" <+> prettyInteger q+ <$$> ", r =" <+> prettyInteger r+ <$$> ", x =" <+> prettyElement x+ <$$> ", y =" <+> prettyElement y+ <$$> "}"+ )+ <$$> "}"+ )++prettyGenerate :: [Curve] -> Doc+prettyGenerate curves+ = prettyImports+ <> prettyBreak+ <$$> prettyCurves curves+ <> prettyBreak+ <$$> prettyParameters curves+ <> prettyBreak
+ generate/Generate/Montgomery/Parameters.hs view
@@ -0,0 +1,139 @@+module Generate.Montgomery.Parameters+ ( curves+ ) where++import Protolude++import Generate.Montgomery.Types++-------------------------------------------------------------------------------+-- Curves+-------------------------------------------------------------------------------++curves :: [Curve]+curves =+ [ curve448+ , curve25519+ , curve383187+ , m221+ , m383+ , m511+ ]++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++curve448 :: Curve+curve448 = Curve+ { types = Types+ { curve = "Curve448"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x262a6+ , b = PF 0x1+ , h = 0x4+ , q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , r = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+ , x = PF 0x5+ , y = PF 0x7d235d1295f5b1f66c98ab6e58326fcecbae5d34f55545d060f75dc28df3f6edb8027e2346430d211312c4b150677af76fd7223d457b5b1a+ }+ }++curve25519 :: Curve+curve25519 = Curve+ { types = Types+ { curve = "Curve25519"+ , field = PrimeField "Fq" 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+ , field' = PrimeField "Fr" 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x76d06+ , b = PF 0x1+ , h = 0x8+ , q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+ , r = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+ , x = PF 0x9+ , y = PF 0x20ae19a1b8a086b4e01edd2c7748d14c923d4d7e6d7c61b229e9c5a27eced3d9+ }+ }++curve383187 :: Curve+curve383187 = Curve+ { types = Types+ { curve = "Curve383187"+ , field = PrimeField "Fq" 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+ , field' = PrimeField "Fr" 0x1000000000000000000000000000000000000000000000000e85a85287a1488acd41ae84b2b7030446f72088b00a0e21+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x38251+ , b = PF 0x1+ , h = 0x8+ , q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+ , r = 0x1000000000000000000000000000000000000000000000000e85a85287a1488acd41ae84b2b7030446f72088b00a0e21+ , x = PF 0x5+ , y = PF 0x1eebe07dc1871896732b12d5504a32370471965c7a11f2c89865f855ab3cbd7c224e3620c31af3370788457dd5ce46df+ }+ }++m221 :: Curve+m221 = Curve+ { types = Types+ { curve = "M221"+ , field = PrimeField "Fq" 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd+ , field' = PrimeField "Fr" 0x40000000000000000000000000015a08ed730e8a2f77f005042605b+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1c93a+ , b = PF 0x1+ , h = 0x8+ , q = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd+ , r = 0x40000000000000000000000000015a08ed730e8a2f77f005042605b+ , x = PF 0x4+ , y = PF 0xf7acdd2a4939571d1cef14eca37c228e61dbff10707dc6c08c5056d+ }+ }++m383 :: Curve+m383 = Curve+ { types = Types+ { curve = "M383"+ , field = PrimeField "Fq" 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+ , field' = PrimeField "Fr" 0x10000000000000000000000000000000000000000000000006c79673ac36ba6e7a32576f7b1b249e46bbc225be9071d7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1f82fe+ , b = PF 0x1+ , h = 0x8+ , q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+ , r = 0x10000000000000000000000000000000000000000000000006c79673ac36ba6e7a32576f7b1b249e46bbc225be9071d7+ , x = PF 0xc+ , y = PF 0x1ec7ed04aaf834af310e304b2da0f328e7c165f0e8988abd3992861290f617aa1f1b2e7d0b6e332e969991b62555e77e+ }+ }++m511 :: Curve+m511 = Curve+ { types = Types+ { curve = "M511"+ , field = PrimeField "Fq" 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+ , field' = PrimeField "Fr" 0x100000000000000000000000000000000000000000000000000000000000000017b5feff30c7f5677ab2aeebd13779a2ac125042a6aa10bfa54c15bab76baf1b+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x81806+ , b = PF 0x1+ , h = 0x8+ , q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+ , r = 0x100000000000000000000000000000000000000000000000000000000000000017b5feff30c7f5677ab2aeebd13779a2ac125042a6aa10bfa54c15bab76baf1b+ , x = PF 0x5+ , y = PF 0x2fbdc0ad8530803d28fdbad354bb488d32399ac1cf8f6e01ee3f96389b90c809422b9429e8a43dbf49308ac4455940abe9f1dbca542093a895e30a64af056fa5+ }+ }
+ generate/Generate/Montgomery/Types.hs view
@@ -0,0 +1,27 @@+module Generate.Montgomery.Types+ ( module Generate.Montgomery.Types+ , module Generate.Types+ ) where++import Protolude++import Generate.Types++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++data Curve = Curve+ { types :: Types+ , parameters :: Parameters+ }++data Parameters = Parameters+ { a :: Element+ , b :: Element+ , h :: Integer+ , q :: Integer+ , r :: Integer+ , x :: Element+ , y :: Element+ }
+ generate/Generate/Pretty.hs view
@@ -0,0 +1,40 @@+module Generate.Pretty+ ( module Generate.Pretty+ ) where++import Protolude++import Numeric (showHex)+import Text.PrettyPrint.Leijen.Text++-------------------------------------------------------------------------------+-- Pretty+-------------------------------------------------------------------------------++prettyBreak :: Doc+prettyBreak+ = linebreak++prettyDocumentation :: Doc -> Doc+prettyDocumentation+ = enclose "-- | " dot++prettyInline :: Doc -> Doc+prettyInline+ = braces . enclose "-# INLINABLE " " #-"++prettyInteger :: Integer -> Doc+prettyInteger+ = (<>) "0x" . pretty . flip showHex ""++prettyLine :: Doc+prettyLine+ = pretty (replicate 79 '-')++prettySection :: Doc -> Doc+prettySection+ = enclose (prettyLine <$$> "-- ") (prettyBreak <> prettyLine <> prettyBreak)++prettyText :: Text -> Doc+prettyText+ = dquotes . pretty
+ generate/Generate/Types.hs view
@@ -0,0 +1,24 @@+module Generate.Types+ ( module Generate.Types+ ) where++import Protolude++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++data Element = BF Integer+ | EF [Element]+ | PF Integer++data Field = BinaryField Text Integer+ | ExtensionField Text Text Text Text (Maybe Field)+ | PrimeField Text Integer++data Types = Types+ { curve :: Text+ , field :: Field+ , field' :: Field+ , imports :: Maybe Text+ }
+ generate/Generate/Weierstrass/Curve.hs view
@@ -0,0 +1,159 @@+module Generate.Weierstrass.Curve+ ( prettyCurve+ ) where++import Protolude++import Text.PrettyPrint.Leijen.Text++import Generate.Curve+import Generate.Pretty+import Generate.Weierstrass.Types++-------------------------------------------------------------------------------+-- Curve+-------------------------------------------------------------------------------++prettyImports :: Types -> Doc+prettyImports Types{..}+ = "module Curve.Weierstrass." <> pretty curve+ <$$> indent 2+ ( "( module Curve.Weierstrass"+ <$$> ", module Curve.Weierstrass." <> pretty curve+ <$$> ") where"+ )+ <> prettyBreak+ <$$> prettyImport field+ <> prettyBreak+ <$$> "import Curve.Weierstrass"+ <$$> maybe mempty pretty imports++prettyTypes :: Types -> Doc+prettyTypes Types{..}+ = prettySection "Types"+ <$$> prettyDocumentation curve'+ <$$> "data" <+> pretty curve+ <> prettyBreak+ <$$> prettyDocumentation ("Field of points of" <+> curve')+ <$$> prettyType field+ <> prettyBreak+ <$$> prettyDocumentation ("Field of coefficients of" <+> curve')+ <$$> prettyType field'+ <> prettyBreak+ <$$> prettyDocumentation (curve' <+> "is a Weierstrass curve")+ <$$> "instance Curve 'Weierstrass c" <+> pretty curve <+> prettyField field+ <+> "Fr => WCurve c" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "a_ = const _a"+ <$$> prettyInline "a_"+ <$$> "b_ = const _b"+ <$$> prettyInline "b_"+ <$$> "h_ = const _h"+ <$$> prettyInline "h_"+ <$$> "q_ = const _q"+ <$$> prettyInline "q_"+ <$$> "r_ = const _r"+ <$$> prettyInline "r_"+ <$$> "x_ = const _x"+ <$$> prettyInline "x_"+ <$$> "y_ = const _y"+ <$$> prettyInline "y_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "point")+ <$$> "type PA = WAPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Affine" <+> curve' <+> "is a Weierstrass affine curve")+ <$$> "instance WACurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gA_ = gA"+ <$$> prettyInline "gA_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Jacobian" <+> pretty curve <+> "point")+ <$$> "type PJ = WJPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Jacobian" <+> curve' <+> "is a Weierstrass Jacobian curve")+ <$$> "instance WJCurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gJ_ = gJ"+ <$$> prettyInline "gJ_"+ )+ <> prettyBreak+ <$$> prettyDocumentation ("Projective" <+> pretty curve <+> "point")+ <$$> "type PP = WPPoint" <+> pretty curve <+> prettyField field <+> "Fr"+ <> prettyBreak+ <$$> prettyDocumentation ("Projective" <+> curve' <+> "is a Weierstrass projective curve")+ <$$> "instance WPCurve" <+> pretty curve <+> prettyField field <+> "Fr where"+ <$$> indent 2+ ( "gP_ = gP"+ <$$> prettyInline "gP_"+ )+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyParameters :: Types -> Parameters -> Doc+prettyParameters Types{..} Parameters{..}+ = prettySection "Parameters"+ <$$> prettyDocumentation ("Coefficient @A@ of" <+> curve')+ <$$> "_a ::" <+> prettyField field+ <$$> "_a =" <+> prettyElement a+ <$$> prettyInline "_a"+ <> prettyBreak+ <$$> prettyDocumentation ("Coefficient @B@ of" <+> curve')+ <$$> "_b ::" <+> prettyField field+ <$$> "_b =" <+> prettyElement b+ <$$> prettyInline "_b"+ <> prettyBreak+ <$$> prettyDocumentation ("Cofactor of" <+> curve')+ <$$> "_h :: Integer"+ <$$> "_h =" <+> prettyInteger h+ <$$> prettyInline "_h"+ <> prettyBreak+ <$$> prettyDocumentation ("Characteristic of" <+> curve')+ <$$> "_q :: Integer"+ <$$> "_q =" <+> prettyInteger q+ <$$> prettyInline "_q"+ <> prettyBreak+ <$$> prettyDocumentation ("Order of" <+> curve')+ <$$> "_r :: Integer"+ <$$> "_r =" <+> prettyInteger r+ <$$> prettyInline "_r"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @X@ of" <+> curve')+ <$$> "_x ::" <+> prettyField field+ <$$> "_x =" <+> prettyElement x+ <$$> prettyInline "_x"+ <> prettyBreak+ <$$> prettyDocumentation ("Coordinate @Y@ of" <+> curve')+ <$$> "_y ::" <+> prettyField field+ <$$> "_y =" <+> prettyElement y+ <$$> prettyInline "_y"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of affine" <+> curve')+ <$$> "gA :: PA"+ <$$> "gA = A _x _y"+ <$$> prettyInline "gA"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of Jacobian" <+> curve')+ <$$> "gJ :: PJ"+ <$$> "gJ = J _x _y 1"+ <$$> prettyInline "gJ"+ <> prettyBreak+ <$$> prettyDocumentation ("Generator of projective" <+> curve')+ <$$> "gP :: PP"+ <$$> "gP = P _x _y 1"+ <$$> prettyInline "gP"+ where+ curve' :: Doc+ curve' = pretty curve <+> "curve"++prettyCurve :: Curve -> Doc+prettyCurve (Curve types parameters)+ = prettyImports types+ <> prettyBreak+ <$$> prettyTypes types+ <> prettyBreak+ <$$> prettyParameters types parameters+ <> prettyBreak
+ generate/Generate/Weierstrass/Generate.hs view
@@ -0,0 +1,84 @@+module Generate.Weierstrass.Generate+ ( prettyGenerate+ ) where++import Protolude++import Data.Text (toLower)+import Text.PrettyPrint.Leijen.Text++import Generate.Generate+import Generate.Pretty+import Generate.Weierstrass.Types++-------------------------------------------------------------------------------+-- Generate+-------------------------------------------------------------------------------++prettyImports :: Doc+prettyImports+ = "module Generate.Weierstrass.Parameters"+ <$$> indent 2+ ( "( curves"+ <$$> ") where"+ )+ <> prettyBreak+ <$$> "import Protolude"+ <> prettyBreak+ <$$> "import Generate.Weierstrass.Types"++prettyCurves :: [Curve] -> Doc+prettyCurves curves+ = prettySection "Curves"+ <$$> "curves :: [Curve]"+ <$$> "curves ="+ <$$> indent 2+ ( "[ "+ <> hcat (punctuate "\n, " (map prettyCurves' curves))+ <$$> "]"+ )+ where+ prettyCurves' :: Curve -> Doc+ prettyCurves' = pretty . toLower . curve . types++prettyParameters :: [Curve] -> Doc+prettyParameters curves+ = prettySection "Parameters"+ <$$> vcat (punctuate prettyBreak (map prettyParameters' curves))+ where+ prettyParameters' :: Curve -> Doc+ prettyParameters' (Curve Types{..} Parameters{..})+ = pretty (toLower curve) <+> ":: Curve"+ <$$> pretty (toLower curve) <+> "= Curve"+ <$$> indent 2+ ( "{ types = Types"+ <$$> indent 2+ ( "{ curve =" <+> prettyText curve+ <$$> ", field =" <+> prettyField field+ <$$> ", field' =" <+> prettyField field'+ <$$> ", imports = "+ <> maybe "Nothing" ((<>) "Just " . prettyText) imports+ <$$> "}"+ )+ <$$> ", parameters = Parameters"+ <$$> indent 2+ ( "{ a =" <+> prettyElement a+ <$$> ", b =" <+> prettyElement b+ <$$> ", h =" <+> prettyInteger h+ <$$> ", q =" <+> prettyInteger q+ <$$> ", r =" <+> prettyInteger r+ <$$> ", x =" <+> prettyElement x+ <$$> ", y =" <+> prettyElement y+ <$$> "}"+ )+ <$$> "}"+ )++prettyGenerate :: [Curve] -> Doc+prettyGenerate curves+ = prettyImports+ <> prettyBreak+ <$$> prettyCurves curves+ <> prettyBreak+ <$$> prettyParameters curves+ <> prettyBreak
+ generate/Generate/Weierstrass/Parameters.hs view
@@ -0,0 +1,1035 @@+module Generate.Weierstrass.Parameters+ ( curves+ ) where++import Protolude++import Generate.Weierstrass.Types++-------------------------------------------------------------------------------+-- Curves+-------------------------------------------------------------------------------++curves :: [Curve]+curves =+ [ anomalous+ , anssifrp256v1+ , bls12381+ , bls12381t+ , bls48581+ , bls48581t+ , bn224+ , bn254+ , bn254t+ , bn254a+ , bn254at+ , bn254b+ , bn254bt+ , bn256+ , bn384+ , bn462+ , bn462t+ , bn512+ , brainpoolp160r1+ , brainpoolp160t1+ , brainpoolp192r1+ , brainpoolp192t1+ , brainpoolp224r1+ , brainpoolp224t1+ , brainpoolp256r1+ , brainpoolp256t1+ , brainpoolp320r1+ , brainpoolp320t1+ , brainpoolp384r1+ , brainpoolp384t1+ , brainpoolp512r1+ , brainpoolp512t1+ , secp112r1+ , secp112r2+ , secp128r1+ , secp128r2+ , secp160k1+ , secp160r1+ , secp160r2+ , secp192k1+ , secp192r1+ , secp224k1+ , secp224r1+ , secp256k1+ , secp256r1+ , secp384r1+ , secp521r1+ ]++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++anomalous :: Curve+anomalous = Curve+ { types = Types+ { curve = "Anomalous"+ , field = PrimeField "Fq" 0xb0000000000000000000000953000000000000000000001f9d7+ , field' = PrimeField "Fr" 0xb0000000000000000000000953000000000000000000001f9d7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x98d0fac687d6343eb1a1f595283eb1a1f58d0fac687d635f5e4+ , b = PF 0x4a1f58d0fac687d6343eb1a5e2d6343eb1a1f58d0fac688ab3f+ , h = 0x1+ , q = 0xb0000000000000000000000953000000000000000000001f9d7+ , r = 0xb0000000000000000000000953000000000000000000001f9d7+ , x = PF 0x101efb35fd1963c4871a2d17edaafa7e249807f58f8705126c6+ , y = PF 0x22389a3954375834304ba1d509a97de6c07148ea7f5951b20e7+ }+ }++anssifrp256v1 :: Curve+anssifrp256v1 = Curve+ { types = Types+ { curve = "ANSSIFRP256V1"+ , field = PrimeField "Fq" 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03+ , field' = PrimeField "Fr" 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c00+ , b = PF 0xee353fca5428a9300d4aba754a44c00fdfec0c9ae4b1a1803075ed967b7bb73f+ , h = 0x1+ , q = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03+ , r = 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1+ , x = PF 0xb6b3d4c356c139eb31183d4749d423958c27d2dcaf98b70164c97a2dd98f5cff+ , y = PF 0x6142e0f7c8b204911f9271f0f3ecef8c2701c307e8e4c9e183115a1554062cfb+ }+ }++bls12381 :: Curve+bls12381 = Curve+ { types = Types+ { curve = "BLS12381"+ , field = PrimeField "Fq" 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+ , field' = PrimeField "Fr" 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x4+ , h = 0x396c8c005555e1568c00aaab0000aaab+ , q = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+ , r = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+ , x = PF 0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb+ , y = PF 0x8b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1+ }+ }++bls12381t :: Curve+bls12381t = Curve+ { types = Types+ { curve = "BLS12381T"+ , field = ExtensionField "Fq2" "Fq" "PolynomialU" "X2 + 1" Nothing+ , field' = PrimeField "Fr" 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+ , imports = Just "import Curve.Weierstrass.BLS12381 (Fq)"+ }+ , parameters = Parameters+ { a = EF [+ ]+ , b = EF [ PF 0x4+ , PF 0x4+ ]+ , h = 0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5+ , q = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+ , r = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+ , x = EF [ PF 0x24aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8+ , PF 0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e+ ]+ , y = EF [ PF 0xce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801+ , PF 0x606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be+ ]+ }+ }++bls48581 :: Curve+bls48581 = Curve+ { types = Types+ { curve = "BLS48581"+ , field = PrimeField "Fq" 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+ , field' = PrimeField "Fr" 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x1+ , h = 0x85555841aaaec4ac+ , q = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+ , r = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+ , x = PF 0x2af59b7ac340f2baf2b73df1e93f860de3f257e0e86868cf61abdbaedffb9f7544550546a9df6f9645847665d859236ebdbc57db368b11786cb74da5d3a1e6d8c3bce8732315af640+ , y = PF 0xcefda44f6531f91f86b3a2d1fb398a488a553c9efeb8a52e991279dd41b720ef7bb7beffb98aee53e80f678584c3ef22f487f77c2876d1b2e35f37aef7b926b576dbb5de3e2587a70+ }+ }++bls48581t :: Curve+bls48581t = Curve+ { types = Types+ { curve = "BLS48581T"+ , field = ExtensionField "Fq8" "Fq4" "PolynomialW" "X2 + Y X" (Just+ ( ExtensionField "Fq4" "Fq2" "PolynomialV" "X2 + 1 + Y X" (Just+ ( ExtensionField "Fq2" "Fq" "PolynomialU" "X2 + 1" Nothing+ ))+ ))+ , field' = PrimeField "Fr" 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+ , imports = Just "import Curve.Weierstrass.BLS48581 (Fq)"+ }+ , parameters = Parameters+ { a = EF [+ ]+ , b = EF [ EF [+ ]+ , EF [ EF [+ ]+ , EF [ PF 0x9407b9ff9a3b7989c12718ea38095002b7427c6891098dd9df36078f9cbaa225245721d7b7041566ce6981ca7a39b6d7b41b3d2a898b877052bc7efb90d2524561f6e0aa732b2c895+ , PF 0x9407b9ff9a3b7989c12718ea38095002b7427c6891098dd9df36078f9cbaa225245721d7b7041566ce6981ca7a39b6d7b41b3d2a898b877052bc7efb90d2524561f6e0aa732b2c896+ ]+ ]+ ]+ , h = 0x170e915cb0a6b7406b8d94042317f811d6bc3fc6e211ada42e58ccfcb3ac076a7e4499d700a0c23dc4b0c078f92def8c87b7fe63e1eea270db353a4ef4d38b5998ad8f0d042ea24c8f02be1c0c83992fe5d7725227bb27123a949e0876c0a8ce0a67326db0e955dcb791b867f31d6bfa62fbdd5f44a00504df04e186fae033f1eb43c1b1a08b6e086eff03c8fee9ebdd1e191a8a4b0466c90b389987de5637d5dd13dab33196bd2e5afa6cd19cf0fc3fc7db7ece1f3fac742626b1b02fcee04043b2ea96492f6afa51739597c54bb78aa6b0b99319fef9d09f768831018ee6564c68d054c62f2e0b4549426fec24ab26957a669dba2a2b6945ce40c9aec6afdeda16c79e15546cd7771fa544d5364236690ea06832679562a68731420ae52d0d35a90b8d10b688e31b6aee45f45b7a5083c71732105852decc888f64839a4de33b99521f0984a418d20fc7b0609530e454f0696fa2a8075ac01cc8ae3869e8d0fe1f3788ffac4c01aa2720e431da333c83d9663bfb1fb7a1a7b90528482c6be7892299030bb51a51dc7e91e9156874416bf4c26f1ea7ec578058563960ef92bbbb8632d3a1b695f954af10e9a78e40acffc13b06540aae9da5287fc4429485d44e6289d8c0d6a3eb2ece35012452751839fb48bc14b515478e2ff412d930ac20307561f3a5c998e6bcbfebd97effc6433033a2361bfcdc4fc74ad379a16c6dea49c209b1+ , q = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+ , r = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+ , x = EF [ EF [ EF [ PF 0x5d615d9a7871e4a38237fa45a2775debabbefc70344dbccb7de64db3a2ef156c46ff79baad1a8c42281a63ca0612f400503004d80491f510317b79766322154dec34fd0b4ace8bfab+ , PF 0x7c4973ece2258512069b0e86abc07e8b22bb6d980e1623e9526f6da12307f4e1c3943a00abfedf16214a76affa62504f0c3c7630d979630ffd75556a01afa143f1669b36676b47c57+ ]+ , EF [ PF 0x1fccc70198f1334e1b2ea1853ad83bc73a8a6ca9ae237ca7a6d6957ccbab5ab6860161c1dbd19242ffae766f0d2a6d55f028cbdfbb879d5fea8ef4cded6b3f0b46488156ca55a3e6a+ , PF 0xbe2218c25ceb6185c78d8012954d4bfe8f5985ac62f3e5821b7b92a393f8be0cc218a95f63e1c776e6ec143b1b279b9468c31c5257c200ca52310b8cb4e80bc3f09a7033cbb7feafe+ ]+ ]+ , EF [ EF [ PF 0x38b91c600b35913a3c598e4caa9dd63007c675d0b1642b5675ff0e7c5805386699981f9e48199d5ac10b2ef492ae589274fad55fc1889aa80c65b5f746c9d4cbb739c3a1c53f8cce5+ , PF 0xc96c7797eb0738603f1311e4ecda088f7b8f35dcef0977a3d1a58677bb037418181df63835d28997eb57b40b9c0b15dd7595a9f177612f097fc7960910fce3370f2004d914a3c093a+ ]+ , EF [ PF 0xb9b7951c6061ee3f0197a498908aee660dea41b39d13852b6db908ba2c0b7a449cef11f293b13ced0fd0caa5efcf3432aad1cbe4324c22d63334b5b0e205c3354e41607e60750e057+ , PF 0x827d5c22fb2bdec5282624c4f4aaa2b1e5d7a9defaf47b5211cf741719728a7f9f8cfca93f29cff364a7190b7e2b0d4585479bd6aebf9fc44e56af2fc9e97c3f84e19da00fbc6ae34+ ]+ ]+ ]+ , y = EF [ EF [ EF [ PF 0xeb53356c375b5dfa497216452f3024b918b4238059a577e6f3b39ebfc435faab0906235afa27748d90f7336d8ae5163c1599abf77eea6d659045012ab12c0ff323edd3fe4d2d7971+ , PF 0x284dc75979e0ff144da6531815fcadc2b75a422ba325e6fba01d72964732fcbf3afb096b243b1f192c5c3d1892ab24e1dd212fa097d760e2e588b423525ffc7b111471db936cd5665+ ]+ , EF [ PF 0xb36a201dd008523e421efb70367669ef2c2fc5030216d5b119d3a480d370514475f7d5c99d0e90411515536ca3295e5e2f0c1d35d51a652269cbc7c46fc3b8fde68332a526a2a8474+ , PF 0xaec25a4621edc0688223fbbd478762b1c2cded3360dcee23dd8b0e710e122d2742c89b224333fa40dced2817742770ba10d67bda503ee5e578fb3d8b8a1e5337316213da92841589d+ ]+ ]+ , EF [ EF [ PF 0xd209d5a223a9c46916503fa5a88325a2554dc541b43dd93b5a959805f1129857ed85c77fa238cdce8a1e2ca4e512b64f59f430135945d137b08857fdddfcf7a43f47831f982e50137+ , PF 0x7d0d03745736b7a513d339d5ad537b90421ad66eb16722b589d82e2055ab7504fa83420e8c270841f6824f47c180d139e3aafc198caa72b679da59ed8226cf3a594eedc58cf90bee4+ ]+ , EF [ PF 0x896767811be65ea25c2d05dfdd17af8a006f364fc0841b064155f14e4c819a6df98f425ae3a2864f22c1fab8c74b2618b5bb40fa639f53dccc9e884017d9aa62b3d41faeafeb23986+ , PF 0x35e2524ff89029d393a5c07e84f981b5e068f1406be8e50c87549b6ef8eca9a9533a3f8e69c31e97e1ad0333ec719205417300d8c4ab33f748e5ac66e84069c55d667ffcb732718b6+ ]+ ]+ ]+ }+ }++bn224 :: Curve+bn224 = Curve+ { types = Types+ { curve = "BN224"+ , field = PrimeField "Fq" 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833+ , field' = PrimeField "Fr" 0xfffffffffff107288ec29e602c4420db4218082b36c2accff76c58ed+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x3+ , h = 0x1+ , q = 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833+ , r = 0xfffffffffff107288ec29e602c4420db4218082b36c2accff76c58ed+ , x = PF 0x1+ , y = PF 0x2+ }+ }++bn254 :: Curve+bn254 = Curve+ { types = Types+ { curve = "BN254"+ , field = PrimeField "Fq" 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+ , field' = PrimeField "Fr" 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x3+ , h = 0x1+ , q = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+ , r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+ , x = PF 0x1+ , y = PF 0x2+ }+ }++bn254t :: Curve+bn254t = Curve+ { types = Types+ { curve = "BN254T"+ , field = ExtensionField "Fq2" "Fq" "PolynomialU" "X2 + 1" Nothing+ , field' = PrimeField "Fr" 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+ , imports = Just "import Curve.Weierstrass.BN254 (Fq)"+ }+ , parameters = Parameters+ { a = EF [+ ]+ , b = EF [ PF 0x2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5+ , PF 0x9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2+ ]+ , h = 0x30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d+ , q = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+ , r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+ , x = EF [ PF 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed+ , PF 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2+ ]+ , y = EF [ PF 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa+ , PF 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b+ ]+ }+ }++bn254a :: Curve+bn254a = Curve+ { types = Types+ { curve = "BN254A"+ , field = PrimeField "Fq" 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+ , field' = PrimeField "Fr" 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x5+ , h = 0x1+ , q = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+ , r = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+ , x = PF 0x1+ , y = PF 0xd45589b158faaf6ab0e4ad38d998e9982e7ff63964ee1460342a592677cccb0+ }+ }++bn254at :: Curve+bn254at = Curve+ { types = Types+ { curve = "BN254AT"+ , field = ExtensionField "Fq2" "Fq" "PolynomialU" "X2 + 5" Nothing+ , field' = PrimeField "Fr" 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+ , imports = Just "import Curve.Weierstrass.BN254A (Fq)"+ }+ , parameters = Parameters+ { a = EF [+ ]+ , b = EF [ PF 0x0+ , PF 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000000+ ]+ , h = 0x2370fb049d410fbe4e761a9886e50241dc42cf101e0000017e80600000000001+ , q = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+ , r = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+ , x = EF [ PF 0x19b0bea4afe4c330da93cc3533da38a9f430b471c6f8a536e81962ed967909b5+ , PF 0xa1cf585585a61c6e9880b1f2a5c539f7d906fff238fa6341e1de1a2e45c3f72+ ]+ , y = EF [ PF 0x17abd366ebbd65333e49c711a80a0cf6d24adf1b9b3990eedcc91731384d2627+ , PF 0xee97d6de9902a27d00e952232a78700863bc9aa9be960c32f5bf9fd0a32d345+ ]+ }+ }++bn254b :: Curve+bn254b = Curve+ { types = Types+ { curve = "BN254B"+ , field = PrimeField "Fq" 0x2523648240000001ba344d80000000086121000000000013a700000000000013+ , field' = PrimeField "Fr" 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x2+ , h = 0x1+ , q = 0x2523648240000001ba344d80000000086121000000000013a700000000000013+ , r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+ , x = PF 0x2523648240000001ba344d80000000086121000000000013a700000000000012+ , y = PF 0x1+ }+ }++bn254bt :: Curve+bn254bt = Curve+ { types = Types+ { curve = "BN254BT"+ , field = ExtensionField "Fq2" "Fq" "PolynomialU" "X2 + 1" Nothing+ , field' = PrimeField "Fr" 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+ , imports = Just "import Curve.Weierstrass.BN254B (Fq)"+ }+ , parameters = Parameters+ { a = EF [+ ]+ , b = EF [ PF 0x1+ , PF 0x2523648240000001ba344d80000000086121000000000013a700000000000012+ ]+ , h = 0x2523648240000001ba344d8000000008c2a2800000000016ad00000000000019+ , q = 0x2523648240000001ba344d80000000086121000000000013a700000000000013+ , r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+ , x = EF [ PF 0x61a10bb519eb62feb8d8c7e8c61edb6a4648bbb4898bf0d91ee4224c803fb2b+ , PF 0x516aaf9ba737833310aa78c5982aa5b1f4d746bae3784b70d8c34c1e7d54cf3+ ]+ , y = EF [ PF 0x21897a06baf93439a90e096698c822329bd0ae6bdbe09bd19f0e07891cd2b9a+ , PF 0xebb2b0e7c8b15268f6d4456f5f38d37b09006ffd739c9578a2d1aec6b3ace9b+ ]+ }+ }++bn256 :: Curve+bn256 = Curve+ { types = Types+ { curve = "BN256"+ , field = PrimeField "Fq" 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013+ , field' = PrimeField "Fr" 0xfffffffffffcf0cd46e5f25eee71a49e0cdc65fb1299921af62d536cd10b500d+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x3+ , h = 0x1+ , q = 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013+ , r = 0xfffffffffffcf0cd46e5f25eee71a49e0cdc65fb1299921af62d536cd10b500d+ , x = PF 0x1+ , y = PF 0x2+ }+ }++bn384 :: Curve+bn384 = Curve+ { types = Types+ { curve = "BN384"+ , field = PrimeField "Fq" 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b+ , field' = PrimeField "Fr" 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca023c8fbe29531892c795356487d8ac63e4f4db17384341a5775+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x3+ , h = 0x1+ , q = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b+ , r = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca023c8fbe29531892c795356487d8ac63e4f4db17384341a5775+ , x = PF 0x1+ , y = PF 0x2+ }+ }++bn462 :: Curve+bn462 = Curve+ { types = Types+ { curve = "BN462"+ , field = PrimeField "Fq" 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+ , field' = PrimeField "Fr" 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x5+ , h = 0x1+ , q = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+ , r = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+ , x = PF 0x21a6d67ef250191fadba34a0a30160b9ac9264b6f95f63b3edbec3cf4b2e689db1bbb4e69a416a0b1e79239c0372e5cd70113c98d91f36b6980d+ , y = PF 0x118ea0460f7f7abb82b33676a7432a490eeda842cccfa7d788c659650426e6af77df11b8ae40eb80f475432c66600622ecaa8a5734d36fb03de+ }+ }++bn462t :: Curve+bn462t = Curve+ { types = Types+ { curve = "BN462T"+ , field = ExtensionField "Fq2" "Fq" "PolynomialU" "X2 + 1" Nothing+ , field' = PrimeField "Fr" 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+ , imports = Just "import Curve.Weierstrass.BN462 (Fq)"+ }+ , parameters = Parameters+ { a = EF [+ ]+ , b = EF [ PF 0x2+ , PF 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138012+ ]+ , h = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908fa1ce0227fffffffff6ff66fc63f5f7f4c0000000002401b008a0168019+ , q = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+ , r = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+ , x = EF [ PF 0x257ccc85b58dda0dfb38e3a8cbdc5482e0337e7c1cd96ed61c913820408208f9ad2699bad92e0032ae1f0aa6a8b48807695468e3d934ae1e4df+ , PF 0x1d2e4343e8599102af8edca849566ba3c98e2a354730cbed9176884058b18134dd86bae555b783718f50af8b59bf7e850e9b73108ba6aa8cd283+ ]+ , y = EF [ PF 0xa0650439da22c1979517427a20809eca035634706e23c3fa7a6bb42fe810f1399a1f41c9ddae32e03695a140e7b11d7c3376e5b68df0db7154e+ , PF 0x73ef0cbd438cbe0172c8ae37306324d44d5e6b0c69ac57b393f1ab370fd725cc647692444a04ef87387aa68d53743493b9eba14cc552ca2a93a+ ]+ }+ }++bn512 :: Curve+bn512 = Curve+ { types = Types+ { curve = "BN512"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33+ , field' = PrimeField "Fr" 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef445146cf1eacbe98b8e48c65deab2679a34a10313e04f9a2b406a64a5f519a09ed+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x3+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33+ , r = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef445146cf1eacbe98b8e48c65deab2679a34a10313e04f9a2b406a64a5f519a09ed+ , x = PF 0x1+ , y = PF 0x2+ }+ }++brainpoolp160r1 :: Curve+brainpoolp160r1 = Curve+ { types = Types+ { curve = "BrainpoolP160R1"+ , field = PrimeField "Fq" 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+ , field' = PrimeField "Fr" 0xe95e4a5f737059dc60df5991d45029409e60fc09+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x340e7be2a280eb74e2be61bada745d97e8f7c300+ , b = PF 0x1e589a8595423412134faa2dbdec95c8d8675e58+ , h = 0x1+ , q = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+ , r = 0xe95e4a5f737059dc60df5991d45029409e60fc09+ , x = PF 0xbed5af16ea3f6a4f62938c4631eb5af7bdbcdbc3+ , y = PF 0x1667cb477a1a8ec338f94741669c976316da6321+ }+ }++brainpoolp160t1 :: Curve+brainpoolp160t1 = Curve+ { types = Types+ { curve = "BrainpoolP160T1"+ , field = PrimeField "Fq" 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+ , field' = PrimeField "Fr" 0xe95e4a5f737059dc60df5991d45029409e60fc09+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xe95e4a5f737059dc60dfc7ad95b3d8139515620c+ , b = PF 0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380+ , h = 0x1+ , q = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+ , r = 0xe95e4a5f737059dc60df5991d45029409e60fc09+ , x = PF 0xb199b13b9b34efc1397e64baeb05acc265ff2378+ , y = PF 0xadd6718b7c7c1961f0991b842443772152c9e0ad+ }+ }++brainpoolp192r1 :: Curve+brainpoolp192r1 = Curve+ { types = Types+ { curve = "BrainpoolP192R1"+ , field = PrimeField "Fq" 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+ , field' = PrimeField "Fr" 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28ef+ , b = PF 0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9+ , h = 0x1+ , q = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+ , r = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+ , x = PF 0xc0a0647eaab6a48753b033c56cb0f0900a2f5c4853375fd6+ , y = PF 0x14b690866abd5bb88b5f4828c1490002e6773fa2fa299b8f+ }+ }++brainpoolp192t1 :: Curve+brainpoolp192t1 = Curve+ { types = Types+ { curve = "BrainpoolP192T1"+ , field = PrimeField "Fq" 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+ , field' = PrimeField "Fr" 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xc302f41d932a36cda7a3463093d18db78fce476de1a86294+ , b = PF 0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79+ , h = 0x1+ , q = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+ , r = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+ , x = PF 0x3ae9e58c82f63c30282e1fe7bbf43fa72c446af6f4618129+ , y = PF 0x97e2c5667c2223a902ab5ca449d0084b7e5b3de7ccc01c9+ }+ }++brainpoolp224r1 :: Curve+brainpoolp224r1 = Curve+ { types = Types+ { curve = "BrainpoolP224R1"+ , field = PrimeField "Fq" 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+ , field' = PrimeField "Fr" 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43+ , b = PF 0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400b+ , h = 0x1+ , q = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+ , r = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+ , x = PF 0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d+ , y = PF 0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd+ }+ }++brainpoolp224t1 :: Curve+brainpoolp224t1 = Curve+ { types = Types+ { curve = "BrainpoolP224T1"+ , field = PrimeField "Fq" 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+ , field' = PrimeField "Fr" 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fc+ , b = PF 0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888d+ , h = 0x1+ , q = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+ , r = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+ , x = PF 0x6ab1e344ce25ff3896424e7ffe14762ecb49f8928ac0c76029b4d580+ , y = PF 0x374e9f5143e568cd23f3f4d7c0d4b1e41c8cc0d1c6abd5f1a46db4c+ }+ }++brainpoolp256r1 :: Curve+brainpoolp256r1 = Curve+ { types = Types+ { curve = "BrainpoolP256R1"+ , field = PrimeField "Fq" 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+ , field' = PrimeField "Fr" 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9+ , b = PF 0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6+ , h = 0x1+ , q = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+ , r = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+ , x = PF 0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262+ , y = PF 0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997+ }+ }++brainpoolp256t1 :: Curve+brainpoolp256t1 = Curve+ { types = Types+ { curve = "BrainpoolP256T1"+ , field = PrimeField "Fq" 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+ , field' = PrimeField "Fr" 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374+ , b = PF 0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04+ , h = 0x1+ , q = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+ , r = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+ , x = PF 0xa3e8eb3cc1cfe7b7732213b23a656149afa142c47aafbc2b79a191562e1305f4+ , y = PF 0x2d996c823439c56d7f7b22e14644417e69bcb6de39d027001dabe8f35b25c9be+ }+ }++brainpoolp320r1 :: Curve+brainpoolp320r1 = Curve+ { types = Types+ { curve = "BrainpoolP320R1"+ , field = PrimeField "Fq" 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+ , field' = PrimeField "Fr" 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4+ , b = PF 0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6+ , h = 0x1+ , q = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+ , r = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+ , x = PF 0x43bd7e9afb53d8b85289bcc48ee5bfe6f20137d10a087eb6e7871e2a10a599c710af8d0d39e20611+ , y = PF 0x14fdd05545ec1cc8ab4093247f77275e0743ffed117182eaa9c77877aaac6ac7d35245d1692e8ee1+ }+ }++brainpoolp320t1 :: Curve+brainpoolp320t1 = Curve+ { types = Types+ { curve = "BrainpoolP320T1"+ , field = PrimeField "Fq" 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+ , field' = PrimeField "Fr" 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24+ , b = PF 0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353+ , h = 0x1+ , q = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+ , r = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+ , x = PF 0x925be9fb01afc6fb4d3e7d4990010f813408ab106c4f09cb7ee07868cc136fff3357f624a21bed52+ , y = PF 0x63ba3a7a27483ebf6671dbef7abb30ebee084e58a0b077ad42a5a0989d1ee71b1b9bc0455fb0d2c3+ }+ }++brainpoolp384r1 :: Curve+brainpoolp384r1 = Curve+ { types = Types+ { curve = "BrainpoolP384R1"+ , field = PrimeField "Fq" 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+ , field' = PrimeField "Fr" 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826+ , b = PF 0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11+ , h = 0x1+ , q = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+ , r = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+ , x = PF 0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e+ , y = PF 0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315+ }+ }++brainpoolp384t1 :: Curve+brainpoolp384t1 = Curve+ { types = Types+ { curve = "BrainpoolP384T1"+ , field = PrimeField "Fq" 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+ , field' = PrimeField "Fr" 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50+ , b = PF 0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471ee+ , h = 0x1+ , q = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+ , r = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+ , x = PF 0x18de98b02db9a306f2afcd7235f72a819b80ab12ebd653172476fecd462aabffc4ff191b946a5f54d8d0aa2f418808cc+ , y = PF 0x25ab056962d30651a114afd2755ad336747f93475b7a1fca3b88f2b6a208ccfe469408584dc2b2912675bf5b9e582928+ }+ }++brainpoolp512r1 :: Curve+brainpoolp512r1 = Curve+ { types = Types+ { curve = "BrainpoolP512R1"+ , field = PrimeField "Fq" 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+ , field' = PrimeField "Fr" 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca+ , b = PF 0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723+ , h = 0x1+ , q = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+ , r = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+ , x = PF 0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822+ , y = PF 0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892+ }+ }++brainpoolp512t1 :: Curve+brainpoolp512t1 = Curve+ { types = Types+ { curve = "BrainpoolP512T1"+ , field = PrimeField "Fq" 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+ , field' = PrimeField "Fr" 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f0+ , b = PF 0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423e+ , h = 0x1+ , q = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+ , r = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+ , x = PF 0x640ece5c12788717b9c1ba06cbc2a6feba85842458c56dde9db1758d39c0313d82ba51735cdb3ea499aa77a7d6943a64f7a3f25fe26f06b51baa2696fa9035da+ , y = PF 0x5b534bd595f5af0fa2c892376c84ace1bb4e3019b71634c01131159cae03cee9d9932184beef216bd71df2dadf86a627306ecff96dbb8bace198b61e00f8b332+ }+ }++secp112r1 :: Curve+secp112r1 = Curve+ { types = Types+ { curve = "SECP112R1"+ , field = PrimeField "Fq" 0xdb7c2abf62e35e668076bead208b+ , field' = PrimeField "Fr" 0xdb7c2abf62e35e7628dfac6561c5+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xdb7c2abf62e35e668076bead2088+ , b = PF 0x659ef8ba043916eede8911702b22+ , h = 0x1+ , q = 0xdb7c2abf62e35e668076bead208b+ , r = 0xdb7c2abf62e35e7628dfac6561c5+ , x = PF 0x9487239995a5ee76b55f9c2f098+ , y = PF 0xa89ce5af8724c0a23e0e0ff77500+ }+ }++secp112r2 :: Curve+secp112r2 = Curve+ { types = Types+ { curve = "SECP112R2"+ , field = PrimeField "Fq" 0xdb7c2abf62e35e668076bead208b+ , field' = PrimeField "Fr" 0x36df0aafd8b8d7597ca10520d04b+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x6127c24c05f38a0aaaf65c0ef02c+ , b = PF 0x51def1815db5ed74fcc34c85d709+ , h = 0x4+ , q = 0xdb7c2abf62e35e668076bead208b+ , r = 0x36df0aafd8b8d7597ca10520d04b+ , x = PF 0x4ba30ab5e892b4e1649dd0928643+ , y = PF 0xadcd46f5882e3747def36e956e97+ }+ }++secp128r1 :: Curve+secp128r1 = Curve+ { types = Types+ { curve = "SECP128R1"+ , field = PrimeField "Fq" 0xfffffffdffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0xfffffffe0000000075a30d1b9038a115+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xfffffffdfffffffffffffffffffffffc+ , b = PF 0xe87579c11079f43dd824993c2cee5ed3+ , h = 0x1+ , q = 0xfffffffdffffffffffffffffffffffff+ , r = 0xfffffffe0000000075a30d1b9038a115+ , x = PF 0x161ff7528b899b2d0c28607ca52c5b86+ , y = PF 0xcf5ac8395bafeb13c02da292dded7a83+ }+ }++secp128r2 :: Curve+secp128r2 = Curve+ { types = Types+ { curve = "SECP128R2"+ , field = PrimeField "Fq" 0xfffffffdffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0x3fffffff7fffffffbe0024720613b5a3+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xd6031998d1b3bbfebf59cc9bbff9aee1+ , b = PF 0x5eeefca380d02919dc2c6558bb6d8a5d+ , h = 0x4+ , q = 0xfffffffdffffffffffffffffffffffff+ , r = 0x3fffffff7fffffffbe0024720613b5a3+ , x = PF 0x7b6aa5d85e572983e6fb32a7cdebc140+ , y = PF 0x27b6916a894d3aee7106fe805fc34b44+ }+ }++secp160k1 :: Curve+secp160k1 = Curve+ { types = Types+ { curve = "SECP160K1"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffeffffac73+ , field' = PrimeField "Fr" 0x100000000000000000001b8fa16dfab9aca16b6b3+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x7+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffeffffac73+ , r = 0x100000000000000000001b8fa16dfab9aca16b6b3+ , x = PF 0x3b4c382ce37aa192a4019e763036f4f5dd4d7ebb+ , y = PF 0x938cf935318fdced6bc28286531733c3f03c4fee+ }+ }++secp160r1 :: Curve+secp160r1 = Curve+ { types = Types+ { curve = "SECP160R1"+ , field = PrimeField "Fq" 0xffffffffffffffffffffffffffffffff7fffffff+ , field' = PrimeField "Fr" 0x100000000000000000001f4c8f927aed3ca752257+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xffffffffffffffffffffffffffffffff7ffffffc+ , b = PF 0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45+ , h = 0x1+ , q = 0xffffffffffffffffffffffffffffffff7fffffff+ , r = 0x100000000000000000001f4c8f927aed3ca752257+ , x = PF 0x4a96b5688ef573284664698968c38bb913cbfc82+ , y = PF 0x23a628553168947d59dcc912042351377ac5fb32+ }+ }++secp160r2 :: Curve+secp160r2 = Curve+ { types = Types+ { curve = "SECP160R2"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffeffffac73+ , field' = PrimeField "Fr" 0x100000000000000000000351ee786a818f3a1a16b+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xfffffffffffffffffffffffffffffffeffffac70+ , b = PF 0xb4e134d3fb59eb8bab57274904664d5af50388ba+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffeffffac73+ , r = 0x100000000000000000000351ee786a818f3a1a16b+ , x = PF 0x52dcb034293a117e1f4ff11b30f7199d3144ce6d+ , y = PF 0xfeaffef2e331f296e071fa0df9982cfea7d43f2e+ }+ }++secp192k1 :: Curve+secp192k1 = Curve+ { types = Types+ { curve = "SECP192K1"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffeffffee37+ , field' = PrimeField "Fr" 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x3+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffffffffffeffffee37+ , r = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d+ , x = PF 0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d+ , y = PF 0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d+ }+ }++secp192r1 :: Curve+secp192r1 = Curve+ { types = Types+ { curve = "SECP192R1"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffeffffffffffffffff+ , field' = PrimeField "Fr" 0xffffffffffffffffffffffff99def836146bc9b1b4d22831+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xfffffffffffffffffffffffffffffffefffffffffffffffc+ , b = PF 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffeffffffffffffffff+ , r = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831+ , x = PF 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012+ , y = PF 0x7192b95ffc8da78631011ed6b24cdd573f977a11e794811+ }+ }++secp224k1 :: Curve+secp224k1 = Curve+ { types = Types+ { curve = "SECP224K1"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d+ , field' = PrimeField "Fr" 0x10000000000000000000000000001dce8d2ec6184caf0a971769fb1f7+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x5+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d+ , r = 0x10000000000000000000000000001dce8d2ec6184caf0a971769fb1f7+ , x = PF 0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c+ , y = PF 0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5+ }+ }++secp224r1 :: Curve+secp224r1 = Curve+ { types = Types+ { curve = "SECP224R1"+ , field = PrimeField "Fq" 0xffffffffffffffffffffffffffffffff000000000000000000000001+ , field' = PrimeField "Fr" 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe+ , b = PF 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4+ , h = 0x1+ , q = 0xffffffffffffffffffffffffffffffff000000000000000000000001+ , r = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d+ , x = PF 0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21+ , y = PF 0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34+ }+ }++secp256k1 :: Curve+secp256k1 = Curve+ { types = Types+ { curve = "SECP256K1"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f+ , field' = PrimeField "Fr" 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x0+ , b = PF 0x7+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f+ , r = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141+ , x = PF 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798+ , y = PF 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8+ }+ }++secp256r1 :: Curve+secp256r1 = Curve+ { types = Types+ { curve = "SECP256R1"+ , field = PrimeField "Fq" 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc+ , b = PF 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b+ , h = 0x1+ , q = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff+ , r = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551+ , x = PF 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296+ , y = PF 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5+ }+ }++secp384r1 :: Curve+secp384r1 = Curve+ { types = Types+ { curve = "SECP384R1"+ , field = PrimeField "Fq" 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff+ , field' = PrimeField "Fr" 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc+ , b = PF 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef+ , h = 0x1+ , q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff+ , r = 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973+ , x = PF 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7+ , y = PF 0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f+ }+ }++secp521r1 :: Curve+secp521r1 = Curve+ { types = Types+ { curve = "SECP521R1"+ , field = PrimeField "Fq" 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , field' = PrimeField "Fr" 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409+ , imports = Nothing+ }+ , parameters = Parameters+ { a = PF 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc+ , b = PF 0x51953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00+ , h = 0x1+ , q = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+ , r = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409+ , x = PF 0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66+ , y = PF 0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650+ }+ }
+ generate/Generate/Weierstrass/Types.hs view
@@ -0,0 +1,27 @@+module Generate.Weierstrass.Types+ ( module Generate.Weierstrass.Types+ , module Generate.Types+ ) where++import Protolude++import Generate.Types++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++data Curve = Curve+ { types :: Types+ , parameters :: Parameters+ }++data Parameters = Parameters+ { a :: Element+ , b :: Element+ , h :: Integer+ , q :: Integer+ , r :: Integer+ , x :: Element+ , y :: Element+ }
+ generate/Main.hs view
@@ -0,0 +1,104 @@+module Main where++import Protolude++import Data.Text (unpack)++import qualified Generate.Binary.Curve as Binary+import qualified Generate.Binary.Generate as Binary+import qualified Generate.Binary.Parameters as Binary+import qualified Generate.Binary.Types as Binary+import qualified Generate.Edwards.Curve as Edwards+import qualified Generate.Edwards.Generate as Edwards+import qualified Generate.Edwards.Parameters as Edwards+import qualified Generate.Edwards.Types as Edwards+import qualified Generate.Montgomery.Curve as Montgomery+import qualified Generate.Montgomery.Generate as Montgomery+import qualified Generate.Montgomery.Parameters as Montgomery+import qualified Generate.Montgomery.Types as Montgomery+import qualified Generate.Weierstrass.Curve as Weierstrass+import qualified Generate.Weierstrass.Generate as Weierstrass+import qualified Generate.Weierstrass.Parameters as Weierstrass+import qualified Generate.Weierstrass.Types as Weierstrass++-------------------------------------------------------------------------------+-- Curve generator+-------------------------------------------------------------------------------++generateCurve :: IO ()+generateCurve = do+ mapM_ (uncurry writeFile) generateBinaryCurve+ mapM_ (uncurry writeFile) generateEdwardsCurve+ mapM_ (uncurry writeFile) generateMontgomeryCurve+ mapM_ (uncurry writeFile) generateWeierstrassCurve++generateBinaryCurve :: [(FilePath, Text)]+generateBinaryCurve = map generateBinaryCurve' Binary.curves+ where+ generateBinaryCurve' :: Binary.Curve -> (FilePath, Text)+ generateBinaryCurve' = generateCurve'+ "Binary" Binary.curve Binary.types Binary.prettyCurve++generateEdwardsCurve :: [(FilePath, Text)]+generateEdwardsCurve = map generateEdwardsCurve' Edwards.curves+ where+ generateEdwardsCurve' :: Edwards.Curve -> (FilePath, Text)+ generateEdwardsCurve' = generateCurve'+ "Edwards" Edwards.curve Edwards.types Edwards.prettyCurve++generateMontgomeryCurve :: [(FilePath, Text)]+generateMontgomeryCurve = map generateMontgomeryCurve' Montgomery.curves+ where+ generateMontgomeryCurve' :: Montgomery.Curve -> (FilePath, Text)+ generateMontgomeryCurve' = generateCurve'+ "Montgomery" Montgomery.curve Montgomery.types Montgomery.prettyCurve++generateWeierstrassCurve :: [(FilePath, Text)]+generateWeierstrassCurve = map generateWeierstrassCurve' Weierstrass.curves+ where+ generateWeierstrassCurve' :: Weierstrass.Curve -> (FilePath, Text)+ generateWeierstrassCurve' = generateCurve'+ "Weierstrass" Weierstrass.curve Weierstrass.types Weierstrass.prettyCurve++generateCurve' :: Show doc => Text -> (types -> Text)+ -> (curve -> types) -> (curve -> doc) -> curve -> (FilePath, Text)+generateCurve' form curve types pretty = (,)+ <$> unpack . (<> ".hs") . (<>) ("../src/Curve/" <> form <> "/") . curve . types+ <*> show . pretty++-------------------------------------------------------------------------------+-- Generate generator+-------------------------------------------------------------------------------++generateGenerate :: IO ()+generateGenerate = do+ writeFile "Generate/Binary/Parameters.hs" generateBinaryGenerate+ writeFile "Generate/Edwards/Parameters.hs" generateEdwardsGenerate+ writeFile "Generate/Montgomery/Parameters.hs" generateMontgomeryGenerate+ writeFile "Generate/Weierstrass/Parameters.hs" generateWeierstrassGenerate++generateBinaryGenerate :: Text+generateBinaryGenerate = generateGenerate'+ Binary.prettyGenerate Binary.curves++generateEdwardsGenerate :: Text+generateEdwardsGenerate = generateGenerate'+ Edwards.prettyGenerate Edwards.curves++generateMontgomeryGenerate :: Text+generateMontgomeryGenerate = generateGenerate'+ Montgomery.prettyGenerate Montgomery.curves++generateWeierstrassGenerate :: Text+generateWeierstrassGenerate = generateGenerate'+ Weierstrass.prettyGenerate Weierstrass.curves++generateGenerate' :: Show doc => (curve -> doc) -> curve -> Text+generateGenerate' = (.) show++-------------------------------------------------------------------------------+-- Main generator+-------------------------------------------------------------------------------++main :: IO ()+main = generateGenerate >> generateCurve
src/Curve.hs view
@@ -1,65 +1,103 @@ module Curve- ( Curve(..)+ ( module Curve+ , module Group ) where import Protolude -import Control.Monad.Random (MonadRandom)+import Control.Monad.Random (Random(..)) import GaloisField (GaloisField)+import PrimeField (PrimeField, toInt)+import Test.Tasty.QuickCheck (Arbitrary(..), suchThatMap) +import Group (Group(..))+ ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Elliptic curves over Galois fields.-class GaloisField k => Curve r c k where- {-# MINIMAL id, inv, add, def, disc, point, rnd #-}+-- | Elliptic curves.+class (GaloisField q, GaloisField r, Group (Point f c e q r))+ => Curve (f :: Form) (c :: Coordinates) e q r where+ {-# MINIMAL char, cof, disc, fromA, point, pointX, toA, yX #-} + -- Parameters++ -- | Curve characteristic.+ char :: Point f c e q r -> Integer++ -- | Curve cofactor.+ cof :: Point f c e q r -> Integer++ -- | Curve discriminant.+ disc :: Point f c e q r -> q++ -- Points+ -- | Curve point.- data family Point r c k :: *+ data family Point f c e q r :: * - -- | Point identity.- id :: Point r c k+ -- | Curve point multiplication.+ mul :: r ~ PrimeField p => Point f c e q r -> r -> Point f c e q r+ mul = (. toInt) . mul'+ {-# INLINABLE mul #-} - -- | Point inversion.- inv :: Point r c k -> Point r c k+ -- | Get point from X and Y coordinates.+ point :: q -> q -> Maybe (Point f c e q r) - -- | Point addition.- add :: Point r c k -> Point r c k -> Point r c k+ -- | Get point from X coordinate.+ pointX :: q -> Maybe (Point f c e q r) - -- | Point doubling.- double :: Point r c k -> Point r c k- double = join add- {-# INLINE double #-}+ -- | Get Y coordinate from X coordinate.+ yX :: Point f c e q r -> q -> Maybe q - -- | 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 #-}+ -- Coordinates - -- | Point is well-defined.- def :: Point r c k -> Bool+ -- | Transform from affine coordinates.+ fromA :: Point f 'Affine e q r -> Point f c e q r - -- | Get curve discriminant.- disc :: Point r c k -> k+ -- | Transform to affine coordinates.+ toA :: Point f c e q r -> Point f 'Affine e q r - -- | Get point from x coordinate.- point :: k -> Maybe (Point r c k)+-- | Curve forms.+data Form = Binary+ | Edwards+ | Montgomery+ | Weierstrass - -- | Get random point.- rnd :: MonadRandom m => m (Point r c k)+-- | Curve coordinates.+data Coordinates = Affine+ | Jacobian+ | Projective --- Elliptic curves are semigroups.-instance Curve r c k => Semigroup (Point r c k) where- (<>) = add+-------------------------------------------------------------------------------+-- Instances+------------------------------------------------------------------------------- --- Elliptic curves are monoids.-instance Curve r c k => Monoid (Point r c k) where+-- Elliptic curve points are monoids.+instance Curve f c e q r => Monoid (Point f c e q r) where+ mempty = id+ {-# INLINABLE mempty #-}++-- Elliptic curve points are semigroups.+instance Curve f c e q r => Semigroup (Point f c e q r) where++ p <> q = if p == q then dbl p else add p q+ {-# INLINABLE (<>) #-}++-- Elliptic curve points are arbitrary.+instance Curve f c e q r => Arbitrary (Point f c e q r) where++ arbitrary = suchThatMap arbitrary pointX+ {-# INLINABLE arbitrary #-}++-- Elliptic curve points are random.+instance Curve f c e q r => Random (Point f c e q r) where++ random g = let (x, g') = random g in case pointX x of+ Just p -> (p, g')+ _ -> random g'+ {-# INLINABLE random #-}++ randomR = panic "not implemented."
src/Curve/Binary.hs view
@@ -1,112 +1,250 @@+{-# OPTIONS -fno-warn-orphans #-}+ module Curve.Binary- ( BCurve(..)- , BPoint- , Point(..)+ ( module Curve+ , module Curve.Binary+ , module Group ) 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(..))+import Curve (Coordinates(..), Curve(..), Form(..))+import Group (Group(..)) ---------------------------------------------------------------------------------- Types+-- Binary form ------------------------------------------------------------------------------- --- | Binary curve representation.-data B+-- | Binary points.+type BPoint = Point 'Binary --- | Binary curve points.-type BPoint = Point B+-- | Binary curves.+class (GaloisField q, GaloisField r, Curve 'Binary c e q r) => BCurve c e q r where+ {-# MINIMAL a_, b_, h_, p_, r_, x_, y_ #-}+ a_ :: BPoint c e q r -> q -- ^ Coefficient @A@.+ b_ :: BPoint c e q r -> q -- ^ Coefficient @B@.+ h_ :: BPoint c e q r -> Integer -- ^ Curve cofactor.+ p_ :: BPoint c e q r -> Integer -- ^ Curve polynomial.+ r_ :: BPoint c e q r -> Integer -- ^ Curve order.+ x_ :: BPoint c e q r -> q -- ^ Coordinate @X@.+ y_ :: BPoint c e q r -> q -- ^ Coordinate @Y@. --- | 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.+-------------------------------------------------------------------------------+-- Affine coordinates+------------------------------------------------------------------------------- --- 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 affine points.+type BAPoint = BPoint 'Affine --- 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 affine curves @y^2 + xy = x^3 + Ax^2 + B@.+class BCurve 'Affine e q r => BACurve e q r where+ {-# MINIMAL gA_ #-}+ gA_ :: BAPoint e q r -- ^ Curve generator. --- 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."+-- Binary affine curves are elliptic curves.+instance BACurve e q r => Curve 'Binary 'Affine e q r where ----------------------------------------------------------------------------------- Operations--------------------------------------------------------------------------------+ data instance Point 'Binary 'Affine e q r = A q q -- ^ Affine point.+ | O -- ^ Infinite point.+ deriving (Eq, Generic, NFData, Read, Show) --- Binary curves are elliptic curves.-instance (GaloisField k, BCurve c k) => Curve B c k where+ char = const 2+ {-# INLINABLE char #-} - data instance Point B c k = A k k -- ^ Affine point.- | O -- ^ Infinite point.- deriving (Eq, Generic, NFData, Read, Show)+ cof = h_+ {-# INLINABLE cof #-} - id = O- {-# INLINE id #-}+ disc _ = b_ (witness :: BAPoint e q r)+ {-# INLINABLE disc #-} - inv O = O- inv (A x y) = A x (x + y)- {-# INLINE inv #-}+ fromA = identity+ {-# INLINABLE fromA #-} - 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+ point x y = let p = A x y in if def p then Just p else Nothing+ {-# INLINABLE point #-}++ pointX x = A x <$> yX (witness :: BAPoint e q r) x+ {-# INLINABLE pointX #-}++ toA = identity+ {-# INLINABLE toA #-}++ yX _ x = quad 1 x ((x + a) * x * x + b) where+ a = a_ (witness :: BAPoint e q r)+ b = b_ (witness :: BAPoint e q r)+ {-# INLINABLE yX #-}++-- Binary affine points are groups.+instance BACurve e q r => Group (BAPoint e q r) where++ add p O = p+ add O q = q+ add (A x1 y1) (A x2 y2)+ | xx == 0 = O+ | otherwise = A x3 y3+ where+ a = a_ (witness :: BAPoint e q r) xx = x1 + x2 yy = y1 + y2 l = yy / xx- x3 = l * (l + 1) + xx + a_ (witness :: c)+ x3 = l * (l + 1) + xx + a y3 = l * (x1 + x3) + x3 + y1- {-# INLINE add #-}+ {-# INLINABLE add #-} - double O = O- double (A x y) = A x' y'+ dbl O = O+ dbl (A x y)+ | x == 0 = O+ | otherwise = A x' y' where+ a = a_ (witness :: BAPoint e q r) l = x + y / x l' = l + 1- x' = l * l' + a_ (witness :: c)+ x' = l * l' + a y' = x * x + l' * x'- {-# INLINE double #-}+ {-# INLINABLE dbl #-} 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 #-}+ a = a_ (witness :: BAPoint e q r)+ b = b_ (witness :: BAPoint e q r)+ {-# INLINABLE def #-} - disc _ = b_ (witness :: c)- {-# INLINE disc #-}+ gen = gA_+ {-# INLINABLE gen #-} - point 0 = A 0 <$> sr (b_ (witness :: c))- point x = A x <$> quad 1 x ((x + a) * x * x + b)+ id = O+ {-# INLINABLE id #-}++ inv O = O+ inv (A x y) = A x (x + y)+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Binary affine points are pretty.+instance BACurve e q r => Pretty (BAPoint e q r) where++ pretty (A x y) = pretty (x, y)+ pretty O = "O"++-------------------------------------------------------------------------------+-- Projective coordinates+-------------------------------------------------------------------------------++-- | Binary projective points.+type BPPoint = BPoint 'Projective++-- | Binary projective curves @y^2z + xyz = x^3 + Ax^2z + Bz@.+class BCurve 'Projective e q r => BPCurve e q r where+ {-# MINIMAL gP_ #-}+ gP_ :: BPPoint e q r -- ^ Curve generator.++-- Binary projective curves are elliptic curves.+instance BPCurve e q r => Curve 'Binary 'Projective e q r where++ data instance Point 'Binary 'Projective e q r = P q q q -- ^ Projective point.+ deriving (Generic, NFData, Read, Show)++ char = const 2+ {-# INLINABLE char #-}++ cof = h_+ {-# INLINABLE cof #-}++ disc _ = b_ (witness :: BPPoint e q r)+ {-# INLINABLE disc #-}++ fromA (A x y) = P x y 1+ fromA _ = P 0 1 0+ {-# INLINABLE fromA #-}++ point x y = let p = P x y 1 in if def p then Just p else Nothing+ {-# INLINABLE point #-}++ pointX x = flip (P x) 1 <$> yX (witness :: BPPoint e q r) x+ {-# INLINABLE pointX #-}++ toA (P _ _ 0) = O+ toA (P x y z) = A (x / z) (y / z)+ {-# INLINABLE toA #-}++ yX _ x = quad 1 x ((x + a) * x * x + b) where- a = a_ (witness :: c)- b = b_ (witness :: c)- {-# INLINE point #-}+ a = a_ (witness :: BPPoint e q r)+ b = b_ (witness :: BPPoint e q r)+ {-# INLINABLE yX #-} - rnd = getRandom- {-# INLINE rnd #-}+-- Binary projective points are groups.+instance BPCurve e q r => Group (BPPoint e q r) where++ -- Addition formula add-2008-bl+ add p (P _ _ 0) = p+ add (P _ _ 0) q = q+ add (P x1 y1 z1) (P x2 y2 z2) = P x3 y3 z3+ where+ a' = a_ (witness :: BPPoint e q r)+ y1z2 = y1 * z2+ x1z2 = x1 * z2+ a = y1z2 + z1 * y2+ b = x1z2 + z1 * x2+ ab = a + b+ c = b * b+ d = z1 * z2+ e = b * c+ f = (a * ab + a' * c) * d + e+ x3 = b * f+ y3 = c * (a * x1z2 + b * y1z2) + ab * f+ z3 = e * d+ {-# INLINABLE add #-}++ -- Doubling formula dbl-2008-bl+ dbl (P _ _ 0) = P 0 1 0+ dbl (P x1 y1 z1) = P x3 y3 z3+ where+ a' = a_ (witness :: BPPoint e q r)+ a = x1 * x1+ b = a + y1 * z1+ c = x1 * z1+ bc = b + c+ d = c * c+ e = b * bc + a' * d+ x3 = c * e+ y3 = bc * e + a * a * c+ z3 = c * d+ {-# INLINABLE dbl #-}++ def (P x y z) = ((x + a * z) * x + yz) * x + y * yz + b * z * z * z == 0+ where+ a = a_ (witness :: BPPoint e q r)+ b = b_ (witness :: BPPoint e q r)+ yz = y * z+ {-# INLINABLE def #-}++ gen = gP_+ {-# INLINABLE gen #-}++ id = P 0 1 0+ {-# INLINABLE id #-}++ inv (P x y z) = P x (x + y) z+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Binary projective points are equatable.+instance BPCurve e q r => Eq (BPPoint e q r) where++ P x1 y1 z1 == P x2 y2 z2 = z1 == 0 && z2 == 0+ || x1 * z2 == x2 * z1 && y1 * z2 == y2 * z1++-- Binary projective points are pretty.+instance BPCurve e q r => Pretty (BPPoint e q r) where++ pretty (P x y z) = pretty (x, y, z)
src/Curve/Binary/SECT113R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT113R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT113R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT113R1 curve+-- | SECT113R1 curve. data SECT113R1 --- | Field of SECT113R1 curve+-- | Field of points of SECT113R1 curve. type F2m = BinaryField 0x20000000000000000000000000201 --- | SECT113R1 curve is a binary curve-instance BCurve SECT113R1 F2m where+-- | Field of coefficients of SECT113R1 curve.+type Fr = PrimeField 0x100000000000000d9ccec8a39e56f++-- | SECT113R1 curve is a binary curve.+instance Curve 'Binary c SECT113R1 F2m Fr => BCurve c SECT113R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT113R1 curve-type P = BPoint SECT113R1 F2m+-- | Affine SECT113R1 curve point.+type PA = BAPoint SECT113R1 F2m Fr +-- | Affine SECT113R1 curve is a binary affine curve.+instance BACurve SECT113R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT113R1 point.+type PP = BPPoint SECT113R1 F2m Fr++-- | Projective SECT113R1 curve is a binary projective curve.+instance BPCurve SECT113R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT113R1 curve+-- | Coefficient @A@ of SECT113R1 curve. _a :: F2m _a = 0x3088250ca6e7c7fe649ce85820f7-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT113R1 curve+-- | Coefficient @B@ of SECT113R1 curve. _b :: F2m _b = 0xe8bee4d3e2260744188be0e9c723-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT113R1 curve-_f :: Integer-_f = 0x20000000000000000000000000201-{-# INLINE _f #-}+-- | Cofactor of SECT113R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT113R1 curve-_g :: P-_g = A- 0x9d73616f35f4ab1407d73562c10f- 0xa52830277958ee84d1315ed31886-{-# INLINE _g #-}+-- | Polynomial of SECT113R1 curve.+_p :: Integer+_p = 0x20000000000000000000000000201+{-# INLINABLE _p #-} --- | Cofactor of SECT113R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT113R1 curve.+_r :: Integer+_r = 0x100000000000000d9ccec8a39e56f+{-# INLINABLE _r #-} --- | Order of SECT113R1 curve-_n :: Integer-_n = 0x100000000000000d9ccec8a39e56f-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT113R1 curve.+_x :: F2m+_x = 0x9d73616f35f4ab1407d73562c10f+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT113R1 curve.+_y :: F2m+_y = 0xa52830277958ee84d1315ed31886+{-# INLINABLE _y #-}++-- | Generator of affine SECT113R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT113R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT113R2.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT113R2- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT113R2 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT113R2 curve+-- | SECT113R2 curve. data SECT113R2 --- | Field of SECT113R2 curve+-- | Field of points of SECT113R2 curve. type F2m = BinaryField 0x20000000000000000000000000201 --- | SECT113R2 curve is a binary curve-instance BCurve SECT113R2 F2m where+-- | Field of coefficients of SECT113R2 curve.+type Fr = PrimeField 0x10000000000000108789b2496af93++-- | SECT113R2 curve is a binary curve.+instance Curve 'Binary c SECT113R2 F2m Fr => BCurve c SECT113R2 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT113R2 curve-type P = BPoint SECT113R2 F2m+-- | Affine SECT113R2 curve point.+type PA = BAPoint SECT113R2 F2m Fr +-- | Affine SECT113R2 curve is a binary affine curve.+instance BACurve SECT113R2 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT113R2 point.+type PP = BPPoint SECT113R2 F2m Fr++-- | Projective SECT113R2 curve is a binary projective curve.+instance BPCurve SECT113R2 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT113R2 curve+-- | Coefficient @A@ of SECT113R2 curve. _a :: F2m _a = 0x689918dbec7e5a0dd6dfc0aa55c7-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT113R2 curve+-- | Coefficient @B@ of SECT113R2 curve. _b :: F2m _b = 0x95e9a9ec9b297bd4bf36e059184f-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT113R2 curve-_f :: Integer-_f = 0x20000000000000000000000000201-{-# INLINE _f #-}+-- | Cofactor of SECT113R2 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT113R2 curve-_g :: P-_g = A- 0x1a57a6a7b26ca5ef52fcdb8164797- 0xb3adc94ed1fe674c06e695baba1d-{-# INLINE _g #-}+-- | Polynomial of SECT113R2 curve.+_p :: Integer+_p = 0x20000000000000000000000000201+{-# INLINABLE _p #-} --- | Cofactor of SECT113R2 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT113R2 curve.+_r :: Integer+_r = 0x10000000000000108789b2496af93+{-# INLINABLE _r #-} --- | Order of SECT113R2 curve-_n :: Integer-_n = 0x10000000000000108789b2496af93-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT113R2 curve.+_x :: F2m+_x = 0x1a57a6a7b26ca5ef52fcdb8164797+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT113R2 curve.+_y :: F2m+_y = 0xb3adc94ed1fe674c06e695baba1d+{-# INLINABLE _y #-}++-- | Generator of affine SECT113R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT113R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT131R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT131R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT131R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT131R1 curve+-- | SECT131R1 curve. data SECT131R1 --- | Field of SECT131R1 curve+-- | Field of points of SECT131R1 curve. type F2m = BinaryField 0x80000000000000000000000000000010d --- | SECT131R1 curve is a binary curve-instance BCurve SECT131R1 F2m where+-- | Field of coefficients of SECT131R1 curve.+type Fr = PrimeField 0x400000000000000023123953a9464b54d++-- | SECT131R1 curve is a binary curve.+instance Curve 'Binary c SECT131R1 F2m Fr => BCurve c SECT131R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT131R1 curve-type P = BPoint SECT131R1 F2m+-- | Affine SECT131R1 curve point.+type PA = BAPoint SECT131R1 F2m Fr +-- | Affine SECT131R1 curve is a binary affine curve.+instance BACurve SECT131R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT131R1 point.+type PP = BPPoint SECT131R1 F2m Fr++-- | Projective SECT131R1 curve is a binary projective curve.+instance BPCurve SECT131R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT131R1 curve+-- | Coefficient @A@ of SECT131R1 curve. _a :: F2m _a = 0x7a11b09a76b562144418ff3ff8c2570b8-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT131R1 curve+-- | Coefficient @B@ of SECT131R1 curve. _b :: F2m _b = 0x217c05610884b63b9c6c7291678f9d341-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT131R1 curve-_f :: Integer-_f = 0x80000000000000000000000000000010d-{-# INLINE _f #-}+-- | Cofactor of SECT131R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT131R1 curve-_g :: P-_g = A- 0x81baf91fdf9833c40f9c181343638399- 0x78c6e7ea38c001f73c8134b1b4ef9e150-{-# INLINE _g #-}+-- | Polynomial of SECT131R1 curve.+_p :: Integer+_p = 0x80000000000000000000000000000010d+{-# INLINABLE _p #-} --- | Cofactor of SECT131R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT131R1 curve.+_r :: Integer+_r = 0x400000000000000023123953a9464b54d+{-# INLINABLE _r #-} --- | Order of SECT131R1 curve-_n :: Integer-_n = 0x400000000000000023123953a9464b54d-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT131R1 curve.+_x :: F2m+_x = 0x81baf91fdf9833c40f9c181343638399+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT131R1 curve.+_y :: F2m+_y = 0x78c6e7ea38c001f73c8134b1b4ef9e150+{-# INLINABLE _y #-}++-- | Generator of affine SECT131R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT131R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT131R2.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT131R2- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT131R2 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT131R2 curve+-- | SECT131R2 curve. data SECT131R2 --- | Field of SECT131R2 curve+-- | Field of points of SECT131R2 curve. type F2m = BinaryField 0x80000000000000000000000000000010d --- | SECT131R2 curve is a binary curve-instance BCurve SECT131R2 F2m where+-- | Field of coefficients of SECT131R2 curve.+type Fr = PrimeField 0x400000000000000016954a233049ba98f++-- | SECT131R2 curve is a binary curve.+instance Curve 'Binary c SECT131R2 F2m Fr => BCurve c SECT131R2 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT131R2 curve-type P = BPoint SECT131R2 F2m+-- | Affine SECT131R2 curve point.+type PA = BAPoint SECT131R2 F2m Fr +-- | Affine SECT131R2 curve is a binary affine curve.+instance BACurve SECT131R2 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT131R2 point.+type PP = BPPoint SECT131R2 F2m Fr++-- | Projective SECT131R2 curve is a binary projective curve.+instance BPCurve SECT131R2 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT131R2 curve+-- | Coefficient @A@ of SECT131R2 curve. _a :: F2m _a = 0x3e5a88919d7cafcbf415f07c2176573b2-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT131R2 curve+-- | Coefficient @B@ of SECT131R2 curve. _b :: F2m _b = 0x4b8266a46c55657ac734ce38f018f2192-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT131R2 curve-_f :: Integer-_f = 0x80000000000000000000000000000010d-{-# INLINE _f #-}+-- | Cofactor of SECT131R2 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT131R2 curve-_g :: P-_g = A- 0x356dcd8f2f95031ad652d23951bb366a8- 0x648f06d867940a5366d9e265de9eb240f-{-# INLINE _g #-}+-- | Polynomial of SECT131R2 curve.+_p :: Integer+_p = 0x80000000000000000000000000000010d+{-# INLINABLE _p #-} --- | Cofactor of SECT131R2 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT131R2 curve.+_r :: Integer+_r = 0x400000000000000016954a233049ba98f+{-# INLINABLE _r #-} --- | Order of SECT131R2 curve-_n :: Integer-_n = 0x400000000000000016954a233049ba98f-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT131R2 curve.+_x :: F2m+_x = 0x356dcd8f2f95031ad652d23951bb366a8+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT131R2 curve.+_y :: F2m+_y = 0x648f06d867940a5366d9e265de9eb240f+{-# INLINABLE _y #-}++-- | Generator of affine SECT131R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT131R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT163K1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT163K1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT163K1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT163K1 curve+-- | SECT163K1 curve. data SECT163K1 --- | Field of SECT163K1 curve+-- | Field of points of SECT163K1 curve. type F2m = BinaryField 0x800000000000000000000000000000000000000c9 --- | SECT163K1 curve is a binary curve-instance BCurve SECT163K1 F2m where+-- | Field of coefficients of SECT163K1 curve.+type Fr = PrimeField 0x4000000000000000000020108a2e0cc0d99f8a5ef++-- | SECT163K1 curve is a binary curve.+instance Curve 'Binary c SECT163K1 F2m Fr => BCurve c SECT163K1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT163K1 curve-type P = BPoint SECT163K1 F2m+-- | Affine SECT163K1 curve point.+type PA = BAPoint SECT163K1 F2m Fr +-- | Affine SECT163K1 curve is a binary affine curve.+instance BACurve SECT163K1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT163K1 point.+type PP = BPPoint SECT163K1 F2m Fr++-- | Projective SECT163K1 curve is a binary projective curve.+instance BPCurve SECT163K1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT163K1 curve+-- | Coefficient @A@ of SECT163K1 curve. _a :: F2m-_a = 1-{-# INLINE _a #-}+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT163K1 curve+-- | Coefficient @B@ of SECT163K1 curve. _b :: F2m-_b = 1-{-# INLINE _b #-}+_b = 0x1+{-# INLINABLE _b #-} --- | Polynomial of SECT163K1 curve-_f :: Integer-_f = 0x800000000000000000000000000000000000000c9-{-# INLINE _f #-}+-- | Cofactor of SECT163K1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT163K1 curve-_g :: P-_g = A- 0x2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8- 0x289070fb05d38ff58321f2e800536d538ccdaa3d9-{-# INLINE _g #-}+-- | Polynomial of SECT163K1 curve.+_p :: Integer+_p = 0x800000000000000000000000000000000000000c9+{-# INLINABLE _p #-} --- | Cofactor of SECT163K1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT163K1 curve.+_r :: Integer+_r = 0x4000000000000000000020108a2e0cc0d99f8a5ef+{-# INLINABLE _r #-} --- | Order of SECT163K1 curve-_n :: Integer-_n = 0x4000000000000000000020108a2e0cc0d99f8a5ef-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT163K1 curve.+_x :: F2m+_x = 0x2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT163K1 curve.+_y :: F2m+_y = 0x289070fb05d38ff58321f2e800536d538ccdaa3d9+{-# INLINABLE _y #-}++-- | Generator of affine SECT163K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT163K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT163R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT163R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT163R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT163R1 curve+-- | SECT163R1 curve. data SECT163R1 --- | Field of SECT163R1 curve+-- | Field of points of SECT163R1 curve. type F2m = BinaryField 0x800000000000000000000000000000000000000c9 --- | SECT163R1 curve is a binary curve-instance BCurve SECT163R1 F2m where+-- | Field of coefficients of SECT163R1 curve.+type Fr = PrimeField 0x3ffffffffffffffffffff48aab689c29ca710279b++-- | SECT163R1 curve is a binary curve.+instance Curve 'Binary c SECT163R1 F2m Fr => BCurve c SECT163R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT163R1 curve-type P = BPoint SECT163R1 F2m+-- | Affine SECT163R1 curve point.+type PA = BAPoint SECT163R1 F2m Fr +-- | Affine SECT163R1 curve is a binary affine curve.+instance BACurve SECT163R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT163R1 point.+type PP = BPPoint SECT163R1 F2m Fr++-- | Projective SECT163R1 curve is a binary projective curve.+instance BPCurve SECT163R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT163R1 curve+-- | Coefficient @A@ of SECT163R1 curve. _a :: F2m _a = 0x7b6882caaefa84f9554ff8428bd88e246d2782ae2-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT163R1 curve+-- | Coefficient @B@ of SECT163R1 curve. _b :: F2m _b = 0x713612dcddcb40aab946bda29ca91f73af958afd9-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT163R1 curve-_f :: Integer-_f = 0x800000000000000000000000000000000000000c9-{-# INLINE _f #-}+-- | Cofactor of SECT163R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT163R1 curve-_g :: P-_g = A- 0x369979697ab43897789566789567f787a7876a654- 0x435edb42efafb2989d51fefce3c80988f41ff883-{-# INLINE _g #-}+-- | Polynomial of SECT163R1 curve.+_p :: Integer+_p = 0x800000000000000000000000000000000000000c9+{-# INLINABLE _p #-} --- | Cofactor of SECT163R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT163R1 curve.+_r :: Integer+_r = 0x3ffffffffffffffffffff48aab689c29ca710279b+{-# INLINABLE _r #-} --- | Order of SECT163R1 curve-_n :: Integer-_n = 0x3ffffffffffffffffffff48aab689c29ca710279b-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT163R1 curve.+_x :: F2m+_x = 0x369979697ab43897789566789567f787a7876a654+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT163R1 curve.+_y :: F2m+_y = 0x435edb42efafb2989d51fefce3c80988f41ff883+{-# INLINABLE _y #-}++-- | Generator of affine SECT163R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT163R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT163R2.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT163R2- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT163R2 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT163R2 curve+-- | SECT163R2 curve. data SECT163R2 --- | Field of SECT163R2 curve+-- | Field of points of SECT163R2 curve. type F2m = BinaryField 0x800000000000000000000000000000000000000c9 --- | SECT163R2 curve is a binary curve-instance BCurve SECT163R2 F2m where+-- | Field of coefficients of SECT163R2 curve.+type Fr = PrimeField 0x40000000000000000000292fe77e70c12a4234c33++-- | SECT163R2 curve is a binary curve.+instance Curve 'Binary c SECT163R2 F2m Fr => BCurve c SECT163R2 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT163R2 curve-type P = BPoint SECT163R2 F2m+-- | Affine SECT163R2 curve point.+type PA = BAPoint SECT163R2 F2m Fr +-- | Affine SECT163R2 curve is a binary affine curve.+instance BACurve SECT163R2 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT163R2 point.+type PP = BPPoint SECT163R2 F2m Fr++-- | Projective SECT163R2 curve is a binary projective curve.+instance BPCurve SECT163R2 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT163R2 curve+-- | Coefficient @A@ of SECT163R2 curve. _a :: F2m-_a = 1-{-# INLINE _a #-}+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT163R2 curve+-- | Coefficient @B@ of SECT163R2 curve. _b :: F2m _b = 0x20a601907b8c953ca1481eb10512f78744a3205fd-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT163R2 curve-_f :: Integer-_f = 0x800000000000000000000000000000000000000c9-{-# INLINE _f #-}+-- | Cofactor of SECT163R2 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT163R2 curve-_g :: P-_g = A- 0x3f0eba16286a2d57ea0991168d4994637e8343e36- 0xd51fbc6c71a0094fa2cdd545b11c5c0c797324f1-{-# INLINE _g #-}+-- | Polynomial of SECT163R2 curve.+_p :: Integer+_p = 0x800000000000000000000000000000000000000c9+{-# INLINABLE _p #-} --- | Cofactor of SECT163R2 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT163R2 curve.+_r :: Integer+_r = 0x40000000000000000000292fe77e70c12a4234c33+{-# INLINABLE _r #-} --- | Order of SECT163R2 curve-_n :: Integer-_n = 0x40000000000000000000292fe77e70c12a4234c33-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT163R2 curve.+_x :: F2m+_x = 0x3f0eba16286a2d57ea0991168d4994637e8343e36+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT163R2 curve.+_y :: F2m+_y = 0xd51fbc6c71a0094fa2cdd545b11c5c0c797324f1+{-# INLINABLE _y #-}++-- | Generator of affine SECT163R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT163R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT193R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT193R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT193R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT193R1 curve+-- | SECT193R1 curve. data SECT193R1 --- | Field of SECT193R1 curve+-- | Field of points of SECT193R1 curve. type F2m = BinaryField 0x2000000000000000000000000000000000000000000008001 --- | SECT193R1 curve is a binary curve-instance BCurve SECT193R1 F2m where+-- | Field of coefficients of SECT193R1 curve.+type Fr = PrimeField 0x1000000000000000000000000c7f34a778f443acc920eba49++-- | SECT193R1 curve is a binary curve.+instance Curve 'Binary c SECT193R1 F2m Fr => BCurve c SECT193R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT193R1 curve-type P = BPoint SECT193R1 F2m+-- | Affine SECT193R1 curve point.+type PA = BAPoint SECT193R1 F2m Fr +-- | Affine SECT193R1 curve is a binary affine curve.+instance BACurve SECT193R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT193R1 point.+type PP = BPPoint SECT193R1 F2m Fr++-- | Projective SECT193R1 curve is a binary projective curve.+instance BPCurve SECT193R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT193R1 curve+-- | Coefficient @A@ of SECT193R1 curve. _a :: F2m _a = 0x17858feb7a98975169e171f77b4087de098ac8a911df7b01-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT193R1 curve+-- | Coefficient @B@ of SECT193R1 curve. _b :: F2m _b = 0xfdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT193R1 curve-_f :: Integer-_f = 0x2000000000000000000000000000000000000000000008001-{-# INLINE _f #-}+-- | Cofactor of SECT193R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT193R1 curve-_g :: P-_g = A- 0x1f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1- 0x25e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05-{-# INLINE _g #-}+-- | Polynomial of SECT193R1 curve.+_p :: Integer+_p = 0x2000000000000000000000000000000000000000000008001+{-# INLINABLE _p #-} --- | Cofactor of SECT193R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT193R1 curve.+_r :: Integer+_r = 0x1000000000000000000000000c7f34a778f443acc920eba49+{-# INLINABLE _r #-} --- | Order of SECT193R1 curve-_n :: Integer-_n = 0x1000000000000000000000000c7f34a778f443acc920eba49-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT193R1 curve.+_x :: F2m+_x = 0x1f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT193R1 curve.+_y :: F2m+_y = 0x25e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05+{-# INLINABLE _y #-}++-- | Generator of affine SECT193R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT193R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT193R2.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT193R2- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT193R2 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT193R2 curve+-- | SECT193R2 curve. data SECT193R2 --- | Field of SECT193R2 curve+-- | Field of points of SECT193R2 curve. type F2m = BinaryField 0x2000000000000000000000000000000000000000000008001 --- | SECT193R2 curve is a binary curve-instance BCurve SECT193R2 F2m where+-- | Field of coefficients of SECT193R2 curve.+type Fr = PrimeField 0x10000000000000000000000015aab561b005413ccd4ee99d5++-- | SECT193R2 curve is a binary curve.+instance Curve 'Binary c SECT193R2 F2m Fr => BCurve c SECT193R2 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT193R2 curve-type P = BPoint SECT193R2 F2m+-- | Affine SECT193R2 curve point.+type PA = BAPoint SECT193R2 F2m Fr +-- | Affine SECT193R2 curve is a binary affine curve.+instance BACurve SECT193R2 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT193R2 point.+type PP = BPPoint SECT193R2 F2m Fr++-- | Projective SECT193R2 curve is a binary projective curve.+instance BPCurve SECT193R2 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT193R2 curve+-- | Coefficient @A@ of SECT193R2 curve. _a :: F2m _a = 0x163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT193R2 curve+-- | Coefficient @B@ of SECT193R2 curve. _b :: F2m _b = 0xc9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT193R2 curve-_f :: Integer-_f = 0x2000000000000000000000000000000000000000000008001-{-# INLINE _f #-}+-- | Cofactor of SECT193R2 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT193R2 curve-_g :: P-_g = A- 0xd9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f- 0x1ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c-{-# INLINE _g #-}+-- | Polynomial of SECT193R2 curve.+_p :: Integer+_p = 0x2000000000000000000000000000000000000000000008001+{-# INLINABLE _p #-} --- | Cofactor of SECT193R2 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT193R2 curve.+_r :: Integer+_r = 0x10000000000000000000000015aab561b005413ccd4ee99d5+{-# INLINABLE _r #-} --- | Order of SECT193R2 curve-_n :: Integer-_n = 0x10000000000000000000000015aab561b005413ccd4ee99d5-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT193R2 curve.+_x :: F2m+_x = 0xd9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT193R2 curve.+_y :: F2m+_y = 0x1ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c+{-# INLINABLE _y #-}++-- | Generator of affine SECT193R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT193R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT233K1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT233K1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT233K1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT233K1 curve+-- | SECT233K1 curve. data SECT233K1 --- | Field of SECT233K1 curve+-- | Field of points of SECT233K1 curve. type F2m = BinaryField 0x20000000000000000000000000000000000000004000000000000000001 --- | SECT233K1 curve is a binary curve-instance BCurve SECT233K1 F2m where+-- | Field of coefficients of SECT233K1 curve.+type Fr = PrimeField 0x8000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf++-- | SECT233K1 curve is a binary curve.+instance Curve 'Binary c SECT233K1 F2m Fr => BCurve c SECT233K1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT233K1 curve-type P = BPoint SECT233K1 F2m+-- | Affine SECT233K1 curve point.+type PA = BAPoint SECT233K1 F2m Fr +-- | Affine SECT233K1 curve is a binary affine curve.+instance BACurve SECT233K1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT233K1 point.+type PP = BPPoint SECT233K1 F2m Fr++-- | Projective SECT233K1 curve is a binary projective curve.+instance BPCurve SECT233K1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT233K1 curve+-- | Coefficient @A@ of SECT233K1 curve. _a :: F2m-_a = 0-{-# INLINE _a #-}+_a = 0x0+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT233K1 curve+-- | Coefficient @B@ of SECT233K1 curve. _b :: F2m-_b = 1-{-# INLINE _b #-}+_b = 0x1+{-# INLINABLE _b #-} --- | Polynomial of SECT233K1 curve-_f :: Integer-_f = 0x20000000000000000000000000000000000000004000000000000000001-{-# INLINE _f #-}+-- | Cofactor of SECT233K1 curve.+_h :: Integer+_h = 0x4+{-# INLINABLE _h #-} --- | Generator of SECT233K1 curve-_g :: P-_g = A- 0x17232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126- 0x1db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3-{-# INLINE _g #-}+-- | Polynomial of SECT233K1 curve.+_p :: Integer+_p = 0x20000000000000000000000000000000000000004000000000000000001+{-# INLINABLE _p #-} --- | Cofactor of SECT233K1 curve-_h :: Integer-_h = 4-{-# INLINE _h #-}+-- | Order of SECT233K1 curve.+_r :: Integer+_r = 0x8000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf+{-# INLINABLE _r #-} --- | Order of SECT233K1 curve-_n :: Integer-_n = 0x8000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT233K1 curve.+_x :: F2m+_x = 0x17232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT233K1 curve.+_y :: F2m+_y = 0x1db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3+{-# INLINABLE _y #-}++-- | Generator of affine SECT233K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT233K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT233R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT233R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT233R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT233R1 curve+-- | SECT233R1 curve. data SECT233R1 --- | Field of SECT233R1 curve+-- | Field of points of SECT233R1 curve. type F2m = BinaryField 0x20000000000000000000000000000000000000004000000000000000001 --- | SECT233R1 curve is a binary curve-instance BCurve SECT233R1 F2m where+-- | Field of coefficients of SECT233R1 curve.+type Fr = PrimeField 0x1000000000000000000000000000013e974e72f8a6922031d2603cfe0d7++-- | SECT233R1 curve is a binary curve.+instance Curve 'Binary c SECT233R1 F2m Fr => BCurve c SECT233R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT233R1 curve-type P = BPoint SECT233R1 F2m+-- | Affine SECT233R1 curve point.+type PA = BAPoint SECT233R1 F2m Fr +-- | Affine SECT233R1 curve is a binary affine curve.+instance BACurve SECT233R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT233R1 point.+type PP = BPPoint SECT233R1 F2m Fr++-- | Projective SECT233R1 curve is a binary projective curve.+instance BPCurve SECT233R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT233R1 curve+-- | Coefficient @A@ of SECT233R1 curve. _a :: F2m-_a = 1-{-# INLINE _a #-}+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT233R1 curve+-- | Coefficient @B@ of SECT233R1 curve. _b :: F2m _b = 0x66647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT233R1 curve-_f :: Integer-_f = 0x20000000000000000000000000000000000000004000000000000000001-{-# INLINE _f #-}+-- | Cofactor of SECT233R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT233R1 curve-_g :: P-_g = A- 0xfac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b- 0x1006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052-{-# INLINE _g #-}+-- | Polynomial of SECT233R1 curve.+_p :: Integer+_p = 0x20000000000000000000000000000000000000004000000000000000001+{-# INLINABLE _p #-} --- | Cofactor of SECT233R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT233R1 curve.+_r :: Integer+_r = 0x1000000000000000000000000000013e974e72f8a6922031d2603cfe0d7+{-# INLINABLE _r #-} --- | Order of SECT233R1 curve-_n :: Integer-_n = 0x1000000000000000000000000000013e974e72f8a6922031d2603cfe0d7-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT233R1 curve.+_x :: F2m+_x = 0xfac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT233R1 curve.+_y :: F2m+_y = 0x1006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052+{-# INLINABLE _y #-}++-- | Generator of affine SECT233R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT233R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT239K1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT239K1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT239K1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT239K1 curve+-- | SECT239K1 curve. data SECT239K1 --- | Field of SECT239K1 curve+-- | Field of points of SECT239K1 curve. type F2m = BinaryField 0x800000000000000000004000000000000000000000000000000000000001 --- | SECT239K1 curve is a binary curve-instance BCurve SECT239K1 F2m where+-- | Field of coefficients of SECT239K1 curve.+type Fr = PrimeField 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5++-- | SECT239K1 curve is a binary curve.+instance Curve 'Binary c SECT239K1 F2m Fr => BCurve c SECT239K1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT239K1 curve-type P = BPoint SECT239K1 F2m+-- | Affine SECT239K1 curve point.+type PA = BAPoint SECT239K1 F2m Fr +-- | Affine SECT239K1 curve is a binary affine curve.+instance BACurve SECT239K1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT239K1 point.+type PP = BPPoint SECT239K1 F2m Fr++-- | Projective SECT239K1 curve is a binary projective curve.+instance BPCurve SECT239K1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT239K1 curve+-- | Coefficient @A@ of SECT239K1 curve. _a :: F2m-_a = 0-{-# INLINE _a #-}+_a = 0x0+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT239K1 curve+-- | Coefficient @B@ of SECT239K1 curve. _b :: F2m-_b = 1-{-# INLINE _b #-}+_b = 0x1+{-# INLINABLE _b #-} --- | Polynomial of SECT239K1 curve-_f :: Integer-_f = 0x800000000000000000004000000000000000000000000000000000000001-{-# INLINE _f #-}+-- | Cofactor of SECT239K1 curve.+_h :: Integer+_h = 0x4+{-# INLINABLE _h #-} --- | Generator of SECT239K1 curve-_g :: P-_g = A- 0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc- 0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca-{-# INLINE _g #-}+-- | Polynomial of SECT239K1 curve.+_p :: Integer+_p = 0x800000000000000000004000000000000000000000000000000000000001+{-# INLINABLE _p #-} --- | Cofactor of SECT239K1 curve-_h :: Integer-_h = 4-{-# INLINE _h #-}+-- | Order of SECT239K1 curve.+_r :: Integer+_r = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5+{-# INLINABLE _r #-} --- | Order of SECT239K1 curve-_n :: Integer-_n = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT239K1 curve.+_x :: F2m+_x = 0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT239K1 curve.+_y :: F2m+_y = 0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca+{-# INLINABLE _y #-}++-- | Generator of affine SECT239K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT239K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT283K1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT283K1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT283K1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT283K1 curve+-- | SECT283K1 curve. data SECT283K1 --- | Field of SECT283K1 curve+-- | Field of points of SECT283K1 curve. type F2m = BinaryField 0x800000000000000000000000000000000000000000000000000000000000000000010a1 --- | SECT283K1 curve is a binary curve-instance BCurve SECT283K1 F2m where+-- | Field of coefficients of SECT283K1 curve.+type Fr = PrimeField 0x1ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61++-- | SECT283K1 curve is a binary curve.+instance Curve 'Binary c SECT283K1 F2m Fr => BCurve c SECT283K1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT283K1 curve-type P = BPoint SECT283K1 F2m+-- | Affine SECT283K1 curve point.+type PA = BAPoint SECT283K1 F2m Fr +-- | Affine SECT283K1 curve is a binary affine curve.+instance BACurve SECT283K1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT283K1 point.+type PP = BPPoint SECT283K1 F2m Fr++-- | Projective SECT283K1 curve is a binary projective curve.+instance BPCurve SECT283K1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT283K1 curve+-- | Coefficient @A@ of SECT283K1 curve. _a :: F2m-_a = 0-{-# INLINE _a #-}+_a = 0x0+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT283K1 curve+-- | Coefficient @B@ of SECT283K1 curve. _b :: F2m-_b = 1-{-# INLINE _b #-}+_b = 0x1+{-# INLINABLE _b #-} --- | Polynomial of SECT283K1 curve-_f :: Integer-_f = 0x800000000000000000000000000000000000000000000000000000000000000000010a1-{-# INLINE _f #-}+-- | Cofactor of SECT283K1 curve.+_h :: Integer+_h = 0x4+{-# INLINABLE _h #-} --- | Generator of SECT283K1 curve-_g :: P-_g = A- 0x503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836- 0x1ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259-{-# INLINE _g #-}+-- | Polynomial of SECT283K1 curve.+_p :: Integer+_p = 0x800000000000000000000000000000000000000000000000000000000000000000010a1+{-# INLINABLE _p #-} --- | Cofactor of SECT283K1 curve-_h :: Integer-_h = 4-{-# INLINE _h #-}+-- | Order of SECT283K1 curve.+_r :: Integer+_r = 0x1ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61+{-# INLINABLE _r #-} --- | Order of SECT283K1 curve-_n :: Integer-_n = 0x1ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT283K1 curve.+_x :: F2m+_x = 0x503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT283K1 curve.+_y :: F2m+_y = 0x1ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259+{-# INLINABLE _y #-}++-- | Generator of affine SECT283K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT283K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT283R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT283R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT283R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT283R1 curve+-- | SECT283R1 curve. data SECT283R1 --- | Field of SECT283R1 curve+-- | Field of points of SECT283R1 curve. type F2m = BinaryField 0x800000000000000000000000000000000000000000000000000000000000000000010a1 --- | SECT283R1 curve is a binary curve-instance BCurve SECT283R1 F2m where+-- | Field of coefficients of SECT283R1 curve.+type Fr = PrimeField 0x3ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307++-- | SECT283R1 curve is a binary curve.+instance Curve 'Binary c SECT283R1 F2m Fr => BCurve c SECT283R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT283R1 curve-type P = BPoint SECT283R1 F2m+-- | Affine SECT283R1 curve point.+type PA = BAPoint SECT283R1 F2m Fr +-- | Affine SECT283R1 curve is a binary affine curve.+instance BACurve SECT283R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT283R1 point.+type PP = BPPoint SECT283R1 F2m Fr++-- | Projective SECT283R1 curve is a binary projective curve.+instance BPCurve SECT283R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT283R1 curve+-- | Coefficient @A@ of SECT283R1 curve. _a :: F2m-_a = 1-{-# INLINE _a #-}+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT283R1 curve+-- | Coefficient @B@ of SECT283R1 curve. _b :: F2m _b = 0x27b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT283R1 curve-_f :: Integer-_f = 0x800000000000000000000000000000000000000000000000000000000000000000010a1-{-# INLINE _f #-}+-- | Cofactor of SECT283R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT283R1 curve-_g :: P-_g = A- 0x5f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053- 0x3676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4-{-# INLINE _g #-}+-- | Polynomial of SECT283R1 curve.+_p :: Integer+_p = 0x800000000000000000000000000000000000000000000000000000000000000000010a1+{-# INLINABLE _p #-} --- | Cofactor of SECT283R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT283R1 curve.+_r :: Integer+_r = 0x3ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307+{-# INLINABLE _r #-} --- | Order of SECT283R1 curve-_n :: Integer-_n = 0x3ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT283R1 curve.+_x :: F2m+_x = 0x5f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT283R1 curve.+_y :: F2m+_y = 0x3676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4+{-# INLINABLE _y #-}++-- | Generator of affine SECT283R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT283R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT409K1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT409K1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT409K1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT409K1 curve+-- | SECT409K1 curve. data SECT409K1 --- | Field of SECT409K1 curve+-- | Field of points of SECT409K1 curve. type F2m = BinaryField 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001 --- | SECT409K1 curve is a binary curve-instance BCurve SECT409K1 F2m where+-- | Field of coefficients of SECT409K1 curve.+type Fr = PrimeField 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf++-- | SECT409K1 curve is a binary curve.+instance Curve 'Binary c SECT409K1 F2m Fr => BCurve c SECT409K1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT409K1 curve-type P = BPoint SECT409K1 F2m+-- | Affine SECT409K1 curve point.+type PA = BAPoint SECT409K1 F2m Fr +-- | Affine SECT409K1 curve is a binary affine curve.+instance BACurve SECT409K1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT409K1 point.+type PP = BPPoint SECT409K1 F2m Fr++-- | Projective SECT409K1 curve is a binary projective curve.+instance BPCurve SECT409K1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT409K1 curve+-- | Coefficient @A@ of SECT409K1 curve. _a :: F2m-_a = 0-{-# INLINE _a #-}+_a = 0x0+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT409K1 curve+-- | Coefficient @B@ of SECT409K1 curve. _b :: F2m-_b = 1-{-# INLINE _b #-}+_b = 0x1+{-# INLINABLE _b #-} --- | Polynomial of SECT409K1 curve-_f :: Integer-_f = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001-{-# INLINE _f #-}+-- | Cofactor of SECT409K1 curve.+_h :: Integer+_h = 0x4+{-# INLINABLE _h #-} --- | Generator of SECT409K1 curve-_g :: P-_g = A- 0x60f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746- 0x1e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b-{-# INLINE _g #-}+-- | Polynomial of SECT409K1 curve.+_p :: Integer+_p = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+{-# INLINABLE _p #-} --- | Cofactor of SECT409K1 curve-_h :: Integer-_h = 4-{-# INLINE _h #-}+-- | Order of SECT409K1 curve.+_r :: Integer+_r = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf+{-# INLINABLE _r #-} --- | Order of SECT409K1 curve-_n :: Integer-_n = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT409K1 curve.+_x :: F2m+_x = 0x60f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT409K1 curve.+_y :: F2m+_y = 0x1e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b+{-# INLINABLE _y #-}++-- | Generator of affine SECT409K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT409K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT409R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT409R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT409R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT409R1 curve+-- | SECT409R1 curve. data SECT409R1 --- | Field of SECT409R1 curve+-- | Field of points of SECT409R1 curve. type F2m = BinaryField 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001 --- | SECT409R1 curve is a binary curve-instance BCurve SECT409R1 F2m where+-- | Field of coefficients of SECT409R1 curve.+type Fr = PrimeField 0x10000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173++-- | SECT409R1 curve is a binary curve.+instance Curve 'Binary c SECT409R1 F2m Fr => BCurve c SECT409R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT409R1 curve-type P = BPoint SECT409R1 F2m+-- | Affine SECT409R1 curve point.+type PA = BAPoint SECT409R1 F2m Fr +-- | Affine SECT409R1 curve is a binary affine curve.+instance BACurve SECT409R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT409R1 point.+type PP = BPPoint SECT409R1 F2m Fr++-- | Projective SECT409R1 curve is a binary projective curve.+instance BPCurve SECT409R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT409R1 curve+-- | Coefficient @A@ of SECT409R1 curve. _a :: F2m-_a = 1-{-# INLINE _a #-}+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT409R1 curve+-- | Coefficient @B@ of SECT409R1 curve. _b :: F2m _b = 0x21a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT409R1 curve-_f :: Integer-_f = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001-{-# INLINE _f #-}+-- | Cofactor of SECT409R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT409R1 curve-_g :: P-_g = A- 0x15d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7- 0x61b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706-{-# INLINE _g #-}+-- | Polynomial of SECT409R1 curve.+_p :: Integer+_p = 0x2000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001+{-# INLINABLE _p #-} --- | Cofactor of SECT409R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT409R1 curve.+_r :: Integer+_r = 0x10000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173+{-# INLINABLE _r #-} --- | Order of SECT409R1 curve-_n :: Integer-_n = 0x10000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT409R1 curve.+_x :: F2m+_x = 0x15d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT409R1 curve.+_y :: F2m+_y = 0x61b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706+{-# INLINABLE _y #-}++-- | Generator of affine SECT409R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT409R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT571K1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT571K1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT571K1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT571K1 curve+-- | SECT571K1 curve. data SECT571K1 --- | Field of SECT571K1 curve+-- | Field of points of SECT571K1 curve. type F2m = BinaryField 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425 --- | SECT571K1 curve is a binary curve-instance BCurve SECT571K1 F2m where+-- | Field of coefficients of SECT571K1 curve.+type Fr = PrimeField 0x20000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001++-- | SECT571K1 curve is a binary curve.+instance Curve 'Binary c SECT571K1 F2m Fr => BCurve c SECT571K1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT571K1 curve-type P = BPoint SECT571K1 F2m+-- | Affine SECT571K1 curve point.+type PA = BAPoint SECT571K1 F2m Fr +-- | Affine SECT571K1 curve is a binary affine curve.+instance BACurve SECT571K1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT571K1 point.+type PP = BPPoint SECT571K1 F2m Fr++-- | Projective SECT571K1 curve is a binary projective curve.+instance BPCurve SECT571K1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT571K1 curve+-- | Coefficient @A@ of SECT571K1 curve. _a :: F2m-_a = 0-{-# INLINE _a #-}+_a = 0x0+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT571K1 curve+-- | Coefficient @B@ of SECT571K1 curve. _b :: F2m-_b = 1-{-# INLINE _b #-}+_b = 0x1+{-# INLINABLE _b #-} --- | Polynomial of SECT571K1 curve-_f :: Integer-_f = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425-{-# INLINE _f #-}+-- | Cofactor of SECT571K1 curve.+_h :: Integer+_h = 0x4+{-# INLINABLE _h #-} --- | Generator of SECT571K1 curve-_g :: P-_g = A- 0x26eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972- 0x349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3-{-# INLINE _g #-}+-- | Polynomial of SECT571K1 curve.+_p :: Integer+_p = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+{-# INLINABLE _p #-} --- | Cofactor of SECT571K1 curve-_h :: Integer-_h = 4-{-# INLINE _h #-}+-- | Order of SECT571K1 curve.+_r :: Integer+_r = 0x20000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001+{-# INLINABLE _r #-} --- | Order of SECT571K1 curve-_n :: Integer-_n = 0x20000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT571K1 curve.+_x :: F2m+_x = 0x26eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT571K1 curve.+_y :: F2m+_y = 0x349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3+{-# INLINABLE _y #-}++-- | Generator of affine SECT571K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT571K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Binary/SECT571R1.hs view
@@ -1,74 +1,106 @@ module Curve.Binary.SECT571R1- ( F2m- , P- , _a- , _b- , _f- , _g- , _h- , _n+ ( module Curve.Binary+ , module Curve.Binary.SECT571R1 ) where import Protolude -import BinaryField (BinaryField)+import BinaryField+import PrimeField -import Curve.Binary (BCurve(..), BPoint, Point(..))+import Curve.Binary ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECT571R1 curve+-- | SECT571R1 curve. data SECT571R1 --- | Field of SECT571R1 curve+-- | Field of points of SECT571R1 curve. type F2m = BinaryField 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425 --- | SECT571R1 curve is a binary curve-instance BCurve SECT571R1 F2m where+-- | Field of coefficients of SECT571R1 curve.+type Fr = PrimeField 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47++-- | SECT571R1 curve is a binary curve.+instance Curve 'Binary c SECT571R1 F2m Fr => BCurve c SECT571R1 F2m Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ p_ = const _p+ {-# INLINABLE p_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECT571R1 curve-type P = BPoint SECT571R1 F2m+-- | Affine SECT571R1 curve point.+type PA = BAPoint SECT571R1 F2m Fr +-- | Affine SECT571R1 curve is a binary affine curve.+instance BACurve SECT571R1 F2m Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective SECT571R1 point.+type PP = BPPoint SECT571R1 F2m Fr++-- | Projective SECT571R1 curve is a binary projective curve.+instance BPCurve SECT571R1 F2m Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECT571R1 curve+-- | Coefficient @A@ of SECT571R1 curve. _a :: F2m-_a = 1-{-# INLINE _a #-}+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECT571R1 curve+-- | Coefficient @B@ of SECT571R1 curve. _b :: F2m _b = 0x2f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a-{-# INLINE _b #-}+{-# INLINABLE _b #-} --- | Polynomial of SECT571R1 curve-_f :: Integer-_f = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425-{-# INLINE _f #-}+-- | Cofactor of SECT571R1 curve.+_h :: Integer+_h = 0x2+{-# INLINABLE _h #-} --- | Generator of SECT571R1 curve-_g :: P-_g = A- 0x303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19- 0x37bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b-{-# INLINE _g #-}+-- | Polynomial of SECT571R1 curve.+_p :: Integer+_p = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425+{-# INLINABLE _p #-} --- | Cofactor of SECT571R1 curve-_h :: Integer-_h = 2-{-# INLINE _h #-}+-- | Order of SECT571R1 curve.+_r :: Integer+_r = 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47+{-# INLINABLE _r #-} --- | Order of SECT571R1 curve-_n :: Integer-_n = 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47-{-# INLINE _n #-}+-- | Coordinate @X@ of SECT571R1 curve.+_x :: F2m+_x = 0x303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECT571R1 curve.+_y :: F2m+_y = 0x37bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b+{-# INLINABLE _y #-}++-- | Generator of affine SECT571R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective SECT571R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards.hs view
@@ -1,72 +1,92 @@+{-# OPTIONS -fno-warn-orphans #-}+ module Curve.Edwards- ( ECurve(..)- , EPoint- , Point(..)+ ( module Curve+ , module Curve.Edwards+ , module Group ) 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(..))+import Curve (Coordinates(..), Curve(..), Form(..))+import Group (Group(..)) ---------------------------------------------------------------------------------- Types+-- Edwards form ------------------------------------------------------------------------------- --- | Edwards curve representation.-data E+-- | Edwards points.+type EPoint = Point 'Edwards --- | Edwards curve points.-type EPoint = Point E+-- | Edwards curves.+class (GaloisField q, GaloisField r, Curve 'Edwards c e q r) => ECurve c e q r where+ {-# MINIMAL a_, d_, h_, q_, r_, x_, y_ #-}+ a_ :: EPoint c e q r -> q -- ^ Coefficient @A@.+ d_ :: EPoint c e q r -> q -- ^ Coefficient @D@.+ h_ :: EPoint c e q r -> Integer -- ^ Curve cofactor.+ q_ :: EPoint c e q r -> Integer -- ^ Curve characteristic.+ r_ :: EPoint c e q r -> Integer -- ^ Curve order.+ x_ :: EPoint c e q r -> q -- ^ Coordinate @X@.+ y_ :: EPoint c e q r -> q -- ^ Coordinate @Y@. --- | 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.+-------------------------------------------------------------------------------+-- Affine coordinates+------------------------------------------------------------------------------- --- Edwards points are arbitrary.-instance (GaloisField k, ECurve c k) => Arbitrary (Point E c k) where- arbitrary = suchThatMap arbitrary point+-- | Edwards affine curves.+type EAPoint = EPoint 'Affine --- Edwards points are pretty.-instance (GaloisField k, ECurve c k) => Pretty (Point E c k) where- pretty (A x y) = pretty (x, y)+-- | Edwards affine curves @Ax^2 + y^2 = 1 + Dx^2y^2@.+class ECurve 'Affine e q r => EACurve e q r where+ {-# MINIMAL gA_ #-}+ gA_ :: EAPoint e q r -- ^ Curve generator. --- 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'+-- Edwards affine curves are elliptic curves.+instance EACurve e q r => Curve 'Edwards 'Affine e q r where++ data instance Point 'Edwards 'Affine e q r = A q q -- ^ Affine point.+ deriving (Eq, Generic, NFData, Read, Show)++ char = q_+ {-# INLINABLE char #-}++ cof = h_+ {-# INLINABLE cof #-}++ disc _ = d * (1 - d) where- (x, g') = random g- {-# INLINE random #-}- randomR = panic "not implemented."+ d = d_ (witness :: EAPoint e q r)+ {-# INLINABLE disc #-} ----------------------------------------------------------------------------------- Operations--------------------------------------------------------------------------------+ fromA = identity+ {-# INLINABLE fromA #-} --- Edwards curves are elliptic curves.-instance (GaloisField k, ECurve c k) => Curve E c k where+ point x y = let p = A x y in if def p then Just p else Nothing+ {-# INLINABLE point #-} - data instance Point E c k = A k k -- ^ Affine point.- deriving (Eq, Generic, NFData, Read, Show)+ pointX x = A x <$> yX (witness :: EAPoint e q r) x+ {-# INLINABLE pointX #-} - id = A 0 1- {-# INLINE id #-}+ toA = identity+ {-# INLINABLE toA #-} - inv (A x y) = A (-x) y- {-# INLINE inv #-}+ yX _ x = sr ((1 - a * xx) / (1 - d * xx))+ where+ a = a_ (witness :: EAPoint e q r)+ d = d_ (witness :: EAPoint e q r)+ xx = x * x+ {-# INLINABLE yX #-} +-- Edwards affine points are groups.+instance EACurve e q r => Group (EAPoint e q r) where+ add (A x1 y1) (A x2 y2) = A x3 y3 where- a = a_ (witness :: c)- d = d_ (witness :: c)+ a = a_ (witness :: EAPoint e q r)+ d = d_ (witness :: EAPoint e q r) x1x2 = x1 * x2 y1y2 = y1 * y2 x1y2 = x1 * y2@@ -74,27 +94,149 @@ dxy = d * x1x2 * y1y2 x3 = (x1y2 + x2y1) / (1 + dxy) y3 = (y1y2 - a * x1x2) / (1 - dxy)- {-# INLINE add #-}+ {-# INLINABLE add #-} + dbl = join add+ {-# INLINABLE dbl #-}+ def (A x y) = a * xx + yy == 1 + d * xx * yy where- a = a_ (witness :: c)- d = d_ (witness :: c)+ a = a_ (witness :: EAPoint e q r)+ d = d_ (witness :: EAPoint e q r) xx = x * x yy = y * y- {-# INLINE def #-}+ {-# INLINABLE def #-} + gen = gA_+ {-# INLINABLE gen #-}++ id = A 0 1+ {-# INLINABLE id #-}++ inv (A x y) = A (-x) y+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Edwards affine points are pretty.+instance EACurve e q r => Pretty (EAPoint e q r) where++ pretty (A x y) = pretty (x, y)++-------------------------------------------------------------------------------+-- Projective coordinates+-------------------------------------------------------------------------------++-- | Edwards projective curves.+type EPPoint = EPoint 'Projective++-- | Edwards projective curves @Ax^2z^2 + y^2z^2 = z^4 + Dx^2y^2@.+class ECurve 'Projective e q r => EPCurve e q r where+ {-# MINIMAL gP_ #-}+ gP_ :: EPPoint e q r -- ^ Curve generator.++-- Edwards projective curves are elliptic curves.+instance EPCurve e q r => Curve 'Edwards 'Projective e q r where++ data instance Point 'Edwards 'Projective e q r = P q q q -- ^ Projective point.+ deriving (Generic, NFData, Read, Show)++ char = q_+ {-# INLINABLE char #-}++ cof = h_+ {-# INLINABLE cof #-}+ disc _ = d * (1 - d) where- d = d_ (witness :: c)- {-# INLINE disc #-}+ d = d_ (witness :: EPPoint e q r)+ {-# INLINABLE disc #-} - point x = A x <$> sr ((1 - a * xx) / (1 - d * xx))+ fromA (A x y) = P x y 1+ {-# INLINABLE fromA #-}++ point x y = let p = P x y 1 in if def p then Just p else Nothing+ {-# INLINABLE point #-}++ pointX x = flip (P x) 1 <$> yX (witness :: EPPoint e q r) x+ {-# INLINABLE pointX #-}++ toA (P x y z) = A (x / z) (y / z)+ {-# INLINABLE toA #-}++ yX _ x = sr ((1 - a * xx) / (1 - d * xx)) where- a = a_ (witness :: c)- d = d_ (witness :: c)+ a = a_ (witness :: EPPoint e q r)+ d = d_ (witness :: EPPoint e q r) xx = x * x- {-# INLINE point #-}+ {-# INLINABLE yX #-} - rnd = getRandom- {-# INLINE rnd #-}+-- Edwards projective points are groups.+instance EPCurve e q r => Group (EPPoint e q r) where++ -- Addition formula add-2008-bbjlp+ add (P x1 y1 z1) (P x2 y2 z2) = P x3 y3 z3+ where+ a' = a_ (witness :: EPPoint e q r)+ d' = d_ (witness :: EPPoint e q r)+ a = z1 * z2+ b = a * a+ c = x1 * x2+ d = y1 * y2+ e = d' * c * d+ f = b - e+ g = b + e+ x3 = a * f * ((x1 + y1) * (x2 + y2) - c - d)+ y3 = a * g * (d - a' * c)+ z3 = f * g+ {-# INLINABLE add #-}++ -- Doubling formula dbl-2008-bbjlp+ dbl (P x1 y1 z1) = P x3 y3 z3+ where+ a = a_ (witness :: EPPoint e q r)+ xy = x1 + y1+ b = xy * xy+ c = x1 * x1+ d = y1 * y1+ e = a * c+ f = e + d+ h = z1 * z1+ j = f - 2 * h+ x3 = (b - c - d) * j+ y3 = f * (e - d)+ z3 = f * j+ {-# INLINABLE dbl #-}++ def (P x y z) = (a * xx + yy - zz) * zz == d * xx * yy+ where+ a = a_ (witness :: EPPoint e q r)+ d = d_ (witness :: EPPoint e q r)+ xx = x * x+ yy = y * y+ zz = z * z+ {-# INLINABLE def #-}++ gen = gP_+ {-# INLINABLE gen #-}++ id = P 0 1 1+ {-# INLINABLE id #-}++ inv (P x y z) = P (-x) y z+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Edwards projective points are equatable.+instance EPCurve e q r => Eq (EPPoint e q r) where++ P x1 y1 z1 == P x2 y2 z2 = z1 == 0 && z2 == 0+ || x1 * z2 == x2 * z1 && y1 * z2 == y2 * z1++-- Edwards projective points are pretty.+instance EPCurve e q r => Pretty (EPPoint e q r) where++ pretty (P x y z) = pretty (x, y, z)
src/Curve/Edwards/Curve1174.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.Curve1174- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.Curve1174 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Curve1174 curve+-- | Curve1174 curve. data Curve1174 --- | Field of Curve1174 curve-type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7+-- | Field of points of Curve1174 curve.+type Fq = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7 --- | Curve1174 curve is an Edwards curve-instance ECurve Curve1174 Fp where+-- | Field of coefficients of Curve1174 curve.+type Fr = PrimeField 0x1fffffffffffffffffffffffffffffff77965c4dfd307348944d45fd166c971++-- | Curve1174 curve is an Edwards curve.+instance Curve 'Edwards c Curve1174 Fq Fr => ECurve c Curve1174 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Curve1174 curve-type P = EPoint Curve1174 Fp+-- | Affine Curve1174 curve point.+type PA = EAPoint Curve1174 Fq Fr +-- | Affine Curve1174 curve is an Edwards affine curve.+instance EACurve Curve1174 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective Curve1174 point.+type PP = EPPoint Curve1174 Fq Fr++-- | Projective Curve1174 curve is an Edwards projective curve.+instance EPCurve Curve1174 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Curve1174 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of Curve1174 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of Curve1174 curve-_d :: Fp+-- | Coefficient @D@ of Curve1174 curve.+_d :: Fq _d = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb61-{-# INLINE _d #-}---- | Generator of Curve1174 curve-_g :: P-_g = A- 0x37fbb0cea308c479343aee7c029a190c021d96a492ecd6516123f27bce29eda- 0x6b72f82d47fb7cc6656841169840e0c4fe2dee2af3f976ba4ccb1bf9b46360e-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of Curve1174 curve+-- | Cofactor of Curve1174 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of Curve1174 curve-_n :: Integer-_n = 0x1fffffffffffffffffffffffffffffff77965c4dfd307348944d45fd166c971-{-# INLINE _n #-}+-- | Characteristic of Curve1174 curve.+_q :: Integer+_q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7+{-# INLINABLE _q #-} --- | Characteristic of Curve1174 curve-_p :: Integer-_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7-{-# INLINE _p #-}+-- | Order of Curve1174 curve.+_r :: Integer+_r = 0x1fffffffffffffffffffffffffffffff77965c4dfd307348944d45fd166c971+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Curve1174 curve.+_x :: Fq+_x = 0x37fbb0cea308c479343aee7c029a190c021d96a492ecd6516123f27bce29eda+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Curve1174 curve.+_y :: Fq+_y = 0x6b72f82d47fb7cc6656841169840e0c4fe2dee2af3f976ba4ccb1bf9b46360e+{-# INLINABLE _y #-}++-- | Generator of affine Curve1174 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective Curve1174 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/Curve41417.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.Curve41417- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.Curve41417 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Curve41417 curve+-- | Curve41417 curve. data Curve41417 --- | Field of Curve41417 curve-type Fp = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef+-- | Field of points of Curve41417 curve.+type Fq = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef --- | Curve41417 curve is an Edwards curve-instance ECurve Curve41417 Fp where+-- | Field of coefficients of Curve41417 curve.+type Fr = PrimeField 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffeb3cc92414cf706022b36f1c0338ad63cf181b0e71a5e106af79++-- | Curve41417 curve is an Edwards curve.+instance Curve 'Edwards c Curve41417 Fq Fr => ECurve c Curve41417 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Curve41417 curve-type P = EPoint Curve41417 Fp+-- | Affine Curve41417 curve point.+type PA = EAPoint Curve41417 Fq Fr +-- | Affine Curve41417 curve is an Edwards affine curve.+instance EACurve Curve41417 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective Curve41417 point.+type PP = EPPoint Curve41417 Fq Fr++-- | Projective Curve41417 curve is an Edwards projective curve.+instance EPCurve Curve41417 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Curve41417 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of Curve41417 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of Curve41417 curve-_d :: Fp+-- | Coefficient @D@ of Curve41417 curve.+_d :: Fq _d = 0xe21-{-# INLINE _d #-}---- | Generator of Curve41417 curve-_g :: P-_g = A- 0x1a334905141443300218c0631c326e5fcd46369f44c03ec7f57ff35498a4ab4d6d6ba111301a73faa8537c64c4fd3812f3cbc595- 0x22-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of Curve41417 curve+-- | Cofactor of Curve41417 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of Curve41417 curve-_n :: Integer-_n = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffeb3cc92414cf706022b36f1c0338ad63cf181b0e71a5e106af79-{-# INLINE _n #-}+-- | Characteristic of Curve41417 curve.+_q :: Integer+_q = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef+{-# INLINABLE _q #-} --- | Characteristic of Curve41417 curve-_p :: Integer-_p = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef-{-# INLINE _p #-}+-- | Order of Curve41417 curve.+_r :: Integer+_r = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffeb3cc92414cf706022b36f1c0338ad63cf181b0e71a5e106af79+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Curve41417 curve.+_x :: Fq+_x = 0x1a334905141443300218c0631c326e5fcd46369f44c03ec7f57ff35498a4ab4d6d6ba111301a73faa8537c64c4fd3812f3cbc595+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Curve41417 curve.+_y :: Fq+_y = 0x22+{-# INLINABLE _y #-}++-- | Generator of affine Curve41417 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective Curve41417 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/E222.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.E222- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.E222 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | E-222 curve+-- | E222 curve. data E222 --- | Field of E-222 curve-type Fp = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b+-- | Field of points of E222 curve.+type Fq = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b --- | E-222 curve is an Edwards curve-instance ECurve E222 Fp where+-- | Field of coefficients of E222 curve.+type Fr = PrimeField 0xffffffffffffffffffffffffffff70cbc95e932f802f31423598cbf++-- | E222 curve is an Edwards curve.+instance Curve 'Edwards c E222 Fq Fr => ECurve c E222 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of E-222 curve-type P = EPoint E222 Fp+-- | Affine E222 curve point.+type PA = EAPoint E222 Fq Fr +-- | Affine E222 curve is an Edwards affine curve.+instance EACurve E222 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective E222 point.+type PP = EPPoint E222 Fq Fr++-- | Projective E222 curve is an Edwards projective curve.+instance EPCurve E222 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of E-222 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of E222 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of E-222 curve-_d :: Fp+-- | Coefficient @D@ of E222 curve.+_d :: Fq _d = 0x27166-{-# INLINE _d #-}---- | Generator of E-222 curve-_g :: P-_g = A- 0x19b12bb156a389e55c9768c303316d07c23adab3736eb2bc3eb54e51- 0x1c-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of E-222 curve+-- | Cofactor of E222 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of E-222 curve-_n :: Integer-_n = 0xffffffffffffffffffffffffffff70cbc95e932f802f31423598cbf-{-# INLINE _n #-}+-- | Characteristic of E222 curve.+_q :: Integer+_q = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b+{-# INLINABLE _q #-} --- | Characteristic of E-222 curve-_p :: Integer-_p = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffff8b-{-# INLINE _p #-}+-- | Order of E222 curve.+_r :: Integer+_r = 0xffffffffffffffffffffffffffff70cbc95e932f802f31423598cbf+{-# INLINABLE _r #-}++-- | Coordinate @X@ of E222 curve.+_x :: Fq+_x = 0x19b12bb156a389e55c9768c303316d07c23adab3736eb2bc3eb54e51+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of E222 curve.+_y :: Fq+_y = 0x1c+{-# INLINABLE _y #-}++-- | Generator of affine E222 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective E222 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/E382.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.E382- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.E382 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | E-382 curve+-- | E382 curve. data E382 --- | Field of E-382 curve-type Fp = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97+-- | Field of points of E382 curve.+type Fq = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97 --- | E-382 curve is an Edwards curve-instance ECurve E382 Fp where+-- | Field of coefficients of E382 curve.+type Fr = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffd5fb21f21e95eee17c5e69281b102d2773e27e13fd3c9719++-- | E382 curve is an Edwards curve.+instance Curve 'Edwards c E382 Fq Fr => ECurve c E382 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of E-382 curve-type P = EPoint E382 Fp+-- | Affine E382 curve point.+type PA = EAPoint E382 Fq Fr +-- | Affine E382 curve is an Edwards affine curve.+instance EACurve E382 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective E382 point.+type PP = EPPoint E382 Fq Fr++-- | Projective E382 curve is an Edwards projective curve.+instance EPCurve E382 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of E-382 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of E382 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of E-382 curve-_d :: Fp+-- | Coefficient @D@ of E382 curve.+_d :: Fq _d = 0x3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef8e1-{-# INLINE _d #-}---- | Generator of E-382 curve-_g :: P-_g = A- 0x196f8dd0eab20391e5f05be96e8d20ae68f840032b0b64352923bab85364841193517dbce8105398ebc0cc9470f79603- 0x11-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of E-382 curve+-- | Cofactor of E382 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of E-382 curve-_n :: Integer-_n = 0xfffffffffffffffffffffffffffffffffffffffffffffffd5fb21f21e95eee17c5e69281b102d2773e27e13fd3c9719-{-# INLINE _n #-}+-- | Characteristic of E382 curve.+_q :: Integer+_q = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97+{-# INLINABLE _q #-} --- | Characteristic of E-382 curve-_p :: Integer-_p = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97-{-# INLINE _p #-}+-- | Order of E382 curve.+_r :: Integer+_r = 0xfffffffffffffffffffffffffffffffffffffffffffffffd5fb21f21e95eee17c5e69281b102d2773e27e13fd3c9719+{-# INLINABLE _r #-}++-- | Coordinate @X@ of E382 curve.+_x :: Fq+_x = 0x196f8dd0eab20391e5f05be96e8d20ae68f840032b0b64352923bab85364841193517dbce8105398ebc0cc9470f79603+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of E382 curve.+_y :: Fq+_y = 0x11+{-# INLINABLE _y #-}++-- | Generator of affine E382 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective E382 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/E521.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.E521- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.E521 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | E-521 curve+-- | E521 curve. data E521 --- | Field of E-521 curve-type Fp = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+-- | Field of points of E521 curve.+type Fq = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff --- | E-521 curve is an Edwards curve-instance ECurve E521 Fp where+-- | Field of coefficients of E521 curve.+type Fr = PrimeField 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd15b6c64746fc85f736b8af5e7ec53f04fbd8c4569a8f1f4540ea2435f5180d6b++-- | E521 curve is an Edwards curve.+instance Curve 'Edwards c E521 Fq Fr => ECurve c E521 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of E-521 curve-type P = EPoint E521 Fp+-- | Affine E521 curve point.+type PA = EAPoint E521 Fq Fr +-- | Affine E521 curve is an Edwards affine curve.+instance EACurve E521 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective E521 point.+type PP = EPPoint E521 Fq Fr++-- | Projective E521 curve is an Edwards projective curve.+instance EPCurve E521 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of E-521 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of E521 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of E-521 curve-_d :: Fp+-- | Coefficient @D@ of E521 curve.+_d :: Fq _d = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa4331-{-# INLINE _d #-}---- | Generator of E-521 curve-_g :: P-_g = A- 0x752cb45c48648b189df90cb2296b2878a3bfd9f42fc6c818ec8bf3c9c0c6203913f6ecc5ccc72434b1ae949d568fc99c6059d0fb13364838aa302a940a2f19ba6c- 0xc-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of E-521 curve+-- | Cofactor of E521 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of E-521 curve-_n :: Integer-_n = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd15b6c64746fc85f736b8af5e7ec53f04fbd8c4569a8f1f4540ea2435f5180d6b-{-# INLINE _n #-}+-- | Characteristic of E521 curve.+_q :: Integer+_q = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of E-521 curve-_p :: Integer-_p = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of E521 curve.+_r :: Integer+_r = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd15b6c64746fc85f736b8af5e7ec53f04fbd8c4569a8f1f4540ea2435f5180d6b+{-# INLINABLE _r #-}++-- | Coordinate @X@ of E521 curve.+_x :: Fq+_x = 0x752cb45c48648b189df90cb2296b2878a3bfd9f42fc6c818ec8bf3c9c0c6203913f6ecc5ccc72434b1ae949d568fc99c6059d0fb13364838aa302a940a2f19ba6c+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of E521 curve.+_y :: Fq+_y = 0xc+{-# INLINABLE _y #-}++-- | Generator of affine E521 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective E521 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/Ed25519.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.Ed25519- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.Ed25519 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Ed25519 curve+-- | Ed25519 curve. data Ed25519 --- | Field of Ed25519 curve-type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+-- | Field of points of Ed25519 curve.+type Fq = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed --- | Ed25519 curve is an Edwards curve-instance ECurve Ed25519 Fp where+-- | Field of coefficients of Ed25519 curve.+type Fr = PrimeField 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed++-- | Ed25519 curve is an Edwards curve.+instance Curve 'Edwards c Ed25519 Fq Fr => ECurve c Ed25519 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Ed25519 curve-type P = EPoint Ed25519 Fp+-- | Affine Ed25519 curve point.+type PA = EAPoint Ed25519 Fq Fr +-- | Affine Ed25519 curve is an Edwards affine curve.+instance EACurve Ed25519 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective Ed25519 point.+type PP = EPPoint Ed25519 Fq Fr++-- | Projective Ed25519 curve is an Edwards projective curve.+instance EPCurve Ed25519 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Ed25519 curve-_a :: Fp-_a = -1-{-# INLINE _a #-}+-- | Coefficient @A@ of Ed25519 curve.+_a :: Fq+_a = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec+{-# INLINABLE _a #-} --- | Coefficient @D@ of Ed25519 curve-_d :: Fp+-- | Coefficient @D@ of Ed25519 curve.+_d :: Fq _d = 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3-{-# INLINE _d #-}---- | Generator of Ed25519 curve-_g :: P-_g = A- 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a- 0x6666666666666666666666666666666666666666666666666666666666666658-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of Ed25519 curve+-- | Cofactor of Ed25519 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of Ed25519 curve-_n :: Integer-_n = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed-{-# INLINE _n #-}+-- | Characteristic of Ed25519 curve.+_q :: Integer+_q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+{-# INLINABLE _q #-} --- | Characteristic of Ed25519 curve-_p :: Integer-_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed-{-# INLINE _p #-}+-- | Order of Ed25519 curve.+_r :: Integer+_r = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Ed25519 curve.+_x :: Fq+_x = 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Ed25519 curve.+_y :: Fq+_y = 0x6666666666666666666666666666666666666666666666666666666666666658+{-# INLINABLE _y #-}++-- | Generator of affine Ed25519 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective Ed25519 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/Ed3363.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.Ed3363- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.Ed3363 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Ed3363 curve+-- | Ed3363 curve. data Ed3363 --- | Field of Ed3363 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd+-- | Field of points of Ed3363 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd --- | Ed3363 curve is an Edwards curve-instance ECurve Ed3363 Fp where+-- | Field of coefficients of Ed3363 curve.+type Fr = PrimeField 0x200000000000000000000000000000000000000000071415fa9850c0bd6b87f93baa7b2f95973e9fa805++-- | Ed3363 curve is an Edwards curve.+instance Curve 'Edwards c Ed3363 Fq Fr => ECurve c Ed3363 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Ed3363 curve-type P = EPoint Ed3363 Fp+-- | Affine Ed3363 curve point.+type PA = EAPoint Ed3363 Fq Fr +-- | Affine Ed3363 curve is an Edwards affine curve.+instance EACurve Ed3363 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective Ed3363 point.+type PP = EPPoint Ed3363 Fq Fr++-- | Projective Ed3363 curve is an Edwards projective curve.+instance EPCurve Ed3363 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Ed3363 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of Ed3363 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of Ed3363 curve-_d :: Fp+-- | Coefficient @D@ of Ed3363 curve.+_d :: Fq _d = 0x2b67-{-# INLINE _d #-}---- | Generator of Ed3363 curve-_g :: P-_g = A- 0xc- 0xc0dc616b56502e18e1c161d007853d1b14b46c3811c7ef435b6db5d5650ca0365db12bec68505fe8632-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of Ed3363 curve+-- | Cofactor of Ed3363 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of Ed3363 curve-_n :: Integer-_n = 0x200000000000000000000000000000000000000000071415fa9850c0bd6b87f93baa7b2f95973e9fa805-{-# INLINE _n #-}+-- | Characteristic of Ed3363 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd+{-# INLINABLE _q #-} --- | Characteristic of Ed3363 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd-{-# INLINE _p #-}+-- | Order of Ed3363 curve.+_r :: Integer+_r = 0x200000000000000000000000000000000000000000071415fa9850c0bd6b87f93baa7b2f95973e9fa805+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Ed3363 curve.+_x :: Fq+_x = 0xc+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Ed3363 curve.+_y :: Fq+_y = 0xc0dc616b56502e18e1c161d007853d1b14b46c3811c7ef435b6db5d5650ca0365db12bec68505fe8632+{-# INLINABLE _y #-}++-- | Generator of affine Ed3363 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective Ed3363 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/Ed448.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.Ed448- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.Ed448 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Ed448 curve+-- | Ed448 curve. data Ed448 --- | Field of Ed448 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+-- | Field of points of Ed448 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff --- | Ed448 curve is an Edwards curve-instance ECurve Ed448 Fp where+-- | Field of coefficients of Ed448 curve.+type Fr = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3++-- | Ed448 curve is an Edwards curve.+instance Curve 'Edwards c Ed448 Fq Fr => ECurve c Ed448 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Ed448 curve-type P = EPoint Ed448 Fp+-- | Affine Ed448 curve point.+type PA = EAPoint Ed448 Fq Fr +-- | Affine Ed448 curve is an Edwards affine curve.+instance EACurve Ed448 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective Ed448 point.+type PP = EPPoint Ed448 Fq Fr++-- | Projective Ed448 curve is an Edwards projective curve.+instance EPCurve Ed448 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Ed448 curve-_a :: Fp-_a = 1-{-# INLINE _a #-}+-- | Coefficient @A@ of Ed448 curve.+_a :: Fq+_a = 0x1+{-# INLINABLE _a #-} --- | Coefficient @D@ of Ed448 curve-_d :: Fp+-- | Coefficient @D@ of Ed448 curve.+_d :: Fq _d = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffff6756-{-# INLINE _d #-}---- | Generator of Ed448 curve-_g :: P-_g = A- 0x297ea0ea2692ff1b4faff46098453a6a26adf733245f065c3c59d0709cecfa96147eaaf3932d94c63d96c170033f4ba0c7f0de840aed939f- 0x13-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of Ed448 curve+-- | Cofactor of Ed448 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of Ed448 curve-_n :: Integer-_n = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3-{-# INLINE _n #-}+-- | Characteristic of Ed448 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of Ed448 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of Ed448 curve.+_r :: Integer+_r = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Ed448 curve.+_x :: Fq+_x = 0x297ea0ea2692ff1b4faff46098453a6a26adf733245f065c3c59d0709cecfa96147eaaf3932d94c63d96c170033f4ba0c7f0de840aed939f+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Ed448 curve.+_y :: Fq+_y = 0x13+{-# INLINABLE _y #-}++-- | Generator of affine Ed448 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective Ed448 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Edwards/JubJub.hs view
@@ -1,74 +1,105 @@ module Curve.Edwards.JubJub- ( Fp- , P- , _a- , _d- , _g- , _h- , _n- , _p+ ( module Curve.Edwards+ , module Curve.Edwards.JubJub ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Edwards (ECurve(..), EPoint, Point(..))+import Curve.Edwards ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | JubJub curve+-- | JubJub curve. data JubJub --- | Field of JubJub curve-type Fp = PrimeField 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+-- | Field of points of JubJub curve.+type Fq = PrimeField 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001 --- | JubJub curve is an Edwards curve-instance ECurve JubJub Fp where+-- | Field of coefficients of JubJub curve.+type Fr = PrimeField 0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7++-- | JubJub curve is an Edwards curve.+instance Curve 'Edwards c JubJub Fq Fr => ECurve c JubJub Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} d_ = const _d- {-# INLINE d_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE d_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of JubJub curve-type P = EPoint JubJub Fp+-- | Affine JubJub curve point.+type PA = EAPoint JubJub Fq Fr +-- | Affine JubJub curve is an Edwards affine curve.+instance EACurve JubJub Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Projective JubJub point.+type PP = EPPoint JubJub Fq Fr++-- | Projective JubJub curve is an Edwards projective curve.+instance EPCurve JubJub Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of JubJub curve-_a :: Fp-_a = -1-{-# INLINE _a #-}+-- | Coefficient @A@ of JubJub curve.+_a :: Fq+_a = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000+{-# INLINABLE _a #-} --- | Coefficient @D@ of JubJub curve-_d :: Fp+-- | Coefficient @D@ of JubJub curve.+_d :: Fq _d = 0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1-{-# INLINE _d #-}---- | Generator of JubJub curve-_g :: P-_g = A- 0x5183972af8eff38ca624b4df00384882000c546bf2f39ede7f4ecf1a74f976c4- 0x3b43f8472ca2fc2c9e8fcc5abd9dc308096c8707ffa6833b146bad709349702e-{-# INLINE _g #-}+{-# INLINABLE _d #-} --- | Cofactor of JubJub curve+-- | Cofactor of JubJub curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of JubJub curve-_n :: Integer-_n = 0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7-{-# INLINE _n #-}+-- | Characteristic of JubJub curve.+_q :: Integer+_q = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+{-# INLINABLE _q #-} --- | Characteristic of JubJub curve-_p :: Integer-_p = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001-{-# INLINE _p #-}+-- | Order of JubJub curve.+_r :: Integer+_r = 0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7+{-# INLINABLE _r #-}++-- | Coordinate @X@ of JubJub curve.+_x :: Fq+_x = 0x5183972af8eff38ca624b4df00384882000c546bf2f39ede7f4ecf1a74f976c4+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of JubJub curve.+_y :: Fq+_y = 0x3b43f8472ca2fc2c9e8fcc5abd9dc308096c8707ffa6833b146bad709349702e+{-# INLINABLE _y #-}++-- | Generator of affine JubJub curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of projective JubJub curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Montgomery.hs view
@@ -1,114 +1,136 @@+{-# OPTIONS -fno-warn-orphans #-}+ module Curve.Montgomery- ( Point(..)- , MCurve(..)- , MPoint+ ( module Curve+ , module Curve.Montgomery+ , module Group ) 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(..))+import Curve (Coordinates(..), Curve(..), Form(..))+import Group (Group(..)) ---------------------------------------------------------------------------------- Types+-- Montgomery form ------------------------------------------------------------------------------- --- | Montgomery curve representation.-data M+-- | Montgomery points.+type MPoint = Point 'Montgomery --- | Montgomery curve points.-type MPoint = Point M+-- | Montgomery curves.+class (GaloisField q, GaloisField r, Curve 'Montgomery c e q r) => MCurve c e q r where+ {-# MINIMAL a_, b_, h_, q_, r_, x_, y_ #-}+ a_ :: MPoint c e q r -> q -- ^ Coefficient @A@.+ b_ :: MPoint c e q r -> q -- ^ Coefficient @B@.+ h_ :: MPoint c e q r -> Integer -- ^ Curve cofactor.+ q_ :: MPoint c e q r -> Integer -- ^ Curve characteristic.+ r_ :: MPoint c e q r -> Integer -- ^ Curve order.+ x_ :: MPoint c e q r -> q -- ^ Coordinate @X@.+ y_ :: MPoint c e q r -> q -- ^ Coordinate @Y@. --- | 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.+-------------------------------------------------------------------------------+-- Affine coordinates+------------------------------------------------------------------------------- --- Montgomery points are arbitrary.-instance (GaloisField k, MCurve c k) => Arbitrary (Point M c k) where- arbitrary = suchThatMap arbitrary point+-- | Montgomery affine points.+type MAPoint = MPoint 'Affine --- 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 affine curves @By^2 = x^3 + Ax^2 + x@.+class MCurve 'Affine e q r => MACurve e q r where+ {-# MINIMAL gA_ #-}+ gA_ :: MAPoint e q r -- ^ Curve generator. --- 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'+-- Montgomery affine curves are elliptic curves.+instance MACurve e q r => Curve 'Montgomery 'Affine e q r where++ data instance Point 'Montgomery 'Affine e q r = A q q -- ^ Affine point.+ | O -- ^ Infinite point.+ deriving (Eq, Generic, NFData, Read, Show)++ char = q_+ {-# INLINABLE char #-}++ cof = h_+ {-# INLINABLE cof #-}++ disc _ = b * (a * a - 4) where- (x, g') = random g- {-# INLINE random #-}- randomR = panic "not implemented."+ a = a_ (witness :: MAPoint e q r)+ b = b_ (witness :: MAPoint e q r)+ {-# INLINABLE disc #-} ----------------------------------------------------------------------------------- Operations--------------------------------------------------------------------------------+ fromA = identity+ {-# INLINABLE fromA #-} --- Montgomery curves are elliptic curves.-instance (GaloisField k, MCurve c k) => Curve M c k where+ point x y = let p = A x y in if def p then Just p else Nothing+ {-# INLINABLE point #-} - data instance Point M c k = A k k -- ^ Affine point.- | O -- ^ Infinite point.- deriving (Eq, Generic, NFData, Read, Show)+ pointX x = A x <$> yX (witness :: MAPoint e q r) x+ {-# INLINABLE pointX #-} - id = O- {-# INLINE id #-}+ toA = identity+ {-# INLINABLE toA #-} - inv O = O- inv (A x y) = A x (-y)- {-# INLINE inv #-}+ yX _ x = sr ((((x + a) * x) + 1) * x / b)+ where+ a = a_ (witness :: MAPoint e q r)+ b = b_ (witness :: MAPoint e q r)+ {-# INLINABLE yX #-} - 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+-- Montgomery affine points are groups.+instance MACurve e q r => Group (MAPoint e q r) where++ add p O = p+ add O q = q+ add (A x1 y1) (A x2 y2)+ | x1 == x2 = O+ | otherwise = A x3 y3 where- a = a_ (witness :: c)- b = b_ (witness :: c)+ a = a_ (witness :: MAPoint e q r)+ b = b_ (witness :: MAPoint e q r) l = (y2 - y1) / (x2 - x1) x3 = b * l * l - a - x1 - x2 y3 = l * (x1 - x3) - y1- {-# INLINE add #-}+ {-# INLINABLE add #-} - double O = O- double (A _ 0) = O- double (A x y) = A x' y'+ dbl O = O+ dbl (A x y)+ | y == 0 = O+ | otherwise = A x' y' where- a = a_ (witness :: c)- b = b_ (witness :: c)+ a = a_ (witness :: MAPoint e q r)+ b = b_ (witness :: MAPoint e q r) l = (x * (3 * x + 2 * a) + 1) / (2 * b * y) x' = b * l * l - a - 2 * x y' = l * (x - x') - y- {-# INLINE double #-}+ {-# INLINABLE dbl #-} 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 #-}+ a = a_ (witness :: MAPoint e q r)+ b = b_ (witness :: MAPoint e q r)+ {-# INLINABLE def #-} - disc _ = b * (a * a - 4)- where- a = a_ (witness :: c)- b = b_ (witness :: c)- {-# INLINE disc #-}+ gen = gA_+ {-# INLINABLE gen #-} - point x = A x <$> sr ((((x + a) * x) + 1) * x / b)- where- a = a_ (witness :: c)- b = b_ (witness :: c)- {-# INLINE point #-}+ id = O+ {-# INLINABLE id #-} - rnd = getRandom- {-# INLINE rnd #-}+ inv O = O+ inv (A x y) = A x (-y)+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Montgomery affine points are pretty.+instance MACurve e q r => Pretty (MAPoint e q r) where++ pretty (A x y) = pretty (x, y)+ pretty O = "O"
src/Curve/Montgomery/Curve25519.hs view
@@ -1,74 +1,92 @@ module Curve.Montgomery.Curve25519- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Montgomery+ , module Curve.Montgomery.Curve25519 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Montgomery (Point(..), MCurve(..), MPoint)+import Curve.Montgomery ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Curve25519 curve+-- | Curve25519 curve. data Curve25519 --- | Field of Curve25519 curve-type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+-- | Field of points of Curve25519 curve.+type Fq = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed --- | Curve25519 curve is a Montgomery curve-instance MCurve Curve25519 Fp where+-- | Field of coefficients of Curve25519 curve.+type Fr = PrimeField 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed++-- | Curve25519 curve is a Montgomery curve.+instance Curve 'Montgomery c Curve25519 Fq Fr => MCurve c Curve25519 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Curve25519 curve-type P = MPoint Curve25519 Fp+-- | Affine Curve25519 curve point.+type PA = MAPoint Curve25519 Fq Fr +-- | Affine Curve25519 curve is a Montgomery affine curve.+instance MACurve Curve25519 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Curve25519 curve-_a :: Fp+-- | Coefficient @A@ of Curve25519 curve.+_a :: Fq _a = 0x76d06-{-# INLINE _a #-}---- | Coefficient @B@ of Curve25519 curve-_b :: Fp-_b = 1-{-# INLINE _b #-}+{-# INLINABLE _a #-} --- | Generator of Curve25519 curve-_g :: P-_g = A- 9- 0x20ae19a1b8a086b4e01edd2c7748d14c923d4d7e6d7c61b229e9c5a27eced3d9-{-# INLINE _g #-}+-- | Coefficient @B@ of Curve25519 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-} --- | Cofactor of Curve25519 curve+-- | Cofactor of Curve25519 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of Curve25519 curve-_n :: Integer-_n = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed-{-# INLINE _n #-}+-- | Characteristic of Curve25519 curve.+_q :: Integer+_q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed+{-# INLINABLE _q #-} --- | Characteristic of Curve25519 curve-_p :: Integer-_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed-{-# INLINE _p #-}+-- | Order of Curve25519 curve.+_r :: Integer+_r = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Curve25519 curve.+_x :: Fq+_x = 0x9+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Curve25519 curve.+_y :: Fq+_y = 0x20ae19a1b8a086b4e01edd2c7748d14c923d4d7e6d7c61b229e9c5a27eced3d9+{-# INLINABLE _y #-}++-- | Generator of affine Curve25519 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}
src/Curve/Montgomery/Curve383187.hs view
@@ -1,74 +1,92 @@ module Curve.Montgomery.Curve383187- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Montgomery+ , module Curve.Montgomery.Curve383187 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Montgomery (Point(..), MCurve(..), MPoint)+import Curve.Montgomery ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Curve383187 curve+-- | Curve383187 curve. data Curve383187 --- | Field of Curve383187 curve-type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+-- | Field of points of Curve383187 curve.+type Fq = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45 --- | Curve383187 curve is a Montgomery curve-instance MCurve Curve383187 Fp where+-- | Field of coefficients of Curve383187 curve.+type Fr = PrimeField 0x1000000000000000000000000000000000000000000000000e85a85287a1488acd41ae84b2b7030446f72088b00a0e21++-- | Curve383187 curve is a Montgomery curve.+instance Curve 'Montgomery c Curve383187 Fq Fr => MCurve c Curve383187 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Curve383187 curve-type P = MPoint Curve383187 Fp+-- | Affine Curve383187 curve point.+type PA = MAPoint Curve383187 Fq Fr +-- | Affine Curve383187 curve is a Montgomery affine curve.+instance MACurve Curve383187 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Curve383187 curve-_a :: Fp+-- | Coefficient @A@ of Curve383187 curve.+_a :: Fq _a = 0x38251-{-# INLINE _a #-}---- | Coefficient @B@ of Curve383187 curve-_b :: Fp-_b = 1-{-# INLINE _b #-}+{-# INLINABLE _a #-} --- | Generator of Curve383187 curve-_g :: P-_g = A- 5- 0x1eebe07dc1871896732b12d5504a32370471965c7a11f2c89865f855ab3cbd7c224e3620c31af3370788457dd5ce46df-{-# INLINE _g #-}+-- | Coefficient @B@ of Curve383187 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-} --- | Cofactor of Curve383187 curve+-- | Cofactor of Curve383187 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of Curve383187 curve-_n :: Integer-_n = 0x1000000000000000000000000000000000000000000000000e85a85287a1488acd41ae84b2b7030446f72088b00a0e21-{-# INLINE _n #-}+-- | Characteristic of Curve383187 curve.+_q :: Integer+_q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+{-# INLINABLE _q #-} --- | Characteristic of Curve383187 curve-_p :: Integer-_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45-{-# INLINE _p #-}+-- | Order of Curve383187 curve.+_r :: Integer+_r = 0x1000000000000000000000000000000000000000000000000e85a85287a1488acd41ae84b2b7030446f72088b00a0e21+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Curve383187 curve.+_x :: Fq+_x = 0x5+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Curve383187 curve.+_y :: Fq+_y = 0x1eebe07dc1871896732b12d5504a32370471965c7a11f2c89865f855ab3cbd7c224e3620c31af3370788457dd5ce46df+{-# INLINABLE _y #-}++-- | Generator of affine Curve383187 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}
src/Curve/Montgomery/Curve448.hs view
@@ -1,74 +1,92 @@ module Curve.Montgomery.Curve448- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Montgomery+ , module Curve.Montgomery.Curve448 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Montgomery (Point(..), MCurve(..), MPoint)+import Curve.Montgomery ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Curve448 curve+-- | Curve448 curve. data Curve448 --- | Field of Curve448 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+-- | Field of points of Curve448 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff --- | Curve448 curve is a Montgomery curve-instance MCurve Curve448 Fp where+-- | Field of coefficients of Curve448 curve.+type Fr = PrimeField 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3++-- | Curve448 curve is a Montgomery curve.+instance Curve 'Montgomery c Curve448 Fq Fr => MCurve c Curve448 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Curve448 curve-type P = MPoint Curve448 Fp+-- | Affine Curve448 curve point.+type PA = MAPoint Curve448 Fq Fr +-- | Affine Curve448 curve is a Montgomery affine curve.+instance MACurve Curve448 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Curve448 curve-_a :: Fp+-- | Coefficient @A@ of Curve448 curve.+_a :: Fq _a = 0x262a6-{-# INLINE _a #-}---- | Coefficient @B@ of Curve448 curve-_b :: Fp-_b = 1-{-# INLINE _b #-}+{-# INLINABLE _a #-} --- | Generator of Curve448 curve-_g :: P-_g = A- 5- 0x7d235d1295f5b1f66c98ab6e58326fcecbae5d34f55545d060f75dc28df3f6edb8027e2346430d211312c4b150677af76fd7223d457b5b1a-{-# INLINE _g #-}+-- | Coefficient @B@ of Curve448 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-} --- | Cofactor of Curve448 curve+-- | Cofactor of Curve448 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of Curve448 curve-_n :: Integer-_n = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3-{-# INLINE _n #-}+-- | Characteristic of Curve448 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of Curve448 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of Curve448 curve.+_r :: Integer+_r = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Curve448 curve.+_x :: Fq+_x = 0x5+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Curve448 curve.+_y :: Fq+_y = 0x7d235d1295f5b1f66c98ab6e58326fcecbae5d34f55545d060f75dc28df3f6edb8027e2346430d211312c4b150677af76fd7223d457b5b1a+{-# INLINABLE _y #-}++-- | Generator of affine Curve448 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}
src/Curve/Montgomery/M221.hs view
@@ -1,74 +1,92 @@ module Curve.Montgomery.M221- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Montgomery+ , module Curve.Montgomery.M221 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Montgomery (Point(..), MCurve(..), MPoint)+import Curve.Montgomery ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | M-221 curve+-- | M221 curve. data M221 --- | Field of M-221 curve-type Fp = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd+-- | Field of points of M221 curve.+type Fq = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd --- | M-221 curve is a Montgomery curve-instance MCurve M221 Fp where+-- | Field of coefficients of M221 curve.+type Fr = PrimeField 0x40000000000000000000000000015a08ed730e8a2f77f005042605b++-- | M221 curve is a Montgomery curve.+instance Curve 'Montgomery c M221 Fq Fr => MCurve c M221 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of M-221 curve-type P = MPoint M221 Fp+-- | Affine M221 curve point.+type PA = MAPoint M221 Fq Fr +-- | Affine M221 curve is a Montgomery affine curve.+instance MACurve M221 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of M-221 curve-_a :: Fp+-- | Coefficient @A@ of M221 curve.+_a :: Fq _a = 0x1c93a-{-# INLINE _a #-}---- | Coefficient @B@ of M-221 curve-_b :: Fp-_b = 1-{-# INLINE _b #-}+{-# INLINABLE _a #-} --- | Generator of M-221 curve-_g :: P-_g = A- 4- 0xf7acdd2a4939571d1cef14eca37c228e61dbff10707dc6c08c5056d-{-# INLINE _g #-}+-- | Coefficient @B@ of M221 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-} --- | Cofactor of M-221 curve+-- | Cofactor of M221 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of M-221 curve-_n :: Integer-_n = 0x40000000000000000000000000015a08ed730e8a2f77f005042605b-{-# INLINE _n #-}+-- | Characteristic of M221 curve.+_q :: Integer+_q = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd+{-# INLINABLE _q #-} --- | Characteristic of M-221 curve-_p :: Integer-_p = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffd-{-# INLINE _p #-}+-- | Order of M221 curve.+_r :: Integer+_r = 0x40000000000000000000000000015a08ed730e8a2f77f005042605b+{-# INLINABLE _r #-}++-- | Coordinate @X@ of M221 curve.+_x :: Fq+_x = 0x4+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of M221 curve.+_y :: Fq+_y = 0xf7acdd2a4939571d1cef14eca37c228e61dbff10707dc6c08c5056d+{-# INLINABLE _y #-}++-- | Generator of affine M221 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}
src/Curve/Montgomery/M383.hs view
@@ -1,74 +1,92 @@ module Curve.Montgomery.M383- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Montgomery+ , module Curve.Montgomery.M383 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Montgomery (Point(..), MCurve(..), MPoint)+import Curve.Montgomery ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | M-383 curve+-- | M383 curve. data M383 --- | Field of M-383 curve-type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+-- | Field of points of M383 curve.+type Fq = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45 --- | M-383 curve is a Montgomery curve-instance MCurve M383 Fp where+-- | Field of coefficients of M383 curve.+type Fr = PrimeField 0x10000000000000000000000000000000000000000000000006c79673ac36ba6e7a32576f7b1b249e46bbc225be9071d7++-- | M383 curve is a Montgomery curve.+instance Curve 'Montgomery c M383 Fq Fr => MCurve c M383 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of M-383 curve-type P = MPoint M383 Fp+-- | Affine M383 curve point.+type PA = MAPoint M383 Fq Fr +-- | Affine M383 curve is a Montgomery affine curve.+instance MACurve M383 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of M-383 curve-_a :: Fp+-- | Coefficient @A@ of M383 curve.+_a :: Fq _a = 0x1f82fe-{-# INLINE _a #-}---- | Coefficient @B@ of M-383 curve-_b :: Fp-_b = 1-{-# INLINE _b #-}+{-# INLINABLE _a #-} --- | Generator of M-383 curve-_g :: P-_g = A- 0xc- 0x1ec7ed04aaf834af310e304b2da0f328e7c165f0e8988abd3992861290f617aa1f1b2e7d0b6e332e969991b62555e77e-{-# INLINE _g #-}+-- | Coefficient @B@ of M383 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-} --- | Cofactor of M-383 curve+-- | Cofactor of M383 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of M-383 curve-_n :: Integer-_n = 0x10000000000000000000000000000000000000000000000006c79673ac36ba6e7a32576f7b1b249e46bbc225be9071d7-{-# INLINE _n #-}+-- | Characteristic of M383 curve.+_q :: Integer+_q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+{-# INLINABLE _q #-} --- | Characteristic of M-383 curve-_p :: Integer-_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45-{-# INLINE _p #-}+-- | Order of M383 curve.+_r :: Integer+_r = 0x10000000000000000000000000000000000000000000000006c79673ac36ba6e7a32576f7b1b249e46bbc225be9071d7+{-# INLINABLE _r #-}++-- | Coordinate @X@ of M383 curve.+_x :: Fq+_x = 0xc+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of M383 curve.+_y :: Fq+_y = 0x1ec7ed04aaf834af310e304b2da0f328e7c165f0e8988abd3992861290f617aa1f1b2e7d0b6e332e969991b62555e77e+{-# INLINABLE _y #-}++-- | Generator of affine M383 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}
src/Curve/Montgomery/M511.hs view
@@ -1,74 +1,92 @@ module Curve.Montgomery.M511- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Montgomery+ , module Curve.Montgomery.M511 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Montgomery (Point(..), MCurve(..), MPoint)+import Curve.Montgomery ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | M-511 curve+-- | M511 curve. data M511 --- | Field of M-511 curve-type Fp = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+-- | Field of points of M511 curve.+type Fq = PrimeField 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45 --- | M-511 curve is a Montgomery curve-instance MCurve M511 Fp where+-- | Field of coefficients of M511 curve.+type Fr = PrimeField 0x100000000000000000000000000000000000000000000000000000000000000017b5feff30c7f5677ab2aeebd13779a2ac125042a6aa10bfa54c15bab76baf1b++-- | M511 curve is a Montgomery curve.+instance Curve 'Montgomery c M511 Fq Fr => MCurve c M511 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of M-511 curve-type P = MPoint M511 Fp+-- | Affine M511 curve point.+type PA = MAPoint M511 Fq Fr +-- | Affine M511 curve is a Montgomery affine curve.+instance MACurve M511 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of M-511 curve-_a :: Fp+-- | Coefficient @A@ of M511 curve.+_a :: Fq _a = 0x81806-{-# INLINE _a #-}---- | Coefficient @B@ of M-511 curve-_b :: Fp-_b = 1-{-# INLINE _b #-}+{-# INLINABLE _a #-} --- | Generator of M-511 curve-_g :: P-_g = A- 5- 0x2fbdc0ad8530803d28fdbad354bb488d32399ac1cf8f6e01ee3f96389b90c809422b9429e8a43dbf49308ac4455940abe9f1dbca542093a895e30a64af056fa5-{-# INLINE _g #-}+-- | Coefficient @B@ of M511 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-} --- | Cofactor of M-511 curve+-- | Cofactor of M511 curve. _h :: Integer-_h = 8-{-# INLINE _h #-}+_h = 0x8+{-# INLINABLE _h #-} --- | Order of M-511 curve-_n :: Integer-_n = 0x100000000000000000000000000000000000000000000000000000000000000017b5feff30c7f5677ab2aeebd13779a2ac125042a6aa10bfa54c15bab76baf1b-{-# INLINE _n #-}+-- | Characteristic of M511 curve.+_q :: Integer+_q = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45+{-# INLINABLE _q #-} --- | Characteristic of M-511 curve-_p :: Integer-_p = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff45-{-# INLINE _p #-}+-- | Order of M511 curve.+_r :: Integer+_r = 0x100000000000000000000000000000000000000000000000000000000000000017b5feff30c7f5677ab2aeebd13779a2ac125042a6aa10bfa54c15bab76baf1b+{-# INLINABLE _r #-}++-- | Coordinate @X@ of M511 curve.+_x :: Fq+_x = 0x5+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of M511 curve.+_y :: Fq+_y = 0x2fbdc0ad8530803d28fdbad354bb488d32399ac1cf8f6e01ee3f96389b90c809422b9429e8a43dbf49308ac4455940abe9f1dbca542093a895e30a64af056fa5+{-# INLINABLE _y #-}++-- | Generator of affine M511 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}
src/Curve/Weierstrass.hs view
@@ -1,117 +1,384 @@+{-# OPTIONS -fno-warn-orphans #-}+ module Curve.Weierstrass- ( Point(..)- , WCurve(..)- , WPoint+ ( module Curve+ , module Curve.Weierstrass+ , module Group ) 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(..))+import Curve (Coordinates(..), Curve(..), Form(..))+import Group (Group(..)) ---------------------------------------------------------------------------------- Types+-- Weierstrass form ------------------------------------------------------------------------------- --- | Weierstrass curve representation.-data W+-- | Weierstrass points.+type WPoint = Point 'Weierstrass --- | Weierstrass curve points.-type WPoint = Point W+-- | Weierstrass curves.+class (GaloisField q, GaloisField r, Curve 'Weierstrass c e q r) => WCurve c e q r where+ {-# MINIMAL a_, b_, h_, q_, r_, x_, y_ #-}+ a_ :: WPoint c e q r -> q -- ^ Coefficient @A@.+ b_ :: WPoint c e q r -> q -- ^ Coefficient @B@.+ h_ :: WPoint c e q r -> Integer -- ^ Curve cofactor.+ q_ :: WPoint c e q r -> Integer -- ^ Curve characteristic.+ r_ :: WPoint c e q r -> Integer -- ^ Curve order.+ x_ :: WPoint c e q r -> q -- ^ Coordinate @X@.+ y_ :: WPoint c e q r -> q -- ^ Coordinate @Y@. --- | 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.+-------------------------------------------------------------------------------+-- Affine coordinates+------------------------------------------------------------------------------- --- 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 affine points.+type WAPoint = WPoint 'Affine --- 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 affine curves @y^2 = x^3 + Ax + B@.+class WCurve 'Affine e q r => WACurve e q r where+ {-# MINIMAL gA_ #-}+ gA_ :: WAPoint e q r -- ^ Curve generator. --- 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."+-- Weierstrass affine curves are elliptic curves.+instance WACurve e q r => Curve 'Weierstrass 'Affine e q r where ----------------------------------------------------------------------------------- Operations--------------------------------------------------------------------------------+ data instance Point 'Weierstrass 'Affine e q r = A q q -- ^ Affine point.+ | O -- ^ Infinite point.+ deriving (Eq, Generic, NFData, Read, Show) --- Weierstrass curves are elliptic curves.-instance (GaloisField k, WCurve c k) => Curve W c k where+ char = q_+ {-# INLINABLE char #-} - data instance Point W c k = A k k -- ^ Affine point.- | O -- ^ Infinite point.- deriving (Eq, Generic, NFData, Read, Show)+ cof = h_+ {-# INLINABLE cof #-} - id = O- {-# INLINE id #-}+ disc _ = 4 * a * a * a + 27 * b * b+ where+ a = a_ (witness :: WAPoint e q r)+ b = b_ (witness :: WAPoint e q r)+ {-# INLINABLE disc #-} - inv O = O- inv (A x y) = A x (-y)- {-# INLINE inv #-}+ fromA = identity+ {-# INLINABLE fromA #-} - 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+ point x y = let p = A x y in if def p then Just p else Nothing+ {-# INLINABLE point #-}++ pointX x = A x <$> yX (witness :: WAPoint e q r) x+ {-# INLINABLE pointX #-}++ toA = identity+ {-# INLINABLE toA #-}++ yX _ x = sr (((x * x + a) * x) + b) where+ a = a_ (witness :: WAPoint e q r)+ b = b_ (witness :: WAPoint e q r)+ {-# INLINABLE yX #-}++-- Weierstrass affine points are groups.+instance WACurve e q r => Group (WAPoint e q r) where++ add p O = p+ add O q = q+ add (A x1 y1) (A x2 y2)+ | x1 == x2 = O+ | otherwise = A x3 y3+ where l = (y1 - y2) / (x1 - x2) x3 = l * l - x1 - x2 y3 = l * (x1 - x3) - y1- {-# INLINE add #-}+ {-# INLINABLE add #-} - double O = O- double (A _ 0) = O- double (A x y) = A x' y'+ dbl O = O+ dbl (A x y)+ | y == 0 = O+ | otherwise = A x' y' where- l = (3 * x * x + a_ (witness :: c)) / (2 * y)+ a = a_ (witness :: WAPoint e q r)+ l = (3 * x * x + a) / (2 * y) x' = l * l - 2 * x y' = l * (x - x') - y- {-# INLINE double #-}+ {-# INLINABLE dbl #-} 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 #-}+ a = a_ (witness :: WAPoint e q r)+ b = b_ (witness :: WAPoint e q r)+ {-# INLINABLE def #-} + gen = gA_+ {-# INLINABLE gen #-}++ id = O+ {-# INLINABLE id #-}++ inv O = O+ inv (A x y) = A x (-y)+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Weierstrass affine points are pretty.+instance WACurve e q r => Pretty (WAPoint e q r) where++ pretty (A x y) = pretty (x, y)+ pretty O = "O"++-------------------------------------------------------------------------------+-- Jacobian coordinates+-------------------------------------------------------------------------------++-- | Weierstrass Jacobian points.+type WJPoint = WPoint 'Jacobian++-- | Weierstrass Jacobian curves @y^2 = x^3 + Ax + B@.+class WCurve 'Jacobian e q r => WJCurve e q r where+ {-# MINIMAL gJ_ #-}+ gJ_ :: WJPoint e q r -- ^ Curve generator.++-- Weierstrass Jacobian curves are elliptic curves.+instance WJCurve e q r => Curve 'Weierstrass 'Jacobian e q r where++ data instance Point 'Weierstrass 'Jacobian e q r = J q q q -- ^ Jacobian point.+ deriving (Generic, NFData, Read, Show)++ char = q_+ {-# INLINABLE char #-}++ cof = h_+ {-# INLINABLE cof #-}+ disc _ = 4 * a * a * a + 27 * b * b where- a = a_ (witness :: c)- b = b_ (witness :: c)- {-# INLINE disc #-}+ a = a_ (witness :: WJPoint e q r)+ b = b_ (witness :: WJPoint e q r)+ {-# INLINABLE disc #-} - point x = A x <$> sr (((x * x + a) * x) + b)+ fromA (A x y) = J x y 1+ fromA _ = J 1 1 0+ {-# INLINABLE fromA #-}++ point x y = let p = J x y 1 in if def p then Just p else Nothing+ {-# INLINABLE point #-}++ pointX x = flip (J x) 1 <$> yX (witness :: WJPoint e q r) x+ {-# INLINABLE pointX #-}++ toA (J _ _ 0) = O+ toA (J x y z) = let zz = z * z in A (x / zz) (y / (z * zz))+ {-# INLINABLE toA #-}++ yX _ x = sr (((x * x + a) * x) + b) where- a = a_ (witness :: c)- b = b_ (witness :: c)- {-# INLINE point #-}+ a = a_ (witness :: WJPoint e q r)+ b = b_ (witness :: WJPoint e q r)+ {-# INLINABLE yX #-} - rnd = getRandom- {-# INLINE rnd #-}+-- Weierstrass Jacobian points are groups.+instance WJCurve e q r => Group (WJPoint e q r) where++ -- Addition formula add-2007-bl+ add p (J _ _ 0) = p+ add (J _ _ 0) q = q+ add (J x1 y1 z1) (J x2 y2 z2) = J x3 y3 z3+ where+ z1z1 = z1 * z1+ z2z2 = z2 * z2+ z1z2 = z1 + z2+ u1 = x1 * z2z2+ u2 = x2 * z1z1+ s1 = y1 * z2 * z2z2+ s2 = y2 * z1 * z1z1+ h = u2 - u1+ h2 = 2 * h+ i = h2 * h2+ j = h * i+ r = 2 * (s2 - s1)+ v = u1 * i+ x3 = r * r - j - 2 * v+ y3 = r * (v - x3) - 2 * s1 * j+ z3 = (z1z2 * z1z2 - z1z1 - z2z2) * h+ {-# INLINABLE add #-}++ -- Doubling formula dbl-2007-bl+ dbl (J _ _ 0) = J 1 1 0+ dbl (J x1 y1 z1) = J x3 y3 z3+ where+ a = a_ (witness :: WJPoint e q r)+ xx = x1 * x1+ yy = y1 * y1+ yyyy = yy * yy+ zz = z1 * z1+ xy = x1 + yy+ yz = y1 + z1+ s = 2 * (xy * xy - xx - yyyy)+ m = 3 * xx + a * zz * zz+ t = m * m - 2 * s+ x3 = t+ y3 = m * (s - t) - 8 * yyyy+ z3 = yz * yz - yy - zz+ {-# INLINABLE dbl #-}++ def (J x y z) = y * y == x * x * x + zz * zz * (a * x + b * zz)+ where+ a = a_ (witness :: WJPoint e q r)+ b = b_ (witness :: WJPoint e q r)+ zz = z * z+ {-# INLINABLE def #-}++ gen = gJ_+ {-# INLINABLE gen #-}++ id = J 1 1 0+ {-# INLINABLE id #-}++ inv (J x y z) = J x (-y) z+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Weierstrass Jacobian points are equatable.+instance WJCurve e q r => Eq (WJPoint e q r) where++ J x1 y1 z1 == J x2 y2 z2 = z1 == 0 && z2 == 0+ || x1 * zz2 == x2 * zz1 && y1 * z2 * zz2 == y2 * z1 * zz1+ where+ zz1 = z1 * z1+ zz2 = z2 * z2++-- Weierstrass Jacobian points are pretty.+instance WJCurve e q r => Pretty (WJPoint e q r) where++ pretty (J x y z) = pretty (x, y, z)++-------------------------------------------------------------------------------+-- Projective coordinates+-------------------------------------------------------------------------------++-- | Weierstrass projective points.+type WPPoint = WPoint 'Projective++-- | Weierstrass projective curves @y^2 = x^3 + Ax + B@.+class WCurve 'Projective e q r => WPCurve e q r where+ {-# MINIMAL gP_ #-}+ gP_ :: WPPoint e q r -- ^ Curve generator.++-- Weierstrass projective curves are elliptic curves.+instance WPCurve e q r => Curve 'Weierstrass 'Projective e q r where++ data instance Point 'Weierstrass 'Projective e q r = P q q q -- ^ Projective point.+ deriving (Generic, NFData, Read, Show)++ char = q_+ {-# INLINABLE char #-}++ cof = h_+ {-# INLINABLE cof #-}++ disc _ = 4 * a * a * a + 27 * b * b+ where+ a = a_ (witness :: WPPoint e q r)+ b = b_ (witness :: WPPoint e q r)+ {-# INLINABLE disc #-}++ fromA (A x y) = P x y 1+ fromA _ = P 0 1 0+ {-# INLINABLE fromA #-}++ point x y = let p = P x y 1 in if def p then Just p else Nothing+ {-# INLINABLE point #-}++ pointX x = flip (P x) 1 <$> yX (witness :: WPPoint e q r) x+ {-# INLINABLE pointX #-}++ toA (P _ _ 0) = O+ toA (P x y z) = A (x / z) (y / z)+ {-# INLINABLE toA #-}++ yX _ x = sr (((x * x + a) * x) + b)+ where+ a = a_ (witness :: WPPoint e q r)+ b = b_ (witness :: WPPoint e q r)+ {-# INLINABLE yX #-}++-- Weierstrass projective points are groups.+instance WPCurve e q r => Group (WPPoint e q r) where++ -- Addition formula add-1998-cmo-2+ add p (P _ _ 0) = p+ add (P _ _ 0) q = q+ add (P x1 y1 z1) (P x2 y2 z2) = P x3 y3 z3+ where+ y1z2 = y1 * z2+ x1z2 = x1 * z2+ z1z2 = z1 * z2+ u = y2 * z1 - y1z2+ uu = u * u+ v = x2 * z1 - x1z2+ vv = v * v+ vvv = v * vv+ r = vv * x1z2+ a = uu * z1z2 - vvv - 2 * r+ x3 = v * a+ y3 = u * (r - a) - vvv * y1z2+ z3 = vvv * z1z2+ {-# INLINABLE add #-}++ -- Doubling formula dbl-2007-bl+ dbl (P _ _ 0) = P 0 1 0+ dbl (P x1 y1 z1) = P x3 y3 z3+ where+ xx = x1 * x1+ zz = z1 * z1+ w = a_ (witness :: WPPoint e q r) * zz + 3 * xx+ s = 2 * y1 * z1+ ss = s * s+ sss = s * ss+ r = y1 * s+ rr = r * r+ xr = x1 + r+ b = xr * xr - xx - rr+ h = w * w - 2 * b+ x3 = h * s+ y3 = w * (b - h) - 2 * rr+ z3 = sss+ {-# INLINABLE dbl #-}++ def (P x y z) = (x * x + a * zz) * x == (y * y - b * zz) * z+ where+ a = a_ (witness :: WPPoint e q r)+ b = b_ (witness :: WPPoint e q r)+ zz = z * z+ {-# INLINABLE def #-}++ gen = gP_+ {-# INLINABLE gen #-}++ id = P 0 1 0+ {-# INLINABLE id #-}++ inv (P x y z) = P x (-y) z+ {-# INLINABLE inv #-}++ order = r_+ {-# INLINABLE order #-}++-- Weierstrass projective points are equatable.+instance WPCurve e q r => Eq (WPPoint e q r) where++ P x1 y1 z1 == P x2 y2 z2 = z1 == 0 && z2 == 0+ || x1 * z2 == x2 * z1 && y1 * z2 == y2 * z1++-- Weierstrass projective points are pretty.+instance WPCurve e q r => Pretty (WPPoint e q r) where++ pretty (P x y z) = pretty (x, y, z)
src/Curve/Weierstrass/ANSSIFRP256V1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.ANSSIFRP256V1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.ANSSIFRP256V1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | ANSSI-FRP256V1 curve+-- | ANSSIFRP256V1 curve. data ANSSIFRP256V1 --- | Field of ANSSI-FRP256V1 curve-type Fp = PrimeField 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03+-- | Field of points of ANSSIFRP256V1 curve.+type Fq = PrimeField 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03 --- | ANSSI-FRP256V1 curve is a Weierstrass curve-instance WCurve ANSSIFRP256V1 Fp where+-- | Field of coefficients of ANSSIFRP256V1 curve.+type Fr = PrimeField 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1++-- | ANSSIFRP256V1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c ANSSIFRP256V1 Fq Fr => WCurve c ANSSIFRP256V1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of ANSSI-FRP256V1 curve-type P = WPoint ANSSIFRP256V1 Fp+-- | Affine ANSSIFRP256V1 curve point.+type PA = WAPoint ANSSIFRP256V1 Fq Fr +-- | Affine ANSSIFRP256V1 curve is a Weierstrass affine curve.+instance WACurve ANSSIFRP256V1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian ANSSIFRP256V1 point.+type PJ = WJPoint ANSSIFRP256V1 Fq Fr++-- | Jacobian ANSSIFRP256V1 curve is a Weierstrass Jacobian curve.+instance WJCurve ANSSIFRP256V1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective ANSSIFRP256V1 point.+type PP = WPPoint ANSSIFRP256V1 Fq Fr++-- | Projective ANSSIFRP256V1 curve is a Weierstrass projective curve.+instance WPCurve ANSSIFRP256V1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of ANSSI-FRP256V1 curve-_a :: Fp+-- | Coefficient @A@ of ANSSIFRP256V1 curve.+_a :: Fq _a = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c00-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of ANSSI-FRP256V1 curve-_b :: Fp+-- | Coefficient @B@ of ANSSIFRP256V1 curve.+_b :: Fq _b = 0xee353fca5428a9300d4aba754a44c00fdfec0c9ae4b1a1803075ed967b7bb73f-{-# INLINE _b #-}---- | Generator of ANSSI-FRP256V1 curve-_g :: P-_g = A- 0xb6b3d4c356c139eb31183d4749d423958c27d2dcaf98b70164c97a2dd98f5cff- 0x6142e0f7c8b204911f9271f0f3ecef8c2701c307e8e4c9e183115a1554062cfb-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of ANSSI-FRP256V1 curve+-- | Cofactor of ANSSIFRP256V1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of ANSSI-FRP256V1 curve-_n :: Integer-_n = 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1-{-# INLINE _n #-}+-- | Characteristic of ANSSIFRP256V1 curve.+_q :: Integer+_q = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03+{-# INLINABLE _q #-} --- | Characteristic of ANSSI-FRP256V1 curve-_p :: Integer-_p = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03-{-# INLINE _p #-}+-- | Order of ANSSIFRP256V1 curve.+_r :: Integer+_r = 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1+{-# INLINABLE _r #-}++-- | Coordinate @X@ of ANSSIFRP256V1 curve.+_x :: Fq+_x = 0xb6b3d4c356c139eb31183d4749d423958c27d2dcaf98b70164c97a2dd98f5cff+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of ANSSIFRP256V1 curve.+_y :: Fq+_y = 0x6142e0f7c8b204911f9271f0f3ecef8c2701c307e8e4c9e183115a1554062cfb+{-# INLINABLE _y #-}++-- | Generator of affine ANSSIFRP256V1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian ANSSIFRP256V1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective ANSSIFRP256V1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/Anomalous.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.Anomalous- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.Anomalous ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Anomalous curve+-- | Anomalous curve. data Anomalous --- | Field of Anomalous curve-type Fp = PrimeField 0xb0000000000000000000000953000000000000000000001f9d7+-- | Field of points of Anomalous curve.+type Fq = PrimeField 0xb0000000000000000000000953000000000000000000001f9d7 --- | Anomalous curve is a Weierstrass curve-instance WCurve Anomalous Fp where+-- | Field of coefficients of Anomalous curve.+type Fr = PrimeField 0xb0000000000000000000000953000000000000000000001f9d7++-- | Anomalous curve is a Weierstrass curve.+instance Curve 'Weierstrass c Anomalous Fq Fr => WCurve c Anomalous Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Anomalous curve-type P = WPoint Anomalous Fp+-- | Affine Anomalous curve point.+type PA = WAPoint Anomalous Fq Fr +-- | Affine Anomalous curve is a Weierstrass affine curve.+instance WACurve Anomalous Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian Anomalous point.+type PJ = WJPoint Anomalous Fq Fr++-- | Jacobian Anomalous curve is a Weierstrass Jacobian curve.+instance WJCurve Anomalous Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective Anomalous point.+type PP = WPPoint Anomalous Fq Fr++-- | Projective Anomalous curve is a Weierstrass projective curve.+instance WPCurve Anomalous Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Anomalous curve-_a :: Fp+-- | Coefficient @A@ of Anomalous curve.+_a :: Fq _a = 0x98d0fac687d6343eb1a1f595283eb1a1f58d0fac687d635f5e4-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Anomalous curve-_b :: Fp+-- | Coefficient @B@ of Anomalous curve.+_b :: Fq _b = 0x4a1f58d0fac687d6343eb1a5e2d6343eb1a1f58d0fac688ab3f-{-# INLINE _b #-}---- | Generator of Anomalous curve-_g :: P-_g = A- 0x101efb35fd1963c4871a2d17edaafa7e249807f58f8705126c6- 0x22389a3954375834304ba1d509a97de6c07148ea7f5951b20e7-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Anomalous curve+-- | Cofactor of Anomalous curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Anomalous curve-_n :: Integer-_n = 0xb0000000000000000000000953000000000000000000001f9d7-{-# INLINE _n #-}+-- | Characteristic of Anomalous curve.+_q :: Integer+_q = 0xb0000000000000000000000953000000000000000000001f9d7+{-# INLINABLE _q #-} --- | Characteristic of Anomalous curve-_p :: Integer-_p = 0xb0000000000000000000000953000000000000000000001f9d7-{-# INLINE _p #-}+-- | Order of Anomalous curve.+_r :: Integer+_r = 0xb0000000000000000000000953000000000000000000001f9d7+{-# INLINABLE _r #-}++-- | Coordinate @X@ of Anomalous curve.+_x :: Fq+_x = 0x101efb35fd1963c4871a2d17edaafa7e249807f58f8705126c6+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of Anomalous curve.+_y :: Fq+_y = 0x22389a3954375834304ba1d509a97de6c07148ea7f5951b20e7+{-# INLINABLE _y #-}++-- | Generator of affine Anomalous curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian Anomalous curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective Anomalous curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
+ src/Curve/Weierstrass/BLS12381.hs view
@@ -0,0 +1,118 @@+module Curve.Weierstrass.BLS12381+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BLS12381+ ) where++import Protolude++import PrimeField++import Curve.Weierstrass++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS12381 curve.+data BLS12381++-- | Field of points of BLS12381 curve.+type Fq = PrimeField 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab++-- | Field of coefficients of BLS12381 curve.+type Fr = PrimeField 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001++-- | BLS12381 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BLS12381 Fq Fr => WCurve c BLS12381 Fq Fr where+ a_ = const _a+ {-# INLINABLE a_ #-}+ b_ = const _b+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-}++-- | Affine BLS12381 curve point.+type PA = WAPoint BLS12381 Fq Fr++-- | Affine BLS12381 curve is a Weierstrass affine curve.+instance WACurve BLS12381 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BLS12381 point.+type PJ = WJPoint BLS12381 Fq Fr++-- | Jacobian BLS12381 curve is a Weierstrass Jacobian curve.+instance WJCurve BLS12381 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BLS12381 point.+type PP = WPPoint BLS12381 Fq Fr++-- | Projective BLS12381 curve is a Weierstrass projective curve.+instance WPCurve BLS12381 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS12381 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-}++-- | Coefficient @B@ of BLS12381 curve.+_b :: Fq+_b = 0x4+{-# INLINABLE _b #-}++-- | Cofactor of BLS12381 curve.+_h :: Integer+_h = 0x396c8c005555e1568c00aaab0000aaab+{-# INLINABLE _h #-}++-- | Characteristic of BLS12381 curve.+_q :: Integer+_q = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+{-# INLINABLE _q #-}++-- | Order of BLS12381 curve.+_r :: Integer+_r = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BLS12381 curve.+_x :: Fq+_x = 0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BLS12381 curve.+_y :: Fq+_y = 0x8b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1+{-# INLINABLE _y #-}++-- | Generator of affine BLS12381 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BLS12381 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BLS12381 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
+ src/Curve/Weierstrass/BLS12381T.hs view
@@ -0,0 +1,130 @@+module Curve.Weierstrass.BLS12381T+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BLS12381T+ ) where++import Protolude++import ExtensionField+import PrimeField++import Curve.Weierstrass+import Curve.Weierstrass.BLS12381 (Fq)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS12381T curve.+data BLS12381T++-- | Field of points of BLS12381T curve.+data PolynomialU+instance IrreducibleMonic Fq PolynomialU where+ split _ = X2 + 1+type Fq2 = ExtensionField Fq PolynomialU++-- | Field of coefficients of BLS12381T curve.+type Fr = PrimeField 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001++-- | BLS12381T curve is a Weierstrass curve.+instance Curve 'Weierstrass c BLS12381T Fq2 Fr => WCurve c BLS12381T Fq2 Fr where+ a_ = const _a+ {-# INLINABLE a_ #-}+ b_ = const _b+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-}++-- | Affine BLS12381T curve point.+type PA = WAPoint BLS12381T Fq2 Fr++-- | Affine BLS12381T curve is a Weierstrass affine curve.+instance WACurve BLS12381T Fq2 Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BLS12381T point.+type PJ = WJPoint BLS12381T Fq2 Fr++-- | Jacobian BLS12381T curve is a Weierstrass Jacobian curve.+instance WJCurve BLS12381T Fq2 Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BLS12381T point.+type PP = WPPoint BLS12381T Fq2 Fr++-- | Projective BLS12381T curve is a Weierstrass projective curve.+instance WPCurve BLS12381T Fq2 Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS12381T curve.+_a :: Fq2+_a = toField [+ ]+{-# INLINABLE _a #-}++-- | Coefficient @B@ of BLS12381T curve.+_b :: Fq2+_b = toField [ 0x4+ , 0x4+ ]+{-# INLINABLE _b #-}++-- | Cofactor of BLS12381T curve.+_h :: Integer+_h = 0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5+{-# INLINABLE _h #-}++-- | Characteristic of BLS12381T curve.+_q :: Integer+_q = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab+{-# INLINABLE _q #-}++-- | Order of BLS12381T curve.+_r :: Integer+_r = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BLS12381T curve.+_x :: Fq2+_x = toField [ 0x24aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8+ , 0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e+ ]+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BLS12381T curve.+_y :: Fq2+_y = toField [ 0xce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801+ , 0x606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be+ ]+{-# INLINABLE _y #-}++-- | Generator of affine BLS12381T curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BLS12381T curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BLS12381T curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
− src/Curve/Weierstrass/BLS12_381.hs
@@ -1,74 +0,0 @@-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
@@ -1,86 +0,0 @@-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/BLS48581.hs view
@@ -0,0 +1,118 @@+module Curve.Weierstrass.BLS48581+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BLS48581+ ) where++import Protolude++import PrimeField++import Curve.Weierstrass++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS48581 curve.+data BLS48581++-- | Field of points of BLS48581 curve.+type Fq = PrimeField 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b++-- | Field of coefficients of BLS48581 curve.+type Fr = PrimeField 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01++-- | BLS48581 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BLS48581 Fq Fr => WCurve c BLS48581 Fq Fr where+ a_ = const _a+ {-# INLINABLE a_ #-}+ b_ = const _b+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-}++-- | Affine BLS48581 curve point.+type PA = WAPoint BLS48581 Fq Fr++-- | Affine BLS48581 curve is a Weierstrass affine curve.+instance WACurve BLS48581 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BLS48581 point.+type PJ = WJPoint BLS48581 Fq Fr++-- | Jacobian BLS48581 curve is a Weierstrass Jacobian curve.+instance WJCurve BLS48581 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BLS48581 point.+type PP = WPPoint BLS48581 Fq Fr++-- | Projective BLS48581 curve is a Weierstrass projective curve.+instance WPCurve BLS48581 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS48581 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-}++-- | Coefficient @B@ of BLS48581 curve.+_b :: Fq+_b = 0x1+{-# INLINABLE _b #-}++-- | Cofactor of BLS48581 curve.+_h :: Integer+_h = 0x85555841aaaec4ac+{-# INLINABLE _h #-}++-- | Characteristic of BLS48581 curve.+_q :: Integer+_q = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+{-# INLINABLE _q #-}++-- | Order of BLS48581 curve.+_r :: Integer+_r = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BLS48581 curve.+_x :: Fq+_x = 0x2af59b7ac340f2baf2b73df1e93f860de3f257e0e86868cf61abdbaedffb9f7544550546a9df6f9645847665d859236ebdbc57db368b11786cb74da5d3a1e6d8c3bce8732315af640+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BLS48581 curve.+_y :: Fq+_y = 0xcefda44f6531f91f86b3a2d1fb398a488a553c9efeb8a52e991279dd41b720ef7bb7beffb98aee53e80f678584c3ef22f487f77c2876d1b2e35f37aef7b926b576dbb5de3e2587a70+{-# INLINABLE _y #-}++-- | Generator of affine BLS48581 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BLS48581 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BLS48581 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
+ src/Curve/Weierstrass/BLS48581T.hs view
@@ -0,0 +1,168 @@+module Curve.Weierstrass.BLS48581T+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BLS48581T+ ) where++import Protolude++import ExtensionField+import PrimeField++import Curve.Weierstrass+import Curve.Weierstrass.BLS48581 (Fq)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | BLS48581T curve.+data BLS48581T++-- | Field of points of BLS48581T curve.+data PolynomialU+instance IrreducibleMonic Fq PolynomialU where+ split _ = X2 + 1+type Fq2 = ExtensionField Fq PolynomialU+data PolynomialV+instance IrreducibleMonic Fq2 PolynomialV where+ split _ = X2 + 1 + Y X+type Fq4 = ExtensionField Fq2 PolynomialV+data PolynomialW+instance IrreducibleMonic Fq4 PolynomialW where+ split _ = X2 + Y X+type Fq8 = ExtensionField Fq4 PolynomialW++-- | Field of coefficients of BLS48581T curve.+type Fr = PrimeField 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01++-- | BLS48581T curve is a Weierstrass curve.+instance Curve 'Weierstrass c BLS48581T Fq8 Fr => WCurve c BLS48581T Fq8 Fr where+ a_ = const _a+ {-# INLINABLE a_ #-}+ b_ = const _b+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-}++-- | Affine BLS48581T curve point.+type PA = WAPoint BLS48581T Fq8 Fr++-- | Affine BLS48581T curve is a Weierstrass affine curve.+instance WACurve BLS48581T Fq8 Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BLS48581T point.+type PJ = WJPoint BLS48581T Fq8 Fr++-- | Jacobian BLS48581T curve is a Weierstrass Jacobian curve.+instance WJCurve BLS48581T Fq8 Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BLS48581T point.+type PP = WPPoint BLS48581T Fq8 Fr++-- | Projective BLS48581T curve is a Weierstrass projective curve.+instance WPCurve BLS48581T Fq8 Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Coefficient @A@ of BLS48581T curve.+_a :: Fq8+_a = toField [+ ]+{-# INLINABLE _a #-}++-- | Coefficient @B@ of BLS48581T curve.+_b :: Fq8+_b = toField [ toField [+ ]+ , toField [ toField [+ ]+ , toField [ 0x9407b9ff9a3b7989c12718ea38095002b7427c6891098dd9df36078f9cbaa225245721d7b7041566ce6981ca7a39b6d7b41b3d2a898b877052bc7efb90d2524561f6e0aa732b2c895+ , 0x9407b9ff9a3b7989c12718ea38095002b7427c6891098dd9df36078f9cbaa225245721d7b7041566ce6981ca7a39b6d7b41b3d2a898b877052bc7efb90d2524561f6e0aa732b2c896+ ]+ ]+ ]+{-# INLINABLE _b #-}++-- | Cofactor of BLS48581T curve.+_h :: Integer+_h = 0x170e915cb0a6b7406b8d94042317f811d6bc3fc6e211ada42e58ccfcb3ac076a7e4499d700a0c23dc4b0c078f92def8c87b7fe63e1eea270db353a4ef4d38b5998ad8f0d042ea24c8f02be1c0c83992fe5d7725227bb27123a949e0876c0a8ce0a67326db0e955dcb791b867f31d6bfa62fbdd5f44a00504df04e186fae033f1eb43c1b1a08b6e086eff03c8fee9ebdd1e191a8a4b0466c90b389987de5637d5dd13dab33196bd2e5afa6cd19cf0fc3fc7db7ece1f3fac742626b1b02fcee04043b2ea96492f6afa51739597c54bb78aa6b0b99319fef9d09f768831018ee6564c68d054c62f2e0b4549426fec24ab26957a669dba2a2b6945ce40c9aec6afdeda16c79e15546cd7771fa544d5364236690ea06832679562a68731420ae52d0d35a90b8d10b688e31b6aee45f45b7a5083c71732105852decc888f64839a4de33b99521f0984a418d20fc7b0609530e454f0696fa2a8075ac01cc8ae3869e8d0fe1f3788ffac4c01aa2720e431da333c83d9663bfb1fb7a1a7b90528482c6be7892299030bb51a51dc7e91e9156874416bf4c26f1ea7ec578058563960ef92bbbb8632d3a1b695f954af10e9a78e40acffc13b06540aae9da5287fc4429485d44e6289d8c0d6a3eb2ece35012452751839fb48bc14b515478e2ff412d930ac20307561f3a5c998e6bcbfebd97effc6433033a2361bfcdc4fc74ad379a16c6dea49c209b1+{-# INLINABLE _h #-}++-- | Characteristic of BLS48581T curve.+_q :: Integer+_q = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b+{-# INLINABLE _q #-}++-- | Order of BLS48581T curve.+_r :: Integer+_r = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BLS48581T curve.+_x :: Fq8+_x = toField [ toField [ toField [ 0x5d615d9a7871e4a38237fa45a2775debabbefc70344dbccb7de64db3a2ef156c46ff79baad1a8c42281a63ca0612f400503004d80491f510317b79766322154dec34fd0b4ace8bfab+ , 0x7c4973ece2258512069b0e86abc07e8b22bb6d980e1623e9526f6da12307f4e1c3943a00abfedf16214a76affa62504f0c3c7630d979630ffd75556a01afa143f1669b36676b47c57+ ]+ , toField [ 0x1fccc70198f1334e1b2ea1853ad83bc73a8a6ca9ae237ca7a6d6957ccbab5ab6860161c1dbd19242ffae766f0d2a6d55f028cbdfbb879d5fea8ef4cded6b3f0b46488156ca55a3e6a+ , 0xbe2218c25ceb6185c78d8012954d4bfe8f5985ac62f3e5821b7b92a393f8be0cc218a95f63e1c776e6ec143b1b279b9468c31c5257c200ca52310b8cb4e80bc3f09a7033cbb7feafe+ ]+ ]+ , toField [ toField [ 0x38b91c600b35913a3c598e4caa9dd63007c675d0b1642b5675ff0e7c5805386699981f9e48199d5ac10b2ef492ae589274fad55fc1889aa80c65b5f746c9d4cbb739c3a1c53f8cce5+ , 0xc96c7797eb0738603f1311e4ecda088f7b8f35dcef0977a3d1a58677bb037418181df63835d28997eb57b40b9c0b15dd7595a9f177612f097fc7960910fce3370f2004d914a3c093a+ ]+ , toField [ 0xb9b7951c6061ee3f0197a498908aee660dea41b39d13852b6db908ba2c0b7a449cef11f293b13ced0fd0caa5efcf3432aad1cbe4324c22d63334b5b0e205c3354e41607e60750e057+ , 0x827d5c22fb2bdec5282624c4f4aaa2b1e5d7a9defaf47b5211cf741719728a7f9f8cfca93f29cff364a7190b7e2b0d4585479bd6aebf9fc44e56af2fc9e97c3f84e19da00fbc6ae34+ ]+ ]+ ]+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BLS48581T curve.+_y :: Fq8+_y = toField [ toField [ toField [ 0xeb53356c375b5dfa497216452f3024b918b4238059a577e6f3b39ebfc435faab0906235afa27748d90f7336d8ae5163c1599abf77eea6d659045012ab12c0ff323edd3fe4d2d7971+ , 0x284dc75979e0ff144da6531815fcadc2b75a422ba325e6fba01d72964732fcbf3afb096b243b1f192c5c3d1892ab24e1dd212fa097d760e2e588b423525ffc7b111471db936cd5665+ ]+ , toField [ 0xb36a201dd008523e421efb70367669ef2c2fc5030216d5b119d3a480d370514475f7d5c99d0e90411515536ca3295e5e2f0c1d35d51a652269cbc7c46fc3b8fde68332a526a2a8474+ , 0xaec25a4621edc0688223fbbd478762b1c2cded3360dcee23dd8b0e710e122d2742c89b224333fa40dced2817742770ba10d67bda503ee5e578fb3d8b8a1e5337316213da92841589d+ ]+ ]+ , toField [ toField [ 0xd209d5a223a9c46916503fa5a88325a2554dc541b43dd93b5a959805f1129857ed85c77fa238cdce8a1e2ca4e512b64f59f430135945d137b08857fdddfcf7a43f47831f982e50137+ , 0x7d0d03745736b7a513d339d5ad537b90421ad66eb16722b589d82e2055ab7504fa83420e8c270841f6824f47c180d139e3aafc198caa72b679da59ed8226cf3a594eedc58cf90bee4+ ]+ , toField [ 0x896767811be65ea25c2d05dfdd17af8a006f364fc0841b064155f14e4c819a6df98f425ae3a2864f22c1fab8c74b2618b5bb40fa639f53dccc9e884017d9aa62b3d41faeafeb23986+ , 0x35e2524ff89029d393a5c07e84f981b5e068f1406be8e50c87549b6ef8eca9a9533a3f8e69c31e97e1ad0333ec719205417300d8c4ab33f748e5ac66e84069c55d667ffcb732718b6+ ]+ ]+ ]+{-# INLINABLE _y #-}++-- | Generator of affine BLS48581T curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BLS48581T curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BLS48581T curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
− src/Curve/Weierstrass/BLS48_581.hs
@@ -1,74 +0,0 @@-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
@@ -1,130 +0,0 @@-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
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN224- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN224 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN224 curve+-- | BN224 curve. data BN224 --- | Field of BN224 curve-type Fp = PrimeField 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833+-- | Field of points of BN224 curve.+type Fq = PrimeField 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833 --- | BN224 curve is a Weierstrass curve-instance WCurve BN224 Fp where+-- | Field of coefficients of BN224 curve.+type Fr = PrimeField 0xfffffffffff107288ec29e602c4420db4218082b36c2accff76c58ed++-- | BN224 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN224 Fq Fr => WCurve c BN224 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN224 curve-type P = WPoint BN224 Fp+-- | Affine BN224 curve point.+type PA = WAPoint BN224 Fq Fr +-- | Affine BN224 curve is a Weierstrass affine curve.+instance WACurve BN224 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN224 point.+type PJ = WJPoint BN224 Fq Fr++-- | Jacobian BN224 curve is a Weierstrass Jacobian curve.+instance WJCurve BN224 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN224 point.+type PP = WPPoint BN224 Fq Fr++-- | Projective BN224 curve is a Weierstrass projective curve.+instance WPCurve BN224 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN224 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN224 curve-_b :: Fp-_b = 3-{-# INLINE _b #-}+-- | Coefficient @A@ of BN224 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN224 curve-_g :: P-_g = A- 1- 2-{-# INLINE _g #-}+-- | Coefficient @B@ of BN224 curve.+_b :: Fq+_b = 0x3+{-# INLINABLE _b #-} --- | Cofactor of BN224 curve+-- | Cofactor of BN224 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN224 curve-_n :: Integer-_n = 0xfffffffffff107288ec29e602c4420db4218082b36c2accff76c58ed-{-# INLINE _n #-}+-- | Characteristic of BN224 curve.+_q :: Integer+_q = 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833+{-# INLINABLE _q #-} --- | Characteristic of BN224 curve-_p :: Integer-_p = 0xfffffffffff107288ec29e602c4520db42180823bb907d1287127833-{-# INLINE _p #-}+-- | Order of BN224 curve.+_r :: Integer+_r = 0xfffffffffff107288ec29e602c4420db4218082b36c2accff76c58ed+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN224 curve.+_x :: Fq+_x = 0x1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN224 curve.+_y :: Fq+_y = 0x2+{-# INLINABLE _y #-}++-- | Generator of affine BN224 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN224 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN224 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN254.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN254- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN254 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN254 curve+-- | BN254 curve. data BN254 --- | Field of BN254 curve-type Fp = PrimeField 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+-- | Field of points of BN254 curve.+type Fq = PrimeField 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 --- | BN254 curve is a Weierstrass curve-instance WCurve BN254 Fp where+-- | Field of coefficients of BN254 curve.+type Fr = PrimeField 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001++-- | BN254 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN254 Fq Fr => WCurve c BN254 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN254 curve-type P = WPoint BN254 Fp+-- | Affine BN254 curve point.+type PA = WAPoint BN254 Fq Fr +-- | Affine BN254 curve is a Weierstrass affine curve.+instance WACurve BN254 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN254 point.+type PJ = WJPoint BN254 Fq Fr++-- | Jacobian BN254 curve is a Weierstrass Jacobian curve.+instance WJCurve BN254 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN254 point.+type PP = WPPoint BN254 Fq Fr++-- | Projective BN254 curve is a Weierstrass projective curve.+instance WPCurve BN254 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN254 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN254 curve-_b :: Fp-_b = 3-{-# INLINE _b #-}+-- | Coefficient @A@ of BN254 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN254 curve-_g :: P-_g = A- 1- 2-{-# INLINE _g #-}+-- | Coefficient @B@ of BN254 curve.+_b :: Fq+_b = 0x3+{-# INLINABLE _b #-} --- | Cofactor of BN254 curve+-- | Cofactor of BN254 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN254 curve-_n :: Integer-_n = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001-{-# INLINE _n #-}+-- | Characteristic of BN254 curve.+_q :: Integer+_q = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+{-# INLINABLE _q #-} --- | Characteristic of BN254 curve-_p :: Integer-_p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47-{-# INLINE _p #-}+-- | Order of BN254 curve.+_r :: Integer+_r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN254 curve.+_x :: Fq+_x = 0x1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN254 curve.+_y :: Fq+_y = 0x2+{-# INLINABLE _y #-}++-- | Generator of affine BN254 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN254 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN254 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN254A.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN254A- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN254A ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN254A curve+-- | BN254A curve. data BN254A --- | Field of BN254A curve-type Fp = PrimeField 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+-- | Field of points of BN254A curve.+type Fq = PrimeField 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001 --- | BN254A curve is a Weierstrass curve-instance WCurve BN254A Fp where+-- | Field of coefficients of BN254A curve.+type Fr = PrimeField 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001++-- | BN254A curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN254A Fq Fr => WCurve c BN254A Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN254A curve-type P = WPoint BN254A Fp+-- | Affine BN254A curve point.+type PA = WAPoint BN254A Fq Fr +-- | Affine BN254A curve is a Weierstrass affine curve.+instance WACurve BN254A Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN254A point.+type PJ = WJPoint BN254A Fq Fr++-- | Jacobian BN254A curve is a Weierstrass Jacobian curve.+instance WJCurve BN254A Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN254A point.+type PP = WPPoint BN254A Fq Fr++-- | Projective BN254A curve is a Weierstrass projective curve.+instance WPCurve BN254A Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN254A curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN254A curve-_b :: Fp-_b = 5-{-# INLINE _b #-}+-- | Coefficient @A@ of BN254A curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN254A curve-_g :: P-_g = A- 1- 0xd45589b158faaf6ab0e4ad38d998e9982e7ff63964ee1460342a592677cccb0-{-# INLINE _g #-}+-- | Coefficient @B@ of BN254A curve.+_b :: Fq+_b = 0x5+{-# INLINABLE _b #-} --- | Cofactor of BN254A curve+-- | Cofactor of BN254A curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN254A curve-_n :: Integer-_n = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001-{-# INLINE _n #-}+-- | Characteristic of BN254A curve.+_q :: Integer+_q = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+{-# INLINABLE _q #-} --- | Characteristic of BN254A curve-_p :: Integer-_p = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001-{-# INLINE _p #-}+-- | Order of BN254A curve.+_r :: Integer+_r = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN254A curve.+_x :: Fq+_x = 0x1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN254A curve.+_y :: Fq+_y = 0xd45589b158faaf6ab0e4ad38d998e9982e7ff63964ee1460342a592677cccb0+{-# INLINABLE _y #-}++-- | Generator of affine BN254A curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN254A curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN254A curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN254AT.hs view
@@ -1,86 +1,130 @@ module Curve.Weierstrass.BN254AT- ( Fp2- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN254AT ) where import Protolude -import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)+import ExtensionField+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)-import Curve.Weierstrass.BN254A (Fp)+import Curve.Weierstrass+import Curve.Weierstrass.BN254A (Fq) ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN254AT curve+-- | BN254AT curve. data BN254AT --- | Field of BN254AT curve+-- | Field of points of BN254AT curve. data PolynomialU-instance IrreducibleMonic Fp PolynomialU where- split _ = x ^ (2 :: Int) + 5-type Fp2 = ExtensionField Fp PolynomialU+instance IrreducibleMonic Fq PolynomialU where+ split _ = X2 + 5+type Fq2 = ExtensionField Fq PolynomialU --- | BN254AT curve is a Weierstrass curve-instance WCurve BN254AT Fp2 where+-- | Field of coefficients of BN254AT curve.+type Fr = PrimeField 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001++-- | BN254AT curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN254AT Fq2 Fr => WCurve c BN254AT Fq2 Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN254AT curve-type P = WPoint BN254AT Fp2+-- | Affine BN254AT curve point.+type PA = WAPoint BN254AT Fq2 Fr +-- | Affine BN254AT curve is a Weierstrass affine curve.+instance WACurve BN254AT Fq2 Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN254AT point.+type PJ = WJPoint BN254AT Fq2 Fr++-- | Jacobian BN254AT curve is a Weierstrass Jacobian curve.+instance WJCurve BN254AT Fq2 Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN254AT point.+type PP = WPPoint BN254AT Fq2 Fr++-- | Projective BN254AT curve is a Weierstrass projective curve.+instance WPCurve BN254AT Fq2 Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- 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 #-}+-- | Coefficient @A@ of BN254AT curve.+_a :: Fq2+_a = toField [+ ]+{-# INLINABLE _a #-} --- | Generator of BN254AT curve-_g :: P-_g = A- ( fromList- [ 0x19b0bea4afe4c330da93cc3533da38a9f430b471c6f8a536e81962ed967909b5- , 0xa1cf585585a61c6e9880b1f2a5c539f7d906fff238fa6341e1de1a2e45c3f72- ]- )- ( fromList- [ 0x17abd366ebbd65333e49c711a80a0cf6d24adf1b9b3990eedcc91731384d2627- , 0xee97d6de9902a27d00e952232a78700863bc9aa9be960C32f5bf9fd0a32d345- ]- )-{-# INLINE _g #-}+-- | Coefficient @B@ of BN254AT curve.+_b :: Fq2+_b = toField [ 0x0+ , 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000000+ ]+{-# INLINABLE _b #-} --- | Cofactor of BN254AT curve+-- | Cofactor of BN254AT curve. _h :: Integer _h = 0x2370fb049d410fbe4e761a9886e50241dc42cf101e0000017e80600000000001-{-# INLINE _h #-}+{-# INLINABLE _h #-} --- | Order of BN254AT curve-_n :: Integer-_n = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001-{-# INLINE _n #-}+-- | Characteristic of BN254AT curve.+_q :: Integer+_q = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001+{-# INLINABLE _q #-} --- | Characteristic of BN254AT curve-_p :: Integer-_p = 0x2370fb049d410fbe4e761a9886e502417d023f40180000017e80600000000001-{-# INLINE _p #-}+-- | Order of BN254AT curve.+_r :: Integer+_r = 0x2370fb049d410fbe4e761a9886e502411dc1af70120000017e80600000000001+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN254AT curve.+_x :: Fq2+_x = toField [ 0x19b0bea4afe4c330da93cc3533da38a9f430b471c6f8a536e81962ed967909b5+ , 0xa1cf585585a61c6e9880b1f2a5c539f7d906fff238fa6341e1de1a2e45c3f72+ ]+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN254AT curve.+_y :: Fq2+_y = toField [ 0x17abd366ebbd65333e49c711a80a0cf6d24adf1b9b3990eedcc91731384d2627+ , 0xee97d6de9902a27d00e952232a78700863bc9aa9be960c32f5bf9fd0a32d345+ ]+{-# INLINABLE _y #-}++-- | Generator of affine BN254AT curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN254AT curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN254AT curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN254B.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN254B- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN254B ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN254B curve+-- | BN254B curve. data BN254B --- | Field of BN254B curve-type Fp = PrimeField 0x2523648240000001ba344d80000000086121000000000013a700000000000013+-- | Field of points of BN254B curve.+type Fq = PrimeField 0x2523648240000001ba344d80000000086121000000000013a700000000000013 --- | BN254B curve is a Weierstrass curve-instance WCurve BN254B Fp where+-- | Field of coefficients of BN254B curve.+type Fr = PrimeField 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d++-- | BN254B curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN254B Fq Fr => WCurve c BN254B Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN254B curve-type P = WPoint BN254B Fp+-- | Affine BN254B curve point.+type PA = WAPoint BN254B Fq Fr +-- | Affine BN254B curve is a Weierstrass affine curve.+instance WACurve BN254B Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN254B point.+type PJ = WJPoint BN254B Fq Fr++-- | Jacobian BN254B curve is a Weierstrass Jacobian curve.+instance WJCurve BN254B Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN254B point.+type PP = WPPoint BN254B Fq Fr++-- | Projective BN254B curve is a Weierstrass projective curve.+instance WPCurve BN254B Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN254B curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN254B curve-_b :: Fp-_b = 2-{-# INLINE _b #-}+-- | Coefficient @A@ of BN254B curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN254B curve-_g :: P-_g = A- 0x2523648240000001ba344d80000000086121000000000013a700000000000012- 1-{-# INLINE _g #-}+-- | Coefficient @B@ of BN254B curve.+_b :: Fq+_b = 0x2+{-# INLINABLE _b #-} --- | Cofactor of BN254B curve+-- | Cofactor of BN254B curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN254B curve-_n :: Integer-_n = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d-{-# INLINE _n #-}+-- | Characteristic of BN254B curve.+_q :: Integer+_q = 0x2523648240000001ba344d80000000086121000000000013a700000000000013+{-# INLINABLE _q #-} --- | Characteristic of BN254B curve-_p :: Integer-_p = 0x2523648240000001ba344d80000000086121000000000013a700000000000013-{-# INLINE _p #-}+-- | Order of BN254B curve.+_r :: Integer+_r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN254B curve.+_x :: Fq+_x = 0x2523648240000001ba344d80000000086121000000000013a700000000000012+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN254B curve.+_y :: Fq+_y = 0x1+{-# INLINABLE _y #-}++-- | Generator of affine BN254B curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN254B curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN254B curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN254BT.hs view
@@ -1,86 +1,130 @@ module Curve.Weierstrass.BN254BT- ( Fp2- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN254BT ) where import Protolude -import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)+import ExtensionField+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)-import Curve.Weierstrass.BN254B (Fp)+import Curve.Weierstrass+import Curve.Weierstrass.BN254B (Fq) ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN254BT curve+-- | BN254BT curve. data BN254BT --- | Field of BN254BT curve+-- | Field of points of BN254BT curve. data PolynomialU-instance IrreducibleMonic Fp PolynomialU where- split _ = x ^ (2 :: Int) + 1-type Fp2 = ExtensionField Fp PolynomialU+instance IrreducibleMonic Fq PolynomialU where+ split _ = X2 + 1+type Fq2 = ExtensionField Fq PolynomialU --- | BN254BT curve is a Weierstrass curve-instance WCurve BN254BT Fp2 where+-- | Field of coefficients of BN254BT curve.+type Fr = PrimeField 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d++-- | BN254BT curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN254BT Fq2 Fr => WCurve c BN254BT Fq2 Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN254BT curve-type P = WPoint BN254BT Fp2+-- | Affine BN254BT curve point.+type PA = WAPoint BN254BT Fq2 Fr +-- | Affine BN254BT curve is a Weierstrass affine curve.+instance WACurve BN254BT Fq2 Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN254BT point.+type PJ = WJPoint BN254BT Fq2 Fr++-- | Jacobian BN254BT curve is a Weierstrass Jacobian curve.+instance WJCurve BN254BT Fq2 Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN254BT point.+type PP = WPPoint BN254BT Fq2 Fr++-- | Projective BN254BT curve is a Weierstrass projective curve.+instance WPCurve BN254BT Fq2 Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- 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 #-}+-- | Coefficient @A@ of BN254BT curve.+_a :: Fq2+_a = toField [+ ]+{-# INLINABLE _a #-} --- | Generator of BN254BT curve-_g :: P-_g = A- ( fromList- [ 0x61a10bb519eb62feb8d8c7e8c61edb6a4648bbb4898bf0d91ee4224c803fb2b- , 0x516aaf9ba737833310aa78c5982aa5b1f4d746bae3784b70d8c34c1e7d54cf3- ]- )- ( fromList- [ 0x21897a06baf93439a90e096698c822329bd0ae6bdbe09bd19f0e07891cd2b9a- , 0xebb2b0e7c8b15268f6d4456f5f38d37b09006ffd739c9578a2d1aec6b3ace9b- ]- )-{-# INLINE _g #-}+-- | Coefficient @B@ of BN254BT curve.+_b :: Fq2+_b = toField [ 0x1+ , 0x2523648240000001ba344d80000000086121000000000013a700000000000012+ ]+{-# INLINABLE _b #-} --- | Cofactor of BN254BT curve+-- | Cofactor of BN254BT curve. _h :: Integer _h = 0x2523648240000001ba344d8000000008c2a2800000000016ad00000000000019-{-# INLINE _h #-}+{-# INLINABLE _h #-} --- | Order of BN254BT curve-_n :: Integer-_n = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d-{-# INLINE _n #-}+-- | Characteristic of BN254BT curve.+_q :: Integer+_q = 0x2523648240000001ba344d80000000086121000000000013a700000000000013+{-# INLINABLE _q #-} --- | Characteristic of BN254BT curve-_p :: Integer-_p = 0x2523648240000001ba344d80000000086121000000000013a700000000000013-{-# INLINE _p #-}+-- | Order of BN254BT curve.+_r :: Integer+_r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN254BT curve.+_x :: Fq2+_x = toField [ 0x61a10bb519eb62feb8d8c7e8c61edb6a4648bbb4898bf0d91ee4224c803fb2b+ , 0x516aaf9ba737833310aa78c5982aa5b1f4d746bae3784b70d8c34c1e7d54cf3+ ]+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN254BT curve.+_y :: Fq2+_y = toField [ 0x21897a06baf93439a90e096698c822329bd0ae6bdbe09bd19f0e07891cd2b9a+ , 0xebb2b0e7c8b15268f6d4456f5f38d37b09006ffd739c9578a2d1aec6b3ace9b+ ]+{-# INLINABLE _y #-}++-- | Generator of affine BN254BT curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN254BT curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN254BT curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN254T.hs view
@@ -1,86 +1,130 @@ module Curve.Weierstrass.BN254T- ( Fp2- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN254T ) where import Protolude -import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)+import ExtensionField+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)-import Curve.Weierstrass.BN254 (Fp)+import Curve.Weierstrass+import Curve.Weierstrass.BN254 (Fq) ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN254T curve+-- | BN254T curve. data BN254T --- | Field of BN254T curve+-- | Field of points of BN254T curve. data PolynomialU-instance IrreducibleMonic Fp PolynomialU where- split _ = x ^ (2 :: Int) + 1-type Fp2 = ExtensionField Fp PolynomialU+instance IrreducibleMonic Fq PolynomialU where+ split _ = X2 + 1+type Fq2 = ExtensionField Fq PolynomialU --- | BN254T curve is a Weierstrass curve-instance WCurve BN254T Fp2 where+-- | Field of coefficients of BN254T curve.+type Fr = PrimeField 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001++-- | BN254T curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN254T Fq2 Fr => WCurve c BN254T Fq2 Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN254T curve-type P = WPoint BN254T Fp2+-- | Affine BN254T curve point.+type PA = WAPoint BN254T Fq2 Fr +-- | Affine BN254T curve is a Weierstrass affine curve.+instance WACurve BN254T Fq2 Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN254T point.+type PJ = WJPoint BN254T Fq2 Fr++-- | Jacobian BN254T curve is a Weierstrass Jacobian curve.+instance WJCurve BN254T Fq2 Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN254T point.+type PP = WPPoint BN254T Fq2 Fr++-- | Projective BN254T curve is a Weierstrass projective curve.+instance WPCurve BN254T Fq2 Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- 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 #-}+-- | Coefficient @A@ of BN254T curve.+_a :: Fq2+_a = toField [+ ]+{-# INLINABLE _a #-} --- | Generator of BN254T curve-_g :: P-_g = A- ( fromList- [ 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed- , 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2- ]- )- ( fromList- [ 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa- , 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b- ]- )-{-# INLINE _g #-}+-- | Coefficient @B@ of BN254T curve.+_b :: Fq2+_b = toField [ 0x2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5+ , 0x9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2+ ]+{-# INLINABLE _b #-} --- | Cofactor of BN254T curve+-- | Cofactor of BN254T curve. _h :: Integer _h = 0x30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d-{-# INLINE _h #-}+{-# INLINABLE _h #-} --- | Order of BN254T curve-_n :: Integer-_n = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001-{-# INLINE _n #-}+-- | Characteristic of BN254T curve.+_q :: Integer+_q = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+{-# INLINABLE _q #-} --- | Characteristic of BN254T curve-_p :: Integer-_p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47-{-# INLINE _p #-}+-- | Order of BN254T curve.+_r :: Integer+_r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN254T curve.+_x :: Fq2+_x = toField [ 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed+ , 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2+ ]+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN254T curve.+_y :: Fq2+_y = toField [ 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa+ , 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b+ ]+{-# INLINABLE _y #-}++-- | Generator of affine BN254T curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN254T curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN254T curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN256.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN256- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN256 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN256 curve+-- | BN256 curve. data BN256 --- | Field of BN256 curve-type Fp = PrimeField 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013+-- | Field of points of BN256 curve.+type Fq = PrimeField 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013 --- | BN256 curve is a Weierstrass curve-instance WCurve BN256 Fp where+-- | Field of coefficients of BN256 curve.+type Fr = PrimeField 0xfffffffffffcf0cd46e5f25eee71a49e0cdc65fb1299921af62d536cd10b500d++-- | BN256 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN256 Fq Fr => WCurve c BN256 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN256 curve-type P = WPoint BN256 Fp+-- | Affine BN256 curve point.+type PA = WAPoint BN256 Fq Fr +-- | Affine BN256 curve is a Weierstrass affine curve.+instance WACurve BN256 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN256 point.+type PJ = WJPoint BN256 Fq Fr++-- | Jacobian BN256 curve is a Weierstrass Jacobian curve.+instance WJCurve BN256 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN256 point.+type PP = WPPoint BN256 Fq Fr++-- | Projective BN256 curve is a Weierstrass projective curve.+instance WPCurve BN256 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN256 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN256 curve-_b :: Fp-_b = 3-{-# INLINE _b #-}+-- | Coefficient @A@ of BN256 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN256 curve-_g :: P-_g = A- 1- 2-{-# INLINE _g #-}+-- | Coefficient @B@ of BN256 curve.+_b :: Fq+_b = 0x3+{-# INLINABLE _b #-} --- | Cofactor of BN256 curve+-- | Cofactor of BN256 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN256 curve-_n :: Integer-_n = 0xfffffffffffcf0cd46e5f25eee71a49e0cdc65fb1299921af62d536cd10b500d-{-# INLINE _n #-}+-- | Characteristic of BN256 curve.+_q :: Integer+_q = 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013+{-# INLINABLE _q #-} --- | Characteristic of BN256 curve-_p :: Integer-_p = 0xfffffffffffcf0cd46e5f25eee71a49f0cdc65fb12980a82d3292ddbaed33013-{-# INLINE _p #-}+-- | Order of BN256 curve.+_r :: Integer+_r = 0xfffffffffffcf0cd46e5f25eee71a49e0cdc65fb1299921af62d536cd10b500d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN256 curve.+_x :: Fq+_x = 0x1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN256 curve.+_y :: Fq+_y = 0x2+{-# INLINABLE _y #-}++-- | Generator of affine BN256 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN256 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN256 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN384.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN384- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN384 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN384 curve+-- | BN384 curve. data BN384 --- | Field of BN384 curve-type Fp = PrimeField 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b+-- | Field of points of BN384 curve.+type Fq = PrimeField 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b --- | BN384 curve is a Weierstrass curve-instance WCurve BN384 Fp where+-- | Field of coefficients of BN384 curve.+type Fr = PrimeField 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca023c8fbe29531892c795356487d8ac63e4f4db17384341a5775++-- | BN384 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN384 Fq Fr => WCurve c BN384 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN384 curve-type P = WPoint BN384 Fp+-- | Affine BN384 curve point.+type PA = WAPoint BN384 Fq Fr +-- | Affine BN384 curve is a Weierstrass affine curve.+instance WACurve BN384 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN384 point.+type PJ = WJPoint BN384 Fq Fr++-- | Jacobian BN384 curve is a Weierstrass Jacobian curve.+instance WJCurve BN384 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN384 point.+type PP = WPPoint BN384 Fq Fr++-- | Projective BN384 curve is a Weierstrass projective curve.+instance WPCurve BN384 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN384 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN384 curve-_b :: Fp-_b = 3-{-# INLINE _b #-}+-- | Coefficient @A@ of BN384 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN384 curve-_g :: P-_g = A- 1- 2-{-# INLINE _g #-}+-- | Coefficient @B@ of BN384 curve.+_b :: Fq+_b = 0x3+{-# INLINABLE _b #-} --- | Cofactor of BN384 curve+-- | Cofactor of BN384 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN384 curve-_n :: Integer-_n = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca023c8fbe29531892c795356487d8ac63e4f4db17384341a5775-{-# INLINE _n #-}+-- | Characteristic of BN384 curve.+_q :: Integer+_q = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b+{-# INLINABLE _q #-} --- | Characteristic of BN384 curve-_p :: Integer-_p = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca024c8fbe29531892c79534f9d306328261550a7cabd7cccd10b-{-# INLINE _p #-}+-- | Order of BN384 curve.+_r :: Integer+_r = 0xfffffffffffffffffff2a96823d5920d2a127e3f6fbca023c8fbe29531892c795356487d8ac63e4f4db17384341a5775+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN384 curve.+_x :: Fq+_x = 0x1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN384 curve.+_y :: Fq+_y = 0x2+{-# INLINABLE _y #-}++-- | Generator of affine BN384 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN384 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN384 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN462.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN462- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN462 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN462 curve+-- | BN462 curve. data BN462 --- | Field of BN462 curve-type Fp = PrimeField 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+-- | Field of points of BN462 curve.+type Fq = PrimeField 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013 --- | BN462 curve is a Weierstrass curve-instance WCurve BN462 Fp where+-- | Field of coefficients of BN462 curve.+type Fr = PrimeField 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d++-- | BN462 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN462 Fq Fr => WCurve c BN462 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN462 curve-type P = WPoint BN462 Fp+-- | Affine BN462 curve point.+type PA = WAPoint BN462 Fq Fr +-- | Affine BN462 curve is a Weierstrass affine curve.+instance WACurve BN462 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN462 point.+type PJ = WJPoint BN462 Fq Fr++-- | Jacobian BN462 curve is a Weierstrass Jacobian curve.+instance WJCurve BN462 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN462 point.+type PP = WPPoint BN462 Fq Fr++-- | Projective BN462 curve is a Weierstrass projective curve.+instance WPCurve BN462 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN462 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN462 curve-_b :: Fp-_b = 5-{-# INLINE _b #-}+-- | Coefficient @A@ of BN462 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN462 curve-_g :: P-_g = A- 0x21a6d67ef250191fadba34a0a30160b9ac9264b6f95f63b3edbec3cf4b2e689db1bbb4e69a416a0b1e79239c0372e5cd70113c98d91f36b6980d- 0x118ea0460f7f7abb82b33676a7432a490eeda842cccfa7d788c659650426e6af77df11b8ae40eb80f475432c66600622ecaa8a5734d36fb03de-{-# INLINE _g #-}+-- | Coefficient @B@ of BN462 curve.+_b :: Fq+_b = 0x5+{-# INLINABLE _b #-} --- | Cofactor of BN462 curve+-- | Cofactor of BN462 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN462 curve-_n :: Integer-_n = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d-{-# INLINE _n #-}+-- | Characteristic of BN462 curve.+_q :: Integer+_q = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+{-# INLINABLE _q #-} --- | Characteristic of BN462 curve-_p :: Integer-_p = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013-{-# INLINE _p #-}+-- | Order of BN462 curve.+_r :: Integer+_r = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN462 curve.+_x :: Fq+_x = 0x21a6d67ef250191fadba34a0a30160b9ac9264b6f95f63b3edbec3cf4b2e689db1bbb4e69a416a0b1e79239c0372e5cd70113c98d91f36b6980d+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN462 curve.+_y :: Fq+_y = 0x118ea0460f7f7abb82b33676a7432a490eeda842cccfa7d788c659650426e6af77df11b8ae40eb80f475432c66600622ecaa8a5734d36fb03de+{-# INLINABLE _y #-}++-- | Generator of affine BN462 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN462 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN462 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN462T.hs view
@@ -1,86 +1,130 @@ module Curve.Weierstrass.BN462T- ( Fp2- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN462T ) where import Protolude -import ExtensionField (ExtensionField, IrreducibleMonic(..), fromList, x)+import ExtensionField+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)-import Curve.Weierstrass.BN462 (Fp)+import Curve.Weierstrass+import Curve.Weierstrass.BN462 (Fq) ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN462T curve+-- | BN462T curve. data BN462T --- | Field of BN462T curve+-- | Field of points of BN462T curve. data PolynomialU-instance IrreducibleMonic Fp PolynomialU where- split _ = x ^ (2 :: Int) + 1-type Fp2 = ExtensionField Fp PolynomialU+instance IrreducibleMonic Fq PolynomialU where+ split _ = X2 + 1+type Fq2 = ExtensionField Fq PolynomialU --- | BN462T curve is a Weierstrass curve-instance WCurve BN462T Fp2 where+-- | Field of coefficients of BN462T curve.+type Fr = PrimeField 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d++-- | BN462T curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN462T Fq2 Fr => WCurve c BN462T Fq2 Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN462T curve-type P = WPoint BN462T Fp2+-- | Affine BN462T curve point.+type PA = WAPoint BN462T Fq2 Fr +-- | Affine BN462T curve is a Weierstrass affine curve.+instance WACurve BN462T Fq2 Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN462T point.+type PJ = WJPoint BN462T Fq2 Fr++-- | Jacobian BN462T curve is a Weierstrass Jacobian curve.+instance WJCurve BN462T Fq2 Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN462T point.+type PP = WPPoint BN462T Fq2 Fr++-- | Projective BN462T curve is a Weierstrass projective curve.+instance WPCurve BN462T Fq2 Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- 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 #-}+-- | Coefficient @A@ of BN462T curve.+_a :: Fq2+_a = toField [+ ]+{-# INLINABLE _a #-} --- | Generator of BN462T curve-_g :: P-_g = A- ( fromList- [ 0x257ccc85b58dda0dfb38e3a8cbdc5482e0337e7c1cd96ed61c913820408208f9ad2699bad92e0032ae1f0aa6a8b48807695468e3d934ae1e4df- , 0x1d2e4343e8599102af8edca849566ba3c98e2a354730cbed9176884058b18134dd86bae555b783718f50af8b59bf7e850e9b73108ba6aa8cd283- ]- )- ( fromList- [ 0xa0650439da22c1979517427a20809eca035634706e23c3fa7a6bb42fe810f1399a1f41c9ddae32e03695a140e7b11d7c3376e5b68df0db7154e- , 0x73ef0cbd438cbe0172c8ae37306324d44d5e6b0c69ac57b393f1ab370fd725cc647692444a04ef87387aa68d53743493b9eba14cc552ca2a93a- ]- )-{-# INLINE _g #-}+-- | Coefficient @B@ of BN462T curve.+_b :: Fq2+_b = toField [ 0x2+ , 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138012+ ]+{-# INLINABLE _b #-} --- | Cofactor of BN462T curve+-- | Cofactor of BN462T curve. _h :: Integer _h = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908fa1ce0227fffffffff6ff66fc63f5f7f4c0000000002401b008a0168019-{-# INLINE _h #-}+{-# INLINABLE _h #-} --- | Order of BN462T curve-_n :: Integer-_n = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d-{-# INLINE _n #-}+-- | Characteristic of BN462T curve.+_q :: Integer+_q = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013+{-# INLINABLE _q #-} --- | Characteristic of BN462T curve-_p :: Integer-_p = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908f41c8020ffffffffff6ff66fc6ff687f640000000002401b00840138013-{-# INLINE _p #-}+-- | Order of BN462T curve.+_r :: Integer+_r = 0x240480360120023ffffffffff6ff0cf6b7d9bfca0000000000d812908ee1c201f7fffffffff6ff66fc7bf717f7c0000000002401b007e010800d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN462T curve.+_x :: Fq2+_x = toField [ 0x257ccc85b58dda0dfb38e3a8cbdc5482e0337e7c1cd96ed61c913820408208f9ad2699bad92e0032ae1f0aa6a8b48807695468e3d934ae1e4df+ , 0x1d2e4343e8599102af8edca849566ba3c98e2a354730cbed9176884058b18134dd86bae555b783718f50af8b59bf7e850e9b73108ba6aa8cd283+ ]+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN462T curve.+_y :: Fq2+_y = toField [ 0xa0650439da22c1979517427a20809eca035634706e23c3fa7a6bb42fe810f1399a1f41c9ddae32e03695a140e7b11d7c3376e5b68df0db7154e+ , 0x73ef0cbd438cbe0172c8ae37306324d44d5e6b0c69ac57b393f1ab370fd725cc647692444a04ef87387aa68d53743493b9eba14cc552ca2a93a+ ]+{-# INLINABLE _y #-}++-- | Generator of affine BN462T curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN462T curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN462T curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BN512.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BN512- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BN512 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | BN512 curve+-- | BN512 curve. data BN512 --- | Field of BN512 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33+-- | Field of points of BN512 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33 --- | BN512 curve is a Weierstrass curve-instance WCurve BN512 Fp where+-- | Field of coefficients of BN512 curve.+type Fr = PrimeField 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef445146cf1eacbe98b8e48c65deab2679a34a10313e04f9a2b406a64a5f519a09ed++-- | BN512 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BN512 Fq Fr => WCurve c BN512 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of BN512 curve-type P = WPoint BN512 Fp+-- | Affine BN512 curve point.+type PA = WAPoint BN512 Fq Fr +-- | Affine BN512 curve is a Weierstrass affine curve.+instance WACurve BN512 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BN512 point.+type PJ = WJPoint BN512 Fq Fr++-- | Jacobian BN512 curve is a Weierstrass Jacobian curve.+instance WJCurve BN512 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BN512 point.+type PP = WPPoint BN512 Fq Fr++-- | Projective BN512 curve is a Weierstrass projective curve.+instance WPCurve BN512 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of BN512 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of BN512 curve-_b :: Fp-_b = 3-{-# INLINE _b #-}+-- | Coefficient @A@ of BN512 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of BN512 curve-_g :: P-_g = A- 1- 2-{-# INLINE _g #-}+-- | Coefficient @B@ of BN512 curve.+_b :: Fq+_b = 0x3+{-# INLINABLE _b #-} --- | Cofactor of BN512 curve+-- | Cofactor of BN512 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of BN512 curve-_n :: Integer-_n = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef445146cf1eacbe98b8e48c65deab2679a34a10313e04f9a2b406a64a5f519a09ed-{-# INLINE _n #-}+-- | Characteristic of BN512 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33+{-# INLINABLE _q #-} --- | Characteristic of BN512 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef455146cf1eacbe98b8e48c65deab236fe1916a55ce5f4c6467b4eb280922adef33-{-# INLINE _p #-}+-- | Order of BN512 curve.+_r :: Integer+_r = 0xfffffffffffffffffffffffffff9ec7f01c60ba1d8cb5307c0bbe3c111b0ef445146cf1eacbe98b8e48c65deab2679a34a10313e04f9a2b406a64a5f519a09ed+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BN512 curve.+_x :: Fq+_x = 0x1+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BN512 curve.+_y :: Fq+_y = 0x2+{-# INLINABLE _y #-}++-- | Generator of affine BN512 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BN512 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BN512 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP160R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP160R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP160R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P160R1 curve+-- | BrainpoolP160R1 curve. data BrainpoolP160R1 --- | Field of Brainpool-P160R1 curve-type Fp = PrimeField 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+-- | Field of points of BrainpoolP160R1 curve.+type Fq = PrimeField 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f --- | Brainpool-P160R1 curve is a Weierstrass curve-instance WCurve BrainpoolP160R1 Fp where+-- | Field of coefficients of BrainpoolP160R1 curve.+type Fr = PrimeField 0xe95e4a5f737059dc60df5991d45029409e60fc09++-- | BrainpoolP160R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP160R1 Fq Fr => WCurve c BrainpoolP160R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P160R1 curve-type P = WPoint BrainpoolP160R1 Fp+-- | Affine BrainpoolP160R1 curve point.+type PA = WAPoint BrainpoolP160R1 Fq Fr +-- | Affine BrainpoolP160R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP160R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP160R1 point.+type PJ = WJPoint BrainpoolP160R1 Fq Fr++-- | Jacobian BrainpoolP160R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP160R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP160R1 point.+type PP = WPPoint BrainpoolP160R1 Fq Fr++-- | Projective BrainpoolP160R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP160R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P160R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP160R1 curve.+_a :: Fq _a = 0x340e7be2a280eb74e2be61bada745d97e8f7c300-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P160R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP160R1 curve.+_b :: Fq _b = 0x1e589a8595423412134faa2dbdec95c8d8675e58-{-# INLINE _b #-}---- | Generator of Brainpool-P160R1 curve-_g :: P-_g = A- 0xbed5af16ea3f6a4f62938c4631eb5af7bdbcdbc3- 0x1667cb477a1a8ec338f94741669c976316da6321-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P160R1 curve+-- | Cofactor of BrainpoolP160R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P160R1 curve-_n :: Integer-_n = 0xe95e4a5f737059dc60df5991d45029409e60fc09-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP160R1 curve.+_q :: Integer+_q = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P160R1 curve-_p :: Integer-_p = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f-{-# INLINE _p #-}+-- | Order of BrainpoolP160R1 curve.+_r :: Integer+_r = 0xe95e4a5f737059dc60df5991d45029409e60fc09+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP160R1 curve.+_x :: Fq+_x = 0xbed5af16ea3f6a4f62938c4631eb5af7bdbcdbc3+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP160R1 curve.+_y :: Fq+_y = 0x1667cb477a1a8ec338f94741669c976316da6321+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP160R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP160R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP160R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP160T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP160T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP160T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P160T1 curve+-- | BrainpoolP160T1 curve. data BrainpoolP160T1 --- | Field of Brainpool-P160T1 curve-type Fp = PrimeField 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+-- | Field of points of BrainpoolP160T1 curve.+type Fq = PrimeField 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f --- | Brainpool-P160T1 curve is a Weierstrass curve-instance WCurve BrainpoolP160T1 Fp where+-- | Field of coefficients of BrainpoolP160T1 curve.+type Fr = PrimeField 0xe95e4a5f737059dc60df5991d45029409e60fc09++-- | BrainpoolP160T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP160T1 Fq Fr => WCurve c BrainpoolP160T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P160T1 curve-type P = WPoint BrainpoolP160T1 Fp+-- | Affine BrainpoolP160T1 curve point.+type PA = WAPoint BrainpoolP160T1 Fq Fr +-- | Affine BrainpoolP160T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP160T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP160T1 point.+type PJ = WJPoint BrainpoolP160T1 Fq Fr++-- | Jacobian BrainpoolP160T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP160T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP160T1 point.+type PP = WPPoint BrainpoolP160T1 Fq Fr++-- | Projective BrainpoolP160T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP160T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P160T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP160T1 curve.+_a :: Fq _a = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620c-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P160T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP160T1 curve.+_b :: Fq _b = 0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380-{-# INLINE _b #-}---- | Generator of Brainpool-P160T1 curve-_g :: P-_g = A- 0xb199b13b9b34efc1397e64baeb05acc265ff2378- 0xadd6718b7c7c1961f0991b842443772152c9e0ad-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P160T1 curve+-- | Cofactor of BrainpoolP160T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P160T1 curve-_n :: Integer-_n = 0xe95e4a5f737059dc60df5991d45029409e60fc09-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP160T1 curve.+_q :: Integer+_q = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P160T1 curve-_p :: Integer-_p = 0xe95e4a5f737059dc60dfc7ad95b3d8139515620f-{-# INLINE _p #-}+-- | Order of BrainpoolP160T1 curve.+_r :: Integer+_r = 0xe95e4a5f737059dc60df5991d45029409e60fc09+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP160T1 curve.+_x :: Fq+_x = 0xb199b13b9b34efc1397e64baeb05acc265ff2378+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP160T1 curve.+_y :: Fq+_y = 0xadd6718b7c7c1961f0991b842443772152c9e0ad+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP160T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP160T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP160T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP192R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP192R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP192R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P192R1 curve+-- | BrainpoolP192R1 curve. data BrainpoolP192R1 --- | Field of Brainpool-P192R1 curve-type Fp = PrimeField 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+-- | Field of points of BrainpoolP192R1 curve.+type Fq = PrimeField 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297 --- | Brainpool-P192R1 curve is a Weierstrass curve-instance WCurve BrainpoolP192R1 Fp where+-- | Field of coefficients of BrainpoolP192R1 curve.+type Fr = PrimeField 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1++-- | BrainpoolP192R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP192R1 Fq Fr => WCurve c BrainpoolP192R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P192R1 curve-type P = WPoint BrainpoolP192R1 Fp+-- | Affine BrainpoolP192R1 curve point.+type PA = WAPoint BrainpoolP192R1 Fq Fr +-- | Affine BrainpoolP192R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP192R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP192R1 point.+type PJ = WJPoint BrainpoolP192R1 Fq Fr++-- | Jacobian BrainpoolP192R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP192R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP192R1 point.+type PP = WPPoint BrainpoolP192R1 Fq Fr++-- | Projective BrainpoolP192R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP192R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P192R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP192R1 curve.+_a :: Fq _a = 0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28ef-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P192R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP192R1 curve.+_b :: Fq _b = 0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9-{-# INLINE _b #-}---- | Generator of Brainpool-P192R1 curve-_g :: P-_g = A- 0xc0a0647eaab6a48753b033c56cb0f0900a2f5c4853375fd6- 0x14b690866abd5bb88b5f4828c1490002e6773fa2fa299b8f-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P192R1 curve+-- | Cofactor of BrainpoolP192R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P192R1 curve-_n :: Integer-_n = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP192R1 curve.+_q :: Integer+_q = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P192R1 curve-_p :: Integer-_p = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297-{-# INLINE _p #-}+-- | Order of BrainpoolP192R1 curve.+_r :: Integer+_r = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP192R1 curve.+_x :: Fq+_x = 0xc0a0647eaab6a48753b033c56cb0f0900a2f5c4853375fd6+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP192R1 curve.+_y :: Fq+_y = 0x14b690866abd5bb88b5f4828c1490002e6773fa2fa299b8f+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP192R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP192R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP192R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP192T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP192T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP192T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P192T1 curve+-- | BrainpoolP192T1 curve. data BrainpoolP192T1 --- | Field of Brainpool-P192T1 curve-type Fp = PrimeField 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+-- | Field of points of BrainpoolP192T1 curve.+type Fq = PrimeField 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297 --- | Brainpool-P192T1 curve is a Weierstrass curve-instance WCurve BrainpoolP192T1 Fp where+-- | Field of coefficients of BrainpoolP192T1 curve.+type Fr = PrimeField 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1++-- | BrainpoolP192T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP192T1 Fq Fr => WCurve c BrainpoolP192T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P192T1 curve-type P = WPoint BrainpoolP192T1 Fp+-- | Affine BrainpoolP192T1 curve point.+type PA = WAPoint BrainpoolP192T1 Fq Fr +-- | Affine BrainpoolP192T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP192T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP192T1 point.+type PJ = WJPoint BrainpoolP192T1 Fq Fr++-- | Jacobian BrainpoolP192T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP192T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP192T1 point.+type PP = WPPoint BrainpoolP192T1 Fq Fr++-- | Projective BrainpoolP192T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP192T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P192T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP192T1 curve.+_a :: Fq _a = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86294-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P192T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP192T1 curve.+_b :: Fq _b = 0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79-{-# INLINE _b #-}---- | Generator of Brainpool-P192T1 curve-_g :: P-_g = A- 0x3ae9e58c82f63c30282e1fe7bbf43fa72c446af6f4618129- 0x97e2c5667c2223a902ab5ca449d0084b7e5b3de7ccc01c9-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P192T1 curve+-- | Cofactor of BrainpoolP192T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P192T1 curve-_n :: Integer-_n = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP192T1 curve.+_q :: Integer+_q = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P192T1 curve-_p :: Integer-_p = 0xc302f41d932a36cda7a3463093d18db78fce476de1a86297-{-# INLINE _p #-}+-- | Order of BrainpoolP192T1 curve.+_r :: Integer+_r = 0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP192T1 curve.+_x :: Fq+_x = 0x3ae9e58c82f63c30282e1fe7bbf43fa72c446af6f4618129+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP192T1 curve.+_y :: Fq+_y = 0x97e2c5667c2223a902ab5ca449d0084b7e5b3de7ccc01c9+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP192T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP192T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP192T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP224R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP224R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP224R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P224R1 curve+-- | BrainpoolP224R1 curve. data BrainpoolP224R1 --- | Field of Brainpool-P224R1 curve-type Fp = PrimeField 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+-- | Field of points of BrainpoolP224R1 curve.+type Fq = PrimeField 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff --- | Brainpool-P224R1 curve is a Weierstrass curve-instance WCurve BrainpoolP224R1 Fp where+-- | Field of coefficients of BrainpoolP224R1 curve.+type Fr = PrimeField 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f++-- | BrainpoolP224R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP224R1 Fq Fr => WCurve c BrainpoolP224R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P224R1 curve-type P = WPoint BrainpoolP224R1 Fp+-- | Affine BrainpoolP224R1 curve point.+type PA = WAPoint BrainpoolP224R1 Fq Fr +-- | Affine BrainpoolP224R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP224R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP224R1 point.+type PJ = WJPoint BrainpoolP224R1 Fq Fr++-- | Jacobian BrainpoolP224R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP224R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP224R1 point.+type PP = WPPoint BrainpoolP224R1 Fq Fr++-- | Projective BrainpoolP224R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP224R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P224R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP224R1 curve.+_a :: Fq _a = 0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P224R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP224R1 curve.+_b :: Fq _b = 0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400b-{-# INLINE _b #-}---- | Generator of Brainpool-P224R1 curve-_g :: P-_g = A- 0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d- 0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P224R1 curve+-- | Cofactor of BrainpoolP224R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P224R1 curve-_n :: Integer-_n = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP224R1 curve.+_q :: Integer+_q = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P224R1 curve-_p :: Integer-_p = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff-{-# INLINE _p #-}+-- | Order of BrainpoolP224R1 curve.+_r :: Integer+_r = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP224R1 curve.+_x :: Fq+_x = 0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP224R1 curve.+_y :: Fq+_y = 0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP224R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP224R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP224R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP224T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP224T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP224T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P224T1 curve+-- | BrainpoolP224T1 curve. data BrainpoolP224T1 --- | Field of Brainpool-P224T1 curve-type Fp = PrimeField 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+-- | Field of points of BrainpoolP224T1 curve.+type Fq = PrimeField 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff --- | Brainpool-P224T1 curve is a Weierstrass curve-instance WCurve BrainpoolP224T1 Fp where+-- | Field of coefficients of BrainpoolP224T1 curve.+type Fr = PrimeField 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f++-- | BrainpoolP224T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP224T1 Fq Fr => WCurve c BrainpoolP224T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P224T1 curve-type P = WPoint BrainpoolP224T1 Fp+-- | Affine BrainpoolP224T1 curve point.+type PA = WAPoint BrainpoolP224T1 Fq Fr +-- | Affine BrainpoolP224T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP224T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP224T1 point.+type PJ = WJPoint BrainpoolP224T1 Fq Fr++-- | Jacobian BrainpoolP224T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP224T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP224T1 point.+type PP = WPPoint BrainpoolP224T1 Fq Fr++-- | Projective BrainpoolP224T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP224T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P224T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP224T1 curve.+_a :: Fq _a = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P224T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP224T1 curve.+_b :: Fq _b = 0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888d-{-# INLINE _b #-}---- | Generator of Brainpool-P224T1 curve-_g :: P-_g = A- 0x6ab1e344ce25ff3896424e7ffe14762ecb49f8928ac0c76029b4d580- 0x374e9f5143e568cd23f3f4d7c0d4b1e41c8cc0d1c6abd5f1a46db4c-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P224T1 curve+-- | Cofactor of BrainpoolP224T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P224T1 curve-_n :: Integer-_n = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP224T1 curve.+_q :: Integer+_q = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P224T1 curve-_p :: Integer-_p = 0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff-{-# INLINE _p #-}+-- | Order of BrainpoolP224T1 curve.+_r :: Integer+_r = 0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP224T1 curve.+_x :: Fq+_x = 0x6ab1e344ce25ff3896424e7ffe14762ecb49f8928ac0c76029b4d580+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP224T1 curve.+_y :: Fq+_y = 0x374e9f5143e568cd23f3f4d7c0d4b1e41c8cc0d1c6abd5f1a46db4c+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP224T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP224T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP224T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP256R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP256R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP256R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P256R1 curve+-- | BrainpoolP256R1 curve. data BrainpoolP256R1 --- | Field of Brainpool-P256R1 curve-type Fp = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+-- | Field of points of BrainpoolP256R1 curve.+type Fq = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377 --- | Brainpool-P256R1 curve is a Weierstrass curve-instance WCurve BrainpoolP256R1 Fp where+-- | Field of coefficients of BrainpoolP256R1 curve.+type Fr = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7++-- | BrainpoolP256R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP256R1 Fq Fr => WCurve c BrainpoolP256R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P256R1 curve-type P = WPoint BrainpoolP256R1 Fp+-- | Affine BrainpoolP256R1 curve point.+type PA = WAPoint BrainpoolP256R1 Fq Fr +-- | Affine BrainpoolP256R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP256R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP256R1 point.+type PJ = WJPoint BrainpoolP256R1 Fq Fr++-- | Jacobian BrainpoolP256R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP256R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP256R1 point.+type PP = WPPoint BrainpoolP256R1 Fq Fr++-- | Projective BrainpoolP256R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP256R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P256R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP256R1 curve.+_a :: Fq _a = 0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P256R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP256R1 curve.+_b :: Fq _b = 0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6-{-# INLINE _b #-}---- | Generator of Brainpool-P256R1 curve-_g :: P-_g = A- 0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262- 0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P256R1 curve+-- | Cofactor of BrainpoolP256R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P256R1 curve-_n :: Integer-_n = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP256R1 curve.+_q :: Integer+_q = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P256R1 curve-_p :: Integer-_p = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377-{-# INLINE _p #-}+-- | Order of BrainpoolP256R1 curve.+_r :: Integer+_r = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP256R1 curve.+_x :: Fq+_x = 0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP256R1 curve.+_y :: Fq+_y = 0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP256R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP256R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP256R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP256T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP256T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP256T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P256T1 curve+-- | BrainpoolP256T1 curve. data BrainpoolP256T1 --- | Field of Brainpool-P256T1 curve-type Fp = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+-- | Field of points of BrainpoolP256T1 curve.+type Fq = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377 --- | Brainpool-P256T1 curve is a Weierstrass curve-instance WCurve BrainpoolP256T1 Fp where+-- | Field of coefficients of BrainpoolP256T1 curve.+type Fr = PrimeField 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7++-- | BrainpoolP256T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP256T1 Fq Fr => WCurve c BrainpoolP256T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P256T1 curve-type P = WPoint BrainpoolP256T1 Fp+-- | Affine BrainpoolP256T1 curve point.+type PA = WAPoint BrainpoolP256T1 Fq Fr +-- | Affine BrainpoolP256T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP256T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP256T1 point.+type PJ = WJPoint BrainpoolP256T1 Fq Fr++-- | Jacobian BrainpoolP256T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP256T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP256T1 point.+type PP = WPPoint BrainpoolP256T1 Fq Fr++-- | Projective BrainpoolP256T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP256T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P256T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP256T1 curve.+_a :: Fq _a = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P256T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP256T1 curve.+_b :: Fq _b = 0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04-{-# INLINE _b #-}---- | Generator of Brainpool-P256T1 curve-_g :: P-_g = A- 0xa3e8eb3cc1cfe7b7732213b23a656149afa142c47aafbc2b79a191562e1305f4- 0x2d996c823439c56d7f7b22e14644417e69bcb6de39d027001dabe8f35b25c9be-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P256T1 curve+-- | Cofactor of BrainpoolP256T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P256T1 curve-_n :: Integer-_n = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP256T1 curve.+_q :: Integer+_q = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P256T1 curve-_p :: Integer-_p = 0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377-{-# INLINE _p #-}+-- | Order of BrainpoolP256T1 curve.+_r :: Integer+_r = 0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP256T1 curve.+_x :: Fq+_x = 0xa3e8eb3cc1cfe7b7732213b23a656149afa142c47aafbc2b79a191562e1305f4+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP256T1 curve.+_y :: Fq+_y = 0x2d996c823439c56d7f7b22e14644417e69bcb6de39d027001dabe8f35b25c9be+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP256T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP256T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP256T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP320R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP320R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP320R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P320R1 curve+-- | BrainpoolP320R1 curve. data BrainpoolP320R1 --- | Field of Brainpool-P320R1 curve-type Fp = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+-- | Field of points of BrainpoolP320R1 curve.+type Fq = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27 --- | Brainpool-P320R1 curve is a Weierstrass curve-instance WCurve BrainpoolP320R1 Fp where+-- | Field of coefficients of BrainpoolP320R1 curve.+type Fr = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311++-- | BrainpoolP320R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP320R1 Fq Fr => WCurve c BrainpoolP320R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P320R1 curve-type P = WPoint BrainpoolP320R1 Fp+-- | Affine BrainpoolP320R1 curve point.+type PA = WAPoint BrainpoolP320R1 Fq Fr +-- | Affine BrainpoolP320R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP320R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP320R1 point.+type PJ = WJPoint BrainpoolP320R1 Fq Fr++-- | Jacobian BrainpoolP320R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP320R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP320R1 point.+type PP = WPPoint BrainpoolP320R1 Fq Fr++-- | Projective BrainpoolP320R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP320R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P320R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP320R1 curve.+_a :: Fq _a = 0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P320R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP320R1 curve.+_b :: Fq _b = 0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6-{-# INLINE _b #-}---- | Generator of Brainpool-P320R1 curve-_g :: P-_g = A- 0x43bd7e9afb53d8b85289bcc48ee5bfe6f20137d10a087eb6e7871e2a10a599c710af8d0d39e20611- 0x14fdd05545ec1cc8ab4093247f77275e0743ffed117182eaa9c77877aaac6ac7d35245d1692e8ee1-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P320R1 curve+-- | Cofactor of BrainpoolP320R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P320R1 curve-_n :: Integer-_n = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP320R1 curve.+_q :: Integer+_q = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P320R1 curve-_p :: Integer-_p = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27-{-# INLINE _p #-}+-- | Order of BrainpoolP320R1 curve.+_r :: Integer+_r = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP320R1 curve.+_x :: Fq+_x = 0x43bd7e9afb53d8b85289bcc48ee5bfe6f20137d10a087eb6e7871e2a10a599c710af8d0d39e20611+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP320R1 curve.+_y :: Fq+_y = 0x14fdd05545ec1cc8ab4093247f77275e0743ffed117182eaa9c77877aaac6ac7d35245d1692e8ee1+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP320R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP320R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP320R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP320T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP320T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP320T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P320T1 curve+-- | BrainpoolP320T1 curve. data BrainpoolP320T1 --- | Field of Brainpool-P320T1 curve-type Fp = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+-- | Field of points of BrainpoolP320T1 curve.+type Fq = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27 --- | Brainpool-P320T1 curve is a Weierstrass curve-instance WCurve BrainpoolP320T1 Fp where+-- | Field of coefficients of BrainpoolP320T1 curve.+type Fr = PrimeField 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311++-- | BrainpoolP320T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP320T1 Fq Fr => WCurve c BrainpoolP320T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P320T1 curve-type P = WPoint BrainpoolP320T1 Fp+-- | Affine BrainpoolP320T1 curve point.+type PA = WAPoint BrainpoolP320T1 Fq Fr +-- | Affine BrainpoolP320T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP320T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP320T1 point.+type PJ = WJPoint BrainpoolP320T1 Fq Fr++-- | Jacobian BrainpoolP320T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP320T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP320T1 point.+type PP = WPPoint BrainpoolP320T1 Fq Fr++-- | Projective BrainpoolP320T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP320T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P320T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP320T1 curve.+_a :: Fq _a = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P320T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP320T1 curve.+_b :: Fq _b = 0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353-{-# INLINE _b #-}---- | Generator of Brainpool-P320T1 curve-_g :: P-_g = A- 0x925be9fb01afc6fb4d3e7d4990010f813408ab106c4f09cb7ee07868cc136fff3357f624a21bed52- 0x63ba3a7a27483ebf6671dbef7abb30ebee084e58a0b077ad42a5a0989d1ee71b1b9bc0455fb0d2c3-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P320T1 curve+-- | Cofactor of BrainpoolP320T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P320T1 curve-_n :: Integer-_n = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP320T1 curve.+_q :: Integer+_q = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P320T1 curve-_p :: Integer-_p = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27-{-# INLINE _p #-}+-- | Order of BrainpoolP320T1 curve.+_r :: Integer+_r = 0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP320T1 curve.+_x :: Fq+_x = 0x925be9fb01afc6fb4d3e7d4990010f813408ab106c4f09cb7ee07868cc136fff3357f624a21bed52+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP320T1 curve.+_y :: Fq+_y = 0x63ba3a7a27483ebf6671dbef7abb30ebee084e58a0b077ad42a5a0989d1ee71b1b9bc0455fb0d2c3+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP320T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP320T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP320T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP384R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP384R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP384R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P384R1 curve+-- | BrainpoolP384R1 curve. data BrainpoolP384R1 --- | Field of Brainpool-P384R1 curve-type Fp = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+-- | Field of points of BrainpoolP384R1 curve.+type Fq = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53 --- | Brainpool-P384R1 curve is a Weierstrass curve-instance WCurve BrainpoolP384R1 Fp where+-- | Field of coefficients of BrainpoolP384R1 curve.+type Fr = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565++-- | BrainpoolP384R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP384R1 Fq Fr => WCurve c BrainpoolP384R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P384R1 curve-type P = WPoint BrainpoolP384R1 Fp+-- | Affine BrainpoolP384R1 curve point.+type PA = WAPoint BrainpoolP384R1 Fq Fr +-- | Affine BrainpoolP384R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP384R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP384R1 point.+type PJ = WJPoint BrainpoolP384R1 Fq Fr++-- | Jacobian BrainpoolP384R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP384R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP384R1 point.+type PP = WPPoint BrainpoolP384R1 Fq Fr++-- | Projective BrainpoolP384R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP384R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P384R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP384R1 curve.+_a :: Fq _a = 0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P384R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP384R1 curve.+_b :: Fq _b = 0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11-{-# INLINE _b #-}---- | Generator of Brainpool-P384R1 curve-_g :: P-_g = A- 0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e- 0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P384R1 curve+-- | Cofactor of BrainpoolP384R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P384R1 curve-_n :: Integer-_n = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP384R1 curve.+_q :: Integer+_q = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P384R1 curve-_p :: Integer-_p = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53-{-# INLINE _p #-}+-- | Order of BrainpoolP384R1 curve.+_r :: Integer+_r = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP384R1 curve.+_x :: Fq+_x = 0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP384R1 curve.+_y :: Fq+_y = 0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP384R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP384R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP384R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP384T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP384T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP384T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ---------------------------------------------------------------------------------- Type+-- Types ------------------------------------------------------------------------------- --- | Brainpool-P384T1 curve+-- | BrainpoolP384T1 curve. data BrainpoolP384T1 --- | Field of Brainpool-P384T1 curve-type Fp = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+-- | Field of points of BrainpoolP384T1 curve.+type Fq = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53 --- | Brainpool-P384T1 curve is a Weierstrass curve-instance WCurve BrainpoolP384T1 Fp where+-- | Field of coefficients of BrainpoolP384T1 curve.+type Fr = PrimeField 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565++-- | BrainpoolP384T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP384T1 Fq Fr => WCurve c BrainpoolP384T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P384T1 curve-type P = WPoint BrainpoolP384T1 Fp+-- | Affine BrainpoolP384T1 curve point.+type PA = WAPoint BrainpoolP384T1 Fq Fr +-- | Affine BrainpoolP384T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP384T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP384T1 point.+type PJ = WJPoint BrainpoolP384T1 Fq Fr++-- | Jacobian BrainpoolP384T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP384T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP384T1 point.+type PP = WPPoint BrainpoolP384T1 Fq Fr++-- | Projective BrainpoolP384T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP384T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P384T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP384T1 curve.+_a :: Fq _a = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P384T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP384T1 curve.+_b :: Fq _b = 0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471ee-{-# INLINE _b #-}---- | Generator of Brainpool-P384T1 curve-_g :: P-_g = A- 0x18de98b02db9a306f2afcd7235f72a819b80ab12ebd653172476fecd462aabffc4ff191b946a5f54d8d0aa2f418808cc- 0x25ab056962d30651a114afd2755ad336747f93475b7a1fca3b88f2b6a208ccfe469408584dc2b2912675bf5b9e582928-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P384T1 curve+-- | Cofactor of BrainpoolP384T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P384T1 curve-_n :: Integer-_n = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP384T1 curve.+_q :: Integer+_q = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P384T1 curve-_p :: Integer-_p = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53-{-# INLINE _p #-}+-- | Order of BrainpoolP384T1 curve.+_r :: Integer+_r = 0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP384T1 curve.+_x :: Fq+_x = 0x18de98b02db9a306f2afcd7235f72a819b80ab12ebd653172476fecd462aabffc4ff191b946a5f54d8d0aa2f418808cc+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP384T1 curve.+_y :: Fq+_y = 0x25ab056962d30651a114afd2755ad336747f93475b7a1fca3b88f2b6a208ccfe469408584dc2b2912675bf5b9e582928+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP384T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP384T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP384T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP512R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP512R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP512R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P512R1 curve+-- | BrainpoolP512R1 curve. data BrainpoolP512R1 --- | Field of Brainpool-P512R1 curve-type Fp = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+-- | Field of points of BrainpoolP512R1 curve.+type Fq = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3 --- | Brainpool-P512R1 curve is a Weierstrass curve-instance WCurve BrainpoolP512R1 Fp where+-- | Field of coefficients of BrainpoolP512R1 curve.+type Fr = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069++-- | BrainpoolP512R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP512R1 Fq Fr => WCurve c BrainpoolP512R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P512R1 curve-type P = WPoint BrainpoolP512R1 Fp+-- | Affine BrainpoolP512R1 curve point.+type PA = WAPoint BrainpoolP512R1 Fq Fr +-- | Affine BrainpoolP512R1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP512R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP512R1 point.+type PJ = WJPoint BrainpoolP512R1 Fq Fr++-- | Jacobian BrainpoolP512R1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP512R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP512R1 point.+type PP = WPPoint BrainpoolP512R1 Fq Fr++-- | Projective BrainpoolP512R1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP512R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P512R1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP512R1 curve.+_a :: Fq _a = 0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P512R1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP512R1 curve.+_b :: Fq _b = 0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723-{-# INLINE _b #-}---- | Generator of Brainpool-P512R1 curve-_g :: P-_g = A- 0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822- 0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P512R1 curve+-- | Cofactor of BrainpoolP512R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P512R1 curve-_n :: Integer-_n = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP512R1 curve.+_q :: Integer+_q = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P512R1 curve-_p :: Integer-_p = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3-{-# INLINE _p #-}+-- | Order of BrainpoolP512R1 curve.+_r :: Integer+_r = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP512R1 curve.+_x :: Fq+_x = 0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP512R1 curve.+_y :: Fq+_y = 0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP512R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP512R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP512R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/BrainpoolP512T1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.BrainpoolP512T1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.BrainpoolP512T1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | Brainpool-P512T1 curve+-- | BrainpoolP512T1 curve. data BrainpoolP512T1 --- | Field of Brainpool-P512T1 curve-type Fp = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+-- | Field of points of BrainpoolP512T1 curve.+type Fq = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3 --- | Brainpool-P512T1 curve is a Weierstrass curve-instance WCurve BrainpoolP512T1 Fp where+-- | Field of coefficients of BrainpoolP512T1 curve.+type Fr = PrimeField 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069++-- | BrainpoolP512T1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c BrainpoolP512T1 Fq Fr => WCurve c BrainpoolP512T1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of Brainpool-P512T1 curve-type P = WPoint BrainpoolP512T1 Fp+-- | Affine BrainpoolP512T1 curve point.+type PA = WAPoint BrainpoolP512T1 Fq Fr +-- | Affine BrainpoolP512T1 curve is a Weierstrass affine curve.+instance WACurve BrainpoolP512T1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian BrainpoolP512T1 point.+type PJ = WJPoint BrainpoolP512T1 Fq Fr++-- | Jacobian BrainpoolP512T1 curve is a Weierstrass Jacobian curve.+instance WJCurve BrainpoolP512T1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective BrainpoolP512T1 point.+type PP = WPPoint BrainpoolP512T1 Fq Fr++-- | Projective BrainpoolP512T1 curve is a Weierstrass projective curve.+instance WPCurve BrainpoolP512T1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of Brainpool-P512T1 curve-_a :: Fp+-- | Coefficient @A@ of BrainpoolP512T1 curve.+_a :: Fq _a = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f0-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of Brainpool-P512T1 curve-_b :: Fp+-- | Coefficient @B@ of BrainpoolP512T1 curve.+_b :: Fq _b = 0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423e-{-# INLINE _b #-}---- | Generator of Brainpool-P512T1 curve-_g :: P-_g = A- 0x640ece5c12788717b9c1ba06cbc2a6feba85842458c56dde9db1758d39c0313d82ba51735cdb3ea499aa77a7d6943a64f7a3f25fe26f06b51baa2696fa9035da- 0x5b534bd595f5af0fa2c892376c84ace1bb4e3019b71634c01131159cae03cee9d9932184beef216bd71df2dadf86a627306ecff96dbb8bace198b61e00f8b332-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of Brainpool-P512T1 curve+-- | Cofactor of BrainpoolP512T1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of Brainpool-P512T1 curve-_n :: Integer-_n = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069-{-# INLINE _n #-}+-- | Characteristic of BrainpoolP512T1 curve.+_q :: Integer+_q = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3+{-# INLINABLE _q #-} --- | Characteristic of Brainpool-P512T1 curve-_p :: Integer-_p = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3-{-# INLINE _p #-}+-- | Order of BrainpoolP512T1 curve.+_r :: Integer+_r = 0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069+{-# INLINABLE _r #-}++-- | Coordinate @X@ of BrainpoolP512T1 curve.+_x :: Fq+_x = 0x640ece5c12788717b9c1ba06cbc2a6feba85842458c56dde9db1758d39c0313d82ba51735cdb3ea499aa77a7d6943a64f7a3f25fe26f06b51baa2696fa9035da+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of BrainpoolP512T1 curve.+_y :: Fq+_y = 0x5b534bd595f5af0fa2c892376c84ace1bb4e3019b71634c01131159cae03cee9d9932184beef216bd71df2dadf86a627306ecff96dbb8bace198b61e00f8b332+{-# INLINABLE _y #-}++-- | Generator of affine BrainpoolP512T1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian BrainpoolP512T1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective BrainpoolP512T1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP112R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP112R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP112R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP112R1 curve+-- | SECP112R1 curve. data SECP112R1 --- | Field of SECP112R1 curve-type Fp = PrimeField 0xdb7c2abf62e35e668076bead208b+-- | Field of points of SECP112R1 curve.+type Fq = PrimeField 0xdb7c2abf62e35e668076bead208b --- | SECP112R1 curve is a Weierstrass curve-instance WCurve SECP112R1 Fp where+-- | Field of coefficients of SECP112R1 curve.+type Fr = PrimeField 0xdb7c2abf62e35e7628dfac6561c5++-- | SECP112R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP112R1 Fq Fr => WCurve c SECP112R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP112R1 curve-type P = WPoint SECP112R1 Fp+-- | Affine SECP112R1 curve point.+type PA = WAPoint SECP112R1 Fq Fr +-- | Affine SECP112R1 curve is a Weierstrass affine curve.+instance WACurve SECP112R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP112R1 point.+type PJ = WJPoint SECP112R1 Fq Fr++-- | Jacobian SECP112R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP112R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP112R1 point.+type PP = WPPoint SECP112R1 Fq Fr++-- | Projective SECP112R1 curve is a Weierstrass projective curve.+instance WPCurve SECP112R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP112R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP112R1 curve.+_a :: Fq _a = 0xdb7c2abf62e35e668076bead2088-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP112R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP112R1 curve.+_b :: Fq _b = 0x659ef8ba043916eede8911702b22-{-# INLINE _b #-}---- | Generator of SECP112R1 curve-_g :: P-_g = A- 0x9487239995a5ee76b55f9c2f098- 0xa89ce5af8724c0a23e0e0ff77500-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP112R1 curve+-- | Cofactor of SECP112R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP112R1 curve-_n :: Integer-_n = 0xdb7c2abf62e35e7628dfac6561c5-{-# INLINE _n #-}+-- | Characteristic of SECP112R1 curve.+_q :: Integer+_q = 0xdb7c2abf62e35e668076bead208b+{-# INLINABLE _q #-} --- | Characteristic of SECP112R1 curve-_p :: Integer-_p = 0xdb7c2abf62e35e668076bead208b-{-# INLINE _p #-}+-- | Order of SECP112R1 curve.+_r :: Integer+_r = 0xdb7c2abf62e35e7628dfac6561c5+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP112R1 curve.+_x :: Fq+_x = 0x9487239995a5ee76b55f9c2f098+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP112R1 curve.+_y :: Fq+_y = 0xa89ce5af8724c0a23e0e0ff77500+{-# INLINABLE _y #-}++-- | Generator of affine SECP112R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP112R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP112R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP112R2.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP112R2- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP112R2 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP112R2 curve+-- | SECP112R2 curve. data SECP112R2 --- | Field of SECP112R2 curve-type Fp = PrimeField 0xdb7c2abf62e35e668076bead208b+-- | Field of points of SECP112R2 curve.+type Fq = PrimeField 0xdb7c2abf62e35e668076bead208b --- | SECP112R2 curve is a Weierstrass curve-instance WCurve SECP112R2 Fp where+-- | Field of coefficients of SECP112R2 curve.+type Fr = PrimeField 0x36df0aafd8b8d7597ca10520d04b++-- | SECP112R2 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP112R2 Fq Fr => WCurve c SECP112R2 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP112R2 curve-type P = WPoint SECP112R2 Fp+-- | Affine SECP112R2 curve point.+type PA = WAPoint SECP112R2 Fq Fr +-- | Affine SECP112R2 curve is a Weierstrass affine curve.+instance WACurve SECP112R2 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP112R2 point.+type PJ = WJPoint SECP112R2 Fq Fr++-- | Jacobian SECP112R2 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP112R2 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP112R2 point.+type PP = WPPoint SECP112R2 Fq Fr++-- | Projective SECP112R2 curve is a Weierstrass projective curve.+instance WPCurve SECP112R2 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP112R2 curve-_a :: Fp+-- | Coefficient @A@ of SECP112R2 curve.+_a :: Fq _a = 0x6127c24c05f38a0aaaf65c0ef02c-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP112R2 curve-_b :: Fp+-- | Coefficient @B@ of SECP112R2 curve.+_b :: Fq _b = 0x51def1815db5ed74fcc34c85d709-{-# INLINE _b #-}---- | Generator of SECP112R2 curve-_g :: P-_g = A- 0x4ba30ab5e892b4e1649dd0928643- 0xadcd46f5882e3747def36e956e97-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP112R2 curve+-- | Cofactor of SECP112R2 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of SECP112R2 curve-_n :: Integer-_n = 0x36df0aafd8b8d7597ca10520d04b-{-# INLINE _n #-}+-- | Characteristic of SECP112R2 curve.+_q :: Integer+_q = 0xdb7c2abf62e35e668076bead208b+{-# INLINABLE _q #-} --- | Characteristic of SECP112R2 curve-_p :: Integer-_p = 0xdb7c2abf62e35e668076bead208b-{-# INLINE _p #-}+-- | Order of SECP112R2 curve.+_r :: Integer+_r = 0x36df0aafd8b8d7597ca10520d04b+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP112R2 curve.+_x :: Fq+_x = 0x4ba30ab5e892b4e1649dd0928643+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP112R2 curve.+_y :: Fq+_y = 0xadcd46f5882e3747def36e956e97+{-# INLINABLE _y #-}++-- | Generator of affine SECP112R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP112R2 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP112R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP128R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP128R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP128R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP128R1 curve+-- | SECP128R1 curve. data SECP128R1 --- | Field of SECP128R1 curve-type Fp = PrimeField 0xfffffffdffffffffffffffffffffffff+-- | Field of points of SECP128R1 curve.+type Fq = PrimeField 0xfffffffdffffffffffffffffffffffff --- | SECP128R1 curve is a Weierstrass curve-instance WCurve SECP128R1 Fp where+-- | Field of coefficients of SECP128R1 curve.+type Fr = PrimeField 0xfffffffe0000000075a30d1b9038a115++-- | SECP128R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP128R1 Fq Fr => WCurve c SECP128R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP128R1 curve-type P = WPoint SECP128R1 Fp+-- | Affine SECP128R1 curve point.+type PA = WAPoint SECP128R1 Fq Fr +-- | Affine SECP128R1 curve is a Weierstrass affine curve.+instance WACurve SECP128R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP128R1 point.+type PJ = WJPoint SECP128R1 Fq Fr++-- | Jacobian SECP128R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP128R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP128R1 point.+type PP = WPPoint SECP128R1 Fq Fr++-- | Projective SECP128R1 curve is a Weierstrass projective curve.+instance WPCurve SECP128R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP128R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP128R1 curve.+_a :: Fq _a = 0xfffffffdfffffffffffffffffffffffc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP128R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP128R1 curve.+_b :: Fq _b = 0xe87579c11079f43dd824993c2cee5ed3-{-# INLINE _b #-}---- | Generator of SECP128R1 curve-_g :: P-_g = A- 0x161ff7528b899b2d0c28607ca52c5b86- 0xcf5ac8395bafeb13c02da292dded7a83-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP128R1 curve+-- | Cofactor of SECP128R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP128R1 curve-_n :: Integer-_n = 0xfffffffe0000000075a30d1b9038a115-{-# INLINE _n #-}+-- | Characteristic of SECP128R1 curve.+_q :: Integer+_q = 0xfffffffdffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP128R1 curve-_p :: Integer-_p = 0xfffffffdffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of SECP128R1 curve.+_r :: Integer+_r = 0xfffffffe0000000075a30d1b9038a115+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP128R1 curve.+_x :: Fq+_x = 0x161ff7528b899b2d0c28607ca52c5b86+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP128R1 curve.+_y :: Fq+_y = 0xcf5ac8395bafeb13c02da292dded7a83+{-# INLINABLE _y #-}++-- | Generator of affine SECP128R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP128R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP128R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP128R2.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP128R2- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP128R2 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP128R2 curve+-- | SECP128R2 curve. data SECP128R2 --- | Field of SECP128R2 curve-type Fp = PrimeField 0xfffffffdffffffffffffffffffffffff+-- | Field of points of SECP128R2 curve.+type Fq = PrimeField 0xfffffffdffffffffffffffffffffffff --- | SECP128R2 curve is a Weierstrass curve-instance WCurve SECP128R2 Fp where+-- | Field of coefficients of SECP128R2 curve.+type Fr = PrimeField 0x3fffffff7fffffffbe0024720613b5a3++-- | SECP128R2 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP128R2 Fq Fr => WCurve c SECP128R2 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP128R2 curve-type P = WPoint SECP128R2 Fp+-- | Affine SECP128R2 curve point.+type PA = WAPoint SECP128R2 Fq Fr +-- | Affine SECP128R2 curve is a Weierstrass affine curve.+instance WACurve SECP128R2 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP128R2 point.+type PJ = WJPoint SECP128R2 Fq Fr++-- | Jacobian SECP128R2 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP128R2 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP128R2 point.+type PP = WPPoint SECP128R2 Fq Fr++-- | Projective SECP128R2 curve is a Weierstrass projective curve.+instance WPCurve SECP128R2 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP128R2 curve-_a :: Fp+-- | Coefficient @A@ of SECP128R2 curve.+_a :: Fq _a = 0xd6031998d1b3bbfebf59cc9bbff9aee1-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP128R2 curve-_b :: Fp+-- | Coefficient @B@ of SECP128R2 curve.+_b :: Fq _b = 0x5eeefca380d02919dc2c6558bb6d8a5d-{-# INLINE _b #-}---- | Generator of SECP128R2 curve-_g :: P-_g = A- 0x7b6aa5d85e572983e6fb32a7cdebc140- 0x27b6916a894d3aee7106fe805fc34b44-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP128R2 curve+-- | Cofactor of SECP128R2 curve. _h :: Integer-_h = 4-{-# INLINE _h #-}+_h = 0x4+{-# INLINABLE _h #-} --- | Order of SECP128R2 curve-_n :: Integer-_n = 0x3fffffff7fffffffbe0024720613b5a3-{-# INLINE _n #-}+-- | Characteristic of SECP128R2 curve.+_q :: Integer+_q = 0xfffffffdffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP128R2 curve-_p :: Integer-_p = 0xfffffffdffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of SECP128R2 curve.+_r :: Integer+_r = 0x3fffffff7fffffffbe0024720613b5a3+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP128R2 curve.+_x :: Fq+_x = 0x7b6aa5d85e572983e6fb32a7cdebc140+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP128R2 curve.+_y :: Fq+_y = 0x27b6916a894d3aee7106fe805fc34b44+{-# INLINABLE _y #-}++-- | Generator of affine SECP128R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP128R2 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP128R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP160K1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP160K1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP160K1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP160K1 curve+-- | SECP160K1 curve. data SECP160K1 --- | Field of SECP160K1 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffeffffac73+-- | Field of points of SECP160K1 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffeffffac73 --- | SECP160K1 curve is a Weierstrass curve-instance WCurve SECP160K1 Fp where+-- | Field of coefficients of SECP160K1 curve.+type Fr = PrimeField 0x100000000000000000001b8fa16dfab9aca16b6b3++-- | SECP160K1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP160K1 Fq Fr => WCurve c SECP160K1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP160K1 curve-type P = WPoint SECP160K1 Fp+-- | Affine SECP160K1 curve point.+type PA = WAPoint SECP160K1 Fq Fr +-- | Affine SECP160K1 curve is a Weierstrass affine curve.+instance WACurve SECP160K1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP160K1 point.+type PJ = WJPoint SECP160K1 Fq Fr++-- | Jacobian SECP160K1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP160K1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP160K1 point.+type PP = WPPoint SECP160K1 Fq Fr++-- | Projective SECP160K1 curve is a Weierstrass projective curve.+instance WPCurve SECP160K1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP160K1 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of SECP160K1 curve-_b :: Fp-_b = 7-{-# INLINE _b #-}+-- | Coefficient @A@ of SECP160K1 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of SECP160K1 curve-_g :: P-_g = A- 0x3b4c382ce37aa192a4019e763036f4f5dd4d7ebb- 0x938cf935318fdced6bc28286531733c3f03c4fee-{-# INLINE _g #-}+-- | Coefficient @B@ of SECP160K1 curve.+_b :: Fq+_b = 0x7+{-# INLINABLE _b #-} --- | Cofactor of SECP160K1 curve+-- | Cofactor of SECP160K1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP160K1 curve-_n :: Integer-_n = 0x100000000000000000001b8fa16dfab9aca16b6b3-{-# INLINE _n #-}+-- | Characteristic of SECP160K1 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffeffffac73+{-# INLINABLE _q #-} --- | Characteristic of SECP160K1 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffeffffac73-{-# INLINE _p #-}+-- | Order of SECP160K1 curve.+_r :: Integer+_r = 0x100000000000000000001b8fa16dfab9aca16b6b3+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP160K1 curve.+_x :: Fq+_x = 0x3b4c382ce37aa192a4019e763036f4f5dd4d7ebb+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP160K1 curve.+_y :: Fq+_y = 0x938cf935318fdced6bc28286531733c3f03c4fee+{-# INLINABLE _y #-}++-- | Generator of affine SECP160K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP160K1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP160K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP160R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP160R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP160R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP160R1 curve+-- | SECP160R1 curve. data SECP160R1 --- | Field of SECP160R1 curve-type Fp = PrimeField 0xffffffffffffffffffffffffffffffff7fffffff+-- | Field of points of SECP160R1 curve.+type Fq = PrimeField 0xffffffffffffffffffffffffffffffff7fffffff --- | SECP160R1 curve is a Weierstrass curve-instance WCurve SECP160R1 Fp where+-- | Field of coefficients of SECP160R1 curve.+type Fr = PrimeField 0x100000000000000000001f4c8f927aed3ca752257++-- | SECP160R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP160R1 Fq Fr => WCurve c SECP160R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP160R1 curve-type P = WPoint SECP160R1 Fp+-- | Affine SECP160R1 curve point.+type PA = WAPoint SECP160R1 Fq Fr +-- | Affine SECP160R1 curve is a Weierstrass affine curve.+instance WACurve SECP160R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP160R1 point.+type PJ = WJPoint SECP160R1 Fq Fr++-- | Jacobian SECP160R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP160R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP160R1 point.+type PP = WPPoint SECP160R1 Fq Fr++-- | Projective SECP160R1 curve is a Weierstrass projective curve.+instance WPCurve SECP160R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP160R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP160R1 curve.+_a :: Fq _a = 0xffffffffffffffffffffffffffffffff7ffffffc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP160R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP160R1 curve.+_b :: Fq _b = 0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45-{-# INLINE _b #-}---- | Generator of SECP160R1 curve-_g :: P-_g = A- 0x4a96b5688ef573284664698968c38bb913cbfc82- 0x23a628553168947d59dcc912042351377ac5fb32-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP160R1 curve+-- | Cofactor of SECP160R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP160R1 curve-_n :: Integer-_n = 0x100000000000000000001f4c8f927aed3ca752257-{-# INLINE _n #-}+-- | Characteristic of SECP160R1 curve.+_q :: Integer+_q = 0xffffffffffffffffffffffffffffffff7fffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP160R1 curve-_p :: Integer-_p = 0xffffffffffffffffffffffffffffffff7fffffff-{-# INLINE _p #-}+-- | Order of SECP160R1 curve.+_r :: Integer+_r = 0x100000000000000000001f4c8f927aed3ca752257+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP160R1 curve.+_x :: Fq+_x = 0x4a96b5688ef573284664698968c38bb913cbfc82+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP160R1 curve.+_y :: Fq+_y = 0x23a628553168947d59dcc912042351377ac5fb32+{-# INLINABLE _y #-}++-- | Generator of affine SECP160R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP160R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP160R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP160R2.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP160R2- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP160R2 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP160R2 curve+-- | SECP160R2 curve. data SECP160R2 --- | Field of SECP160R2 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffeffffac73+-- | Field of points of SECP160R2 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffeffffac73 --- | SECP160R2 curve is a Weierstrass curve-instance WCurve SECP160R2 Fp where+-- | Field of coefficients of SECP160R2 curve.+type Fr = PrimeField 0x100000000000000000000351ee786a818f3a1a16b++-- | SECP160R2 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP160R2 Fq Fr => WCurve c SECP160R2 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP160R2 curve-type P = WPoint SECP160R2 Fp+-- | Affine SECP160R2 curve point.+type PA = WAPoint SECP160R2 Fq Fr +-- | Affine SECP160R2 curve is a Weierstrass affine curve.+instance WACurve SECP160R2 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP160R2 point.+type PJ = WJPoint SECP160R2 Fq Fr++-- | Jacobian SECP160R2 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP160R2 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP160R2 point.+type PP = WPPoint SECP160R2 Fq Fr++-- | Projective SECP160R2 curve is a Weierstrass projective curve.+instance WPCurve SECP160R2 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP160R2 curve-_a :: Fp+-- | Coefficient @A@ of SECP160R2 curve.+_a :: Fq _a = 0xfffffffffffffffffffffffffffffffeffffac70-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP160R2 curve-_b :: Fp+-- | Coefficient @B@ of SECP160R2 curve.+_b :: Fq _b = 0xb4e134d3fb59eb8bab57274904664d5af50388ba-{-# INLINE _b #-}---- | Generator of SECP160R2 curve-_g :: P-_g = A- 0x52dcb034293a117e1f4ff11b30f7199d3144ce6d- 0xfeaffef2e331f296e071fa0df9982cfea7d43f2e-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP160R2 curve+-- | Cofactor of SECP160R2 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP160R2 curve-_n :: Integer-_n = 0x100000000000000000000351ee786a818f3a1a16b-{-# INLINE _n #-}+-- | Characteristic of SECP160R2 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffeffffac73+{-# INLINABLE _q #-} --- | Characteristic of SECP160R2 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffeffffac73-{-# INLINE _p #-}+-- | Order of SECP160R2 curve.+_r :: Integer+_r = 0x100000000000000000000351ee786a818f3a1a16b+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP160R2 curve.+_x :: Fq+_x = 0x52dcb034293a117e1f4ff11b30f7199d3144ce6d+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP160R2 curve.+_y :: Fq+_y = 0xfeaffef2e331f296e071fa0df9982cfea7d43f2e+{-# INLINABLE _y #-}++-- | Generator of affine SECP160R2 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP160R2 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP160R2 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP192K1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP192K1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP192K1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP192K1 curve+-- | SECP192K1 curve. data SECP192K1 --- | Field of SECP192K1 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffeffffee37+-- | Field of points of SECP192K1 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffeffffee37 --- | SECP192K1 curve is a Weierstrass curve-instance WCurve SECP192K1 Fp where+-- | Field of coefficients of SECP192K1 curve.+type Fr = PrimeField 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d++-- | SECP192K1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP192K1 Fq Fr => WCurve c SECP192K1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP192K1 curve-type P = WPoint SECP192K1 Fp+-- | Affine SECP192K1 curve point.+type PA = WAPoint SECP192K1 Fq Fr +-- | Affine SECP192K1 curve is a Weierstrass affine curve.+instance WACurve SECP192K1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP192K1 point.+type PJ = WJPoint SECP192K1 Fq Fr++-- | Jacobian SECP192K1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP192K1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP192K1 point.+type PP = WPPoint SECP192K1 Fq Fr++-- | Projective SECP192K1 curve is a Weierstrass projective curve.+instance WPCurve SECP192K1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP192K1 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of SECP192K1 curve-_b :: Fp-_b = 3-{-# INLINE _b #-}+-- | Coefficient @A@ of SECP192K1 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of SECP192K1 curve-_g :: P-_g = A- 0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d- 0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d-{-# INLINE _g #-}+-- | Coefficient @B@ of SECP192K1 curve.+_b :: Fq+_b = 0x3+{-# INLINABLE _b #-} --- | Cofactor of SECP192K1 curve+-- | Cofactor of SECP192K1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP192K1 curve-_n :: Integer-_n = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d-{-# INLINE _n #-}+-- | Characteristic of SECP192K1 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffeffffee37+{-# INLINABLE _q #-} --- | Characteristic of SECP192K1 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffeffffee37-{-# INLINE _p #-}+-- | Order of SECP192K1 curve.+_r :: Integer+_r = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP192K1 curve.+_x :: Fq+_x = 0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP192K1 curve.+_y :: Fq+_y = 0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d+{-# INLINABLE _y #-}++-- | Generator of affine SECP192K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP192K1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP192K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP192R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP192R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP192R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP192R1 curve+-- | SECP192R1 curve. data SECP192R1 --- | Field of SECP192R1 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffeffffffffffffffff+-- | Field of points of SECP192R1 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffeffffffffffffffff --- | SECP192R1 curve is a Weierstrass curve-instance WCurve SECP192R1 Fp where+-- | Field of coefficients of SECP192R1 curve.+type Fr = PrimeField 0xffffffffffffffffffffffff99def836146bc9b1b4d22831++-- | SECP192R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP192R1 Fq Fr => WCurve c SECP192R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP192R1 curve-type P = WPoint SECP192R1 Fp+-- | Affine SECP192R1 curve point.+type PA = WAPoint SECP192R1 Fq Fr +-- | Affine SECP192R1 curve is a Weierstrass affine curve.+instance WACurve SECP192R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP192R1 point.+type PJ = WJPoint SECP192R1 Fq Fr++-- | Jacobian SECP192R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP192R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP192R1 point.+type PP = WPPoint SECP192R1 Fq Fr++-- | Projective SECP192R1 curve is a Weierstrass projective curve.+instance WPCurve SECP192R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP192R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP192R1 curve.+_a :: Fq _a = 0xfffffffffffffffffffffffffffffffefffffffffffffffc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP192R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP192R1 curve.+_b :: Fq _b = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1-{-# INLINE _b #-}---- | Generator of SECP192R1 curve-_g :: P-_g = A- 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012- 0x7192b95ffc8da78631011ed6b24cdd573f977a11e794811-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP192R1 curve+-- | Cofactor of SECP192R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP192R1 curve-_n :: Integer-_n = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831-{-# INLINE _n #-}+-- | Characteristic of SECP192R1 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffeffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP192R1 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffeffffffffffffffff-{-# INLINE _p #-}+-- | Order of SECP192R1 curve.+_r :: Integer+_r = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP192R1 curve.+_x :: Fq+_x = 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP192R1 curve.+_y :: Fq+_y = 0x7192b95ffc8da78631011ed6b24cdd573f977a11e794811+{-# INLINABLE _y #-}++-- | Generator of affine SECP192R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP192R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP192R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP224K1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP224K1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP224K1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP224K1 curve+-- | SECP224K1 curve. data SECP224K1 --- | Field of SECP224K1 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d+-- | Field of points of SECP224K1 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d --- | SECP224K1 curve is a Weierstrass curve-instance WCurve SECP224K1 Fp where+-- | Field of coefficients of SECP224K1 curve.+type Fr = PrimeField 0x10000000000000000000000000001dce8d2ec6184caf0a971769fb1f7++-- | SECP224K1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP224K1 Fq Fr => WCurve c SECP224K1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP224K1 curve-type P = WPoint SECP224K1 Fp+-- | Affine SECP224K1 curve point.+type PA = WAPoint SECP224K1 Fq Fr +-- | Affine SECP224K1 curve is a Weierstrass affine curve.+instance WACurve SECP224K1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP224K1 point.+type PJ = WJPoint SECP224K1 Fq Fr++-- | Jacobian SECP224K1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP224K1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP224K1 point.+type PP = WPPoint SECP224K1 Fq Fr++-- | Projective SECP224K1 curve is a Weierstrass projective curve.+instance WPCurve SECP224K1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP224K1 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of SECP224K1 curve-_b :: Fp-_b = 5-{-# INLINE _b #-}+-- | Coefficient @A@ of SECP224K1 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of SECP224K1 curve-_g :: P-_g = A- 0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c- 0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5-{-# INLINE _g #-}+-- | Coefficient @B@ of SECP224K1 curve.+_b :: Fq+_b = 0x5+{-# INLINABLE _b #-} --- | Cofactor of SECP224K1 curve+-- | Cofactor of SECP224K1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP224K1 curve-_n :: Integer-_n = 0x10000000000000000000000000001dce8d2ec6184caf0a971769fb1f7-{-# INLINE _n #-}+-- | Characteristic of SECP224K1 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d+{-# INLINABLE _q #-} --- | Characteristic of SECP224K1 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffeffffe56d-{-# INLINE _p #-}+-- | Order of SECP224K1 curve.+_r :: Integer+_r = 0x10000000000000000000000000001dce8d2ec6184caf0a971769fb1f7+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP224K1 curve.+_x :: Fq+_x = 0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP224K1 curve.+_y :: Fq+_y = 0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5+{-# INLINABLE _y #-}++-- | Generator of affine SECP224K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP224K1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP224K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP224R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP224R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP224R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP224R1 curve+-- | SECP224R1 curve. data SECP224R1 --- | Field of SECP224R1 curve-type Fp = PrimeField 0xffffffffffffffffffffffffffffffff000000000000000000000001+-- | Field of points of SECP224R1 curve.+type Fq = PrimeField 0xffffffffffffffffffffffffffffffff000000000000000000000001 --- | SECP224R1 curve is a Weierstrass curve-instance WCurve SECP224R1 Fp where+-- | Field of coefficients of SECP224R1 curve.+type Fr = PrimeField 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d++-- | SECP224R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP224R1 Fq Fr => WCurve c SECP224R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP224R1 curve-type P = WPoint SECP224R1 Fp+-- | Affine SECP224R1 curve point.+type PA = WAPoint SECP224R1 Fq Fr +-- | Affine SECP224R1 curve is a Weierstrass affine curve.+instance WACurve SECP224R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP224R1 point.+type PJ = WJPoint SECP224R1 Fq Fr++-- | Jacobian SECP224R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP224R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP224R1 point.+type PP = WPPoint SECP224R1 Fq Fr++-- | Projective SECP224R1 curve is a Weierstrass projective curve.+instance WPCurve SECP224R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP224R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP224R1 curve.+_a :: Fq _a = 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP224R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP224R1 curve.+_b :: Fq _b = 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4-{-# INLINE _b #-}---- | Generator of SECP224R1 curve-_g :: P-_g = A- 0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21- 0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP224R1 curve+-- | Cofactor of SECP224R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP224R1 curve-_n :: Integer-_n = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d-{-# INLINE _n #-}+-- | Characteristic of SECP224R1 curve.+_q :: Integer+_q = 0xffffffffffffffffffffffffffffffff000000000000000000000001+{-# INLINABLE _q #-} --- | Characteristic of SECP224R1 curve-_p :: Integer-_p = 0xffffffffffffffffffffffffffffffff000000000000000000000001-{-# INLINE _p #-}+-- | Order of SECP224R1 curve.+_r :: Integer+_r = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP224R1 curve.+_x :: Fq+_x = 0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP224R1 curve.+_y :: Fq+_y = 0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34+{-# INLINABLE _y #-}++-- | Generator of affine SECP224R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP224R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP224R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP256K1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP256K1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP256K1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP256K1 curve+-- | SECP256K1 curve. data SECP256K1 --- | Field of SECP256K1 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f+-- | Field of points of SECP256K1 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f --- | SECP256K1 curve is a Weierstrass curve-instance WCurve SECP256K1 Fp where+-- | Field of coefficients of SECP256K1 curve.+type Fr = PrimeField 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141++-- | SECP256K1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP256K1 Fq Fr => WCurve c SECP256K1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP256K1 curve-type P = WPoint SECP256K1 Fp+-- | Affine SECP256K1 curve point.+type PA = WAPoint SECP256K1 Fq Fr +-- | Affine SECP256K1 curve is a Weierstrass affine curve.+instance WACurve SECP256K1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP256K1 point.+type PJ = WJPoint SECP256K1 Fq Fr++-- | Jacobian SECP256K1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP256K1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP256K1 point.+type PP = WPPoint SECP256K1 Fq Fr++-- | Projective SECP256K1 curve is a Weierstrass projective curve.+instance WPCurve SECP256K1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP256K1 curve-_a :: Fp-_a = 0-{-# INLINE _a #-}---- | Coefficient @B@ of SECP256K1 curve-_b :: Fp-_b = 7-{-# INLINE _b #-}+-- | Coefficient @A@ of SECP256K1 curve.+_a :: Fq+_a = 0x0+{-# INLINABLE _a #-} --- | Generator of SECP256K1 curve-_g :: P-_g = A- 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798- 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8-{-# INLINE _g #-}+-- | Coefficient @B@ of SECP256K1 curve.+_b :: Fq+_b = 0x7+{-# INLINABLE _b #-} --- | Cofactor of SECP256K1 curve+-- | Cofactor of SECP256K1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP256K1 curve-_n :: Integer-_n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141-{-# INLINE _n #-}+-- | Characteristic of SECP256K1 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f+{-# INLINABLE _q #-} --- | Characteristic of SECP256K1 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f-{-# INLINE _p #-}+-- | Order of SECP256K1 curve.+_r :: Integer+_r = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP256K1 curve.+_x :: Fq+_x = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP256K1 curve.+_y :: Fq+_y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8+{-# INLINABLE _y #-}++-- | Generator of affine SECP256K1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP256K1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP256K1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP256R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP256R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP256R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP256R1 curve+-- | SECP256R1 curve. data SECP256R1 --- | Field of SECP256R1 curve-type Fp = PrimeField 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff+-- | Field of points of SECP256R1 curve.+type Fq = PrimeField 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff --- | SECP256R1 curve is a Weierstrass curve-instance WCurve SECP256R1 Fp where+-- | Field of coefficients of SECP256R1 curve.+type Fr = PrimeField 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551++-- | SECP256R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP256R1 Fq Fr => WCurve c SECP256R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP256R1 curve-type P = WPoint SECP256R1 Fp+-- | Affine SECP256R1 curve point.+type PA = WAPoint SECP256R1 Fq Fr +-- | Affine SECP256R1 curve is a Weierstrass affine curve.+instance WACurve SECP256R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP256R1 point.+type PJ = WJPoint SECP256R1 Fq Fr++-- | Jacobian SECP256R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP256R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP256R1 point.+type PP = WPPoint SECP256R1 Fq Fr++-- | Projective SECP256R1 curve is a Weierstrass projective curve.+instance WPCurve SECP256R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP256R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP256R1 curve.+_a :: Fq _a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP256R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP256R1 curve.+_b :: Fq _b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b-{-# INLINE _b #-}---- | Generator of SECP256R1 curve-_g :: P-_g = A- 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296- 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP256R1 curve+-- | Cofactor of SECP256R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP256R1 curve-_n :: Integer-_n = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551-{-# INLINE _n #-}+-- | Characteristic of SECP256R1 curve.+_q :: Integer+_q = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP256R1 curve-_p :: Integer-_p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of SECP256R1 curve.+_r :: Integer+_r = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP256R1 curve.+_x :: Fq+_x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP256R1 curve.+_y :: Fq+_y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5+{-# INLINABLE _y #-}++-- | Generator of affine SECP256R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP256R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP256R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP384R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP384R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP384R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP384R1 curve+-- | SECP384R1 curve. data SECP384R1 --- | Field of SECP384R1 curve-type Fp = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff+-- | Field of points of SECP384R1 curve.+type Fq = PrimeField 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff --- | SECP384R1 curve is a Weierstrass curve-instance WCurve SECP384R1 Fp where+-- | Field of coefficients of SECP384R1 curve.+type Fr = PrimeField 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973++-- | SECP384R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP384R1 Fq Fr => WCurve c SECP384R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP384R1 curve-type P = WPoint SECP384R1 Fp+-- | Affine SECP384R1 curve point.+type PA = WAPoint SECP384R1 Fq Fr +-- | Affine SECP384R1 curve is a Weierstrass affine curve.+instance WACurve SECP384R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP384R1 point.+type PJ = WJPoint SECP384R1 Fq Fr++-- | Jacobian SECP384R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP384R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP384R1 point.+type PP = WPPoint SECP384R1 Fq Fr++-- | Projective SECP384R1 curve is a Weierstrass projective curve.+instance WPCurve SECP384R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP384R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP384R1 curve.+_a :: Fq _a = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP384R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP384R1 curve.+_b :: Fq _b = 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef-{-# INLINE _b #-}---- | Generator of SECP384R1 curve-_g :: P-_g = A- 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7- 0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP384R1 curve+-- | Cofactor of SECP384R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP384R1 curve-_n :: Integer-_n = 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973-{-# INLINE _n #-}+-- | Characteristic of SECP384R1 curve.+_q :: Integer+_q = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP384R1 curve-_p :: Integer-_p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff-{-# INLINE _p #-}+-- | Order of SECP384R1 curve.+_r :: Integer+_r = 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP384R1 curve.+_x :: Fq+_x = 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP384R1 curve.+_y :: Fq+_y = 0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f+{-# INLINABLE _y #-}++-- | Generator of affine SECP384R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP384R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP384R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
src/Curve/Weierstrass/SECP521R1.hs view
@@ -1,74 +1,118 @@ module Curve.Weierstrass.SECP521R1- ( Fp- , P- , _a- , _b- , _g- , _h- , _n- , _p+ ( module Curve.Weierstrass+ , module Curve.Weierstrass.SECP521R1 ) where import Protolude -import PrimeField (PrimeField)+import PrimeField -import Curve.Weierstrass (Point(..), WCurve(..), WPoint)+import Curve.Weierstrass ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- --- | SECP521R1 curve+-- | SECP521R1 curve. data SECP521R1 --- | Field of SECP521R1 curve-type Fp = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+-- | Field of points of SECP521R1 curve.+type Fq = PrimeField 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff --- | SECP521R1 curve is a Weierstrass curve-instance WCurve SECP521R1 Fp where+-- | Field of coefficients of SECP521R1 curve.+type Fr = PrimeField 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409++-- | SECP521R1 curve is a Weierstrass curve.+instance Curve 'Weierstrass c SECP521R1 Fq Fr => WCurve c SECP521R1 Fq Fr where a_ = const _a- {-# INLINE a_ #-}+ {-# INLINABLE a_ #-} b_ = const _b- {-# INLINE b_ #-}- g_ = _g- {-# INLINE g_ #-}+ {-# INLINABLE b_ #-}+ h_ = const _h+ {-# INLINABLE h_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = const _x+ {-# INLINABLE x_ #-}+ y_ = const _y+ {-# INLINABLE y_ #-} --- | Point of SECP521R1 curve-type P = WPoint SECP521R1 Fp+-- | Affine SECP521R1 curve point.+type PA = WAPoint SECP521R1 Fq Fr +-- | Affine SECP521R1 curve is a Weierstrass affine curve.+instance WACurve SECP521R1 Fq Fr where+ gA_ = gA+ {-# INLINABLE gA_ #-}++-- | Jacobian SECP521R1 point.+type PJ = WJPoint SECP521R1 Fq Fr++-- | Jacobian SECP521R1 curve is a Weierstrass Jacobian curve.+instance WJCurve SECP521R1 Fq Fr where+ gJ_ = gJ+ {-# INLINABLE gJ_ #-}++-- | Projective SECP521R1 point.+type PP = WPPoint SECP521R1 Fq Fr++-- | Projective SECP521R1 curve is a Weierstrass projective curve.+instance WPCurve SECP521R1 Fq Fr where+ gP_ = gP+ {-# INLINABLE gP_ #-}+ ------------------------------------------------------------------------------- -- Parameters ------------------------------------------------------------------------------- --- | Coefficient @A@ of SECP521R1 curve-_a :: Fp+-- | Coefficient @A@ of SECP521R1 curve.+_a :: Fq _a = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc-{-# INLINE _a #-}+{-# INLINABLE _a #-} --- | Coefficient @B@ of SECP521R1 curve-_b :: Fp+-- | Coefficient @B@ of SECP521R1 curve.+_b :: Fq _b = 0x51953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00-{-# INLINE _b #-}---- | Generator of SECP521R1 curve-_g :: P-_g = A- 0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66- 0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650-{-# INLINE _g #-}+{-# INLINABLE _b #-} --- | Cofactor of SECP521R1 curve+-- | Cofactor of SECP521R1 curve. _h :: Integer-_h = 1-{-# INLINE _h #-}+_h = 0x1+{-# INLINABLE _h #-} --- | Order of SECP521R1 curve-_n :: Integer-_n = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409-{-# INLINE _n #-}+-- | Characteristic of SECP521R1 curve.+_q :: Integer+_q = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff+{-# INLINABLE _q #-} --- | Characteristic of SECP521R1 curve-_p :: Integer-_p = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff-{-# INLINE _p #-}+-- | Order of SECP521R1 curve.+_r :: Integer+_r = 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409+{-# INLINABLE _r #-}++-- | Coordinate @X@ of SECP521R1 curve.+_x :: Fq+_x = 0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66+{-# INLINABLE _x #-}++-- | Coordinate @Y@ of SECP521R1 curve.+_y :: Fq+_y = 0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650+{-# INLINABLE _y #-}++-- | Generator of affine SECP521R1 curve.+gA :: PA+gA = A _x _y+{-# INLINABLE gA #-}++-- | Generator of Jacobian SECP521R1 curve.+gJ :: PJ+gJ = J _x _y 1+{-# INLINABLE gJ #-}++-- | Generator of projective SECP521R1 curve.+gP :: PP+gP = P _x _y 1+{-# INLINABLE gP #-}
+ src/Group.hs view
@@ -0,0 +1,56 @@+module Group+ ( Group(..)+ ) where++import Protolude++import Control.Monad.Random (MonadRandom, Random, getRandom)+import Test.Tasty.QuickCheck (Arbitrary)+import Text.PrettyPrint.Leijen.Text (Pretty)++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Groups.+class (Arbitrary g, Eq g, Generic g,+ Monoid g, Pretty g, Random g, Show g) => Group g where+ {-# MINIMAL add, dbl, def, gen, id, inv, order #-}++ -- | Element addition.+ add :: g -> g -> g++ -- | Element doubling.+ dbl :: g -> g++ -- | Check well-defined.+ def :: g -> Bool++ -- | Group generator.+ gen :: g++ -- | Identity element.+ id :: g++ -- | Element inversion.+ inv :: g -> g++ -- | Element multiplication.+ mul' :: g -> Integer -> g+ mul' p n+ | n < 0 = inv (mul' p (-n))+ | n == 0 = id+ | n == 1 = p+ | even n = p'+ | otherwise = add p p'+ where+ p' = mul' (dbl p) (div n 2)+ {-# INLINABLE mul' #-}++ -- | Curve order.+ order :: g -> Integer++ -- | Random element.+ rnd :: MonadRandom m => m g+ rnd = getRandom+ {-# INLINABLE rnd #-}
+ src/Group/Field.hs view
@@ -0,0 +1,100 @@+module Group.Field+ ( module Group+ , module Group.Field+ ) where++import Protolude++import Control.Monad.Random (Random(..))+import GaloisField (GaloisField(..))+import Test.Tasty.QuickCheck (Arbitrary(..), suchThatMap)+import Text.PrettyPrint.Leijen.Text (Pretty(..))++import Group (Group(..))++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Field groups.+class GaloisField k => FGroup k where+ {-# MINIMAL g_, q_, r_, x_ #-}+ g_ :: Element k -- ^ Group generator.+ q_ :: Element k -> Integer -- ^ Group characteristic.+ r_ :: Element k -> Integer -- ^ Group order.+ x_ :: k -- ^ Group element.++-- | Field elements.+newtype Element k = F k+ deriving (Eq, Functor, Generic, NFData, Read, Show)++-------------------------------------------------------------------------------+-- Operations+-------------------------------------------------------------------------------++-- Field elements are groups.+instance FGroup k => Group (Element k) where++ add = (<>)+ {-# INLINABLE add #-}++ dbl = join (<>)+ {-# INLINABLE dbl #-}++ def (F x) = x /= 0+ {-# INLINABLE def #-}++ gen = g_+ {-# INLINABLE gen #-}++ id = mempty+ {-# INLINABLE id #-}++ inv (F x) = F (recip x)+ {-# INLINABLE inv #-}++ mul' (F x) n = F (pow x n)+ {-# INLINABLE mul' #-}++ order = r_+ {-# INLINABLE order #-}++-- Field elements are monoids.+instance FGroup k => Monoid (Element k) where++ mempty = F 1+ {-# INLINABLE mempty #-}++-- Field elements are semigroups.+instance FGroup k => Semigroup (Element k) where++ F x <> F y = F (x * y)+ {-# INLINABLE (<>) #-}++-------------------------------------------------------------------------------+-- Instances+-------------------------------------------------------------------------------++-- Field elements are arbitrary.+instance FGroup k => Arbitrary (Element k) where++ arbitrary = suchThatMap arbitrary defX+ where+ defX 0 = Nothing+ defX x = Just (F x)+ {-# INLINABLE arbitrary #-}++-- Field elements are pretty.+instance FGroup k => Pretty (Element k) where++ pretty (F x) = pretty x++-- Field elements are random.+instance FGroup k => Random (Element k) where++ random g = case random g of+ (0, g') -> random g'+ (x, g') -> (F x, g')+ {-# INLINABLE random #-}++ randomR = panic "not implemented."
+ src/Group/Field/BN254TF.hs view
@@ -0,0 +1,85 @@+module Group.Field.BN254TF+ ( module Group+ , module Group.Field+ , module Group.Field.BN254TF+ ) where++import Protolude++import ExtensionField++import Curve.Weierstrass.BN254T (Fq2)+import Group+import Group.Field++-------------------------------------------------------------------------------+-- Types+-------------------------------------------------------------------------------++-- | Field of BN254TF group.+data PolynomialV+instance IrreducibleMonic Fq2 PolynomialV where+ split _ = X3 - Y X - 9+type Fq6 = ExtensionField Fq2 PolynomialV+data PolynomialW+instance IrreducibleMonic Fq6 PolynomialW where+ split _ = X2 - Y X+type Fq12 = ExtensionField Fq6 PolynomialW++-- | BN254TF group is a field group.+instance FGroup Fq12 where+ g_ = _g+ {-# INLINABLE g_ #-}+ q_ = const _q+ {-# INLINABLE q_ #-}+ r_ = const _r+ {-# INLINABLE r_ #-}+ x_ = _x+ {-# INLINABLE x_ #-}++-- | Element of BN254TF group.+type P = Element Fq12++-------------------------------------------------------------------------------+-- Parameters+-------------------------------------------------------------------------------++-- | Generator of BN254TF group.+_g :: P+_g = F _x+{-# INLINABLE _g #-}++-- | Characteristic of BN254TF group.+_q :: Integer+_q = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47+{-# INLINABLE _q #-}++-- | Order of BN254TF group.+_r :: Integer+_r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001+{-# INLINABLE _r #-}++-- | Element @X@ of BN254TF group.+_x :: Fq12+_x = toField [ toField [ toField [ 0x12c70e90e12b7874510cd1707e8856f71bf7f61d72631e268fca81000db9a1f5+ , 0x84f330485b09e866bc2f2ea2b897394deaf3f12aa31f28cb0552990967d4704+ ]+ , toField [ 0xe841c2ac18a4003ac9326b9558380e0bc27fdd375e3605f96b819a358d34bde+ , 0x2067586885c3318eeffa1938c754fe3c60224ee5ae15e66af6b5104c47c8c5d8+ ]+ , toField [ 0x1676555de427abc409c4a394bc5426886302996919d4bf4bdd02236e14b3636+ , 0x2b03614464f04dd772d86df88674c270ffc8747ea13e72da95e3594468f222c4+ ]+ ]+ , toField [ toField [ 0x2c53748bcd21a7c038fb30ddc8ac3bf0af25d7859cfbc12c30c866276c565909+ , 0x27ed208e7a0b55ae6e710bbfbd2fd922669c026360e37cc5b2ab862411536104+ ]+ , toField [ 0x1ad9db1937fd72f4ac462173d31d3d6117411fa48dba8d499d762b47edb3b54a+ , 0x279db296f9d479292532c7c493d8e0722b6efae42158387564889c79fc038ee3+ ]+ , toField [ 0xdc26f240656bbe2029bd441d77c221f0ba4c70c94b29b5f17f0f6d08745a069+ , 0x108c19d15f9446f744d0f110405d3856d6cc3bda6c4d537663729f5257628417+ ]+ ]+ ]+{-# INLINABLE _x #-}
tests/BinaryTests.hs view
@@ -1,8 +1,7 @@ module BinaryTests where -import Test.Tasty+import Protolude -import CurveTests import qualified Curve.Binary.SECT113R1 as SECT113R1 import qualified Curve.Binary.SECT113R2 as SECT113R2 import qualified Curve.Binary.SECT131R1 as SECT131R1@@ -21,25 +20,34 @@ import qualified Curve.Binary.SECT409R1 as SECT409R1 import qualified Curve.Binary.SECT571K1 as SECT571K1 import qualified Curve.Binary.SECT571R1 as SECT571R1+import Test.Tasty+import Test.Tasty.QuickCheck +import GroupTests+ 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+ [ testBinary' 1 "SECT113R1" SECT113R1._h 2 SECT113R1._r SECT113R1.gA SECT113R1.gP+ , testBinary' 1 "SECT113R2" SECT113R2._h 2 SECT113R2._r SECT113R2.gA SECT113R2.gP+ , testBinary' 1 "SECT131R1" SECT131R1._h 2 SECT131R1._r SECT131R1.gA SECT131R1.gP+ , testBinary' 1 "SECT131R2" SECT131R2._h 2 SECT131R2._r SECT131R2.gA SECT131R2.gP+ , testBinary' 1 "SECT163K1" SECT163K1._h 2 SECT163K1._r SECT163K1.gA SECT163K1.gP+ , testBinary' 1 "SECT163R1" SECT163R1._h 2 SECT163R1._r SECT163R1.gA SECT163R1.gP+ , testBinary' 1 "SECT163R2" SECT163R2._h 2 SECT163R2._r SECT163R2.gA SECT163R2.gP+ , testBinary' 1 "SECT193R1" SECT193R1._h 2 SECT193R1._r SECT193R1.gA SECT193R1.gP+ , testBinary' 1 "SECT193R2" SECT193R2._h 2 SECT193R2._r SECT193R2.gA SECT193R2.gP+ , testBinary' 1 "SECT233K1" SECT233K1._h 2 SECT233K1._r SECT233K1.gA SECT233K1.gP+ , testBinary' 1 "SECT233R1" SECT233R1._h 2 SECT233R1._r SECT233R1.gA SECT233R1.gP+ , testBinary' 1 "SECT239K1" SECT239K1._h 2 SECT239K1._r SECT239K1.gA SECT239K1.gP+ , testBinary' 1 "SECT283K1" SECT283K1._h 2 SECT283K1._r SECT283K1.gA SECT283K1.gP+ , testBinary' 1 "SECT283R1" SECT283R1._h 2 SECT283R1._r SECT283R1.gA SECT283R1.gP+ , testBinary' 1 "SECT409K1" SECT409K1._h 2 SECT409K1._r SECT409K1.gA SECT409K1.gP+ , testBinary' 1 "SECT409R1" SECT409R1._h 2 SECT409R1._r SECT409R1.gA SECT409R1.gP+ , testBinary' 1 "SECT571K1" SECT571K1._h 2 SECT571K1._r SECT571K1.gA SECT571K1.gP+ , testBinary' 1 "SECT571R1" SECT571R1._h 2 SECT571R1._r SECT571R1.gA SECT571R1.gP ]+ where+ testBinary' n c h q r a p = localOption (QuickCheckTests n) $ testGroup c+ [ test "Affine" a h q r+ , test "Projective" p h q r+ ]
− tests/CurveTests.hs
@@ -1,74 +0,0 @@-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
@@ -1,8 +1,7 @@ module EdwardsTests where -import Test.Tasty+import Protolude -import CurveTests import qualified Curve.Edwards.Curve1174 as Curve1174 import qualified Curve.Edwards.Curve41417 as Curve41417 import qualified Curve.Edwards.E222 as E222@@ -12,16 +11,25 @@ import qualified Curve.Edwards.Ed3363 as Ed3363 import qualified Curve.Edwards.Ed25519 as Ed25519 import qualified Curve.Edwards.JubJub as JubJub+import Test.Tasty+import Test.Tasty.QuickCheck +import GroupTests+ 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+ [ testEdwards' 100 "Curve1174" Curve1174._h Curve1174._q Curve1174._r Curve1174.gA Curve1174.gP+ , testEdwards' 100 "Curve41417" Curve41417._h Curve41417._q Curve41417._r Curve41417.gA Curve41417.gP+ , testEdwards' 100 "E222" E222._h E222._q E222._r E222.gA E222.gP+ , testEdwards' 100 "E382" E382._h E382._q E382._r E382.gA E382.gP+ , testEdwards' 100 "E521" E521._h E521._q E521._r E521.gA E521.gP+ , testEdwards' 100 "Ed448" Ed448._h Ed448._q Ed448._r Ed448.gA Ed448.gP+ , testEdwards' 100 "Ed3363" Ed3363._h Ed3363._q Ed3363._r Ed3363.gA Ed3363.gP+ , testEdwards' 100 "Ed25519" Ed25519._h Ed25519._q Ed25519._r Ed25519.gA Ed25519.gP+ , testEdwards' 100 "JubJub" JubJub._h JubJub._q JubJub._r JubJub.gA JubJub.gP ]+ where+ testEdwards' n c h q r a p = localOption (QuickCheckTests n) $ testGroup c+ [ test "Affine" a h q r+ , test "Projective" p h q r+ ]
+ tests/FieldTests.hs view
@@ -0,0 +1,11 @@+module FieldTests where++import qualified Group.Field.BN254TF as BN254TF+import Test.Tasty++import GroupTests++testField :: TestTree+testField = testGroup "Field"+ [ test' "BN254TF" BN254TF._g BN254TF._q BN254TF._r+ ]
+ tests/GroupTests.hs view
@@ -0,0 +1,122 @@+module GroupTests where++import Protolude++import Curve+import GaloisField+import Group+import Group.Field+import Math.NumberTheory.Primes.Testing+import PrimeField+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 g . Group g => g -> TestTree+groupAxioms _ = testGroup "Group axioms"+ [ testCase "identity closure" $+ def (mempty :: g) @?= True+ , testProperty "point closure" $+ (def :: g -> Bool)+ , testProperty "inversion closure" $+ def . (inv :: g -> g)+ , testProperty "addition closure" $+ (.) def . ((<>) :: g -> g -> g)+ , testProperty "doubling closure" $+ def . (join (<>) :: g -> g)+ , testProperty "multiplication closure" $+ def . (flip mul' (-3) :: g -> g)+ , testProperty "identity" $+ identities ((<>) :: g -> g -> g) mempty+ , testProperty "inverses" $+ inverses ((<>) :: g -> g -> g) inv mempty+ , testProperty "commutativity" $+ commutativity ((<>) :: g -> g -> g)+ , testProperty "associativity" $+ associativity ((<>) :: g -> g -> g)+ ]++hasseTheorem :: Integer -> Integer -> Integer -> Bool+hasseTheorem h r q = join (*) (h * r - q - 1) <= 4 * q++doubleIdentities :: (Eq a, Eq b) => (a -> b) -> (b -> a) -> a -> b -> Bool+doubleIdentities f t e e' = f e == e' && t e' == e++doubleDefined :: (a -> Bool) -> (b -> Bool) -> (b -> a) -> b -> Bool+doubleDefined d d' t x = d' x && d (t x)++doubleInverses :: (Eq a, Eq b) => (a -> b) -> (b -> a) -> b -> Bool+doubleInverses f t x = f (t x) == x && t (f (t x)) == t x++doubleHomeomorphism :: (Eq a, Eq b) => (a -> a) -> (b -> b) -> (a -> b) -> (b -> a) -> b -> Bool+doubleHomeomorphism op op' f t x = t (op' x) == op (t x) && f (op (t x)) == op' x++curveParameters :: forall f c e q r p+ . (r ~ PrimeField p, Curve f 'Affine e q r, Curve f c e q r)+ => Point f c e q r -> Integer -> Integer -> Integer -> TestTree+curveParameters g h q r = testGroup "Curve parameters"+ [ testCase "generator is parametrised" $+ gen @?= g+ , testCase "cofactor is parametrised" $+ cof (witness :: Point f c e q r) @?= h+ , testCase "characteristic is parametrised" $+ Curve.char (witness :: Point f c e q r) @?= q+ , testCase "order is parametrised" $+ Group.order (witness :: Point f c e q r) @?= r+ , testCase "characteristic is prime" $+ isPrime q @?= True+ , testCase "discriminant is nonzero" $+ disc (witness :: Point f c e q r) /= 0 @?= True+ , testCase "generator is well-defined" $+ def (gen :: Point f c e q r) @?= True+ , testCase "generator is in cyclic subgroup" $+ mul' g r @?= mempty+ , testCase "cyclic subgroup has prime order" $+ isPrime r @?= True+ , testCase "hasse theorem holds" $+ hasseTheorem h r (GaloisField.order (witness :: q)) @?= True+ , testCase "affine transformation is doubly identity-preserving" $+ doubleIdentities fromA (toA :: Point f c e q r -> Point f 'Affine e q r) mempty mempty @?= True+ , testProperty "affine transformation is doubly well-defined" $+ doubleDefined def def (toA :: Point f c e q r -> Point f 'Affine e q r)+ , testProperty "affine transformation is doubly invertible" $+ doubleInverses fromA (toA :: Point f c e q r -> Point f 'Affine e q r)+ , testProperty "affine transformation is doubly homeomorphic" $+ doubleHomeomorphism (flip mul 3) (flip mul 3) fromA (toA :: Point f c e q r -> Point f 'Affine e q r)+ ]++test :: (r ~ PrimeField p, Curve f c e q r, Curve f 'Affine e q r)+ => TestName -> Point f c e q r -> Integer -> Integer -> Integer -> TestTree+test s g h q r = testGroup s [groupAxioms g, curveParameters g h q r]++fieldParameters :: forall k . FGroup k+ => Element k -> Integer -> Integer -> TestTree+fieldParameters g q r = testGroup "Group parameters"+ [ testCase "generator is parametrised" $+ gen @?= g+ , testCase "characteristic is parametrised" $+ GaloisField.char (witness :: k) @?= q+ , testCase "order is parametrised" $+ Group.order (witness :: Element k) @?= r+ , testCase "characteristic is prime" $+ isPrime q @?= True+ , testCase "generator is well-defined" $+ def (gen :: Element k) @?= True+ , testCase "generator is in cyclic subgroup" $+ mul' g r @?= mempty+ ]++test' :: FGroup k => TestName -> Element k -> Integer -> Integer -> TestTree+test' s g q r = testGroup s [groupAxioms g, fieldParameters g q r]
tests/Main.hs view
@@ -6,9 +6,10 @@ import BinaryTests import EdwardsTests+import FieldTests import MontgomeryTests import WeierstrassTests main :: IO () main = defaultMain $- testGroup "Tests" [testBinary, testEdwards, testMontgomery, testWeierstrass]+ testGroup "Tests" [testBinary, testEdwards, testMontgomery, testWeierstrass, testField]
tests/MontgomeryTests.hs view
@@ -1,21 +1,28 @@ module MontgomeryTests where +import Protolude++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 Test.Tasty+import Test.Tasty.QuickCheck -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+import GroupTests 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+ [ testMontgomery' 100 "Curve448" Curve448._h Curve448._q Curve448._r Curve448.gA+ , testMontgomery' 100 "Curve25519" Curve25519._h Curve25519._q Curve25519._r Curve25519.gA+ , testMontgomery' 100 "Curve383187" Curve383187._h Curve383187._q Curve383187._r Curve383187.gA+ , testMontgomery' 100 "M221" M221._h M221._q M221._r M221.gA+ , testMontgomery' 100 "M383" M383._h M383._q M383._r M383.gA+ , testMontgomery' 100 "M511" M511._h M511._q M511._r M511.gA ]+ where+ testMontgomery' n c h q r a = localOption (QuickCheckTests n) $ testGroup c+ [ test "Affine" a h q r+ ]
tests/WeierstrassTests.hs view
@@ -1,14 +1,13 @@ module WeierstrassTests where -import Test.Tasty+import Protolude -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.BLS12381 as BLS12381+import qualified Curve.Weierstrass.BLS12381T as BLS12381T+import qualified Curve.Weierstrass.BLS48581 as BLS48581+import qualified Curve.Weierstrass.BLS48581T as BLS48581T import qualified Curve.Weierstrass.BN224 as BN224 import qualified Curve.Weierstrass.BN254 as BN254 import qualified Curve.Weierstrass.BN254T as BN254T@@ -50,54 +49,64 @@ import qualified Curve.Weierstrass.SECP256R1 as SECP256R1 import qualified Curve.Weierstrass.SECP384R1 as SECP384R1 import qualified Curve.Weierstrass.SECP521R1 as SECP521R1+import Test.Tasty+import Test.Tasty.QuickCheck +import GroupTests+ 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+ [ testWeierstrass' 100 "Anomalous" Anomalous._h Anomalous._q Anomalous._r Anomalous.gA Anomalous.gJ Anomalous.gP+ , testWeierstrass' 100 "ANSSIFRP256V1" ANSSIFRP256V1._h ANSSIFRP256V1._q ANSSIFRP256V1._r ANSSIFRP256V1.gA ANSSIFRP256V1.gJ ANSSIFRP256V1.gP+ , testWeierstrass' 100 "BLS12381" BLS12381._h BLS12381._q BLS12381._r BLS12381.gA BLS12381.gJ BLS12381.gP+ , testWeierstrass' 10 "BLS12381T" BLS12381T._h BLS12381T._q BLS12381T._r BLS12381T.gA BLS12381T.gJ BLS12381T.gP+ , testWeierstrass' 100 "BLS48581" BLS48581._h BLS48581._q BLS48581._r BLS48581.gA BLS48581.gJ BLS48581.gP+ , testWeierstrass' 0 "BLS48581T" BLS48581T._h BLS48581T._q BLS48581T._r BLS48581T.gA BLS48581T.gJ BLS48581T.gP+ , testWeierstrass' 100 "BN224" BN224._h BN224._q BN224._r BN224.gA BN224.gJ BN224.gP+ , testWeierstrass' 100 "BN254" BN254._h BN254._q BN254._r BN254.gA BN254.gJ BN254.gP+ , testWeierstrass' 10 "BN254T" BN254T._h BN254T._q BN254T._r BN254T.gA BN254T.gJ BN254T.gP+ , testWeierstrass' 100 "BN254A" BN254A._h BN254A._q BN254A._r BN254A.gA BN254A.gJ BN254A.gP+ , testWeierstrass' 10 "BN254AT" BN254AT._h BN254AT._q BN254AT._r BN254AT.gA BN254AT.gJ BN254AT.gP+ , testWeierstrass' 100 "BN254B" BN254B._h BN254B._q BN254B._r BN254B.gA BN254B.gJ BN254B.gP+ , testWeierstrass' 10 "BN254BT" BN254BT._h BN254BT._q BN254BT._r BN254BT.gA BN254BT.gJ BN254BT.gP+ , testWeierstrass' 100 "BN256" BN256._h BN256._q BN256._r BN256.gA BN256.gJ BN256.gP+ , testWeierstrass' 100 "BN384" BN384._h BN384._q BN384._r BN384.gA BN384.gJ BN384.gP+ , testWeierstrass' 100 "BN462" BN462._h BN462._q BN462._r BN462.gA BN462.gJ BN462.gP+ , testWeierstrass' 10 "BN462T" BN462T._h BN462T._q BN462T._r BN462T.gA BN462T.gJ BN462T.gP+ , testWeierstrass' 100 "BN512" BN512._h BN512._q BN512._r BN512.gA BN512.gJ BN512.gP+ , testWeierstrass' 100 "BrainpoolP160R1" BrainpoolP160R1._h BrainpoolP160R1._q BrainpoolP160R1._r BrainpoolP160R1.gA BrainpoolP160R1.gJ BrainpoolP160R1.gP+ , testWeierstrass' 100 "BrainpoolP160T1" BrainpoolP160T1._h BrainpoolP160T1._q BrainpoolP160T1._r BrainpoolP160T1.gA BrainpoolP160T1.gJ BrainpoolP160T1.gP+ , testWeierstrass' 100 "BrainpoolP192R1" BrainpoolP192R1._h BrainpoolP192R1._q BrainpoolP192R1._r BrainpoolP192R1.gA BrainpoolP192R1.gJ BrainpoolP192R1.gP+ , testWeierstrass' 100 "BrainpoolP192T1" BrainpoolP192T1._h BrainpoolP192T1._q BrainpoolP192T1._r BrainpoolP192T1.gA BrainpoolP192T1.gJ BrainpoolP192T1.gP+ , testWeierstrass' 100 "BrainpoolP224R1" BrainpoolP224R1._h BrainpoolP224R1._q BrainpoolP224R1._r BrainpoolP224R1.gA BrainpoolP224R1.gJ BrainpoolP224R1.gP+ , testWeierstrass' 100 "BrainpoolP224T1" BrainpoolP224T1._h BrainpoolP224T1._q BrainpoolP224T1._r BrainpoolP224T1.gA BrainpoolP224T1.gJ BrainpoolP224T1.gP+ , testWeierstrass' 100 "BrainpoolP256R1" BrainpoolP256R1._h BrainpoolP256R1._q BrainpoolP256R1._r BrainpoolP256R1.gA BrainpoolP256R1.gJ BrainpoolP256R1.gP+ , testWeierstrass' 100 "BrainpoolP256T1" BrainpoolP256T1._h BrainpoolP256T1._q BrainpoolP256T1._r BrainpoolP256T1.gA BrainpoolP256T1.gJ BrainpoolP256T1.gP+ , testWeierstrass' 100 "BrainpoolP320R1" BrainpoolP320R1._h BrainpoolP320R1._q BrainpoolP320R1._r BrainpoolP320R1.gA BrainpoolP320R1.gJ BrainpoolP320R1.gP+ , testWeierstrass' 100 "BrainpoolP320T1" BrainpoolP320T1._h BrainpoolP320T1._q BrainpoolP320T1._r BrainpoolP320T1.gA BrainpoolP320T1.gJ BrainpoolP320T1.gP+ , testWeierstrass' 100 "BrainpoolP384R1" BrainpoolP384R1._h BrainpoolP384R1._q BrainpoolP384R1._r BrainpoolP384R1.gA BrainpoolP384R1.gJ BrainpoolP384R1.gP+ , testWeierstrass' 100 "BrainpoolP384T1" BrainpoolP384T1._h BrainpoolP384T1._q BrainpoolP384T1._r BrainpoolP384T1.gA BrainpoolP384T1.gJ BrainpoolP384T1.gP+ , testWeierstrass' 100 "BrainpoolP512R1" BrainpoolP512R1._h BrainpoolP512R1._q BrainpoolP512R1._r BrainpoolP512R1.gA BrainpoolP512R1.gJ BrainpoolP512R1.gP+ , testWeierstrass' 100 "BrainpoolP512T1" BrainpoolP512T1._h BrainpoolP512T1._q BrainpoolP512T1._r BrainpoolP512T1.gA BrainpoolP512T1.gJ BrainpoolP512T1.gP+ , testWeierstrass' 100 "SECP112R1" SECP112R1._h SECP112R1._q SECP112R1._r SECP112R1.gA SECP112R1.gJ SECP112R1.gP+ , testWeierstrass' 100 "SECP112R2" SECP112R2._h SECP112R2._q SECP112R2._r SECP112R2.gA SECP112R2.gJ SECP112R2.gP+ , testWeierstrass' 100 "SECP128R1" SECP128R1._h SECP128R1._q SECP128R1._r SECP128R1.gA SECP128R1.gJ SECP128R1.gP+ , testWeierstrass' 100 "SECP128R2" SECP128R2._h SECP128R2._q SECP128R2._r SECP128R2.gA SECP128R2.gJ SECP128R2.gP+ , testWeierstrass' 100 "SECP160K1" SECP160K1._h SECP160K1._q SECP160K1._r SECP160K1.gA SECP160K1.gJ SECP160K1.gP+ , testWeierstrass' 100 "SECP160R1" SECP160R1._h SECP160R1._q SECP160R1._r SECP160R1.gA SECP160R1.gJ SECP160R1.gP+ , testWeierstrass' 100 "SECP160R2" SECP160R2._h SECP160R2._q SECP160R2._r SECP160R2.gA SECP160R2.gJ SECP160R2.gP+ , testWeierstrass' 100 "SECP192K1" SECP192K1._h SECP192K1._q SECP192K1._r SECP192K1.gA SECP192K1.gJ SECP192K1.gP+ , testWeierstrass' 100 "SECP192R1" SECP192R1._h SECP192R1._q SECP192R1._r SECP192R1.gA SECP192R1.gJ SECP192R1.gP+ , testWeierstrass' 100 "SECP224K1" SECP224K1._h SECP224K1._q SECP224K1._r SECP224K1.gA SECP224K1.gJ SECP224K1.gP+ , testWeierstrass' 100 "SECP224R1" SECP224R1._h SECP224R1._q SECP224R1._r SECP224R1.gA SECP224R1.gJ SECP224R1.gP+ , testWeierstrass' 100 "SECP256K1" SECP256K1._h SECP256K1._q SECP256K1._r SECP256K1.gA SECP256K1.gJ SECP256K1.gP+ , testWeierstrass' 100 "SECP256R1" SECP256R1._h SECP256R1._q SECP256R1._r SECP256R1.gA SECP256R1.gJ SECP256R1.gP+ , testWeierstrass' 100 "SECP384R1" SECP384R1._h SECP384R1._q SECP384R1._r SECP384R1.gA SECP384R1.gJ SECP384R1.gP+ , testWeierstrass' 100 "SECP521R1" SECP521R1._h SECP521R1._q SECP521R1._r SECP521R1.gA SECP521R1.gJ SECP521R1.gP ]+ where+ testWeierstrass' n c h q r a j p = localOption (QuickCheckTests n) $ testGroup c+ [ test "Affine" a h q r+ , test "Jacobian" j h q r+ , test "Projective" p h q r+ ]