Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove verifyCellKzgProof #91

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions api_eip7594.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ func (ctx *Context) RecoverCellsAndComputeKZGProofs(cellIDs []uint64, cells []*C
return ctx.computeCellsAndKZGProofsFromPolyCoeff(polyCoeff, numGoRoutines)
}

func (ctx *Context) VerifyCellKZGProof(commitment KZGCommitment, cellID uint64, cell *Cell, proof KZGProof) error {
return ctx.VerifyCellKZGProofBatch([]KZGCommitment{commitment}, []uint64{0}, []uint64{cellID}, []*Cell{cell}, []KZGProof{proof})
}

func (ctx *Context) VerifyCellKZGProofBatch(rowCommitments []KZGCommitment, rowIndices, columnIndices []uint64, cells []*Cell, proofs []KZGProof) error {
// Check that all components in the batch have the same size, expect the rowCommitments
batchSize := len(rowIndices)
Expand Down
62 changes: 0 additions & 62 deletions consensus_specs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var (
verifyBlobKZGProofTests = filepath.Join(testDir, "verify_blob_kzg_proof/*/*/*")
verifyBlobKZGProofBatchTests = filepath.Join(testDir, "verify_blob_kzg_proof_batch/*/*/*")
computeCellsAndKZGProofsTests = filepath.Join(testDir, "compute_cells_and_kzg_proofs/*/*/*")
verifyCellKZGProofTests = filepath.Join(testDir, "verify_cell_kzg_proof/*/*/*")
verifyCellKZGProofBatchTests = filepath.Join(testDir, "verify_cell_kzg_proof_batch/*/*/*")
recoverCellsAndKZGProofsTests = filepath.Join(testDir, "recover_cells_and_kzg_proofs/*/*/*")
)
Expand Down Expand Up @@ -405,67 +404,6 @@ func TestComputeCellsAndKZGProofs(t *testing.T) {
}
}

func TestVerifyCellKZGProof(t *testing.T) {
type Test struct {
Input struct {
Commitment string `yaml:"commitment"`
CellId uint64 `yaml:"cell_id"`
Cell string `yaml:"cell"`
Proof string `yaml:"proof"`
}
Output *bool `yaml:"output"`
}

tests, err := filepath.Glob(verifyCellKZGProofTests)
require.NoError(t, err)
require.True(t, len(tests) > 0)

for _, testPath := range tests {
t.Run(testPath, func(t *testing.T) {
testFile, err := os.Open(testPath)
require.NoError(t, err)
test := Test{}
err = yaml.NewDecoder(testFile).Decode(&test)
require.NoError(t, testFile.Close())
require.NoError(t, err)
testCaseValid := test.Output != nil

commitment, err := hexStrToCommitment(test.Input.Commitment)
if err != nil {
require.False(t, testCaseValid)
return
}

cellId := test.Input.CellId

cell, err := hexStrToCell(test.Input.Cell)
if err != nil {
require.False(t, testCaseValid)
return
}

proof, err := hexStrToProof(test.Input.Proof)
if err != nil {
require.False(t, testCaseValid)
return
}

err = ctx.VerifyCellKZGProof(commitment, cellId, cell, proof)
// Test specifically distinguish between the test failing
// because of the pairing check and failing because of
// validation errors on the input
if err != nil && !errors.Is(err, kzg.ErrVerifyOpeningProof) {
require.False(t, testCaseValid)
} else {
// Either the error is nil or it is a verification error
expectedOutput := *test.Output
gotOutput := !errors.Is(err, kzg.ErrVerifyOpeningProof)
require.Equal(t, expectedOutput, gotOutput)
}
})
}
}

func TestVerifyCellKZGProofBatch(t *testing.T) {
type Test struct {
Input struct {
Expand Down
Loading