Skip to content

Commit 8b7e387

Browse files
committed
refactor: simplify pvs copying
1 parent 0a6416e commit 8b7e387

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/OpenVmHalo2Verifier.sol

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,8 @@ contract OpenVmHalo2Verifier is AxiomV2QueryVerifier {
122122
let wordCount := div(GUEST_PVS_LENGTH, 32)
123123

124124
let guestPvsMemOffset := add(proofPtr, 0x1c0)
125-
for { let i := 0 } iszero(eq(i, wordCount)) { i := add(i, 1) } {
126-
// Load the current word
127-
let word := calldataload(add(guestPvs.offset, shl(5, i)))
128-
129-
// Copy each byte of the word into the proof
130-
for { let j := 0 } iszero(eq(j, 32)) { j := add(j, 1) } {
131-
// 32 * 32 * i + 32 * j
132-
let pvsByteOffset := add(shl(10, i), shl(5, j))
133-
mstore(add(guestPvsMemOffset, pvsByteOffset), byte(j, word))
134-
}
135-
}
136-
137-
// Then, copy the remaining bytes into the memory buffer.
138-
let remainder := mod(GUEST_PVS_LENGTH, 32)
139-
guestPvsMemOffset := add(guestPvsMemOffset, shl(5, wordCount))
140-
141-
let remainingBytes := calldataload(add(guestPvs.offset, shl(5, wordCount)))
142-
for { let j := 0 } iszero(eq(j, remainder)) { j := add(j, 1) } {
143-
// 32 * 32 * wordCount + 32 * j
144-
let pvsByteOffset := add(shl(10, wordCount), shl(5, j))
145-
mstore(add(guestPvsMemOffset, pvsByteOffset), byte(j, remainingBytes))
125+
for { let i := 0 } lt(i, GUEST_PVS_LENGTH) { i := add(i, 1) } {
126+
calldatacopy(add(guestPvsMemOffset, add(shl(5, i), 0x1f)), add(guestPvs.offset, i), 0x01)
146127
}
147128
}
148129
}

0 commit comments

Comments
 (0)