Skip to content

Commit

Permalink
do not validate nil shares from ErrByzantine
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Nov 3, 2022
1 parent 25894fc commit 9fa7035
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions share/eds/byzantine/share_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (s *ShareWithProof) Validate(root cid.Cid) bool {
}

func (s *ShareWithProof) ShareWithProofToProto() *pb.Share {
if s == nil {
return &pb.Share{}
}

return &pb.Share{
Data: s.Share,
Proof: &pb.MerkleProof{
Expand Down Expand Up @@ -94,12 +98,18 @@ func GetProofsForShares(
func ProtoToShare(protoShares []*pb.Share) []*ShareWithProof {
shares := make([]*ShareWithProof, len(protoShares))
for i, share := range protoShares {
if share.Proof == nil {
continue
}
proof := ProtoToProof(share.Proof)
shares[i] = &ShareWithProof{share.Data, &proof}
}
return shares
}

func ProtoToProof(protoProof *pb.MerkleProof) nmt.Proof {
if protoProof == nil {
return nmt.Proof{}
}
return nmt.NewInclusionProof(int(protoProof.Start), int(protoProof.End), protoProof.Nodes, true)
}

0 comments on commit 9fa7035

Please sign in to comment.