Skip to content

Commit

Permalink
fix(ecdata): minor fixes after specs revision (#821)
Browse files Browse the repository at this point in the history
Co-authored-by: Tsvetan Dimitrov <tsvetan.dimitrov@consensys.net>
  • Loading branch information
lorenzogentile404 and powerslider authored Jul 5, 2024
1 parent 599bc9e commit 582b127
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,18 @@ public void setReturnData(Bytes returnData) {
limb.set(limb.size() - 1, pairingResult.lo());

// Set successBit
/*
if (!internalChecksPassed || notOnG2AccMax) {
successBit = false;
} else {
successBit = true;
}
*/
if (!internalChecksPassed) {
successBit = false;
} else {
successBit = !notOnG2AccMax;
}
}
}
returnDataSet = true;
Expand Down Expand Up @@ -599,7 +606,7 @@ void handlePairing() {

// Success bit is set in setReturnData

// acceptablePairOfPointForPairingCircuit, g2MembershipTestRequired, circuitSelectorEcpairing,
// acceptablePairOfPointsForPairingCircuit, g2MembershipTestRequired, circuitSelectorEcpairing,
// circuitSelectorG2Membership are set in the trace method
}

Expand Down Expand Up @@ -634,8 +641,12 @@ void trace(Trace trace, final int stamp, final long previousId) {
notOnG2AccMax
? isLargePoint && !largePointIsAtInfinity && notOnG2.get(i)
: isLargePoint && !largePointIsAtInfinity && smallPointIsAtInfinity;
boolean acceptablePairOfPointForPairingCircuit =
!notOnG2AccMax && !largePointIsAtInfinity && !smallPointIsAtInfinity;
boolean acceptablePairOfPointsForPairingCircuit =
ecType == ECPAIRING
&& successBit
&& !notOnG2AccMax
&& !largePointIsAtInfinity
&& !smallPointIsAtInfinity;

if (ecType != ECPAIRING || !isData) {
Preconditions.checkArgument(ct == 0);
Expand Down Expand Up @@ -683,11 +694,11 @@ void trace(Trace trace, final int stamp, final long previousId) {
&& overallTrivialPairing.get(
i)) // && conditions necessary because default value is true
.g2MembershipTestRequired(g2MembershipTestRequired)
.acceptablePairOfPointForPairingCircuit(acceptablePairOfPointForPairingCircuit)
.acceptablePairOfPointsForPairingCircuit(acceptablePairOfPointsForPairingCircuit)
.circuitSelectorEcrecover(circuitSelectorEcrecover)
.circuitSelectorEcadd(circuitSelectorEcadd)
.circuitSelectorEcmul(circuitSelectorEcmul)
.circuitSelectorEcpairing(acceptablePairOfPointForPairingCircuit)
.circuitSelectorEcpairing(acceptablePairOfPointsForPairingCircuit)
.circuitSelectorG2Membership(g2MembershipTestRequired)
.wcpFlag(wcpFlag.get(i))
.wcpArg1Hi(wcpArg1Hi.get(i))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class Trace {
private int currentLine = 0;

private final MappedByteBuffer accPairings;
private final MappedByteBuffer acceptablePairOfPointForPairingCircuit;
private final MappedByteBuffer acceptablePairOfPointsForPairingCircuit;
private final MappedByteBuffer byteDelta;
private final MappedByteBuffer circuitSelectorEcadd;
private final MappedByteBuffer circuitSelectorEcmul;
Expand Down Expand Up @@ -124,7 +124,7 @@ public class Trace {
static List<ColumnHeader> headers(int length) {
return List.of(
new ColumnHeader("ecdata.ACC_PAIRINGS", 32, length),
new ColumnHeader("ecdata.ACCEPTABLE_PAIR_OF_POINT_FOR_PAIRING_CIRCUIT", 1, length),
new ColumnHeader("ecdata.ACCEPTABLE_PAIR_OF_POINTS_FOR_PAIRING_CIRCUIT", 1, length),
new ColumnHeader("ecdata.BYTE_DELTA", 1, length),
new ColumnHeader("ecdata.CIRCUIT_SELECTOR_ECADD", 1, length),
new ColumnHeader("ecdata.CIRCUIT_SELECTOR_ECMUL", 1, length),
Expand Down Expand Up @@ -181,7 +181,7 @@ static List<ColumnHeader> headers(int length) {

public Trace(List<MappedByteBuffer> buffers) {
this.accPairings = buffers.get(0);
this.acceptablePairOfPointForPairingCircuit = buffers.get(1);
this.acceptablePairOfPointsForPairingCircuit = buffers.get(1);
this.byteDelta = buffers.get(2);
this.circuitSelectorEcadd = buffers.get(3);
this.circuitSelectorEcmul = buffers.get(4);
Expand Down Expand Up @@ -260,15 +260,15 @@ public Trace accPairings(final Bytes b) {
return this;
}

public Trace acceptablePairOfPointForPairingCircuit(final Boolean b) {
public Trace acceptablePairOfPointsForPairingCircuit(final Boolean b) {
if (filled.get(0)) {
throw new IllegalStateException(
"ecdata.ACCEPTABLE_PAIR_OF_POINT_FOR_PAIRING_CIRCUIT already set");
"ecdata.ACCEPTABLE_PAIR_OF_POINTS_FOR_PAIRING_CIRCUIT already set");
} else {
filled.set(0);
}

acceptablePairOfPointForPairingCircuit.put((byte) (b ? 1 : 0));
acceptablePairOfPointsForPairingCircuit.put((byte) (b ? 1 : 0));

return this;
}
Expand Down Expand Up @@ -968,7 +968,7 @@ public Trace validateRow() {

if (!filled.get(0)) {
throw new IllegalStateException(
"ecdata.ACCEPTABLE_PAIR_OF_POINT_FOR_PAIRING_CIRCUIT has not been filled");
"ecdata.ACCEPTABLE_PAIR_OF_POINTS_FOR_PAIRING_CIRCUIT has not been filled");
}

if (!filled.get(2)) {
Expand Down Expand Up @@ -1191,8 +1191,8 @@ public Trace fillAndValidateRow() {
}

if (!filled.get(0)) {
acceptablePairOfPointForPairingCircuit.position(
acceptablePairOfPointForPairingCircuit.position() + 1);
acceptablePairOfPointsForPairingCircuit.position(
acceptablePairOfPointsForPairingCircuit.position() + 1);
}

if (!filled.get(2)) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/trace-files.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tasks.register('binreftable', TraceFilesTask) {
['mmu', 'blake2fmodexpdata', 'blockdata', 'oob', 'exp', 'rlptxrcpt', 'rlpaddr', 'shakiradata', 'mxp', 'ecdata', 'gas'].each {moduleName ->
tasks.register(moduleName, TraceFilesTask) {
group "Trace files generation"
dependsOn corsetExists
// dependsOn corsetExists

module = moduleName
files = ["${moduleName}/columns.lisp", "${moduleName}/constants.lisp"]
Expand Down
2 changes: 1 addition & 1 deletion zkevm-constraints

0 comments on commit 582b127

Please sign in to comment.