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

Feat/plonk update #1044

Merged
merged 54 commits into from
Apr 22, 2024
Merged

Feat/plonk update #1044

merged 54 commits into from
Apr 22, 2024

Conversation

ThomasPiellard
Copy link
Collaborator

@ThomasPiellard ThomasPiellard commented Feb 8, 2024

Description

Updating plonk to the latest version https://eprint.iacr.org/archive/2019/953/1660839633.pdf

[wait for linea to redeploy the contract before merging to avoid incompatibility between prover/verifier]

  • The folded quotient is appended to the linearisation polynomial
  • the opening of the linearisation polynomial corresponds to the constant term of the algebraic relation
  • one less opening to do (since the quotient is now opened throughout the opening of the linearisation polynomial)
  • no more modular inverse to compute in the algebraic check to verify a plonk proof

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Test suite for plonk unchanged

benchmark

  • for native chain bls12-377 -> bw6-761 we go from 319k to 312k constraints
  • for non native (bw6 -> bn254) the number of constraints is unchanged -> something might be off

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

@ivokub
Copy link
Collaborator

ivokub commented Apr 10, 2024

Hmm, something is also off - BW6 in BN254 is 1131765 constraints more with the new version. I guess the additional hashing and folding is more expensive than the saved scalar multiplication.

Hmm, I think one place where we add constraints is that previously when we folded H separately, we were able to do 2-MSM and one addition (H0 + zeta^(n+2) H1 + zeta^m(n+2) H2), but now when doing together with rest of linearized polynomial we're doing computing scalar mul for H0. But now we have more hashing as kzg proof folding has more inputs.

@ivokub
Copy link
Collaborator

ivokub commented Apr 10, 2024

Hmm, something is also off - BW6 in BN254 is 1131765 constraints more with the new version. I guess the additional hashing and folding is more expensive than the saved scalar multiplication.

@yelhousni may investigate; but perf wise, if the finalization circuit is 41M or 42M constraint, doesn't matter we still pay for 64M price.

It is 34949956 now vs 33818191 previously.

@ivokub
Copy link
Collaborator

ivokub commented Apr 10, 2024

@ThomasPiellard , I retained the in-circuit version which folds H before computing big MSM in linearized polynomial computation. This allows to avoid one scalar multiplication as before. Now the benchmarks are:

  • BLS12 in BW6 master 367119, now 359241
  • BW6 in BN254 master 33818191, now 33871880

There is still net increase in the number of constraints, but I guess this has to do that for MSM we internally use 2-by-2 MSM and with change of input nb oddity we fall into different case. In case with complete arithmetic (as the test circuits are defined with), we get suboptimal results. But indeed, we can keep rest of optimization for later.

Just for a remark -- with incomplete arithmetic BW6-in-BN254 is now at 29711173, so under 32M threshold.

@gbotrel gbotrel marked this pull request as ready for review April 11, 2024 01:17
@yelhousni
Copy link
Contributor

yelhousni commented Apr 12, 2024

After c73574c:

  • BLS12 in BW6 master 367119, now 358515 358153 scs.
  • BW6 in BN254 master 33818191, now 33885256 33884909 33883478 scs (after 747d11f).

@yelhousni
Copy link
Contributor

After c73574c:

  • BLS12 in BW6 master 367119, now 358515 358153 scs.
  • BW6 in BN254 master 33818191, now 33885256 33884909 33883478 scs (after 747d11f).
  • BLS12 in BW6 master 367119, now 358153 scs.
  • BW6 in BN254 master 33818191, now 32145464 scs.

@yelhousni yelhousni self-requested a review April 16, 2024 13:41
Copy link
Contributor

@yelhousni yelhousni left a comment

Choose a reason for hiding this comment

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

Good to merge on my side 👍

@gbotrel
Copy link
Collaborator

gbotrel commented Apr 18, 2024

can we merge?

@ThomasPiellard ThomasPiellard merged commit b2dfec7 into master Apr 22, 2024
6 of 7 checks passed
@ThomasPiellard ThomasPiellard deleted the feat/plonk_update branch April 22, 2024 13:57
Tabaie added a commit that referenced this pull request Apr 22, 2024
commit 6d37cb5
Author: Arya Tabaie <arya.pourtabatabaie@gmail.com>
Date:   Mon Apr 22 16:44:27 2024 -0500

    refac remove UnpackIntoBytes

commit 18f235c
Author: Arya Tabaie <arya.pourtabatabaie@gmail.com>
Date:   Mon Apr 22 15:26:12 2024 -0500

    update compilation test sizes

commit b2dfec7
Merge: c902244 b33c093
Author: ThomasPiellard <thomas.piellard@consensys.net>
Date:   Mon Apr 22 15:57:16 2024 +0200

    Merge pull request #1044 from Consensys/feat/plonk_update

    Feat/plonk update

