Skip to content

Commit f5285d1

Browse files
committed
chore: use p constants everywhere
1 parent d795138 commit f5285d1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

barretenberg/sol/src/honk/optimised/blake-opt.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ contract BlakeOptHonkVerifier is IVerifier {
994994
// TOOD: maybe verify vk points are on curve in constructor
995995
constructor() {}
996996

997-
function verify(bytes calldata, bytes32[] calldata) public override returns (bool) {
997+
function verify(bytes calldata, bytes32[] calldata) public override view returns (bool) {
998998
// Load the proof from calldata in one large chunk
999999
assembly {
10001000
// Inline the verification key code here for the meantime
@@ -1630,7 +1630,7 @@ contract BlakeOptHonkVerifier is IVerifier {
16301630
mstore(0x20, 0x20)
16311631
mstore(0x40, 0x20)
16321632
mstore(0x60, accumulator)
1633-
mstore(0x80, sub(p, 2))
1633+
mstore(0x80, P_SUB_2)
16341634
mstore(0xa0, p)
16351635
if iszero(staticcall(gas(), 0x05, 0x00, 0xc0, 0x00, 0x20)) {
16361636
mstore(0x00, MODEXP_FAILED_SELECTOR)
@@ -1767,7 +1767,7 @@ contract BlakeOptHonkVerifier is IVerifier {
17671767
mulmod(
17681768
mulmod(
17691769
mulmod(mulmod(mload(W1_EVAL_LOC), mload(W2_EVAL_LOC), p), mload(QM_EVAL_LOC), p),
1770-
addmod(q_arith, sub(p, 3), p),
1770+
addmod(q_arith, P_SUB_3, p),
17711771
p
17721772
),
17731773
NEG_HALF_MODULO_P,
@@ -1788,7 +1788,7 @@ contract BlakeOptHonkVerifier is IVerifier {
17881788
// α * (q_arith - 2) * (w_1 + w_4 - w_1_omega + q_m)
17891789
let extra_small_addition_gate_identity :=
17901790
mulmod(
1791-
addmod(q_arith, sub(p, 2), p),
1791+
addmod(q_arith, P_SUB_2, p),
17921792
addmod(
17931793
mload(QM_EVAL_LOC),
17941794
addmod(
@@ -1801,11 +1801,11 @@ contract BlakeOptHonkVerifier is IVerifier {
18011801

18021802
// Split up the two relations
18031803
let contribution_0 :=
1804-
addmod(identity, mulmod(addmod(q_arith, sub(p, 1), p), mload(W4_SHIFT_EVAL_LOC), p), p)
1804+
addmod(identity, mulmod(addmod(q_arith, P_SUB_1, p), mload(W4_SHIFT_EVAL_LOC), p), p)
18051805
contribution_0 := mulmod(mulmod(contribution_0, q_arith, p), mload(POW_PARTIAL_EVALUATION_LOC), p)
18061806
mstore(SUBRELATION_EVAL_0_LOC, contribution_0)
18071807

1808-
let contribution_1 := mulmod(extra_small_addition_gate_identity, addmod(q_arith, sub(p, 1), p), p)
1808+
let contribution_1 := mulmod(extra_small_addition_gate_identity, addmod(q_arith, P_SUB_1, p), p)
18091809
contribution_1 := mulmod(contribution_1, q_arith, p)
18101810
contribution_1 := mulmod(contribution_1, mload(POW_PARTIAL_EVALUATION_LOC), p)
18111811
mstore(SUBRELATION_EVAL_1_LOC, contribution_1)
@@ -1940,7 +1940,7 @@ contract BlakeOptHonkVerifier is IVerifier {
19401940
addmod(accumulator_one, sub(p, mulmod(mload(LOOKUP_READ_COUNTS_EVAL_LOC), write_inverse, p)), p)
19411941

19421942
let read_tag := mload(LOOKUP_READ_TAGS_EVAL_LOC)
1943-
let read_tag_boolean_relation := mulmod(read_tag, addmod(read_tag, sub(p, 1), p), p)
1943+
let read_tag_boolean_relation := mulmod(read_tag, addmod(read_tag, P_SUB_1, p), p)
19441944
read_tag_boolean_relation := mulmod(read_tag_boolean_relation, mload(POW_PARTIAL_EVALUATION_LOC), p)
19451945

19461946
mstore(SUBRELATION_EVAL_4_LOC, accumulator_none)
@@ -1953,9 +1953,9 @@ contract BlakeOptHonkVerifier is IVerifier {
19531953
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
19541954
{
19551955
// TODO(md): optimise the calculations
1956-
let minus_one := sub(p, 1)
1957-
let minus_two := sub(p, 2)
1958-
let minus_three := sub(p, 3)
1956+
let minus_one := P_SUB_1
1957+
let minus_two := P_SUB_2
1958+
let minus_three := P_SUB_3
19591959

19601960
let delta_1 := addmod(mload(W2_EVAL_LOC), sub(p, mload(W1_EVAL_LOC)), p)
19611961
let delta_2 := addmod(mload(W3_EVAL_LOC), sub(p, mload(W2_EVAL_LOC)), p)
@@ -2178,7 +2178,7 @@ contract BlakeOptHonkVerifier is IVerifier {
21782178

21792179
// index_is_monotonically_increasing = index_delta * (index_delta - 1)
21802180
let index_is_monotonically_increasing :=
2181-
mulmod(index_delta, addmod(index_delta, sub(p, 1), p), p)
2181+
mulmod(index_delta, addmod(index_delta, P_SUB_1, p), p)
21822182

21832183
// adjacent_values_match_if_adjacent_indices_match = record_delta * (1 - index_delta)
21842184
let adjacent_values_match_if_adjacent_indices_match :=
@@ -2282,9 +2282,9 @@ contract BlakeOptHonkVerifier is IVerifier {
22822282
* next_gate_access_type_is_boolean = next_gate_access_type^2 - next_gate_access_type
22832283
*/
22842284
let access_type := addmod(mload(W4_EVAL_LOC), sub(p, partial_record_check), p)
2285-
let access_check := mulmod(access_type, addmod(access_type, sub(p, 1), p), p)
2285+
let access_check := mulmod(access_type, addmod(access_type, P_SUB_1, p), p)
22862286
let next_gate_access_type_is_boolean :=
2287-
mulmod(next_gate_access_type, addmod(next_gate_access_type, sub(p, 1), p), p)
2287+
mulmod(next_gate_access_type, addmod(next_gate_access_type, P_SUB_1, p), p)
22882288

22892289
// scaled_activation_selector = q_arith * q_aux * alpha
22902290
let scaled_activation_selector :=
@@ -2935,7 +2935,7 @@ contract BlakeOptHonkVerifier is IVerifier {
29352935
mstore(0x20, 0x20)
29362936
mstore(0x40, 0x20)
29372937
mstore(0x60, accumulator)
2938-
mstore(0x80, sub(p, 2))
2938+
mstore(0x80, P_SUB_2)
29392939
mstore(0xa0, p)
29402940
if iszero(staticcall(gas(), 0x05, 0x00, 0xc0, 0x00, 0x20)) {
29412941
mstore(0x00, MODEXP_FAILED_SELECTOR)

barretenberg/sol/src/interfaces/IVerifier.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
pragma solidity >=0.8.4;
44

55
interface IVerifier {
6-
function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external returns (bool);
6+
function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool);
77
}

0 commit comments

Comments
 (0)