Skip to content

Commit 9cf6c53

Browse files
authored
chore: Publishing PeerDAS KZG (java) (#30)
1 parent fb6df2e commit 9cf6c53

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
rustup target add x86_64-apple-darwin aarch64-apple-darwin x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-pc-windows-gnu

.github/workflows/release-csharp-bindings.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
- name: Install Rust
2121
uses: dtolnay/rust-toolchain@1.74.1
2222

23+
- name: Install all of the relevant targets
24+
run: |
25+
chmod +x .github/scripts/install_all_targets.sh
26+
.github/scripts/install_all_targets.sh
27+
2328
- name: Install .NET SDK
2429
uses: actions/setup-dotnet@v3
2530
with:
@@ -58,8 +63,8 @@ jobs:
5863

5964
- name: Run compile script
6065
run: |
61-
chmod +x scripts/compile_all_targets_c_sharp.sh
62-
scripts/compile_all_targets_c_sharp.sh
66+
chmod +x .github/scripts/compile_all_targets_c_sharp.sh
67+
.github/scripts/compile_all_targets_c_sharp.sh
6368
6469
- name: Restore NuGet packages
6570
working-directory: bindings/csharp/csharp_code/PeerDASKZG.bindings

.github/workflows/release-java-bindings.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ jobs:
1515
- name: Checkout sources
1616
uses: actions/checkout@v4
1717
with:
18-
ref: master
18+
ref: ${{ inputs.ref }}
1919

2020
- name: Install Rust
2121
uses: dtolnay/rust-toolchain@1.74.1
2222

23+
- name: Install all of the relevant targets
24+
run: |
25+
chmod +x .github/scripts/install_all_targets.sh
26+
.github/scripts/install_all_targets.sh
27+
2328
- name: Set up JDK
2429
uses: actions/setup-java@v3
2530
with:
@@ -63,10 +68,11 @@ jobs:
6368
6469
- name: Run compile script
6570
run: |
66-
chmod +x scripts/compile_all_targets_java.sh
67-
scripts/compile_all_targets_java.sh
71+
chmod +x .github/scripts/compile_all_targets_java.sh
72+
.github/scripts/compile_all_targets_java.sh
6873
6974
- name: Publish Java package to Maven Central
75+
working-directory: bindings/java/java_code
7076
env:
7177
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_TOKEN_USERNAME }}
7278
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.CENTRAL_PORTAL_TOKEN_PASSWORD }}
@@ -83,5 +89,5 @@ jobs:
8389
with:
8490
name: jreleaser-logs
8591
path: |
86-
build/jreleaser/trace.log
87-
build/jreleaser/output.properties
92+
bindings/java/java_code/build/jreleaser/trace.log
93+
bindings/java/java_code/build/jreleaser/output.properties

bindings/java/java_code/build.gradle

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ plugins {
77
id 'org.jreleaser' version '1.12.0'
88
}
99

10-
group = 'io.github.crate-crypto.peerdas-kzg'
11-
version = '0.0.1' // x-release-please-version
10+
group = 'io.github.crate-crypto'
11+
version = '0.0.7' // x-release-please-version
1212

1313

1414
java {
@@ -84,6 +84,14 @@ publishing {
8484
}
8585

8686
jreleaser {
87+
// Jreleaser will look for .git and its at the top level repository
88+
gitRootSearch = true
89+
release {
90+
// Skip releases as this is handled by release-please
91+
github {
92+
skipRelease = true
93+
}
94+
}
8795
signing {
8896
active = 'ALWAYS'
8997
armored = true
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
rootProject.name = 'java-peerdas-ij'
1+
rootProject.name = 'peerdas-kzg'
22

bindings/java/java_code/src/main/java/ethereum/cryptography/LibPeerDASKZG.java

+15
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,49 @@ public void destroy() {
5959
}
6060
}
6161

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+
6270
public byte[] blobToKZGCommitment(byte[] blob) {
71+
checkContextHasNotBeenFreed();
6372
return blobToKZGCommitment(contextPtr, blob);
6473
}
6574

6675
public CellsAndProofs computeCellsAndKZGProofs(byte[] blob) {
76+
checkContextHasNotBeenFreed();
6777
CellsAndProofs cellsAndProofs = computeCellsAndKZGProofs(contextPtr, blob);
6878
return cellsAndProofs;
6979
}
7080

7181
public byte[][] computeCells(byte[] blob) {
82+
checkContextHasNotBeenFreed();
7283
CellsAndProofs cellsAndProofs = computeCellsAndKZGProofs(blob);
7384
return cellsAndProofs.cells;
7485
}
7586

7687
public boolean verifyCellKZGProof(byte[] commitment, long cellID, byte[] cell, byte[] proof) {
88+
checkContextHasNotBeenFreed();
7789
return verifyCellKZGProof(contextPtr, commitment, cellID, cell, proof);
7890
}
7991

8092
public boolean verifyCellKZGProofBatch(byte[][] commitmentsArr, long[] rowIndices, long[] columnIndices, byte[][] cellsArr,
8193
byte[][] proofsArr) {
94+
checkContextHasNotBeenFreed();
8295
return verifyCellKZGProofBatch(contextPtr, commitmentsArr, rowIndices, columnIndices, cellsArr, proofsArr);
8396
}
8497

8598
public byte[][] recoverAllCells(long[] cellIDs, byte[][] cellsArr) {
99+
checkContextHasNotBeenFreed();
86100
return recoverCellsAndProofs(cellIDs, cellsArr).cells;
87101
}
88102

89103
public CellsAndProofs recoverCellsAndProofs(long[] cellIDs, byte[][] cellsArr) {
104+
checkContextHasNotBeenFreed();
90105
return recoverCellsAndProof(contextPtr, cellIDs, cellsArr);
91106
}
92107

0 commit comments

Comments
 (0)