Skip to content

Commit

Permalink
nova_cyclefold_decider.sol header
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaucube committed Apr 16, 2024
1 parent 88b623d commit 9c68076
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions solidity-verifiers/templates/nova_cyclefold_decider.askama.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/*
Sonobe's Nova + CycleFold decider verifier.
More details at https://github.com/privacy-scaling-explorations/sonobe
Joint effort by 0xPARC & PSE.
*/

/* Groth16 verifier methods */
{{ groth16_verifier }}

/* KZG10 verifier methods */
{{ kzg10_verifier }}

/**
Expand All @@ -26,7 +34,7 @@ contract NovaDecider is Groth16Verifier, KZG10Verifier {
* @notice Computes the linear combination of a and b with r as the coefficient.
* @dev All ops are done mod the BN254 scalar field prime
*/
function rlCombination(uint256 a, uint256 r, uint256 b) internal pure returns (uint256 result) {
function rlc(uint256 a, uint256 r, uint256 b) internal pure returns (uint256 result) {
assembly {
result := addmod(a, mulmod(r, b, BN254_SCALAR_FIELD), BN254_SCALAR_FIELD)
}
Expand Down Expand Up @@ -63,10 +71,10 @@ contract NovaDecider is Groth16Verifier, KZG10Verifier {

{
// U_i.u + r * u_i.u
uint256 u = rlCombination(U_i_u_u_i_u_r[0], U_i_u_u_i_u_r[2], U_i_u_u_i_u_r[1]);
uint256 u = rlc(U_i_u_u_i_u_r[0], U_i_u_u_i_u_r[2], U_i_u_u_i_u_r[1]);
// U_i.x + r * u_i.x
uint256 x0 = rlCombination(U_i_x_u_i_cmW[0], U_i_u_u_i_u_r[2], u_i_x_cmT[0]);
uint256 x1 = rlCombination(U_i_x_u_i_cmW[1], U_i_u_u_i_u_r[2], u_i_x_cmT[1]);
uint256 x0 = rlc(U_i_x_u_i_cmW[0], U_i_u_u_i_u_r[2], u_i_x_cmT[0]);
uint256 x1 = rlc(U_i_x_u_i_cmW[1], U_i_u_u_i_u_r[2], u_i_x_cmT[1]);

public_inputs[{{ z_len * 2 + 1 }}] = u;
public_inputs[{{ z_len * 2 + 2 }}] = x0;
Expand Down

0 comments on commit 9c68076

Please sign in to comment.