Closed
Description
As part of ergoplatform/sigma-rust implementation of BatchMerkleProof #538, I found a way to trigger stack overflow in BatchMerkleProof::valid implementation. After some testing, this issue occured in both the scala implementation and Rust. In loop() code, if a is empty, then it will still keep recursing and passing yet another empty array of indices to loop(). Here is a minimally failing example:
val batch = BatchMerkleProof(Seq(), Seq((Digest32 @@ Array.fill[Byte](32)(0),MerkleProof.LeftSide)))
batch.valid(Digest32 @@ Array.fill[Byte](32)(0))