From 582b127d47d390bfc1e247e7c7c598097561fbdd Mon Sep 17 00:00:00 2001 From: Lorenzo Gentile Date: Fri, 5 Jul 2024 11:47:37 +0200 Subject: [PATCH] fix(ecdata): minor fixes after specs revision (#821) Co-authored-by: Tsvetan Dimitrov --- .../module/ecdata/EcDataOperation.java | 21 ++++++++++++++----- .../linea/zktracer/module/ecdata/Trace.java | 18 ++++++++-------- gradle/trace-files.gradle | 2 +- zkevm-constraints | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcDataOperation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcDataOperation.java index dd4affbb01..7514949b82 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcDataOperation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcDataOperation.java @@ -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; @@ -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 } @@ -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); @@ -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)) diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/Trace.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/Trace.java index 56b8981084..711d84ea33 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/Trace.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/Trace.java @@ -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; @@ -124,7 +124,7 @@ public class Trace { static List 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), @@ -181,7 +181,7 @@ static List headers(int length) { public Trace(List 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); @@ -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; } @@ -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)) { @@ -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)) { diff --git a/gradle/trace-files.gradle b/gradle/trace-files.gradle index b43f38bbec..14c433a041 100644 --- a/gradle/trace-files.gradle +++ b/gradle/trace-files.gradle @@ -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"] diff --git a/zkevm-constraints b/zkevm-constraints index f577b759dc..ceb6511578 160000 --- a/zkevm-constraints +++ b/zkevm-constraints @@ -1 +1 @@ -Subproject commit f577b759dca3208b0afefbe562dde5afea39bd98 +Subproject commit ceb6511578461474dcdb3c2b2d5c07196d243d47