commit b33c093
Merge: 5af51c3 c902244
Author: ThomasPiellard <thomas.piellard@consensys.net>
Date:   Mon Apr 22 15:55:21 2024 +0200

    Merge branch 'master' into feat/plonk_update

commit c902244
Author: Gautam Botrel <gautam.botrel@gmail.com>
Date:   Fri Apr 19 21:54:24 2024 -0500

    fix: plonk.SRSSize takes constraint.ConstraintSystem as input, not constraint.System

commit 3c506fd
Author: Ivo Kubjas <ivo.kubjas@consensys.net>
Date:   Thu Apr 18 16:35:16 2024 +0200

    feat: expmod with variable modulus (#1090)

    * chore: remove unused arguments

    * feat: allow non-default modulus

    * feat: implement non-default modulus arithmetic

    * test: tests for non-default arithmetic

    * remove debug calls

    * chore: clean only if set

    * feat: add zero check with custom modulus

    * feat: change quotient length in case of var modulus

    * refactor: subtraction padding into callable function

    * feat: implement variable modulus subtraction

    * feat: implement variable modulus equality assertion

    * test: variable modulus tests

    * feat: implement custom mod exp

    * refactor: rename methods

    * refactor: use single impl of mulmod and checkzero

    * feat: add automatic lazy reduction for var-mod addition

    * refactor: make var-mod sub private

    It is difficult to implement automatic reduction here due to the
    recursive dependency of methods. As the goal is to provide only very
    limited API for now, then make it private for now.

    * refactor: move parameters

    * refactor: move var-mod methods to Field

    * refactor: subPaddingHint to hints file

    * docs: add package documentation

    * feat: implement fixed-mod exp

    * test: make tests cheaper to run

    * fix: handle mul hint edge case when modulus is zero

    * feat: implement expmod precompile

    * perf: select first bit in expmod instead of mul

    * docs: indicate implementation of Expmod

    ---------

    Co-authored-by: Youssef El Housni <youssef.elhousni@consensys.net>

commit c38cdd3
Author: bernard-wagner <bernard-wagner@users.noreply.github.com>
Date:   Thu Apr 18 13:04:16 2024 +0200

    feat: groth16 solidity use calldatacopy for commitments (#1097)

    * feat: groth16 solidity use calldatacopy for commitments

    * consistently use publicAndCommitmentCommittedOffset

    * do not redeclare publicAndCommitmentCommitted

    * contiguous segments

    * only if index exists

    * test: re-enable solidity checks

    ---------

    Co-authored-by: Ivo Kubjas <ivo.kubjas@consensys.net>

commit 5af51c3
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Mon Apr 15 18:41:21 2024 -0400

    test: update stats

commit bdcdb27
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Mon Apr 15 18:31:58 2024 -0400

    perf(pairing/bw6): optimize Miller loop

commit 704bb4d
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Fri Apr 12 18:16:42 2024 -0400

    test: update stats

commit 747d11f
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Fri Apr 12 18:00:57 2024 -0400

    perf(pairing/bw6,bls12-381): optimize Mul014By014

commit c73574c
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Fri Apr 12 13:45:23 2024 -0400

    perf(std/plonk): small optim

commit 5886ddb
Merge: 79aece1 c4d989b
Author: Youssef El Housni <youssef.elhousni@consensys.net>
Date:   Fri Apr 12 12:04:50 2024 -0400

    Merge branch 'master' into feat/plonk_update

commit 79aece1
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Thu Apr 11 20:01:57 2024 -0400

    perf(std/plonk): small optims

commit 4dc4a07
Author: Youssef El Housni <youssef.housni21@gmail.com>
Date:   Thu Apr 11 19:17:20 2024 -0400

    perf(std/plonk): save 1 neg

commit a69f445
Merge: 3fd24ea 1836468
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Thu Apr 11 10:01:24 2024 +0200

    Merge branch 'feat/plonk_update' of github.com:Consensys/gnark into feat/plonk_update

commit 3fd24ea
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Thu Apr 11 10:01:18 2024 +0200

    feat: modified comment

commit 65f6f46
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Thu Apr 11 09:30:08 2024 +0200

    feat: updated comment in fold_state

commit 1836468
Merge: 2b63a66 acd3529
Author: Gautam Botrel <gautam.botrel@gmail.com>
Date:   Wed Apr 10 20:17:24 2024 -0500

    Merge branch 'master' into feat/plonk_update

commit 2b63a66
Author: Ivo Kubjas <ivo.kubjas@consensys.net>
Date:   Wed Apr 10 20:42:48 2024 +0000

    perf: fold H before big MSM

commit 24bca50
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Apr 10 15:05:49 2024 +0200

    feat: moved claimed values of linearised polynomial out of the proof

commit 0803a5f
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Apr 10 11:20:00 2024 +0200

    feat: re enable test bs12->bw6

commit 1b03f76
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Apr 10 11:16:37 2024 +0200

    feat: code gen

commit f4f402e
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Apr 10 11:14:38 2024 +0200

    feat: change sign in comment

commit 2026b9d
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Apr 10 11:08:10 2024 +0200

    feat: code gen

commit 1e20b9e
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Apr 10 11:07:35 2024 +0200

    fix: bn254 -> {{ toLower .Curve }}

commit 61d9424
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Apr 8 19:59:58 2024 +0200

    feat: replaced precompiles opcode with constants

commit 47b9ec8
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Apr 8 19:58:23 2024 +0200

    feat: addition of precompiles as constants

commit ad52500
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Apr 8 19:55:52 2024 +0200

    feat: used  to compute offsets in state

commit 626b1a7
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Apr 8 19:52:27 2024 +0200

    fix: fixed type

commit 3437008
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Apr 8 19:45:40 2024 +0200

    feat: used  in template for proof offsetss

commit b0aed98
Merge: 2d91f29 9761428
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Apr 8 18:09:29 2024 +0200

    Merge branch 'master' into feat/plonk_update

commit 2d91f29
Merge: ae58b42 ce0186e
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Mar 20 10:35:15 2024 +0100

    Merge branch 'master' into feat/plonk_update

commit ae58b42
Merge: 8f32eab 781de03
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Wed Mar 13 09:01:54 2024 +0100

    Merge branch 'master' into feat/plonk_update

commit 8f32eab
Merge: 3abd77d 7fc72ae
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Tue Feb 13 09:29:13 2024 +0100

    Merge branch 'master' into feat/plonk_update

commit 3abd77d
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Feb 5 21:47:40 2024 +0100

    fix: verifier works

commit 5ee479d
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Feb 2 23:00:18 2024 +0100

    fix: fixed size slice

commit e9b89bd
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Feb 2 17:23:17 2024 +0100

    fix: fixed formula in comments

commit 019da3d
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Feb 2 17:20:56 2024 +0100

    feat: modified algebraic relation

commit b381aa9
Merge: 5f06013 a824c48
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Feb 2 10:27:31 2024 +0100

    Merge branch 'master' into feat/plonk_update

commit 5f06013
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 19:05:20 2024 +0100

    fix: fixed compute_gamma_kzg

commit d87ca3c
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 18:51:25 2024 +0100

    fix: fixed offset opening at zeta-omega

commit 99398b2
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 18:01:25 2024 +0100

    fix: fixed typo

commit e84d083
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 17:59:18 2024 +0100

    feat: pairing precompile error handled

commit f39e31e
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 17:03:39 2024 +0100

    fix: fixed verify_opening_linearised_polynomial

commit c0e403b
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 12:08:59 2024 +0100

    fix: fixed proof size

commit 80f3a1e
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 12:02:28 2024 +0100

    feat: code gen

commit 42f5e71
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 12:01:28 2024 +0100

    fix: fixed generator

commit d544aca
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 12:00:31 2024 +0100

    fix: fixed comment derive alpha

commit ba50ca2
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 11:58:50 2024 +0100

    feat: clean MarshalSolidity

commit f6f0d87
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 26 11:57:49 2024 +0100

    fix: fixed MarshalSolidity

commit 5218925
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Thu Jan 25 17:04:21 2024 +0100

    feat: fix unmarshalling solidity

commit 5ec808d
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Tue Jan 23 15:12:46 2024 +0100

    feat: code gen plonk upgrade

commit 3faae35
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Tue Jan 23 14:57:47 2024 +0100

    fix: verifier ok

commit 58a4539
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Jan 22 15:11:46 2024 +0100

    feat: renaming zhZeta

commit f8ab0e4
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Mon Jan 22 12:00:29 2024 +0100

    feat: opening of h0, h1, h2 ok

commit 03ddda0
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 19 19:39:13 2024 +0100

    feat: using batch inversion

commit 6f39e5e
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 19 16:59:25 2024 +0100

    feat: remove foldedHDigest

commit e4ff8ce
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 19 16:32:16 2024 +0100

    feat: add quotient to the linearised polynomial

commit ca41676
Author: Thomas Piellard <thomas.piellard@consensys.net>
Date:   Fri Jan 19 13:32:17 2024 +0100

    feat: multiply s1, s2 by alpha
@Sickies
Copy link

Sickies commented Jun 27, 2024

Duplicado de #1

@Sickies
Copy link

Sickies commented Jun 28, 2024

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.

5 participants