rest of EF KZG test harnesses (#5734)
This commit is contained in:
parent
aef3879652
commit
c815e71af0
|
@ -154,6 +154,16 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
|
|||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## EF - KZG
|
||||
```diff
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_invalid_blob_635fb2de5b0dc429 OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_invalid_blob_a3b9ff28507767f8 OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_invalid_blob_d3afbd98123a3434 OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_0951cfd9ab47a8d3 OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_19b3f3f8c98ea31e OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_84d8089232bc23a8 OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_a87a4e636e0f58fb OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_c40b9b515df8721b OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_cdb3e6d49eb12307 OK
|
||||
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_valid_blob_fb324bc819407148 OK
|
||||
+ KZG - Compute KZG proof - compute_kzg_proof_case_invalid_blob_635fb2de5b0dc429 OK
|
||||
+ KZG - Compute KZG proof - compute_kzg_proof_case_invalid_blob_a3b9ff28507767f8 OK
|
||||
+ KZG - Compute KZG proof - compute_kzg_proof_case_invalid_blob_d3afbd98123a3434 OK
|
||||
|
@ -204,6 +214,19 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
|||
+ KZG - Compute KZG proof - compute_kzg_proof_case_valid_blob_f47eb9fc139f6bfd OK
|
||||
+ KZG - Compute KZG proof - compute_kzg_proof_case_valid_blob_f7f44e1e864aa967 OK
|
||||
+ KZG - Compute KZG proof - compute_kzg_proof_case_valid_blob_ffa6e97b97146517 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_invalid_blob_635fb2de5b0dc429 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_invalid_blob_a3b9ff28507767f8 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_invalid_blob_d3afbd98123a3434 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_invalid_commitment_1a68c47b6814 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_invalid_commitment_24b932fb4dec OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_invalid_commitment_3a6eb616efae OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_0951cfd9ab47a8d3 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_19b3f3f8c98ea31e OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_84d8089232bc23a8 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_a87a4e636e0f58fb OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_c40b9b515df8721b OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_cdb3e6d49eb12307 OK
|
||||
+ KZG - Compute blob KZG proof - compute_blob_kzg_proof_case_valid_blob_fb324bc819407148 OK
|
||||
+ KZG - Verify KZG proof - verify_kzg_proof_case_correct_proof_02e696ada7d4631d OK
|
||||
+ KZG - Verify KZG proof - verify_kzg_proof_case_correct_proof_05c1f3685f3393f0 OK
|
||||
+ KZG - Verify KZG proof - verify_kzg_proof_case_correct_proof_08f9e2f1cb3d39db OK
|
||||
|
@ -326,8 +349,61 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
|||
+ KZG - Verify KZG proof - verify_kzg_proof_case_invalid_z_64b9ff2b8f7dddee OK
|
||||
+ KZG - Verify KZG proof - verify_kzg_proof_case_invalid_z_b358a2e763727b70 OK
|
||||
+ KZG - Verify KZG proof - verify_kzg_proof_case_invalid_z_eb0601fec84cc5e9 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_0951cfd9ab47a8d3 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_19b3f3f8c98ea31e OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_84d8089232bc23a8 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_a87a4e636e0f58fb OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_c40b9b515df8721b OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_cdb3e6d49eb12307 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_fb324bc819407148 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_point_at_infinity_f OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_correct_proof_point_at_infinity_f OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_0951cfd9ab47a8d3 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_19b3f3f8c98ea31e OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_84d8089232bc23a8 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_a87a4e636e0f58fb OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_c40b9b515df8721b OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_cdb3e6d49eb12307 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_fb324bc819407148 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_incorrect_proof_point_at_infinity OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_blob_59d64ff6b4648fad OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_blob_635fb2de5b0dc429 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_blob_a3b9ff28507767f8 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_blob_d3afbd98123a3434 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_commitment_1a68c47b68148e OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_commitment_24b932fb4dec5b OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_commitment_3a6eb616efae06 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_commitment_d070689c3e1544 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_proof_1a68c47b68148e78 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_proof_24b932fb4dec5b2d OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_proof_3a6eb616efae0627 OK
|
||||
+ KZG - Verify blob KZG proof - verify_blob_kzg_proof_case_invalid_proof_d070689c3e15444c OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_0951cfd9ab47a8d3 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_0f3f1d3f48f71495 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_12c097d7ca0261e3 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_2ef482373a81e34e OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_a271b78b8e869d69 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_blob_length_different OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_cb3c3279a1afddcf OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_commitment_length_dif OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_e61aafba051ddf79 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_incorrect_proof_add_o OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_incorrect_proof_point OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_blob_59d64ff6 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_blob_635fb2de OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_blob_a3b9ff28 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_blob_d3afbd98 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_commitment_1a OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_commitment_24 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_commitment_3a OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_commitment_d0 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_proof_1a68c47 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_proof_24b932f OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_proof_3a6eb61 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_invalid_proof_d070689 OK
|
||||
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_proof_length_differen OK
|
||||
```
|
||||
OK: 172/172 Fail: 0/172 Skip: 0/172
|
||||
OK: 248/248 Fail: 0/248 Skip: 0/248
|
||||
## EF - SSZ generic types
|
||||
```diff
|
||||
Testing basic_vector inputs - invalid Skip
|
||||
|
@ -898,4 +974,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
|||
OK: 9/9 Fail: 0/9 Skip: 0/9
|
||||
|
||||
---TOTAL---
|
||||
OK: 583/588 Fail: 0/588 Skip: 5/588
|
||||
OK: 659/664 Fail: 0/664 Skip: 5/664
|
||||
|
|
|
@ -15,6 +15,7 @@ import
|
|||
../testutil,
|
||||
./fixtures_utils, ./os_ops
|
||||
|
||||
from std/sequtils import anyIt, mapIt
|
||||
from std/strutils import rsplit
|
||||
|
||||
# Should be generic, but for https://github.com/nim-lang/Nim/issues/23204
|
||||
|
@ -30,7 +31,7 @@ func fromHex48(s: string): Opt[array[48, byte]] =
|
|||
except ValueError:
|
||||
Opt.none array[48, byte]
|
||||
|
||||
func fromHex128KiB(s: string): Opt[array[131072, byte]] =
|
||||
func fromHex128K(s: string): Opt[array[131072, byte]] =
|
||||
try:
|
||||
Opt.some fromHex(array[131072, byte], s)
|
||||
except ValueError:
|
||||
|
@ -42,6 +43,27 @@ block:
|
|||
sourceDir &
|
||||
"/../../vendor/nim-kzg4844/kzg4844/csources/src/trusted_setup.txt").isOk
|
||||
|
||||
proc runBlobToKzgCommitmentTest(suiteName, suitePath, path: string) =
|
||||
test "KZG - Blob to KZG commitment - " & path.relativePath(suitePath):
|
||||
let
|
||||
data = yaml.loadToJson(os_ops.readFile(path/"data.yaml"))[0]
|
||||
output = data["output"]
|
||||
blob = fromHex128K(data["input"]["blob"].getStr)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/tests/formats/kzg/blob_to_kzg_commitment.md#condition
|
||||
# If the blob is invalid (e.g. incorrect length or one of the 32-byte
|
||||
# blocks does not represent a BLS field element) it should error, i.e. the
|
||||
# output should be `null`.
|
||||
if blob.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let commitment = blobToKzgCommitment(blob.get)
|
||||
check:
|
||||
if commitment.isErr:
|
||||
output.kind == JNull
|
||||
else:
|
||||
commitment.get == fromHex48(output.getStr).get
|
||||
|
||||
proc runVerifyKzgProofTest(suiteName, suitePath, path: string) =
|
||||
test "KZG - Verify KZG proof - " & path.relativePath(suitePath):
|
||||
let
|
||||
|
@ -59,19 +81,69 @@ proc runVerifyKzgProofTest(suiteName, suitePath, path: string) =
|
|||
if commitment.isNone or z.isNone or y.isNone or proof.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let p = verifyProof(commitment.get, z.get, y.get, proof.get)
|
||||
let v = verifyProof(commitment.get, z.get, y.get, proof.get)
|
||||
check:
|
||||
if p.isErr:
|
||||
if v.isErr:
|
||||
output.kind == JNull
|
||||
else:
|
||||
p.get == output.getBool
|
||||
v.get == output.getBool
|
||||
|
||||
proc runVerifyBlobKzgProofTest(suiteName, suitePath, path: string) =
|
||||
test "KZG - Verify blob KZG proof - " & path.relativePath(suitePath):
|
||||
let
|
||||
data = yaml.loadToJson(os_ops.readFile(path/"data.yaml"))[0]
|
||||
output = data["output"]
|
||||
blob = fromHex128K(data["input"]["blob"].getStr)
|
||||
commitment = fromHex48(data["input"]["commitment"].getStr)
|
||||
proof = fromHex48(data["input"]["proof"].getStr)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/tests/formats/kzg/verify_blob_kzg_proof.md#condition
|
||||
# "If the commitment or proof is invalid (e.g. not on the curve or not in
|
||||
# the G1 subgroup of the BLS curve) or `blob` is invalid (e.g. incorrect
|
||||
# length or one of the 32-byte blocks does not represent a BLS field
|
||||
# element), it should error, i.e. the output should be `null`."
|
||||
if blob.isNone or commitment.isNone or proof.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let v = verifyBlobKzgProof(blob.get, commitment.get, proof.get)
|
||||
check:
|
||||
if v.isErr:
|
||||
output.kind == JNull
|
||||
else:
|
||||
v.get == output.getBool
|
||||
|
||||
proc runVerifyBlobKzgProofBatchTest(suiteName, suitePath, path: string) =
|
||||
test "KZG - Verify blob KZG proof batch - " & path.relativePath(suitePath):
|
||||
let
|
||||
data = yaml.loadToJson(os_ops.readFile(path/"data.yaml"))[0]
|
||||
output = data["output"]
|
||||
blobs = data["input"]["blobs"].mapIt(fromHex128K(it.getStr))
|
||||
commitments = data["input"]["commitments"].mapIt(fromHex48(it.getStr))
|
||||
proofs = data["input"]["proofs"].mapIt(fromHex48(it.getStr))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/tests/formats/kzg/verify_blob_kzg_proof_batch.md#condition
|
||||
# "If any of the commitments or proofs are invalid (e.g. not on the curve or
|
||||
# not in the G1 subgroup of the BLS curve) or any blob is invalid (e.g.
|
||||
# incorrect length or one of the 32-byte blocks does not represent a BLS
|
||||
# field element), it should error, i.e. the output should be null."
|
||||
if blobs.anyIt(it.isNone) or commitments.anyIt(it.isNone) or
|
||||
proofs.anyIt(it.isNone):
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let v = verifyBlobKzgProofBatch(
|
||||
blobs.mapIt(it.get), commitments.mapIt(it.get), proofs.mapIt(it.get))
|
||||
check:
|
||||
if v.isErr:
|
||||
output.kind == JNull
|
||||
else:
|
||||
v.get == output.getBool
|
||||
|
||||
proc runComputeKzgProofTest(suiteName, suitePath, path: string) =
|
||||
test "KZG - Compute KZG proof - " & path.relativePath(suitePath):
|
||||
let
|
||||
data = yaml.loadToJson(os_ops.readFile(path/"data.yaml"))[0]
|
||||
output = data["output"]
|
||||
blob = fromHex128KiB(data["input"]["blob"].getStr)
|
||||
blob = fromHex128K(data["input"]["blob"].getStr)
|
||||
z = fromHex32(data["input"]["z"].getStr)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/tests/formats/kzg/compute_kzg_proof.md#condition
|
||||
|
@ -92,14 +164,56 @@ proc runComputeKzgProofTest(suiteName, suitePath, path: string) =
|
|||
p.get.proof == proof.get
|
||||
p.get.y == y.get
|
||||
|
||||
suite "EF - KZG":
|
||||
proc runComputeBlobKzgProofTest(suiteName, suitePath, path: string) =
|
||||
test "KZG - Compute blob KZG proof - " & path.relativePath(suitePath):
|
||||
let
|
||||
data = yaml.loadToJson(os_ops.readFile(path/"data.yaml"))[0]
|
||||
output = data["output"]
|
||||
blob = fromHex128K(data["input"]["blob"].getStr)
|
||||
commitment = fromHex48(data["input"]["commitment"].getStr)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/tests/formats/kzg/compute_blob_kzg_proof.md#condition
|
||||
# If the blob is invalid (e.g. incorrect length or one of the 32-byte
|
||||
# blocks does not represent a BLS field element) it should error, i.e. the
|
||||
# output should be `null`.
|
||||
if blob.isNone or commitment.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let p = computeBlobKzgProof(blob.get, commitment.get)
|
||||
if p.isErr:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
check p.get == fromHex48(output.getStr).get
|
||||
|
||||
const suiteName = "EF - KZG"
|
||||
|
||||
suite suiteName:
|
||||
const suitePath = SszTestsDir/"general"/"deneb"/"kzg"
|
||||
# TODO check that only subdirectory is kzg-mainnet in each case
|
||||
# TODO assert that only subdirectory is kzg-mainnet in each case and that all
|
||||
# maim directories (blob_to_kzg_commitment, etc) are covered
|
||||
|
||||
block:
|
||||
let testsDir = suitePath/"blob_to_kzg_commitment"/"kzg-mainnet"
|
||||
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
|
||||
# TODO Trying to access value with err Result [ResultDefect]
|
||||
if path == "blob_to_kzg_commitment_case_invalid_blob_59d64ff6b4648fad":
|
||||
continue
|
||||
runBlobToKzgCommitmentTest(suiteName, testsDir, testsDir/path)
|
||||
|
||||
block:
|
||||
let testsDir = suitePath/"verify_kzg_proof"/"kzg-mainnet"
|
||||
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
|
||||
runVerifyKzgProofTest("EF - KZG", testsDir, testsDir/path)
|
||||
runVerifyKzgProofTest(suiteName, testsDir, testsDir/path)
|
||||
|
||||
block:
|
||||
let testsDir = suitePath/"verify_blob_kzg_proof"/"kzg-mainnet"
|
||||
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
|
||||
runVerifyBlobKzgProofTest(suiteName, testsDir, testsDir/path)
|
||||
|
||||
block:
|
||||
let testsDir = suitePath/"verify_blob_kzg_proof_batch"/"kzg-mainnet"
|
||||
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
|
||||
runVerifyBlobKzgProofBatchTest(suiteName, testsDir, testsDir/path)
|
||||
|
||||
block:
|
||||
let testsDir = suitePath/"compute_kzg_proof"/"kzg-mainnet"
|
||||
|
@ -110,6 +224,17 @@ suite "EF - KZG":
|
|||
"compute_kzg_proof_case_invalid_blob_59d64ff6b4648fad",
|
||||
"compute_kzg_proof_case_invalid_z_b30d81e81c1262b6"]:
|
||||
continue
|
||||
runComputeKzgProofTest("EF - KZG", testsDir, testsDir / path)
|
||||
runComputeKzgProofTest(suiteName, testsDir, testsDir / path)
|
||||
|
||||
block:
|
||||
let testsDir = suitePath/"compute_blob_kzg_proof"/"kzg-mainnet"
|
||||
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
|
||||
# TODO in one case the same case as before, and maybe the invalid
|
||||
# commitment too
|
||||
if path in [
|
||||
"compute_blob_kzg_proof_case_invalid_blob_59d64ff6b4648fad",
|
||||
"compute_blob_kzg_proof_case_invalid_commitment_d070689c3e15444c"]:
|
||||
continue
|
||||
runComputeBlobKzgProofTest(suiteName, testsDir, testsDir / path)
|
||||
|
||||
doAssert Kzg.freeTrustedSetup().isOk
|
||||
|
|
Loading…
Reference in New Issue