Skip to content

Commit

Permalink
revert tree.Push api to only use []byte and not also the axis (celest…
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes authored Sep 28, 2022
1 parent 58bebde commit 33a5763
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions datasquare.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ func (ds *dataSquare) getRowRoot(x uint) []byte {
}

tree := ds.createTreeFn(Row, x)
for i, d := range ds.row(x) {
tree.Push(d, SquareIndex{Cell: uint(i), Axis: x})
for _, d := range ds.row(x) {
tree.Push(d)
}

return tree.Root()
Expand All @@ -246,8 +246,8 @@ func (ds *dataSquare) getColRoot(y uint) []byte {
}

tree := ds.createTreeFn(Col, y)
for i, d := range ds.col(y) {
tree.Push(d, SquareIndex{Axis: y, Cell: uint(i)})
for _, d := range ds.col(y) {
tree.Push(d)
}

return tree.Root()
Expand Down
4 changes: 2 additions & 2 deletions datasquare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func computeRowProof(ds *dataSquare, x uint, y uint) ([]byte, [][]byte, uint, ui
data := ds.row(x)

for i := uint(0); i < ds.width; i++ {
tree.Push(data[i], SquareIndex{Axis: y, Cell: uint(i)})
tree.Push(data[i])
}

merkleRoot, proof, proofIndex, numLeaves := treeProve(tree.(*DefaultTree), int(y))
Expand All @@ -231,7 +231,7 @@ func computeColProof(ds *dataSquare, x uint, y uint) ([]byte, [][]byte, uint, ui
data := ds.col(y)

for i := uint(0); i < ds.width; i++ {
tree.Push(data[i], SquareIndex{Axis: y, Cell: uint(i)})
tree.Push(data[i])
}
// TODO(ismail): check for overflow when casting from uint -> int
merkleRoot, proof, proofIndex, numLeaves := treeProve(tree.(*DefaultTree), int(x))
Expand Down
4 changes: 2 additions & 2 deletions extendeddatacrossword.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ func noMissingData(input [][]byte) bool {

func (eds *ExtendedDataSquare) computeSharesRoot(shares [][]byte, axis Axis, i uint) []byte {
tree := eds.createTreeFn(axis, i)
for cell, d := range shares {
tree.Push(d, SquareIndex{Cell: uint(cell), Axis: i})
for _, d := range shares {
tree.Push(d)
}
return tree.Root()
}
Expand Down
4 changes: 2 additions & 2 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type SquareIndex struct {

// Tree wraps Merkle tree implementations to work with rsmt2d
type Tree interface {
Push(data []byte, idx SquareIndex)
Push(data []byte)
Root() []byte
}

Expand All @@ -36,7 +36,7 @@ func NewDefaultTree(axis Axis, index uint) Tree {
}
}

func (d *DefaultTree) Push(data []byte, _idx SquareIndex) {
func (d *DefaultTree) Push(data []byte) {
// ignore the idx, as this implementation doesn't need that info
d.leaves = append(d.leaves, data)
}
Expand Down

0 comments on commit 33a5763

Please sign in to comment.