Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit/final commit #1191

Merged
merged 56 commits into from
Jul 11, 2024
Merged

Conversation

ThomasPiellard
Copy link
Collaborator

@ThomasPiellard ThomasPiellard commented Jul 9, 2024

Description

Final commit fixing Openzeppelin findings

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

style: cleaner computation nb BSB commitments
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I have two suggestions essentially, one is just a something nice to have but the second one imo would introduce an invalid comment. But I'm not sure if we can fix it as you changes are already approved.

However, I don't know what to do with the merge conflict - it there seem to have already modifications in the PLONK template and maybe it would apply nicely. In any case I think it needs to be resolved manually because otherwise the merge would mess up the PLONK Solidity template.

backend/plonk/bls12-377/prove.go Show resolved Hide resolved
@@ -222,6 +223,17 @@ contract PlonkVerifier {
revert(ptError, 0x64)
}

/// Called when an operation on Bn254 fails
/// @dev for instance when calling EcMul on a point not on Bn254.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment invalid? The error is for mod exp, but comment is about EcMul?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right it's a mistake

{{ range $index, $element := .CommitmentConstraintIndexes}}
mstore(add(mPtr, {{ hex (add 544 (mul $index 64)) }}), VK_QCP_{{ $index }}_X)
mstore(add(mPtr, {{ hex (add 576 (mul $index 64)) }}), VK_QCP_{{ $index }}_Y)
mstore(add(mPtr, {{ hex (add $offset (mul $index 64)) }}), VK_QCP_{{ $index }}_X)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do similarly as before {{ $offset = add $offset 0x20 }} and then use $offset in the next line.

@@ -73,7 +71,7 @@ func UnmarshalSolidity(s []byte, nbCommits int) Proof {
// uint256[] selector_commit_api_at_zeta;
// uint256[] wire_committed_commitments;
for i := 0; i < nbCommits; i++ {
proof.BatchedProof.ClaimedValues[7+i].SetBytes(s[offset : offset+fr_size])
proof.BatchedProof.ClaimedValues[6+i].SetBytes(s[offset : offset+fr_size])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I'm not mistaken, UnmarshalSolidity is untested in our codebase --> can you add a simple round trip test with the MarshalSolidity func to ensure non regression / offset errors ?

Copy link
Collaborator Author

@ThomasPiellard ThomasPiellard Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I discussed a bit with OZ about that, in fact UnmarshalSolidity was used for debugging only (at the time there was an issue on testnet and I had to check the proof that was given by linea). At the time MarshalSolidity serialised all the elements of the proof. Now there has been an optimisation such that we don't serialise the opening of the linearised polynomial, it is recomputed in the verifier. To recompute this value we need the public inputs. So UnmarshalSolidity would have a weird signature (we would need to pass the public inputs). I told OZ that this function should be used internally for debugging only, I don't think we should keep it in the repo

@ThomasPiellard ThomasPiellard merged commit e23bfe6 into Consensys:master Jul 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants