Skip to content

Commit

Permalink
refactor: validate against ID, not commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed Sep 25, 2023
1 parent 60fc3a9 commit d1935ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion da.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type DA interface {
Submit(blobs []Blob) ([]ID, []Proof, error)

// Validate validates Commitment against Proof. This should be possible without retrieving Blob.
Validate(commits []ID, proofs []Proof) ([]bool, error)
Validate(ids []ID, proofs []Proof) ([]bool, error)
}

// Blob is the data submitted/received from DA interface.
Expand Down
13 changes: 10 additions & 3 deletions da_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,28 @@ func ExecuteDATest(t *testing.T, da da.DA) {
assert.NoError(t, err)
assert.NotEmpty(t, commitment2)

oks, err := da.Validate(commitment1, proof1)
oks, err := da.Validate(id1, proof1)
assert.NoError(t, err)
assert.NotEmpty(t, oks)
for _, ok := range oks {
assert.True(t, ok)
}

oks, err = da.Validate(commitment1, proof2)
oks, err = da.Validate(id2, proof2)
assert.NoError(t, err)
assert.NotEmpty(t, oks)
for _, ok := range oks {
assert.True(t, ok)
}

oks, err = da.Validate(id1, proof2)
assert.NoError(t, err)
assert.NotEmpty(t, oks)
for _, ok := range oks {
assert.False(t, ok)
}

oks, err = da.Validate(commitment2, proof1)
oks, err = da.Validate(id2, proof1)
assert.NoError(t, err)
assert.NotEmpty(t, oks)
for _, ok := range oks {
Expand Down
8 changes: 4 additions & 4 deletions dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func (d *DummyDA) Submit(blobs []da.Blob) ([]da.ID, []da.Proof, error) {
proofs := make([]da.Proof, len(blobs))
for i, blob := range blobs {
id := d.nextID()
ids[i] = id
proofs[i] = d.getProof(id, blob)
ids[i] = append(id, d.getHash(blob)...)
proofs[i] = d.getProof(ids[i], blob)

d.data[string(id)] = blob
d.data[string(ids[i])] = blob
}

return ids, proofs, nil
Expand All @@ -72,7 +72,7 @@ func (d *DummyDA) Validate(ids []da.ID, proofs []da.Proof) ([]bool, error) {
}
results := make([]bool, len(ids))
for i := 0; i < len(ids); i++ {
results[i] = ed25519.Verify(d.pubKey, ids[i], proofs[i])
results[i] = ed25519.Verify(d.pubKey, ids[i][8:], proofs[i])
}
return results, nil
}
Expand Down

0 comments on commit d1935ef

Please sign in to comment.