@@ -59,34 +59,49 @@ public void destroy() {
59
59
}
60
60
}
61
61
62
+ // TODO: we could move this to the rust code but it requires a double pointer
63
+ // TODO: add this code to all bindings
64
+ private void checkContextHasNotBeenFreed () {
65
+ if (contextPtr == 0 ) {
66
+ throw new IllegalStateException ("PeerDAS context has been destroyed" );
67
+ }
68
+ }
69
+
62
70
public byte [] blobToKZGCommitment (byte [] blob ) {
71
+ checkContextHasNotBeenFreed ();
63
72
return blobToKZGCommitment (contextPtr , blob );
64
73
}
65
74
66
75
public CellsAndProofs computeCellsAndKZGProofs (byte [] blob ) {
76
+ checkContextHasNotBeenFreed ();
67
77
CellsAndProofs cellsAndProofs = computeCellsAndKZGProofs (contextPtr , blob );
68
78
return cellsAndProofs ;
69
79
}
70
80
71
81
public byte [][] computeCells (byte [] blob ) {
82
+ checkContextHasNotBeenFreed ();
72
83
CellsAndProofs cellsAndProofs = computeCellsAndKZGProofs (blob );
73
84
return cellsAndProofs .cells ;
74
85
}
75
86
76
87
public boolean verifyCellKZGProof (byte [] commitment , long cellID , byte [] cell , byte [] proof ) {
88
+ checkContextHasNotBeenFreed ();
77
89
return verifyCellKZGProof (contextPtr , commitment , cellID , cell , proof );
78
90
}
79
91
80
92
public boolean verifyCellKZGProofBatch (byte [][] commitmentsArr , long [] rowIndices , long [] columnIndices , byte [][] cellsArr ,
81
93
byte [][] proofsArr ) {
94
+ checkContextHasNotBeenFreed ();
82
95
return verifyCellKZGProofBatch (contextPtr , commitmentsArr , rowIndices , columnIndices , cellsArr , proofsArr );
83
96
}
84
97
85
98
public byte [][] recoverAllCells (long [] cellIDs , byte [][] cellsArr ) {
99
+ checkContextHasNotBeenFreed ();
86
100
return recoverCellsAndProofs (cellIDs , cellsArr ).cells ;
87
101
}
88
102
89
103
public CellsAndProofs recoverCellsAndProofs (long [] cellIDs , byte [][] cellsArr ) {
104
+ checkContextHasNotBeenFreed ();
90
105
return recoverCellsAndProof (contextPtr , cellIDs , cellsArr );
91
106
}
92
107
0 commit comments