Skip to content

Commit

Permalink
Update jc-kzg-4844 (Consensys#7418)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Aug 13, 2023
1 parent 3c74f07 commit b54882a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencyManagement {

dependency 'io.libp2p:jvm-libp2p-minimal:0.10.0-RELEASE'
dependency 'tech.pegasys:jblst:0.3.10'
dependency 'tech.pegasys:jc-kzg-4844:0.7.1'
dependency 'tech.pegasys:jc-kzg-4844:0.7.2'

dependency 'org.hdrhistogram:HdrHistogram:2.1.12'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package tech.pegasys.teku.kzg;

import static com.google.common.base.Preconditions.checkArgument;
import static tech.pegasys.teku.kzg.ckzg4844.CKZG4844.G1_POINT_SIZE;
import static tech.pegasys.teku.kzg.ckzg4844.CKZG4844.G2_POINT_SIZE;
import static ethereum.ckzg4844.CKZG4844JNI.BYTES_PER_G1;
import static ethereum.ckzg4844.CKZG4844JNI.BYTES_PER_G2;

import java.util.List;
import org.apache.tuweni.bytes.Bytes;
Expand All @@ -28,12 +28,10 @@ public record TrustedSetup(List<Bytes> g1Points, List<Bytes> g2Points) {
}

private void validateG1Point(final Bytes g1Point) {
checkArgument(
g1Point.size() == G1_POINT_SIZE, "Expected G1 point to be %s bytes", G1_POINT_SIZE);
checkArgument(g1Point.size() == BYTES_PER_G1, "Expected G1 point to be %s bytes", BYTES_PER_G1);
}

private void validateG2Point(final Bytes g2Point) {
checkArgument(
g2Point.size() == G2_POINT_SIZE, "Expected G2 point to be %s bytes", G2_POINT_SIZE);
checkArgument(g2Point.size() == BYTES_PER_G2, "Expected G2 point to be %s bytes", BYTES_PER_G2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
*/
public final class CKZG4844 implements KZG {

public static final int G1_POINT_SIZE = 48;
public static final int G2_POINT_SIZE = 96;

private static final Logger LOG = LogManager.getLogger();

private static CKZG4844 instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public static byte[] flattenProofs(final List<KZGProof> kzgProofs) {
}

public static byte[] flattenG1Points(final List<Bytes> g1Points) {
return flattenBytes(g1Points, CKZG4844.G1_POINT_SIZE * g1Points.size());
return flattenBytes(g1Points, CKZG4844JNI.BYTES_PER_G1 * g1Points.size());
}

public static byte[] flattenG2Points(final List<Bytes> g2Points) {
return flattenBytes(g2Points, CKZG4844.G2_POINT_SIZE * g2Points.size());
return flattenBytes(g2Points, CKZG4844JNI.BYTES_PER_G2 * g2Points.size());
}

public static TrustedSetup parseTrustedSetupFile(final String filePath) throws IOException {
Expand All @@ -75,13 +75,13 @@ public static TrustedSetup parseTrustedSetupFile(final String filePath) throws I
// List of G1 points, one on each new line
final List<Bytes> g1Points = new ArrayList<>();
for (int i = 0; i < g1Size; i++) {
final Bytes g1Point = Bytes.fromHexString(reader.readLine(), CKZG4844.G1_POINT_SIZE);
final Bytes g1Point = Bytes.fromHexString(reader.readLine(), CKZG4844JNI.BYTES_PER_G1);
g1Points.add(g1Point);
}
// List of G2 points, one on each new line
final List<Bytes> g2Points = new ArrayList<>();
for (int i = 0; i < g2Size; i++) {
final Bytes g2Point = Bytes.fromHexString(reader.readLine(), CKZG4844.G2_POINT_SIZE);
final Bytes g2Point = Bytes.fromHexString(reader.readLine(), CKZG4844JNI.BYTES_PER_G2);
g2Points.add(g2Point);
}

Expand Down

0 comments on commit b54882a

Please sign in to comment.