mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
add proposed bls multiexp and g2 mul repricings
This commit is contained in:
parent
08e6bdb550
commit
9dd1726bbe
2 changed files with 10 additions and 8 deletions
|
|
@ -801,10 +801,10 @@ func (c *bls12381G1MultiExp) RequiredGas(input []byte) uint64 {
|
||||||
}
|
}
|
||||||
// Lookup discount value for G1 point, scalar value pair length
|
// Lookup discount value for G1 point, scalar value pair length
|
||||||
var discount uint64
|
var discount uint64
|
||||||
if dLen := len(params.Bls12381MultiExpDiscountTable); k < dLen {
|
if dLen := len(params.Bls12381G1MultiExpDiscountTable); k < dLen {
|
||||||
discount = params.Bls12381MultiExpDiscountTable[k-1]
|
discount = params.Bls12381G1MultiExpDiscountTable[k-1]
|
||||||
} else {
|
} else {
|
||||||
discount = params.Bls12381MultiExpDiscountTable[dLen-1]
|
discount = params.Bls12381G1MultiExpDiscountTable[dLen-1]
|
||||||
}
|
}
|
||||||
// Calculate gas and return the result
|
// Calculate gas and return the result
|
||||||
return (uint64(k) * params.Bls12381G1MulGas * discount) / 1000
|
return (uint64(k) * params.Bls12381G1MulGas * discount) / 1000
|
||||||
|
|
@ -936,10 +936,10 @@ func (c *bls12381G2MultiExp) RequiredGas(input []byte) uint64 {
|
||||||
}
|
}
|
||||||
// Lookup discount value for G2 point, scalar value pair length
|
// Lookup discount value for G2 point, scalar value pair length
|
||||||
var discount uint64
|
var discount uint64
|
||||||
if dLen := len(params.Bls12381MultiExpDiscountTable); k < dLen {
|
if dLen := len(params.Bls12381G2MultiExpDiscountTable); k < dLen {
|
||||||
discount = params.Bls12381MultiExpDiscountTable[k-1]
|
discount = params.Bls12381G2MultiExpDiscountTable[k-1]
|
||||||
} else {
|
} else {
|
||||||
discount = params.Bls12381MultiExpDiscountTable[dLen-1]
|
discount = params.Bls12381G2MultiExpDiscountTable[dLen-1]
|
||||||
}
|
}
|
||||||
// Calculate gas and return the result
|
// Calculate gas and return the result
|
||||||
return (uint64(k) * params.Bls12381G2MulGas * discount) / 1000
|
return (uint64(k) * params.Bls12381G2MulGas * discount) / 1000
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ const (
|
||||||
Bls12381G1AddGas uint64 = 500 // Price for BLS12-381 elliptic curve G1 point addition
|
Bls12381G1AddGas uint64 = 500 // Price for BLS12-381 elliptic curve G1 point addition
|
||||||
Bls12381G1MulGas uint64 = 12000 // Price for BLS12-381 elliptic curve G1 point scalar multiplication
|
Bls12381G1MulGas uint64 = 12000 // Price for BLS12-381 elliptic curve G1 point scalar multiplication
|
||||||
Bls12381G2AddGas uint64 = 800 // Price for BLS12-381 elliptic curve G2 point addition
|
Bls12381G2AddGas uint64 = 800 // Price for BLS12-381 elliptic curve G2 point addition
|
||||||
Bls12381G2MulGas uint64 = 45000 // Price for BLS12-381 elliptic curve G2 point scalar multiplication
|
Bls12381G2MulGas uint64 = 22500 // Price for BLS12-381 elliptic curve G2 point scalar multiplication
|
||||||
Bls12381PairingBaseGas uint64 = 65000 // Base gas price for BLS12-381 elliptic curve pairing check
|
Bls12381PairingBaseGas uint64 = 65000 // Base gas price for BLS12-381 elliptic curve pairing check
|
||||||
Bls12381PairingPerPairGas uint64 = 43000 // Per-point pair gas price for BLS12-381 elliptic curve pairing check
|
Bls12381PairingPerPairGas uint64 = 43000 // Per-point pair gas price for BLS12-381 elliptic curve pairing check
|
||||||
Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation
|
Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation
|
||||||
|
|
@ -179,7 +179,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations
|
// Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations
|
||||||
var Bls12381MultiExpDiscountTable = [128]uint64{1200, 888, 764, 641, 594, 547, 500, 453, 438, 423, 408, 394, 379, 364, 349, 334, 330, 326, 322, 318, 314, 310, 306, 302, 298, 294, 289, 285, 281, 277, 273, 269, 268, 266, 265, 263, 262, 260, 259, 257, 256, 254, 253, 251, 250, 248, 247, 245, 244, 242, 241, 239, 238, 236, 235, 233, 232, 231, 229, 228, 226, 225, 223, 222, 221, 220, 219, 219, 218, 217, 216, 216, 215, 214, 213, 213, 212, 211, 211, 210, 209, 208, 208, 207, 206, 205, 205, 204, 203, 202, 202, 201, 200, 199, 199, 198, 197, 196, 196, 195, 194, 193, 193, 192, 191, 191, 190, 189, 188, 188, 187, 186, 185, 185, 184, 183, 182, 182, 181, 180, 179, 179, 178, 177, 176, 176, 175, 174}
|
var Bls12381G1MultiExpDiscountTable = [128]uint64{900, 888, 955, 802, 743, 821, 750, 680, 657, 635, 612, 591, 664, 637, 611, 585, 578, 571, 564, 557, 628, 620, 612, 604, 596, 588, 578, 570, 562, 693, 683, 673, 670, 665, 663, 658, 655, 650, 648, 643, 640, 635, 633, 628, 625, 620, 618, 613, 610, 605, 603, 598, 595, 590, 588, 583, 580, 578, 573, 570, 565, 563, 558, 555, 553, 550, 548, 548, 545, 543, 540, 540, 538, 535, 533, 533, 530, 528, 528, 525, 523, 520, 520, 518, 515, 513, 513, 510, 508, 505, 505, 503, 500, 498, 498, 495, 493, 490, 490, 488, 485, 483, 483, 480, 478, 478, 475, 473, 470, 470, 468, 465, 463, 463, 460, 458, 455, 455, 453, 450, 448, 448, 445, 443, 440, 440, 438, 435}
|
||||||
|
|
||||||
|
var Bls12381G2MultiExpDiscountTable = [128]uint64{1800, 1776, 1528, 1282, 1188, 1368, 1250, 1133, 1095, 1269, 1224, 1182, 1137, 1274, 1222, 1169, 1155, 1141, 1127, 1113, 1256, 1240, 1224, 1208, 1192, 1176, 1156, 1140, 1124, 1108, 1092, 1076, 1072, 1064, 1060, 1052, 1048, 1040, 1036, 1028, 1024, 1016, 1012, 1004, 1000, 992, 988, 980, 976, 968, 964, 956, 952, 944, 940, 932, 928, 924, 916, 912, 904, 900, 892, 888, 884, 880, 876, 876, 872, 868, 864, 864, 860, 856, 852, 852, 848, 844, 844, 840, 836, 832, 832, 828, 824, 820, 820, 816, 812, 808, 808, 804, 800, 796, 796, 792, 788, 784, 784, 780, 776, 772, 772, 768, 764, 764, 760, 756, 752, 752, 748, 744, 740, 740, 736, 732, 728, 728, 724, 720, 716, 716, 712, 708, 704, 704, 700, 696}
|
||||||
|
|
||||||
// Difficulty parameters.
|
// Difficulty parameters.
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue