Skip to content

Commit

Permalink
fix: check unused result (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored Apr 16, 2024
1 parent 8e45d96 commit cd89edd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ This repo consists of:

## Building
1. **C++**
On ubuntu make sure you have a cpp toolchain installed ->
On ubuntu make sure you have a cpp toolchain installed -> (or most up to date, i just use whatever works with clang16)
```
sudo apt-get install cmake clang clang-format ninja-build libstdc++-12-dev
sudo apt-get install cmake clang clang-format ninja-build libstdc++-12-dev
```
We will be building with clang16 - so make sure you have that compiler :)

Expand All @@ -37,5 +37,5 @@ $ forge build # Build the contracts
### Test

```shell
$ forge test
$ forge test --no-match-contract TestBaseHonk
```
5 changes: 3 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
echo "Downloading srs..."
(cd ./barretenberg/barretenberg/cpp/srs_db && ./download_ignition.sh 3)
(cd ./barretenberg/barretenberg/cpp && cmake --preset clang16)
(cd ./barretenberg/barretenberg/cpp && cmake --preset clang16)
(cd ./barretenberg/barretenberg/cpp && cmake --build --preset clang16 --target honk_solidity_proof_gen)


echo "Building w/ forge..."
forge build
echo "Done building: test with "forge test""
25 changes: 13 additions & 12 deletions src/reference/EcdsaHonkVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ contract EcdsaHonkVerifier is IVerifier {
return sumcheckVerified && zeromorphVerified; // Boolean condition not required - nice for vanity :)
}

function loadVerificationKey() internal view returns (Honk.VerificationKey memory) {
function loadVerificationKey() internal pure returns (Honk.VerificationKey memory) {
return VK.loadVerificationKey();
}

// TODO: mod q proof points
// TODO: Preprocess all of the memory locations
// TODO: Adjust proof point serde away from poseidon forced field elements
function loadProof(bytes calldata proof) internal view returns (Honk.Proof memory) {
function loadProof(bytes calldata proof) internal pure returns (Honk.Proof memory) {
Honk.Proof memory p;

// Metadata
Expand Down Expand Up @@ -224,7 +224,7 @@ contract EcdsaHonkVerifier is IVerifier {
// Incorportate the original plookup construction into honk
function computeLookupGrandProductDelta(Fr beta, Fr gamma, uint256 domainSize)
internal
view
pure
returns (Fr lookupGrandProductDelta)
{
Fr gammaByOnePlusBeta = gamma * (beta + Fr.wrap(1));
Expand All @@ -242,6 +242,7 @@ contract EcdsaHonkVerifier is IVerifier {
for (uint256 round; round < LOG_N; ++round) {
Fr[BATCHED_RELATION_PARTIAL_LENGTH] memory roundUnivariate = proof.sumcheckUnivariates[round];
bool valid = checkSum(roundUnivariate, roundTarget);
if (!valid) revert SumcheckFailed();

Fr roundChallenge = tp.sumCheckUChallenges[round];

Expand All @@ -257,11 +258,11 @@ contract EcdsaHonkVerifier is IVerifier {

function checkSum(Fr[BATCHED_RELATION_PARTIAL_LENGTH] memory roundUnivariate, Fr roundTarget)
internal
view
pure
returns (bool checked)
{
Fr totalSum = roundUnivariate[0] + roundUnivariate[1];
checked = totalSum != roundTarget;
checked = totalSum == roundTarget;
}

// Return the new target sum for the next sumcheck round
Expand Down Expand Up @@ -315,7 +316,7 @@ contract EcdsaHonkVerifier is IVerifier {
// Univariate evaluation of the monomial ((1-X_l) + X_l.B_l) at the challenge point X_l=u_l
function partiallyEvaluatePOW(Transcript memory tp, Fr currentEvaluation, Fr roundChallenge, uint256 round)
internal
view
pure
returns (Fr newEvaluation)
{
Fr univariateEval = Fr.wrap(1) + (roundChallenge * (tp.gateChallenges[round] - Fr.wrap(1)));
Expand Down Expand Up @@ -401,7 +402,7 @@ contract EcdsaHonkVerifier is IVerifier {
Transcript memory tp,
Fr[NUMBER_OF_SUBRELATIONS] memory evals,
Fr domainSep
) internal view {
) internal pure {
Fr grand_product_numerator;
Fr grand_product_denominator;

Expand Down Expand Up @@ -458,7 +459,7 @@ contract EcdsaHonkVerifier is IVerifier {
Transcript memory tp,
Fr[NUMBER_OF_SUBRELATIONS] memory evals,
Fr domainSep
) internal view {
) internal pure {
Fr grand_product_numerator;
Fr grand_product_denominator;

Expand Down Expand Up @@ -533,7 +534,7 @@ contract EcdsaHonkVerifier is IVerifier {
Fr[NUMBER_OF_ENTITIES] memory p,
Fr[NUMBER_OF_SUBRELATIONS] memory evals,
Fr domainSep
) internal view {
) internal pure {
Fr minus_one = Fr.wrap(0) - Fr.wrap(1);
Fr minus_two = Fr.wrap(0) - Fr.wrap(2);
Fr minus_three = Fr.wrap(0) - Fr.wrap(3);
Expand Down Expand Up @@ -605,7 +606,7 @@ contract EcdsaHonkVerifier is IVerifier {
Fr[NUMBER_OF_ENTITIES] memory p,
Fr[NUMBER_OF_SUBRELATIONS] memory evals,
Fr domainSep
) internal view {
) internal pure {
EllipticParams memory ep;
ep.x_1 = wire(p, WIRE.W_R);
ep.y_1 = wire(p, WIRE.W_O);
Expand Down Expand Up @@ -941,7 +942,7 @@ contract EcdsaHonkVerifier is IVerifier {
function scaleAndBatchSubrelations(
Fr[NUMBER_OF_SUBRELATIONS] memory evaluations,
Fr[NUMBER_OF_ALPHAS] memory subrelationChallenges
) internal view returns (Fr accumulator) {
) internal pure returns (Fr accumulator) {
accumulator = accumulator + evaluations[0];

for (uint256 i = 1; i < NUMBER_OF_SUBRELATIONS; ++i) {
Expand Down Expand Up @@ -1251,7 +1252,7 @@ contract EcdsaHonkVerifier is IVerifier {
);

(bool success, bytes memory result) = address(0x08).staticcall(input);
return abi.decode(result, (bool));
return (abi.decode(result, (bool)) && success);
}
}

Expand Down

0 comments on commit cd89edd

Please sign in to comment.