@@ -15,7 +15,7 @@ static const char HONK_CONTRACT_SOURCE[] = R"(
15
15
pragma solidity ^0.8.27;
16
16
17
17
interface IVerifier {
18
- function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool);
18
+ function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external returns (bool);
19
19
}
20
20
21
21
type Fr is uint256;
@@ -68,7 +68,7 @@ library FrLib {
68
68
mstore(add(free, 0x20), 0x20)
69
69
mstore(add(free, 0x40), 0x20)
70
70
mstore(add(free, 0x60), v)
71
- mstore(add(free, 0x80), sub(MODULUS, 2))
71
+ mstore(add(free, 0x80), sub(MODULUS, 2))
72
72
mstore(add(free, 0xa0), MODULUS)
73
73
let success := staticcall(gas(), 0x05, free, 0xc0, 0x00, 0x20)
74
74
if iszero(success) {
@@ -92,7 +92,7 @@ library FrLib {
92
92
mstore(add(free, 0x20), 0x20)
93
93
mstore(add(free, 0x40), 0x20)
94
94
mstore(add(free, 0x60), b)
95
- mstore(add(free, 0x80), v)
95
+ mstore(add(free, 0x80), v)
96
96
mstore(add(free, 0xa0), MODULUS)
97
97
let success := staticcall(gas(), 0x05, free, 0xc0, 0x00, 0x20)
98
98
if iszero(success) {
@@ -674,6 +674,7 @@ library RelationsLib {
674
674
accumulateNnfRelation(purportedEvaluations, evaluations, powPartialEval);
675
675
accumulatePoseidonExternalRelation(purportedEvaluations, evaluations, powPartialEval);
676
676
accumulatePoseidonInternalRelation(purportedEvaluations, evaluations, powPartialEval);
677
+
677
678
// batch the subrelations with the alpha challenges to obtain the full honk relation
678
679
accumulator = scaleAndBatchSubrelations(evaluations, alphas);
679
680
}
@@ -1051,7 +1052,7 @@ library RelationsLib {
1051
1052
ap.index_delta = wire(p, WIRE.W_L_SHIFT) - wire(p, WIRE.W_L);
1052
1053
ap.record_delta = wire(p, WIRE.W_4_SHIFT) - wire(p, WIRE.W_4);
1053
1054
1054
- ap.index_is_monotonically_increasing = ap.index_delta * ap.index_delta - ap.index_delta ; // deg 2
1055
+ ap.index_is_monotonically_increasing = ap.index_delta * ( ap.index_delta - Fr.wrap(1)) ; // deg 2
1055
1056
1056
1057
ap.adjacent_values_match_if_adjacent_indices_match = (ap.index_delta * MINUS_ONE + ONE) * ap.record_delta; // deg 2
1057
1058
@@ -1082,7 +1083,7 @@ library RelationsLib {
1082
1083
* with a WRITE operation.
1083
1084
*/
1084
1085
Fr access_type = (wire(p, WIRE.W_4) - ap.partial_record_check); // will be 0 or 1 for honest Prover; deg 1 or 4
1085
- ap.access_check = access_type * access_type - access_type ; // check value is 0 or 1; deg 2 or 8
1086
+ ap.access_check = access_type * ( access_type - Fr.wrap(1)) ; // check value is 0 or 1; deg 2 or 8
1086
1087
1087
1088
// reverse order we could re-use `ap.partial_record_check` 1 - ((w3' * eta + w2') * eta + w1') * eta
1088
1089
// deg 1 or 4
@@ -1256,7 +1257,7 @@ library RelationsLib {
1256
1257
function accumulatePoseidonExternalRelation(
1257
1258
Fr[NUMBER_OF_ENTITIES] memory p,
1258
1259
Fr[NUMBER_OF_SUBRELATIONS] memory evals,
1259
- Fr domainSep // i guess this is the scaling factor?
1260
+ Fr domainSep
1260
1261
) internal pure {
1261
1262
PoseidonExternalParams memory ep;
1262
1263
@@ -1354,7 +1355,7 @@ library RelationsLib {
1354
1355
Fr[NUMBER_OF_SUBRELATIONS] memory evaluations,
1355
1356
Fr[NUMBER_OF_ALPHAS] memory subrelationChallenges
1356
1357
) internal pure returns (Fr accumulator) {
1357
- accumulator = accumulator + evaluations[0];
1358
+ accumulator = evaluations[0];
1358
1359
1359
1360
for (uint256 i = 1; i < NUMBER_OF_SUBRELATIONS; ++i) {
1360
1361
accumulator = accumulator + evaluations[i] * subrelationChallenges[i - 1];
@@ -1421,10 +1422,9 @@ library CommitmentSchemeLib {
1421
1422
);
1422
1423
// Divide by the denominator
1423
1424
batchedEvalRoundAcc = batchedEvalRoundAcc * (challengePower * (ONE - u) + u).invert();
1424
- if (i <= logSize) {
1425
- batchedEvalAccumulator = batchedEvalRoundAcc;
1426
- foldPosEvaluations[i - 1] = batchedEvalRoundAcc;
1427
- }
1425
+
1426
+ batchedEvalAccumulator = batchedEvalRoundAcc;
1427
+ foldPosEvaluations[i - 1] = batchedEvalRoundAcc;
1428
1428
}
1429
1429
return foldPosEvaluations;
1430
1430
}
@@ -2073,27 +2073,24 @@ abstract contract BaseHonkVerifier is IVerifier {
2073
2073
// Compute Shplonk constant term contributions from Aₗ(± r^{2ˡ}) for l = 1, ..., m-1;
2074
2074
// Compute scalar multipliers for each fold commitment
2075
2075
for (uint256 i = 0; i < $LOG_N - 1; ++i) {
2076
- bool dummy_round = i >= ($LOG_N - 1);
2077
-
2078
- if (!dummy_round) {
2079
- // Update inverted denominators
2080
- mem.posInvertedDenominator = (tp.shplonkZ - powers_of_evaluation_challenge[i + 1]).invert();
2081
- mem.negInvertedDenominator = (tp.shplonkZ + powers_of_evaluation_challenge[i + 1]).invert();
2082
-
2083
- // Compute the scalar multipliers for Aₗ(± r^{2ˡ}) and [Aₗ]
2084
- mem.scalingFactorPos = mem.batchingChallenge * mem.posInvertedDenominator;
2085
- mem.scalingFactorNeg = mem.batchingChallenge * tp.shplonkNu * mem.negInvertedDenominator;
2086
- // [Aₗ] is multiplied by -v^{2l}/(z-r^{2^l}) - v^{2l+1} /(z+ r^{2^l})
2087
- scalars[NUMBER_UNSHIFTED + 1 + i] = mem.scalingFactorNeg.neg() + mem.scalingFactorPos.neg();
2088
-
2089
- // Accumulate the const term contribution given by
2090
- // v^{2l} * Aₗ(r^{2ˡ}) /(z-r^{2^l}) + v^{2l+1} * Aₗ(-r^{2ˡ}) /(z+ r^{2^l})
2091
- Fr accumContribution = mem.scalingFactorNeg * proof.geminiAEvaluations[i + 1];
2092
- accumContribution = accumContribution + mem.scalingFactorPos * foldPosEvaluations[i + 1];
2093
- mem.constantTermAccumulator = mem.constantTermAccumulator + accumContribution;
2094
- // Update the running power of v
2095
- mem.batchingChallenge = mem.batchingChallenge * tp.shplonkNu * tp.shplonkNu;
2096
- }
2076
+ // Update inverted denominators
2077
+ mem.posInvertedDenominator = (tp.shplonkZ - powers_of_evaluation_challenge[i + 1]).invert();
2078
+ mem.negInvertedDenominator = (tp.shplonkZ + powers_of_evaluation_challenge[i + 1]).invert();
2079
+
2080
+ // Compute the scalar multipliers for Aₗ(± r^{2ˡ}) and [Aₗ]
2081
+ mem.scalingFactorPos = mem.batchingChallenge * mem.posInvertedDenominator;
2082
+ mem.scalingFactorNeg = mem.batchingChallenge * tp.shplonkNu * mem.negInvertedDenominator;
2083
+ // [Aₗ] is multiplied by -v^{2l}/(z-r^{2^l}) - v^{2l+1} /(z+ r^{2^l})
2084
+ scalars[NUMBER_UNSHIFTED + 1 + i] = mem.scalingFactorNeg.neg() + mem.scalingFactorPos.neg();
2085
+
2086
+ // Accumulate the const term contribution given by
2087
+ // v^{2l} * Aₗ(r^{2ˡ}) /(z-r^{2^l}) + v^{2l+1} * Aₗ(-r^{2ˡ}) /(z+ r^{2^l})
2088
+ Fr accumContribution = mem.scalingFactorNeg * proof.geminiAEvaluations[i + 1];
2089
+
2090
+ accumContribution = accumContribution + mem.scalingFactorPos * foldPosEvaluations[i + 1];
2091
+ mem.constantTermAccumulator = mem.constantTermAccumulator + accumContribution;
2092
+ // Update the running power of v
2093
+ mem.batchingChallenge = mem.batchingChallenge * tp.shplonkNu * tp.shplonkNu;
2097
2094
2098
2095
commitments[NUMBER_UNSHIFTED + 1 + i] = proof.geminiFoldComms[i];
2099
2096
}
0 commit comments