EIP2537 part 1
This commit is contained in:
parent
360b74327e
commit
c1b7ae5b02
|
@ -3,12 +3,12 @@ PrecompileTests
|
|||
## PrecompileTests
|
||||
```diff
|
||||
+ blake2F.json OK
|
||||
- blsG1Add.json Fail
|
||||
- blsG1Mul.json Fail
|
||||
- blsG1MultiExp.json Fail
|
||||
- blsG2Add.json Fail
|
||||
- blsG2Mul.json Fail
|
||||
- blsG2MultiExp.json Fail
|
||||
+ blsG1Add.json OK
|
||||
+ blsG1Mul.json OK
|
||||
+ blsG1MultiExp.json OK
|
||||
+ blsG2Add.json OK
|
||||
+ blsG2Mul.json OK
|
||||
+ blsG2MultiExp.json OK
|
||||
- blsMapG1.json Fail
|
||||
- blsMapG2.json Fail
|
||||
- blsPairing.json Fail
|
||||
|
@ -25,7 +25,7 @@ PrecompileTests
|
|||
+ ripemd160.json OK
|
||||
+ sha256.json OK
|
||||
```
|
||||
OK: 13/22 Fail: 9/22 Skip: 0/22
|
||||
OK: 19/22 Fail: 3/22 Skip: 0/22
|
||||
|
||||
---TOTAL---
|
||||
OK: 13/22 Fail: 9/22 Skip: 0/22
|
||||
OK: 19/22 Fail: 3/22 Skip: 0/22
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
import blscurve/bls_backend
|
||||
|
||||
when BLS_BACKEND == Miracl:
|
||||
import blscurve/miracl/[common, milagro]
|
||||
export common
|
||||
|
||||
type
|
||||
BLS_G1* = ECP_BLS12381
|
||||
BLS_G2* = ECP2_BLS12381
|
||||
BLS_FP* = BIG_384
|
||||
BLS_FP2* = FP2_BLS12381
|
||||
BLS_SCALAR* = BIG_384
|
||||
BLS_FE* = FP_BLS12381
|
||||
BLS_FE2* = FP2_BLS12381
|
||||
|
||||
proc ECP_BLS12381_map2point(P: var ECP_BLS12381, h: FP_BLS12381) {.importc, cdecl.}
|
||||
proc ECP2_BLS12381_map2point(P: var ECP2_BLS12381, h: FP2_BLS12381) {.importc, cdecl.}
|
||||
proc ECP_BLS12381_set(p: ptr ECP_BLS12381, x, y: BIG_384): cint {.importc, cdecl.}
|
||||
proc FP_BLS12381_sqr(w: ptr FP_BLS12381, x: ptr FP_BLS12381) {.importc, cdecl.}
|
||||
|
||||
proc sqr*(x: FP_BLS12381): FP_BLS12381 {.inline.} =
|
||||
## Retruns ``x ^ 2``.
|
||||
FP_BLS12381_sqr(addr result, unsafeAddr x)
|
||||
|
||||
proc rhs*(x: FP_BLS12381): FP_BLS12381 {.inline.} =
|
||||
## Returns ``x ^ 3 + b``.
|
||||
ECP_BLS12381_rhs(addr result, unsafeAddr x)
|
||||
|
||||
proc isOnCurv*(x, y: FP_BLS12381 or FP2_BLS12381): bool =
|
||||
## Returns ``true`` if point is on curve or points to infinite.
|
||||
if x.iszilch() and y.iszilch():
|
||||
result = true
|
||||
else:
|
||||
result = (sqr(y) == rhs(x))
|
||||
|
||||
func pack(g: var BLS_G1, x, y: BLS_FP): bool {.inline.} =
|
||||
discard ECP_BLS12381_set(g.addr, x, y)
|
||||
let xx = x.nres
|
||||
let yy = y.nres
|
||||
isOnCurv(xx, yy)
|
||||
|
||||
func unpack(g: BLS_G1, x, y: var BLS_FP): bool {.inline.} =
|
||||
discard g.get(x, y)
|
||||
true
|
||||
|
||||
func pack(g: var BLS_G2, x0, x1, y0, y1: BLS_FP): bool =
|
||||
var x, y: BLS_FP2
|
||||
x.fromBigs(x0, x1)
|
||||
y.fromBigs(y0, y1)
|
||||
discard ECP2_BLS12381_set(g.addr, x.addr, y.addr)
|
||||
isOnCurv(x, y)
|
||||
|
||||
func unpack(g: BLS_G2, x0, x1, y0, y1: var BLS_FP): bool =
|
||||
var x, y: BLS_FP2
|
||||
result = g.get(x, y) <= 0.cint
|
||||
FP_BLS12381_redc(x0, addr x.a)
|
||||
FP_BLS12381_redc(x1, addr x.b)
|
||||
FP_BLS12381_redc(y0, addr y.a)
|
||||
FP_BLS12381_redc(y1, addr y.b)
|
||||
|
||||
else:
|
||||
import blscurve/blst/[blst_lowlevel]
|
||||
|
||||
type
|
||||
BLS_G1* = blst_p1
|
||||
BLS_G2* = blst_p2
|
||||
BLS_FP* = blst_fp
|
||||
BLS_FP2* = blst_fp2
|
||||
BLS_SCALAR* = blst_scalar
|
||||
BLS_FE* = blst_fp
|
||||
BLS_FE2* = blst_fp2
|
||||
|
||||
func fromBytes*(ret: var BLS_SCALAR, raw: openArray[byte]): bool =
|
||||
const L = 32
|
||||
if raw.len < L:
|
||||
return false
|
||||
let pa = cast[ptr array[L, byte]](raw[0].unsafeAddr)
|
||||
blst_scalar_from_bendian(ret, pa[])
|
||||
true
|
||||
|
||||
func fromBytes(ret: var BLS_FP, raw: openArray[byte]): bool =
|
||||
const L = 48
|
||||
if raw.len < L:
|
||||
return false
|
||||
let pa = cast[ptr array[L, byte]](raw[0].unsafeAddr)
|
||||
blst_fp_from_bendian(ret, pa[])
|
||||
true
|
||||
|
||||
func toBytes(fp: BLS_FP, output: var openArray[byte]): bool =
|
||||
const L = 48
|
||||
if output.len < L:
|
||||
return false
|
||||
let pa = cast[ptr array[L, byte]](output[0].unsafeAddr)
|
||||
blst_bendian_from_fp(pa[], fp)
|
||||
true
|
||||
|
||||
func pack(g: var BLS_G1, x, y: BLS_FP): bool =
|
||||
let src = blst_p1_affine(x: x, y: y)
|
||||
blst_p1_from_affine(g, src)
|
||||
blst_p1_on_curve(g).int == 1
|
||||
|
||||
func unpack(g: BLS_G1, x, y: var BLS_FP): bool =
|
||||
var dst: blst_p1_affine
|
||||
blst_p1_to_affine(dst, g)
|
||||
x = dst.x
|
||||
y = dst.y
|
||||
true
|
||||
|
||||
func pack(g: var BLS_G2, x0, x1, y0, y1: BLS_FP): bool =
|
||||
let src = blst_p2_affine(x: blst_fp2(fp: [x0, x1]), y: blst_fp2(fp: [y0, y1]))
|
||||
blst_p2_from_affine(g, src)
|
||||
blst_p2_on_curve(g)
|
||||
|
||||
func unpack(g: BLS_G2, x0, x1, y0, y1: var BLS_FP): bool =
|
||||
var dst: blst_p2_affine
|
||||
blst_p2_to_affine(dst, g)
|
||||
x0 = dst.x.fp[0]
|
||||
x1 = dst.x.fp[1]
|
||||
y0 = dst.y.fp[0]
|
||||
y1 = dst.y.fp[1]
|
||||
true
|
||||
|
||||
func nbits(s: BLS_SCALAR): uint =
|
||||
var k = sizeof(s.l) - 1
|
||||
while k >= 0 and s.l[k] == 0: dec k
|
||||
if k < 0: return 0
|
||||
var
|
||||
bts = k shl 3
|
||||
c = s.l[k]
|
||||
|
||||
while c != 0:
|
||||
c = c shr 1
|
||||
inc bts
|
||||
|
||||
result = bts.uint
|
||||
|
||||
func add*(a: var BLS_G1, b: BLS_G1) {.inline.} =
|
||||
# ?? add_or_double ??
|
||||
blst_p1_add_or_double(a, a, b)
|
||||
|
||||
func mul*(a: var BLS_G1, b: BLS_SCALAR) {.inline.} =
|
||||
blst_p1_mult(a, a, b, b.nbits)
|
||||
|
||||
func add*(a: var BLS_G2, b: BLS_G2) {.inline.} =
|
||||
# ?? add_or_double ??
|
||||
blst_p2_add_or_double(a, a, b)
|
||||
|
||||
func mul*(a: var BLS_G2, b: BLS_SCALAR) {.inline.} =
|
||||
blst_p2_mult(a, a, b, b.nbits)
|
||||
|
||||
# decodeFieldElement expects 64 byte input with zero top 16 bytes,
|
||||
# returns lower 48 bytes.
|
||||
func decodeFieldElement*(res: var BLS_FP, input: openArray[byte]): bool =
|
||||
if input.len != 64:
|
||||
debugEcho "DEF A ERR"
|
||||
return false
|
||||
|
||||
# check top bytes
|
||||
for i in 0..<16:
|
||||
if input[i] != 0.byte:
|
||||
debugEcho "DEF B ERR"
|
||||
return false
|
||||
|
||||
if not res.fromBytes input.toOpenArray(16, 63):
|
||||
debugEcho "DEF C ERR"
|
||||
return false
|
||||
|
||||
true
|
||||
|
||||
when BLS_BACKEND == Miracl:
|
||||
func decodeFieldElement*(res: var BLS_FE, input: openArray[byte]): bool =
|
||||
var big: BLS_FP
|
||||
if not big.decodeFieldElement(input):
|
||||
return false
|
||||
res = big.nres()
|
||||
true
|
||||
|
||||
# DecodePoint given encoded (x, y) coordinates in 128 bytes returns a valid G1 Point.
|
||||
func decodePoint*(g: var BLS_G1, data: openArray[byte]): bool =
|
||||
if data.len != 128:
|
||||
debugEcho "G1 init A ERR"
|
||||
return false
|
||||
|
||||
var x, y: BLS_FP
|
||||
if not x.decodeFieldElement data.toOpenArray(0, 63):
|
||||
return false
|
||||
|
||||
if not y.decodeFieldElement data.toOpenArray(64, 127):
|
||||
return false
|
||||
|
||||
if not g.pack(x, y):
|
||||
debugEcho "ECP set err"
|
||||
return false
|
||||
|
||||
true
|
||||
|
||||
# EncodePoint encodes a point into 128 bytes.
|
||||
func encodePoint*(g: BLS_G1, output: var openArray[byte]): bool =
|
||||
if output.len != 128:
|
||||
debugEcho "encodePoint ERR"
|
||||
return false
|
||||
|
||||
var x, y: BLS_FP
|
||||
if not g.unpack(x, y):
|
||||
debugEcho "encodePoint get"
|
||||
return false
|
||||
|
||||
if not x.toBytes output.toOpenArray(16, 63):
|
||||
debugEcho "encodePoint ERR X"
|
||||
return false
|
||||
|
||||
if not y.toBytes output.toOpenArray(64+16, 127):
|
||||
debugEcho "encodePoint ERR Y"
|
||||
return false
|
||||
|
||||
true
|
||||
|
||||
func decodePoint*(g: var BLS_G2, data: openArray[byte]): bool =
|
||||
if data.len != 256:
|
||||
debugEcho "G2 init ERR"
|
||||
return false
|
||||
|
||||
var x0, x1, y0, y1: BLS_FP
|
||||
if not x0.decodeFieldElement data.toOpenArray(0, 63):
|
||||
return false
|
||||
|
||||
if not x1.decodeFieldElement data.toOpenArray(64, 127):
|
||||
return false
|
||||
|
||||
if not y0.decodeFieldElement data.toOpenArray(128, 191):
|
||||
return false
|
||||
|
||||
if not y1.decodeFieldElement data.toOpenArray(192, 255):
|
||||
return false
|
||||
|
||||
if not g.pack(x0, x1, y0, y1):
|
||||
debugEcho "G2 pack err"
|
||||
return false
|
||||
|
||||
true
|
||||
|
||||
func encodePoint*(g: BLS_G2, output: var openArray[byte]): bool =
|
||||
if output.len != 256:
|
||||
debugEcho "encodePoint G2 ERR"
|
||||
return false
|
||||
|
||||
var x0, x1, y0, y1: BLS_FP
|
||||
if not g.unpack(x0, x1, y0, y1):
|
||||
debugEcho "encodePoint G2 get"
|
||||
return false
|
||||
|
||||
if not x0.toBytes output.toOpenArray(16, 63):
|
||||
debugEcho "encodePoint G2 ERR X0"
|
||||
return false
|
||||
|
||||
if not x1.toBytes output.toOpenArray(80, 127):
|
||||
debugEcho "encodePoint G2 ERR X1"
|
||||
return false
|
||||
|
||||
if not y0.toBytes output.toOpenArray(144, 192):
|
||||
debugEcho "encodePoint G2 ERR Y0"
|
||||
return false
|
||||
|
||||
if not y1.toBytes output.toOpenArray(208, 255):
|
||||
debugEcho "encodePoint G2 ERR Y1"
|
||||
return false
|
||||
|
||||
true
|
|
@ -759,4 +759,14 @@ const
|
|||
# The Yellow Paper is special casing the GasQuadDivisor.
|
||||
# It is defined in Appendix G with the other GasFeeKind constants
|
||||
# instead of Appendix E for precompiled contracts
|
||||
GasQuadDivisor* = 20
|
||||
GasQuadDivisor* = 20
|
||||
GasQuadDivisorEIP2565* = 3
|
||||
# EIP2537 BLS12 381
|
||||
Bls12381G1AddGas* = 600
|
||||
Bls12381G1MulGas* = 12000
|
||||
Bls12381G2AddGas* = 4500
|
||||
Bls12381G2MulGas* = 55000
|
||||
Bls12381PairingBaseGas* = 115000
|
||||
Bls12381PairingPerPairGas* = 23000
|
||||
Bls12381MapG1Gas* = 5500
|
||||
Bls12381MapG2Gas* = 110000
|
||||
|
|
|
@ -1,22 +1,32 @@
|
|||
import
|
||||
../vm_types, interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks],
|
||||
../errors, stint, eth/[keys, common], chronicles, tables, macros,
|
||||
math, nimcrypto, bncurve/[fields, groups], blake2b_f
|
||||
math, nimcrypto, bncurve/[fields, groups], blake2b_f, ./blscurve
|
||||
|
||||
type
|
||||
PrecompileAddresses* = enum
|
||||
# Frontier to Spurious Dragron
|
||||
paEcRecover = 1,
|
||||
paSha256,
|
||||
paRipeMd160,
|
||||
paIdentity,
|
||||
paEcRecover = 1
|
||||
paSha256
|
||||
paRipeMd160
|
||||
paIdentity
|
||||
# Byzantium and Constantinople
|
||||
paModExp,
|
||||
paEcAdd,
|
||||
paEcMul,
|
||||
paPairing,
|
||||
paModExp
|
||||
paEcAdd
|
||||
paEcMul
|
||||
paPairing
|
||||
# Istanbul
|
||||
paBlake2bf = 9
|
||||
paBlake2bf
|
||||
# Berlin
|
||||
paBlsG1Add
|
||||
paBlsG1Mul
|
||||
paBlsG1MultiExp
|
||||
paBlsG2Add
|
||||
paBlsG2Mul
|
||||
paBlsG2MultiExp
|
||||
paBlsPairing
|
||||
paBlsMapG1
|
||||
paBlsMapG2
|
||||
|
||||
proc getSignature(computation: Computation): (array[32, byte], Signature) =
|
||||
# input is Hash, V, R, S
|
||||
|
@ -218,7 +228,7 @@ proc modExpFee(c: Computation, baseLen, expLen, modLen: Uint256, fork: Fork): Ga
|
|||
max(adjExpLen, 1.u256)
|
||||
) div divisor
|
||||
|
||||
let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, 3)
|
||||
let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
|
||||
else: gasCalc(mulComplexity, GasQuadDivisor)
|
||||
|
||||
if gasFee > high(GasInt).u256:
|
||||
|
@ -344,23 +354,236 @@ proc bn256ecPairing*(computation: Computation, fork: Fork = FkByzantium) =
|
|||
|
||||
computation.output = @output
|
||||
|
||||
proc blake2bf*(computation: Computation) =
|
||||
template input(): untyped =
|
||||
computation.msg.data
|
||||
proc blake2bf*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
if len(input) == blake2FInputLength:
|
||||
let gasFee = GasInt(beLoad32(input, 0))
|
||||
computation.gasMeter.consumeGas(gasFee, reason="blake2bf Precompile")
|
||||
c.gasMeter.consumeGas(gasFee, reason="blake2bf Precompile")
|
||||
|
||||
var output: array[64, byte]
|
||||
if not blake2b_F(input, output):
|
||||
raise newException(ValidationError, "Blake2b F function invalid input")
|
||||
else:
|
||||
computation.output = @output
|
||||
c.output = @output
|
||||
|
||||
proc blsG1Add*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
if input.len != 256:
|
||||
raise newException(ValidationError, "blsG1Add invalid input len")
|
||||
|
||||
c.gasMeter.consumeGas(Bls12381G1AddGas, reason="blsG1Add Precompile")
|
||||
|
||||
var a, b: BLS_G1
|
||||
if not a.decodePoint(input.toOpenArray(0, 127)):
|
||||
raise newException(ValidationError, "blsG1Add invalid input A")
|
||||
|
||||
if not b.decodePoint(input.toOpenArray(128, 255)):
|
||||
raise newException(ValidationError, "blsG1Add invalid input B")
|
||||
|
||||
a.add b
|
||||
|
||||
c.output = newSeq[byte](128)
|
||||
if not encodePoint(a, c.output):
|
||||
raise newException(ValidationError, "blsG1Add encodePoint error")
|
||||
|
||||
proc blsG1Mul*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
if input.len != 160:
|
||||
raise newException(ValidationError, "blsG1Mul invalid input len")
|
||||
|
||||
c.gasMeter.consumeGas(Bls12381G1MulGas, reason="blsG1Mul Precompile")
|
||||
|
||||
var a: BLS_G1
|
||||
if not a.decodePoint(input.toOpenArray(0, 127)):
|
||||
raise newException(ValidationError, "blsG1Mul invalid input A")
|
||||
|
||||
var scalar: BLS_SCALAR
|
||||
if not scalar.fromBytes(input.toOpenArray(128, 159)):
|
||||
raise newException(ValidationError, "blsG1Mul invalid scalar")
|
||||
|
||||
a.mul(scalar)
|
||||
|
||||
c.output = newSeq[byte](128)
|
||||
if not encodePoint(a, c.output):
|
||||
raise newException(ValidationError, "blsG1Mul encodePoint error")
|
||||
|
||||
const
|
||||
Bls12381MultiExpDiscountTable = [
|
||||
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
|
||||
]
|
||||
|
||||
func calcBlsMultiExpGas(K: int, gasCost: GasInt): GasInt =
|
||||
# Calculate G1 point, scalar value pair length
|
||||
if K == 0:
|
||||
# Return 0 gas for small input length
|
||||
return 0.GasInt
|
||||
|
||||
const dLen = Bls12381MultiExpDiscountTable.len
|
||||
# Lookup discount value for G1 point, scalar value pair length
|
||||
let discount = if K < dLen: Bls12381MultiExpDiscountTable[K-1]
|
||||
else: Bls12381MultiExpDiscountTable[dLen-1]
|
||||
|
||||
# Calculate gas and return the result
|
||||
result = (K * gasCost * discount) div 1000
|
||||
|
||||
proc blsG1MultiExp*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
const L = 160
|
||||
if (input.len == 0) or ((input.len mod L) != 0):
|
||||
raise newException(ValidationError, "blsG1MultiExp invalid input len")
|
||||
|
||||
let
|
||||
K = input.len div L
|
||||
gas = K.calcBlsMultiExpGas(Bls12381G1MulGas)
|
||||
|
||||
c.gasMeter.consumeGas(gas, reason="blsG1MultiExp Precompile")
|
||||
|
||||
var
|
||||
p: BLS_G1
|
||||
s: BLS_SCALAR
|
||||
acc: BLS_G1
|
||||
|
||||
# Decode point scalar pairs
|
||||
for i in 0..<K:
|
||||
let off = L * i
|
||||
|
||||
# Decode G1 point
|
||||
if not p.decodePoint(input.toOpenArray(off, off+127)):
|
||||
raise newException(ValidationError, "blsG1MultiExp invalid input P")
|
||||
|
||||
# Decode scalar value
|
||||
if not s.fromBytes(input.toOpenArray(off+128, off+159)):
|
||||
raise newException(ValidationError, "blsG1MultiExp invalid scalar")
|
||||
|
||||
p.mul(s)
|
||||
if i == 0:
|
||||
acc = p
|
||||
else:
|
||||
acc.add(p)
|
||||
|
||||
c.output = newSeq[byte](128)
|
||||
if not encodePoint(acc, c.output):
|
||||
raise newException(ValidationError, "blsG1MuliExp encodePoint error")
|
||||
|
||||
proc blsG2Add*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
if input.len != 512:
|
||||
raise newException(ValidationError, "blsG2Add invalid input len")
|
||||
|
||||
c.gasMeter.consumeGas(Bls12381G2AddGas, reason="blsG2Add Precompile")
|
||||
|
||||
var a, b: BLS_G2
|
||||
if not a.decodePoint(input.toOpenArray(0, 255)):
|
||||
raise newException(ValidationError, "blsG2Add invalid input A")
|
||||
|
||||
if not b.decodePoint(input.toOpenArray(256, 511)):
|
||||
raise newException(ValidationError, "blsG2Add invalid input B")
|
||||
|
||||
a.add b
|
||||
|
||||
c.output = newSeq[byte](256)
|
||||
if not encodePoint(a, c.output):
|
||||
raise newException(ValidationError, "blsG2Add encodePoint error")
|
||||
|
||||
proc blsG2Mul*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
if input.len != 288:
|
||||
raise newException(ValidationError, "blsG2Mul invalid input len")
|
||||
|
||||
c.gasMeter.consumeGas(Bls12381G2MulGas, reason="blsG2Mul Precompile")
|
||||
|
||||
var a: BLS_G2
|
||||
if not a.decodePoint(input.toOpenArray(0, 255)):
|
||||
raise newException(ValidationError, "blsG2Mul invalid input A")
|
||||
|
||||
var scalar: BLS_SCALAR
|
||||
if not scalar.fromBytes(input.toOpenArray(256, 287)):
|
||||
raise newException(ValidationError, "blsG2Mul invalid scalar")
|
||||
|
||||
a.mul(scalar)
|
||||
|
||||
c.output = newSeq[byte](256)
|
||||
if not encodePoint(a, c.output):
|
||||
raise newException(ValidationError, "blsG2Mul encodePoint error")
|
||||
|
||||
proc blsG2MultiExp*(c: Computation) =
|
||||
template input: untyped =
|
||||
c.msg.data
|
||||
|
||||
const L = 288
|
||||
if (input.len == 0) or ((input.len mod L) != 0):
|
||||
raise newException(ValidationError, "blsG2MultiExp invalid input len")
|
||||
|
||||
let
|
||||
K = input.len div L
|
||||
gas = K.calcBlsMultiExpGas(Bls12381G2MulGas)
|
||||
|
||||
c.gasMeter.consumeGas(gas, reason="blsG2MultiExp Precompile")
|
||||
|
||||
var
|
||||
p: BLS_G2
|
||||
s: BLS_SCALAR
|
||||
acc: BLS_G2
|
||||
|
||||
# Decode point scalar pairs
|
||||
for i in 0..<K:
|
||||
let off = L * i
|
||||
|
||||
# Decode G1 point
|
||||
if not p.decodePoint(input.toOpenArray(off, off+255)):
|
||||
raise newException(ValidationError, "blsG2MultiExp invalid input P")
|
||||
|
||||
# Decode scalar value
|
||||
if not s.fromBytes(input.toOpenArray(off+256, off+287)):
|
||||
raise newException(ValidationError, "blsG2MultiExp invalid scalar")
|
||||
|
||||
p.mul(s)
|
||||
if i == 0:
|
||||
acc = p
|
||||
else:
|
||||
acc.add(p)
|
||||
|
||||
c.output = newSeq[byte](256)
|
||||
if not encodePoint(acc, c.output):
|
||||
raise newException(ValidationError, "blsG2MuliExp encodePoint error")
|
||||
|
||||
proc blsPairing*(c: Computation) =
|
||||
discard
|
||||
|
||||
proc blsMapG1*(c: Computation) =
|
||||
discard
|
||||
|
||||
proc blsMapG2*(c: Computation) =
|
||||
discard
|
||||
|
||||
proc getMaxPrecompileAddr(fork: Fork): PrecompileAddresses =
|
||||
if fork < FkByzantium: paIdentity
|
||||
elif fork < FkIstanbul: paPairing
|
||||
elif fork < FkBerlin: paBlake2bf
|
||||
else: PrecompileAddresses.high
|
||||
|
||||
proc execPrecompiles*(computation: Computation, fork: Fork): bool {.inline.} =
|
||||
|
@ -384,6 +607,15 @@ proc execPrecompiles*(computation: Computation, fork: Fork): bool {.inline.} =
|
|||
of paEcMul: bn256ecMul(computation, fork)
|
||||
of paPairing: bn256ecPairing(computation, fork)
|
||||
of paBlake2bf: blake2bf(computation)
|
||||
of paBlsG1Add: blsG1Add(computation)
|
||||
of paBlsG1Mul: blsG1Mul(computation)
|
||||
of paBlsG1MultiExp: blsG1MultiExp(computation)
|
||||
of paBlsG2Add: blsG2Add(computation)
|
||||
of paBlsG2Mul: blsG2Mul(computation)
|
||||
of paBlsG2MultiExp: blsG2MultiExp(computation)
|
||||
of paBlsPairing: blsPairing(computation)
|
||||
of paBlsMapG1: blsMapG1(computation)
|
||||
of paBlsMapG2: blsMapG2(computation)
|
||||
except OutOfGas as e:
|
||||
# cannot use setError here, cyclic dependency
|
||||
computation.error = Error(info: e.msg, burnsGas: true)
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
[
|
||||
{
|
||||
"Input": "",
|
||||
"Expected": "error",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "vector 0: empty input"
|
||||
},
|
||||
{
|
||||
"Input": "00000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001",
|
||||
"Expected": "error",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "vector 1: less than 213 bytes input"
|
||||
},
|
||||
{
|
||||
"Input": "000000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001",
|
||||
"Expected": "error",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "vector 2: more than 213 bytes input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000002",
|
||||
"Expected": "error",
|
||||
"ExpectedError": "invalid final flag",
|
||||
"Name": "vector 3: malformed final block indicator flag"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -3,6 +3,36 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1add_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1add_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1add_large_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000108b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_g1add_violate_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_g1add_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_g1add_point_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
|
||||
"Expected": "000000000000000000000000000000000572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e00000000000000000000000000000000166a9d8cabc673a322fda673779d8e3822ba3ecb8670e461f73bb9021d5fd76a4c56d9d4cd16bd1bba86881979749d28",
|
||||
|
|
|
@ -3,6 +3,36 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1mul_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1mul_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1mul_large_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000108b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_g1mul_violate_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_g1mul_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_g1mul_point_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000000",
|
||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
|
|
|
@ -3,6 +3,36 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1multiexp_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1multiexp_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g1multiexp_large_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_g1multiexp_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000108b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_g1multiexp_violate_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_g1multiexp_point_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000011",
|
||||
"Expected": "000000000000000000000000000000001098f178f84fc753a76bb63709e9be91eec3ff5f7f3a5f4836f34fe8a1a6d6c5578d8fd820573cef3a01e2bfef3eaf3a000000000000000000000000000000000ea923110b733b531006075f796cc9368f2477fe26020f465468efbb380ce1f8eebaf5c770f31d320f9bd378dc758436",
|
||||
|
|
|
@ -3,6 +3,36 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2add_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b828010000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2add_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b8280100000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2add_large_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000010606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_g2add_violate_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_g2add_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_g2add_point_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"Expected": "000000000000000000000000000000001638533957d540a9d2370f17cc7ed5863bc0b995b8825e0ee1ea1e1e4d00dbae81f14b0bf3611b78c952aacab827a053000000000000000000000000000000000a4edef9c1ed7f729f520e47730a124fd70662a904ba1074728114d1031e1572c6c886f6b57ec72a6178288c47c33577000000000000000000000000000000000468fb440d82b0630aeb8dca2b5256789a66da69bf91009cbfe6bd221e47aa8ae88dece9764bf3bd999d95d71e4c9899000000000000000000000000000000000f6d4552fa65dd2638b361543f887136a43253d9c66c411697003f7a13c308f5422e1aa0a59c8967acdefd8b6e36ccf3",
|
||||
|
|
|
@ -3,6 +3,36 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2mul_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b828010000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2mul_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b8280100000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2mul_large_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000010606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_g2mul_violate_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_g2mul_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_g2mul_point_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
|
|
|
@ -3,6 +3,36 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2multiexp_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b828010000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2multiexp_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b8280100000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_g2multiexp_large_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000010606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_g2multiexp_violate_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000000000000000000000000000000000007",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_g2multiexp_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_g2multiexp_point_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000011",
|
||||
"Expected": "000000000000000000000000000000000ef786ebdcda12e142a32f091307f2fedf52f6c36beb278b0007a03ad81bf9fee3710a04928e43e541d02c9be44722e8000000000000000000000000000000000d05ceb0be53d2624a796a7a033aec59d9463c18d672c451ec4f2e679daef882cab7d8dd88789065156a1340ca9d426500000000000000000000000000000000118ed350274bc45e63eaaa4b8ddf119b3bf38418b5b9748597edfc456d9bc3e864ec7283426e840fd29fa84e7d89c934000000000000000000000000000000001594b866a28946b6d444bf0481558812769ea3222f5dfc961ca33e78e0ea62ee8ba63fd1ece9cc3e315abfa96d536944",
|
||||
|
|
|
@ -3,6 +3,26 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_mapg1_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_mapg1_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_mapg1_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_mapg1_invalid_fq_element"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000014406e5bfb9209256a3820879a29ac2f62d6aca82324bf3ae2aa7d3c54792043bd8c791fccdb080c1a52dc68b8b69350",
|
||||
"Expected": "000000000000000000000000000000000d7721bcdb7ce1047557776eb2659a444166dc6dd55c7ca6e240e21ae9aa18f529f04ac31d861b54faf3307692545db700000000000000000000000000000000108286acbdf4384f67659a8abe89e712a504cb3ce1cba07a716869025d60d499a00d1da8cdc92958918c222ea93d87f0",
|
||||
|
|
|
@ -3,6 +3,26 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_mapg2_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_mapg2_short_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_mapg2_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_mapg2_invalid_fq_element"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000014406e5bfb9209256a3820879a29ac2f62d6aca82324bf3ae2aa7d3c54792043bd8c791fccdb080c1a52dc68b8b69350000000000000000000000000000000000e885bb33996e12f07da69073e2c0cc880bc8eff26d2a724299eb12d54f4bcf26f4748bb020e80a7e3794a7b0e47a641",
|
||||
"Expected": "000000000000000000000000000000000d029393d3a13ff5b26fe52bd8953768946c5510f9441f1136f1e938957882db6adbd7504177ee49281ecccba596f2bf000000000000000000000000000000001993f668fb1ae603aefbb1323000033fcb3b65d8ed3bf09c84c61e27704b745f540299a1872cd697ae45a5afd780f1d600000000000000000000000000000000079cb41060ef7a128d286c9ef8638689a49ca19da8672ea5c47b6ba6dbde193ee835d3b87a76a689966037c07159c10d0000000000000000000000000000000017c688ae9a8b59a7069c27f2d58dd2196cb414f4fb89da8510518a1142ab19d158badd1c3bad03408fafb1669903cd6c",
|
||||
|
|
|
@ -3,6 +3,46 @@
|
|||
"fork": "berlin",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"Input": "",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_pairing_empty_input"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b8280100000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "invalid input length",
|
||||
"Name": "bls_pairing_extra_data"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac",
|
||||
"ExpectedError": "must be less than modulus",
|
||||
"Name": "bls_pairing_invalid_field_element"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000010606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "invalid field element top bytes",
|
||||
"Name": "bls_pairing_top_bytes"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_pairing_g1_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
||||
"ExpectedError": "point is not on curve",
|
||||
"Name": "bls_pairing_g2_not_on_curve"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000a989badd40d6212b33cffc3f3763e9bc760f988c9926b26da9dd85e928483446346b8ed00e1de5d5ea93e354abe706c00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be",
|
||||
"ExpectedError": "g1 point is not on correct subgroup",
|
||||
"Name": "bls_pairing_g1_not_in_correct_subgroup"
|
||||
},
|
||||
{
|
||||
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013a59858b6809fca4d9a3b6539246a70051a3c88899964a42bc9a69cf9acdd9dd387cfa9086b894185b9a46a402be730000000000000000000000000000000002d27e0ec3356299a346a09ad7dc4ef68a483c3aed53f9139d2f929a3eecebf72082e5e58c6da24ee32e03040c406d4f",
|
||||
"ExpectedError": "g2 point is not on correct subgroup",
|
||||
"Name": "bls_pairing_g2_not_in_correct_subgroup"
|
||||
},
|
||||
{
|
||||
"Input": "000000000000000000000000000000000572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e00000000000000000000000000000000166a9d8cabc673a322fda673779d8e3822ba3ecb8670e461f73bb9021d5fd76a4c56d9d4cd16bd1bba86881979749d2800000000000000000000000000000000122915c824a0857e2ee414a3dccb23ae691ae54329781315a0c75df1c04d6d7a50a030fc866f09d516020ef82324afae0000000000000000000000000000000009380275bbc8e5dcea7dc4dd7e0550ff2ac480905396eda55062650f8d251c96eb480673937cc6d9d6a44aaa56ca66dc000000000000000000000000000000000b21da7955969e61010c7a1abc1a6f0136961d1e3b20b1a7326ac738fef5c721479dfd948b52fdf2455e44813ecfd8920000000000000000000000000000000008f239ba329b3967fe48d718a36cfe5f62a7e42e0bf1c1ed714150a166bfbd6bcf6b3b58b975b9edea56d53f23a0e8490000000000000000000000000000000006e82f6da4520f85c5d27d8f329eccfa05944fd1096b20734c894966d12a9e2a9a9744529d7212d33883113a0cadb9090000000000000000000000000000000017d81038f7d60bee9110d9c0d6d1102fe2d998c957f28e31ec284cc04134df8e47e8f82ff3af2e60a6d9688a4563477c00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed",
|
||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
||||
|
|
|
@ -18,8 +18,8 @@ template doTest(fixture: JsonNode, fork: Fork, address: PrecompileAddresses): un
|
|||
let
|
||||
blockNum = 1.u256 # TODO: Check other forks
|
||||
header = BlockHeader(blockNumber: blockNum)
|
||||
expectedStr = test["Expected"].getStr
|
||||
expected = if expectedStr != "error": expectedStr.hexToSeqByte else: @[]
|
||||
expectedErr = test.hasKey("ExpectedError")
|
||||
expected = if test.hasKey("Expected"): hexToSeqByte(test["Expected"].getStr) else: @[]
|
||||
dataStr = test["Input"].getStr
|
||||
data = if dataStr.len > 0: dataStr.hexToSeqByte else: @[]
|
||||
vmState = newBaseVMState(header.stateRoot, header, newBaseChainDB(newMemoryDb()))
|
||||
|
@ -49,7 +49,7 @@ template doTest(fixture: JsonNode, fork: Fork, address: PrecompileAddresses): un
|
|||
let initialGas = comp.gasMeter.gasRemaining
|
||||
discard execPrecompiles(comp, fork)
|
||||
|
||||
if expectedStr == "error":
|
||||
if expectedErr:
|
||||
check comp.isError
|
||||
else:
|
||||
let c = comp.output == expected
|
||||
|
@ -78,6 +78,12 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
|||
of "bn256mul" : data.doTest(fork, paEcMul)
|
||||
of "ecpairing": data.doTest(fork, paPairing)
|
||||
of "blake2f" : data.doTest(fork, paBlake2bf)
|
||||
of "blsg1add" : data.doTest(fork, pablsG1Add)
|
||||
of "blsg1mul" : data.doTest(fork, pablsG1Mul)
|
||||
of "blsg1multiexp" : data.doTest(fork, pablsG1MultiExp)
|
||||
of "blsg2add" : data.doTest(fork, pablsG2Add)
|
||||
of "blsg2mul" : data.doTest(fork, pablsG2Mul)
|
||||
of "blsg2multiexp" : data.doTest(fork, pablsG2MultiExp)
|
||||
else:
|
||||
echo "Unknown test vector '" & $label & "'"
|
||||
testStatusIMPL = SKIPPED
|
||||
|
|
Loading…
Reference in New Issue