-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.go
46 lines (40 loc) · 1.27 KB
/
convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package celestia_da_light_client
import (
tmtypes "github.com/tendermint/tendermint/types"
cometcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
)
// Convert celestia core' share proof to celestia light client's share proof
func TmShareProofToProto(sp *tmtypes.ShareProof) ShareProof {
rowRoots := make([][]byte, len(sp.RowProof.RowRoots))
rowProofs := make([]*cometcrypto.Proof, len(sp.RowProof.Proofs))
for i := range sp.RowProof.RowRoots {
rowRoots[i] = sp.RowProof.RowRoots[i].Bytes()
rowProofs[i] = &cometcrypto.Proof{
Total: sp.RowProof.Proofs[i].Total,
Index: sp.RowProof.Proofs[i].Index,
LeafHash: sp.RowProof.Proofs[i].LeafHash,
Aunts: sp.RowProof.Proofs[i].Aunts,
}
}
shareProofs := make([]*NMTProof, len(sp.ShareProofs))
for i := range sp.ShareProofs {
shareProofs[i] = &NMTProof{
Start: sp.ShareProofs[i].Start,
End: sp.ShareProofs[i].End,
Nodes: sp.ShareProofs[i].Nodes,
LeafHash: sp.ShareProofs[i].LeafHash,
}
}
return ShareProof{
Data: sp.Data,
ShareProofs: shareProofs,
NamespaceId: sp.NamespaceID,
RowProof: &RowProof{
RowRoots: rowRoots,
Proofs: rowProofs,
StartRow: sp.RowProof.StartRow,
EndRow: sp.RowProof.EndRow,
},
NamespaceVersion: sp.NamespaceVersion,
}
}