Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove point-at-infinity for proofs/commitments #8063

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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