Skip to content

Commit

Permalink
Remove point-at-infinity for proofs/commitments (#8063)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia committed Mar 13, 2024
1 parent be4dfc0 commit 6e1f521
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String toLogString() {
getBlockRoot(),
getIndex(),
getBlob().toBriefString(),
getKZGCommitment().toHexString(),
getKZGCommitment().toAbbreviatedString(),
getKZGProof().toAbbreviatedString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.List;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes48;

/**
* This interface specifies all the KZG functions needed for the Deneb specification and is the
Expand Down Expand Up @@ -53,13 +54,13 @@ public boolean verifyBlobKzgProofBatch(

@Override
public KZGCommitment blobToKzgCommitment(final Bytes blob) throws KZGException {
return KZGCommitment.infinity();
return KZGCommitment.fromBytesCompressed(Bytes48.ZERO);
}

@Override
public KZGProof computeBlobKzgProof(final Bytes blob, final KZGCommitment kzgCommitment)
throws KZGException {
return KZGProof.INFINITY;
return KZGProof.fromBytesCompressed(Bytes48.ZERO);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@

public final class KZGCommitment {

/**
* Creates 0x00..00 for point-at-infinity
*
* @return point-at-infinity as per the Eth2 spec
*/
public static KZGCommitment infinity() {
return KZGCommitment.fromBytesCompressed(Bytes48.ZERO);
}

public static KZGCommitment fromHexString(final String hexString) {
return KZGCommitment.fromBytesCompressed(Bytes48.fromHexString(hexString));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

public final class KZGProof {

/** Creates 0x00..00 for point-at-infinity */
public static final KZGProof INFINITY = KZGProof.fromBytesCompressed(Bytes48.ZERO);

public static KZGProof fromHexString(final String hexString) {
return KZGProof.fromBytesCompressed(Bytes48.fromHexString(hexString));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public void testUsageWithoutLoadedTrustedSetup_shouldThrowException() {
() ->
CKZG.verifyBlobKzgProofBatch(
List.of(Bytes.fromHexString("0x", BYTES_PER_BLOB)),
List.of(KZGCommitment.infinity()),
List.of(KZGProof.INFINITY))),
List.of(getSampleCommitment()),
List.of(getSampleProof()))),
assertThrows(KZGException.class, () -> CKZG.blobToKzgCommitment(Bytes.EMPTY)),
assertThrows(
KZGException.class,
() -> CKZG.computeBlobKzgProof(Bytes.EMPTY, KZGCommitment.infinity())));
() -> CKZG.computeBlobKzgProof(Bytes.EMPTY, getSampleCommitment())));

assertThat(exceptions)
.allSatisfy(
Expand Down Expand Up @@ -293,6 +293,10 @@ private KZGCommitment getSampleCommitment() {
return CKZG.blobToKzgCommitment(getSampleBlob());
}

private KZGProof getSampleProof() {
return CKZG.computeBlobKzgProof(getSampleBlob(), getSampleCommitment());
}

private UInt256 randomBLSFieldElement() {
while (true) {
final BigInteger attempt = new BigInteger(BLS_MODULUS.bitLength(), RND);
Expand Down

0 comments on commit 6e1f521

Please sign in to comment.