diff --git a/backend/plonk/bn254/solidity.go b/backend/plonk/bn254/solidity.go index d804a77285..d474058b64 100644 --- a/backend/plonk/bn254/solidity.go +++ b/backend/plonk/bn254/solidity.go @@ -248,6 +248,31 @@ contract PlonkVerifier { event PrintUint256(uint256 a); + {{ if (gt (len .CommitmentConstraintIndexes) 0 ) -}} + // read the commitments to the wires related to the commit api and store them in wire_commitments. + // The commitments are points on Bn254(Fp) so they are stored on 2 uint256. + function load_wire_commitments_commit_api(uint256[] memory wire_commitments, bytes memory proof) + internal pure { + assembly { + let w := add(wire_commitments, 0x20) + let p := add(proof, proof_openings_selector_commit_api_at_zeta) + p := add(p, mul(vk_nb_commitments_commit_api, 0x20)) + for {let i:=0} lt(i, vk_nb_commitments_commit_api) {i:=add(i,1)} + { + // x coordinate + mstore(w, mload(p)) + w := add(w,0x20) + p := add(p,0x20) + + // y coordinate + mstore(w, mload(p)) + w := add(w,0x20) + p := add(p,0x20) + } + } + } + {{ end }} + function derive_gamma_beta_alpha_zeta(bytes memory proof, uint256[] memory public_inputs) internal view returns(uint256, uint256, uint256, uint256) { @@ -385,26 +410,6 @@ contract PlonkVerifier { return (gamma, beta, alpha, zeta); } - // read the commitments to the wires related to the commit api and store them in wire_commitments. - // The commitments are points on Bn254(Fp) so they are stored on 2 uint256. - function load_wire_commitments_commit_api(uint256[] memory wire_commitments, bytes memory proof) - internal pure { - assembly { - let w := add(wire_commitments, 0x20) - let p := add(proof, proof_openings_selector_commit_api_at_zeta) - p := add(p, mul(vk_nb_commitments_commit_api, 0x20)) - for {let i:=0} lt(i, mul(vk_nb_commitments_commit_api,2)) {i:=add(i,1)} - { - mstore(w, mload(p)) - w := add(w,0x20) - p := add(p,0x20) - mstore(w, mload(p)) - w := add(w,0x20) - p := add(p,0x20) - } - } - } - // Computes L_i(zeta) = ωⁱ/n * (ζⁿ-1)/(ζ-ωⁱ) where: // * n = vk_domain_size // * ω = vk_omega (generator of the multiplicative cyclic group of order n in (ℤ/rℤ)*)