30 Commits

Author SHA1 Message Date
Xavier Pinsach
a6dcd89a15 Refactor groth16 smart contract (#372)
* Plonk refactored with new clsses and working

* change logger.in -> logger.debug

* update protocol to last version

* Refactor Fiat-Shamir adding preprocessed circuit dependent values

* Add check functions in js and sc

* refactor groth16 smart contract to assembly code

* fix calldata types and test passing

* fix errors. working

* wip

* add debug function

* remove console.log import

* Plonk smart contracte refactored.

* Added test with circuits using +1 inputs

* Added cricuits tests with +1 inputs

* mod package.json

* Plonk refactored with new clsses and working

* change logger.in -> logger.debug

* update protocol to last version

* Refactor Fiat-Shamir adding preprocessed circuit dependent values

* fix errors. working

* wip

* add debug function

* Plonk smart contracte refactored.

* Added cricuits tests with +1 inputs

* mod package.json

* update ffjavascript to 0.2.59

* Add check functions in js and sc

* refactor groth16 smart contract to assembly code

* fix calldata types and test passing

* remove console.log import

* add scalar import

* Add check functions in js and sc

* refactor groth16 smart contract to assembly code

* fix calldata types and test passing

* remove console.log import

* add scalar import

* remove hardhat import

---------

Co-authored-by: Jordi Baylina <jordi@baylina.cat>
2023-05-18 19:13:36 +02:00
Xavier Pinsach
274e1eef6a Plonk refactor (#371)
* Plonk refactored with new clsses and working

* change logger.in -> logger.debug

* update protocol to last version

* Refactor Fiat-Shamir adding preprocessed circuit dependent values

* fix errors. working

* wip

* add debug function

* Plonk smart contracte refactored.

* Added test with circuits using +1 inputs

* Added cricuits tests with +1 inputs

* mod package.json

* Plonk refactored with new clsses and working

* change logger.in -> logger.debug

* update protocol to last version

* Refactor Fiat-Shamir adding preprocessed circuit dependent values

* fix errors. working

* wip

* add debug function

* Plonk smart contracte refactored.

* Added cricuits tests with +1 inputs

* mod package.json

* update ffjavascript to 0.2.59
2023-05-18 19:10:11 +02:00
Roger Taulé Buxadera
e70271b30a Feat lagrange verifier (#368)
* update fflonk SC change memory->calldata

* Optimizing Lagrange calculation

* Fixing Fflonk when having multiple public inputs

---------

Co-authored-by: Xavi Pinsach <10213118+xavi-pinsach@users.noreply.github.com>
2023-05-18 17:02:13 +02:00
Xavier Pinsach
96b7d2786d Refactor fflonk test (#336)
* fflonk files test moved

* fflonk SC verification added to test suite

* add again length proof check to smart contract

* fix tests.yml for continous integration

* add hardhat dependencies to github action

* add more options to launch.json file

* remove hardhat-toolbox

* add missed packages

* skip smart contract testing in node version < 14

* fix smart contract tests

* fix typo and move variables inside function

* add plonk&groth16 smart contract tests

* add setup and prove on smart contracts tests
2023-03-22 08:21:27 +01:00
Xavier Pinsach
8a2e4f30e4 add check G1 proof points belong to elliptic curve (#334) 2023-03-15 05:45:59 +01:00
Xavier Pinsach
87526e9122 Fix transcript add previous challenges (#323) 2023-03-01 11:48:57 +01:00
Xavier Pinsach
4be826c8af Fflonk sec audit 1 (#322)
* Add C0 to seed transcript

* fix dev
2023-02-28 15:18:36 +01:00
Xavier Pinsach
ce67d4672d fflonk smart contract improvement (#321)
* fflonk smart contract improvement

* fix k1 -> k2
2023-02-27 11:16:49 +01:00
invocamanman
13fd58de6d lintTemplate (#316)
* lintTemplate

* lint and rename contract
2023-02-22 15:55:15 +01:00
invocamanman
fe05438702 fix pLastMem (#314) 2023-02-21 17:26:27 +01:00
invocamanman
bab14c65a8 FFLONK Smart contract optimizations (#312)
* Small fixes

- Fix identation
- Erase the mstore at the end of the execution that updates the "free memory pointer" since the following lines no more memory is allocated, ( basically only an mstore and return happen

* update template with fixed array pub inputs

* udpate to calldata
2023-02-21 09:40:59 +01:00
Xavier Pinsach
6555d901a7 Fflonk (#305)
This PR includes all the FFLONK implementation

* baby plonk added

* wip

* commands added

* fix babyplonk command calls

* refactor cmd calls

* WIP

* Add header babyplonk to zkey utils

* wip

* Wip baby plonk verifier

* Add baby plonk test

* babyplonk export verification keu aded

* wip

* refactor polynomial & add some tests

* refactor setup, extract a new class to process r1cs constraints

* improve polynomial.4T

* fix

* refactor setup

* refactor

* massive update

* Add comments to round1 and 2

* organize fflonk prover

* organize fflonk verifier

* Change format add a section for each sigma

* read sigma from each section

* add T0 polynomial computation

* mul_z transformed to a class

* add C1 polynomial computation

* add function to X^n to Polynomial class

* Add C2 polynomial computation

* typos

* added computeZ

* Add T1 polynomial computation

* T2 polynomial computation added

* Compute h1, h2, h3 and xi

* polynomial F added (wip)

* Improve comments in fflonk prover

* typo

* fix comments

* compute F(X) and L(X) polynomials added

* fflonk verifier added

* Remove QL, QR, QM, QO, QC, S1, S2 and S3 commitments in verification key and zkey because they are not used on either the verifier or the prover

* remove unused variables

* Fix in final pairing

* Add omega 3 and omega 4 in setup process and export vk process

* Add omega3 and omega4 to the prover&verifier

* omega3 and omega4 comments

* change folder name to fflonk

* fix proof messages

* change polynomial length getter to function

* change evalutions length getter to function

* dev

* fix error on sigma computings & increase ptau buffer

* fflonk setup memory improvements

* fflonk prover & verifier refactor

* wip fflonk exportcalldata & export solidity done, refactor fflonk prove and verifier

* wip

* fix r1(x) & r2(x) and refactor h1w3, h2w3 & h3w3 converted to arrays

* improve comments

* improve lagrange4

* refactoring polynomial lagrange4

* Add Lagrange polynomials interpolation methods (optimized and non optimized)

* Added polynomials methods: fromCoefficientsArray, divBy === eucledian division and changed method name fromBuffer to fromEvaluations

* Refactor polynomial.js to take in account when use BigBuffer or Uint8Array

* Add div by ZT's

* massive updates

* add polynomial zerofier test

* massive updates

* Move computation of 3th root of omega to fflonk_setup to setup

* fix: L polynomial computation

* fix: remove default parameter in evaluations

* Add logger to export verification key

* fix: several improvements

* Change evaluations.getEvaluation(i) from byte-based i parameter to index-based

* fix: first proof verified

* dev

* solidity verifier added and working with r1(y) and r2(y) inside the proof

* fflonk verifier in Solidity working

* Added zero knowledge and degree checking

* fix typo

* fix: save & load the exact SRS length string

* prover improvement

* fix: add zero knowledge

* Improve add batch inverse in lagrange polynomials computation

* wip develop part of the verifier developed in Solidity in Javascript to check if could work

* added beta version of the first fflonk verifier smart contract

* remove babyplonk references

* fix: Check if Ptau is big enough for the circuit

* remove polynomials and evakuations from memory when not used

* add fflonk tests suite

* Add fflonk full prove command

* Add readme documentation for fflonk

* fix typos

* fix: force to clean memory with globalThis.gc()

* fix: extract constant multiplication part outside of the loop for better performance

* perfomance: removed all the divisions in smart contract by sending a single evaluation from the prover and the rebuild the onverses using the Montgomery batched algorithm

* smart contract updated

* Refactor fflonk smart contract

* improve comments in smart contract

* Refactor lagrange interpolation. Specific lagrange from 4 and 6 points removed

* improve prover performance

* improve performance of the prover

* resolve conflict

* improve performance of the prover

* write fflonk tests into github action workflow tutorial.yml

* comment previous fflonk workflow

* Fix: load constraints dinamically

* fix dev

* add more comments in fflonk setup

* improve comments

* improve comments

* improve comments

* improve comments in setup process

* improve prompt comments in setup process

* dev

* change divZh() arguments, added domainSize

* dev

* fix coef.length by coef.byteLength

* fix dev

* dev

* fix dev

* add more messages

* Improve comments & add a new parameter in Evaluation::fromPolynomial to choose the extension size

* dev

* fflonk security issue fixed

* Add comments in fflonk_proer and fast divison and new method "fromPolynomial" to create a new Polynomial

* add w16 to setup and remove w3, w4 and w8

* CPolynomial added

* fix dev

* use CPolynomial class in setup and us multiexp from polynomial

* fix computeT1

* improve round 5

* fix r1cs processor

* fix r1cs process constraints

* adapt solidity verifier to new implementation

* remove unnecessary debug functions

* fix typo

* refactor computeF and computeL

* fix

* refactor computeF

* update package-lock.json
2023-02-10 17:12:08 +01:00
Jordi Baylina
304c18de10 Fix Put public inputs in the transcirpt 2022-04-05 17:57:54 +02:00
Jordi Baylina
bfe302e846 Force uint32 in n in the plonk solidity verifier 2022-02-16 06:28:03 -07:00
prabal-banerjee
dd88958f24 fix: uint size for higher powers in PLONK verifier sol 2022-01-11 22:52:52 +05:30
Jordi Baylina
e9fb96c976 Fix plonk solidity generation when zeros 2021-05-31 23:06:10 +02:00
Jordi Baylina
577b3f3580 Plonk finished 2021-05-31 13:21:07 +02:00
Jordi Baylina
9b418568f6 api and tutorial start 2020-07-11 10:31:52 +02:00
Jordi Baylina
6598f9df4a powersof taw new export and contribute 2020-05-09 15:05:45 +02:00
Koh Wei Jie
2e9be76932 added revert reasons to the snark_scalar_field checks in verifier.sol templates 2019-07-30 10:20:33 +08:00
Jordi Baylina
f8ba7cbfa7 Fix brackets in the in field check 2019-07-26 14:19:26 +02:00
Kobi Gurkan
25dc1fc6e3 Ensures public inputs are less than the scalar field size 2019-07-26 15:07:46 +03:00
Jordi Baylina
5fe2bd4642 Merge pull request #23 from adria0/master
sol 0.5.0, remove warnings, add require messages
2019-06-27 11:43:32 +02:00
adriamb
d2b3be19ef Revert "Generate contract name by its name output"
This reverts commit 22a5b7bc46.
2019-06-18 17:07:11 +02:00
adriamb
22a5b7bc46 Generate contract name by its name output 2019-06-18 16:33:14 +02:00
Jordi Baylina
406ec9fd62 log functions 2019-06-16 00:12:50 +02:00
adriamb
c5cd822350 sol 0.5.0, remove warnings, add require messages 2019-06-14 16:42:23 +02:00
DalaiLlaama
b33aacb1a5 Updated solidity version pragma to 0.4.17 2019-01-14 13:30:46 +11:00
Jordi Baylina
448dc345ad Groth protocol imlemented 2018-11-10 14:43:37 +01:00
Jordi Baylina
54a4be447f Rename to snarkjs, cli and some fixes 2018-10-21 18:24:49 +02:00