-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathBLS48581T.hs
165 lines (142 loc) · 7.63 KB
/
BLS48581T.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
module Data.Curve.Weierstrass.BLS48581T
( module Data.Curve.Weierstrass
, Point(..)
-- * BLS48581 curve
, module Data.Curve.Weierstrass.BLS48581T
) where
import Protolude
import Data.Field.Galois
import GHC.Natural (Natural)
import Data.Curve.Weierstrass
import Data.Curve.Weierstrass.BLS48581 (BLS48581, Fq, Fr)
-------------------------------------------------------------------------------
-- Types
-------------------------------------------------------------------------------
-- | Field of points of BLS48581 curve over @Fq2@.
type Fq2 = Extension U Fq
data U
instance IrreducibleMonic U Fq where
poly _ = [1, 0, 1]
{-# INLINABLE poly #-}
-- | Field of points of BLS48581 curve over @Fq4@.
type Fq4 = Extension V Fq2
data V
instance IrreducibleMonic V Fq2 where
poly _ = [U + 1, 0, 1]
{-# INLINABLE poly #-}
-- | Field of points of BLS48581 curve over @Fq8@.
type Fq8 = Extension W Fq4
data W
instance IrreducibleMonic W Fq4 where
poly _ = [U, 0, 1]
{-# INLINABLE poly #-}
-- BLS48581 curve is a Weierstrass curve.
instance Curve 'Weierstrass c BLS48581 Fq8 Fr => WCurve c BLS48581 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_ #-}
-- | Affine BLS48581 curve point.
type PA = WAPoint BLS48581 Fq8 Fr
-- Affine BLS48581 curve is a Weierstrass affine curve.
instance WACurve BLS48581 Fq8 Fr where
gA_ = gA
{-# INLINABLE gA_ #-}
-- | Jacobian BLS48581 point.
type PJ = WJPoint BLS48581 Fq8 Fr
-- Jacobian BLS48581 curve is a Weierstrass Jacobian curve.
instance WJCurve BLS48581 Fq8 Fr where
gJ_ = gJ
{-# INLINABLE gJ_ #-}
-- | Projective BLS48581 point.
type PP = WPPoint BLS48581 Fq8 Fr
-- Projective BLS48581 curve is a Weierstrass projective curve.
instance WPCurve BLS48581 Fq8 Fr where
gP_ = gP
{-# INLINABLE gP_ #-}
-------------------------------------------------------------------------------
-- Parameters
-------------------------------------------------------------------------------
-- | Coefficient @A@ of BLS48581 curve.
_a :: Fq8
_a = toE' [
]
{-# INLINABLE _a #-}
-- | Coefficient @B@ of BLS48581 curve.
_b :: Fq8
_b = toE' [ toE' [
]
, toE' [ toE' [
]
, toE' [ 0x9407b9ff9a3b7989c12718ea38095002b7427c6891098dd9df36078f9cbaa225245721d7b7041566ce6981ca7a39b6d7b41b3d2a898b877052bc7efb90d2524561f6e0aa732b2c895
, 0x9407b9ff9a3b7989c12718ea38095002b7427c6891098dd9df36078f9cbaa225245721d7b7041566ce6981ca7a39b6d7b41b3d2a898b877052bc7efb90d2524561f6e0aa732b2c896
]
]
]
{-# INLINABLE _b #-}
-- | Cofactor of BLS48581 curve.
_h :: Natural
_h = 0x170e915cb0a6b7406b8d94042317f811d6bc3fc6e211ada42e58ccfcb3ac076a7e4499d700a0c23dc4b0c078f92def8c87b7fe63e1eea270db353a4ef4d38b5998ad8f0d042ea24c8f02be1c0c83992fe5d7725227bb27123a949e0876c0a8ce0a67326db0e955dcb791b867f31d6bfa62fbdd5f44a00504df04e186fae033f1eb43c1b1a08b6e086eff03c8fee9ebdd1e191a8a4b0466c90b389987de5637d5dd13dab33196bd2e5afa6cd19cf0fc3fc7db7ece1f3fac742626b1b02fcee04043b2ea96492f6afa51739597c54bb78aa6b0b99319fef9d09f768831018ee6564c68d054c62f2e0b4549426fec24ab26957a669dba2a2b6945ce40c9aec6afdeda16c79e15546cd7771fa544d5364236690ea06832679562a68731420ae52d0d35a90b8d10b688e31b6aee45f45b7a5083c71732105852decc888f64839a4de33b99521f0984a418d20fc7b0609530e454f0696fa2a8075ac01cc8ae3869e8d0fe1f3788ffac4c01aa2720e431da333c83d9663bfb1fb7a1a7b90528482c6be7892299030bb51a51dc7e91e9156874416bf4c26f1ea7ec578058563960ef92bbbb8632d3a1b695f954af10e9a78e40acffc13b06540aae9da5287fc4429485d44e6289d8c0d6a3eb2ece35012452751839fb48bc14b515478e2ff412d930ac20307561f3a5c998e6bcbfebd97effc6433033a2361bfcdc4fc74ad379a16c6dea49c209b1
{-# INLINABLE _h #-}
-- | Characteristic of BLS48581 curve.
_q :: Natural
_q = 0x1280f73ff3476f313824e31d47012a0056e84f8d122131bb3be6c0f1f3975444a48ae43af6e082acd9cd30394f4736daf68367a5513170ee0a578fdf721a4a48ac3edc154e6565912b
{-# INLINABLE _q #-}
-- | Order of BLS48581 curve.
_r :: Natural
_r = 0x2386f8a925e2885e233a9ccc1615c0d6c635387a3f0b3cbe003fad6bc972c2e6e741969d34c4c92016a85c7cd0562303c4ccbe599467c24da118a5fe6fcd671c01
{-# INLINABLE _r #-}
-- | Coordinate @X@ of BLS48581 curve.
_x :: Fq8
_x = toE' [ toE' [ toE' [ 0x5d615d9a7871e4a38237fa45a2775debabbefc70344dbccb7de64db3a2ef156c46ff79baad1a8c42281a63ca0612f400503004d80491f510317b79766322154dec34fd0b4ace8bfab
, 0x7c4973ece2258512069b0e86abc07e8b22bb6d980e1623e9526f6da12307f4e1c3943a00abfedf16214a76affa62504f0c3c7630d979630ffd75556a01afa143f1669b36676b47c57
]
, toE' [ 0x1fccc70198f1334e1b2ea1853ad83bc73a8a6ca9ae237ca7a6d6957ccbab5ab6860161c1dbd19242ffae766f0d2a6d55f028cbdfbb879d5fea8ef4cded6b3f0b46488156ca55a3e6a
, 0xbe2218c25ceb6185c78d8012954d4bfe8f5985ac62f3e5821b7b92a393f8be0cc218a95f63e1c776e6ec143b1b279b9468c31c5257c200ca52310b8cb4e80bc3f09a7033cbb7feafe
]
]
, toE' [ toE' [ 0x38b91c600b35913a3c598e4caa9dd63007c675d0b1642b5675ff0e7c5805386699981f9e48199d5ac10b2ef492ae589274fad55fc1889aa80c65b5f746c9d4cbb739c3a1c53f8cce5
, 0xc96c7797eb0738603f1311e4ecda088f7b8f35dcef0977a3d1a58677bb037418181df63835d28997eb57b40b9c0b15dd7595a9f177612f097fc7960910fce3370f2004d914a3c093a
]
, toE' [ 0xb9b7951c6061ee3f0197a498908aee660dea41b39d13852b6db908ba2c0b7a449cef11f293b13ced0fd0caa5efcf3432aad1cbe4324c22d63334b5b0e205c3354e41607e60750e057
, 0x827d5c22fb2bdec5282624c4f4aaa2b1e5d7a9defaf47b5211cf741719728a7f9f8cfca93f29cff364a7190b7e2b0d4585479bd6aebf9fc44e56af2fc9e97c3f84e19da00fbc6ae34
]
]
]
{-# INLINABLE _x #-}
-- | Coordinate @Y@ of BLS48581 curve.
_y :: Fq8
_y = toE' [ toE' [ toE' [ 0xeb53356c375b5dfa497216452f3024b918b4238059a577e6f3b39ebfc435faab0906235afa27748d90f7336d8ae5163c1599abf77eea6d659045012ab12c0ff323edd3fe4d2d7971
, 0x284dc75979e0ff144da6531815fcadc2b75a422ba325e6fba01d72964732fcbf3afb096b243b1f192c5c3d1892ab24e1dd212fa097d760e2e588b423525ffc7b111471db936cd5665
]
, toE' [ 0xb36a201dd008523e421efb70367669ef2c2fc5030216d5b119d3a480d370514475f7d5c99d0e90411515536ca3295e5e2f0c1d35d51a652269cbc7c46fc3b8fde68332a526a2a8474
, 0xaec25a4621edc0688223fbbd478762b1c2cded3360dcee23dd8b0e710e122d2742c89b224333fa40dced2817742770ba10d67bda503ee5e578fb3d8b8a1e5337316213da92841589d
]
]
, toE' [ toE' [ 0xd209d5a223a9c46916503fa5a88325a2554dc541b43dd93b5a959805f1129857ed85c77fa238cdce8a1e2ca4e512b64f59f430135945d137b08857fdddfcf7a43f47831f982e50137
, 0x7d0d03745736b7a513d339d5ad537b90421ad66eb16722b589d82e2055ab7504fa83420e8c270841f6824f47c180d139e3aafc198caa72b679da59ed8226cf3a594eedc58cf90bee4
]
, toE' [ 0x896767811be65ea25c2d05dfdd17af8a006f364fc0841b064155f14e4c819a6df98f425ae3a2864f22c1fab8c74b2618b5bb40fa639f53dccc9e884017d9aa62b3d41faeafeb23986
, 0x35e2524ff89029d393a5c07e84f981b5e068f1406be8e50c87549b6ef8eca9a9533a3f8e69c31e97e1ad0333ec719205417300d8c4ab33f748e5ac66e84069c55d667ffcb732718b6
]
]
]
{-# 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 #-}