ethereum.forks.amsterdam.vm.precompiled_contracts.bls12_381ethereum.forks.bogota.vm.precompiled_contracts.bls12_381
BLS12 381 Precompile.
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Precompile for BLS12-381 curve operations.
ZERO_PAD¶
| 19 | ZERO_PAD = b"\x00" * 16 |
|---|
unpad_fp ¶
Remove the 16-byte zero padding from a 64-byte field element.
Parameters
data : The 64-byte big-endian padded field element.
Returns
raw : Bytes The 48-byte unpadded field element.
Raises
InvalidParameter If the leading 16 bytes are not zero.
unpad_g1 ¶
Strip padding from a 128-byte G1 encoding to 96 raw bytes.
Parameters
data : The 128-byte padded G1 point.
Returns
raw : Bytes The 96-byte unpadded G1 point.
Raises
InvalidParameter If the padding is invalid.
unpad_g2 ¶
Strip padding from a 256-byte G2 encoding to 192 raw bytes.
Parameters
data : The 256-byte padded G2 point.
Returns
raw : Bytes The 192-byte unpadded G2 point.
Raises
InvalidParameter If the padding is invalid.
pad_g1 ¶
Add 16-byte zero padding to a 96-byte G1 point.
Parameters
raw : The 96-byte raw G1 point.
Returns
padded : Bytes The 128-byte padded G1 point.
pad_g2 ¶
Add 16-byte zero padding to a 192-byte G2 point.
Parameters
raw : The 192-byte raw G2 point.
Returns
padded : Bytes The 256-byte padded G2 point.
G1_K_DISCOUNT¶
| 143 | G1_K_DISCOUNT = [ |
|---|---|
| 144 | 1000, |
| 145 | 949, |
| 146 | 848, |
| 147 | 797, |
| 148 | 764, |
| 149 | 750, |
| 150 | 738, |
| 151 | 728, |
| 152 | 719, |
| 153 | 712, |
| 154 | 705, |
| 155 | 698, |
| 156 | 692, |
| 157 | 687, |
| 158 | 682, |
| 159 | 677, |
| 160 | 673, |
| 161 | 669, |
| 162 | 665, |
| 163 | 661, |
| 164 | 658, |
| 165 | 654, |
| 166 | 651, |
| 167 | 648, |
| 168 | 645, |
| 169 | 642, |
| 170 | 640, |
| 171 | 637, |
| 172 | 635, |
| 173 | 632, |
| 174 | 630, |
| 175 | 627, |
| 176 | 625, |
| 177 | 623, |
| 178 | 621, |
| 179 | 619, |
| 180 | 617, |
| 181 | 615, |
| 182 | 613, |
| 183 | 611, |
| 184 | 609, |
| 185 | 608, |
| 186 | 606, |
| 187 | 604, |
| 188 | 603, |
| 189 | 601, |
| 190 | 599, |
| 191 | 598, |
| 192 | 596, |
| 193 | 595, |
| 194 | 593, |
| 195 | 592, |
| 196 | 591, |
| 197 | 589, |
| 198 | 588, |
| 199 | 586, |
| 200 | 585, |
| 201 | 584, |
| 202 | 582, |
| 203 | 581, |
| 204 | 580, |
| 205 | 579, |
| 206 | 577, |
| 207 | 576, |
| 208 | 575, |
| 209 | 574, |
| 210 | 573, |
| 211 | 572, |
| 212 | 570, |
| 213 | 569, |
| 214 | 568, |
| 215 | 567, |
| 216 | 566, |
| 217 | 565, |
| 218 | 564, |
| 219 | 563, |
| 220 | 562, |
| 221 | 561, |
| 222 | 560, |
| 223 | 559, |
| 224 | 558, |
| 225 | 557, |
| 226 | 556, |
| 227 | 555, |
| 228 | 554, |
| 229 | 553, |
| 230 | 552, |
| 231 | 551, |
| 232 | 550, |
| 233 | 549, |
| 234 | 548, |
| 235 | 547, |
| 236 | 547, |
| 237 | 546, |
| 238 | 545, |
| 239 | 544, |
| 240 | 543, |
| 241 | 542, |
| 242 | 541, |
| 243 | 540, |
| 244 | 540, |
| 245 | 539, |
| 246 | 538, |
| 247 | 537, |
| 248 | 536, |
| 249 | 536, |
| 250 | 535, |
| 251 | 534, |
| 252 | 533, |
| 253 | 532, |
| 254 | 532, |
| 255 | 531, |
| 256 | 530, |
| 257 | 529, |
| 258 | 528, |
| 259 | 528, |
| 260 | 527, |
| 261 | 526, |
| 262 | 525, |
| 263 | 525, |
| 264 | 524, |
| 265 | 523, |
| 266 | 522, |
| 267 | 522, |
| 268 | 521, |
| 269 | 520, |
| 270 | 520, |
| 271 | 519, |
| 272 | ] |
G2_K_DISCOUNT¶
| 274 | G2_K_DISCOUNT = [ |
|---|---|
| 275 | 1000, |
| 276 | 1000, |
| 277 | 923, |
| 278 | 884, |
| 279 | 855, |
| 280 | 832, |
| 281 | 812, |
| 282 | 796, |
| 283 | 782, |
| 284 | 770, |
| 285 | 759, |
| 286 | 749, |
| 287 | 740, |
| 288 | 732, |
| 289 | 724, |
| 290 | 717, |
| 291 | 711, |
| 292 | 704, |
| 293 | 699, |
| 294 | 693, |
| 295 | 688, |
| 296 | 683, |
| 297 | 679, |
| 298 | 674, |
| 299 | 670, |
| 300 | 666, |
| 301 | 663, |
| 302 | 659, |
| 303 | 655, |
| 304 | 652, |
| 305 | 649, |
| 306 | 646, |
| 307 | 643, |
| 308 | 640, |
| 309 | 637, |
| 310 | 634, |
| 311 | 632, |
| 312 | 629, |
| 313 | 627, |
| 314 | 624, |
| 315 | 622, |
| 316 | 620, |
| 317 | 618, |
| 318 | 615, |
| 319 | 613, |
| 320 | 611, |
| 321 | 609, |
| 322 | 607, |
| 323 | 606, |
| 324 | 604, |
| 325 | 602, |
| 326 | 600, |
| 327 | 598, |
| 328 | 597, |
| 329 | 595, |
| 330 | 593, |
| 331 | 592, |
| 332 | 590, |
| 333 | 589, |
| 334 | 587, |
| 335 | 586, |
| 336 | 584, |
| 337 | 583, |
| 338 | 582, |
| 339 | 580, |
| 340 | 579, |
| 341 | 578, |
| 342 | 576, |
| 343 | 575, |
| 344 | 574, |
| 345 | 573, |
| 346 | 571, |
| 347 | 570, |
| 348 | 569, |
| 349 | 568, |
| 350 | 567, |
| 351 | 566, |
| 352 | 565, |
| 353 | 563, |
| 354 | 562, |
| 355 | 561, |
| 356 | 560, |
| 357 | 559, |
| 358 | 558, |
| 359 | 557, |
| 360 | 556, |
| 361 | 555, |
| 362 | 554, |
| 363 | 553, |
| 364 | 552, |
| 365 | 552, |
| 366 | 551, |
| 367 | 550, |
| 368 | 549, |
| 369 | 548, |
| 370 | 547, |
| 371 | 546, |
| 372 | 545, |
| 373 | 545, |
| 374 | 544, |
| 375 | 543, |
| 376 | 542, |
| 377 | 541, |
| 378 | 541, |
| 379 | 540, |
| 380 | 539, |
| 381 | 538, |
| 382 | 537, |
| 383 | 537, |
| 384 | 536, |
| 385 | 535, |
| 386 | 535, |
| 387 | 534, |
| 388 | 533, |
| 389 | 532, |
| 390 | 532, |
| 391 | 531, |
| 392 | 530, |
| 393 | 530, |
| 394 | 529, |
| 395 | 528, |
| 396 | 528, |
| 397 | 527, |
| 398 | 526, |
| 399 | 526, |
| 400 | 525, |
| 401 | 524, |
| 402 | 524, |
| 403 | ] |
G1_MAX_DISCOUNT¶
| 405 | G1_MAX_DISCOUNT = 519 |
|---|
G2_MAX_DISCOUNT¶
| 406 | G2_MAX_DISCOUNT = 524 |
|---|
MULTIPLIER¶
| 407 | MULTIPLIER = Uint(1000) |
|---|