Skip to content

Commit cda6700

Browse files
authored
Merge pull request #237 from ConsenSys/develop
v0.8.0
2 parents 450e020 + abdac5a commit cda6700

275 files changed

Lines changed: 10586 additions & 3845 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,72 @@
11
<a name="v0.8.0"></a>
22

3-
Note: this version will be partially audited (bn254 & bls12-381 packages).
3+
## [v0.8.0] - 2022-08-03
44

5-
## [v0.8.0] - 2022-05-31
5+
This version was partially audited by Kudelski Security for the Algorand Foundation. (TODO insert report link).
6+
The scope of the audit covered `bn254` and `bls12-381` packages (including field arithmetic).
67

78
### Feat
89

9-
- field/generator suppors 1-limb modulus ([#175](https://github.com/ConsenSys/gnark-crypto/issues/175))
1010
- field/goldilocks (more efficient 1-limb modulus arith) ([#177](https://github.com/ConsenSys/gnark-crypto/issues/177))
11-
- **fri:** FRI protocol support and improvments
12-
- field.SetRandom: use random uniform sampling instead of mod reduce (zero-allocs)
13-
- adds BLS24-317 curve optimized for KZG ([#179](https://github.com/ConsenSys/gnark-crypto/pull/179))
11+
- field/generator suppors 1-limb modulus ([#175](https://github.com/ConsenSys/gnark-crypto/issues/175))
12+
- field.SetRandom zero-alloc uniform sampling
13+
- **E6/E12/E24:** GT torus-based batch compression/decompression
14+
- **fri:** modified challenge generation so it fits in a snark variable
15+
- **fri:** added check of correctness between rounds
1416

1517
### Fix
1618

19+
- Handle edge case in Karabina decompression ([#219](https://github.com/ConsenSys/gnark-crypto/issues/219))
20+
- check nbTasks config when running msm, test all possible c-bit windows in when testing.Short not set) ([#226](https://github.com/ConsenSys/gnark-crypto/issues/226))
21+
- element.SetString(_) returns error if invalid input instead of panic
22+
- expand_msg_xmd copy bug, a few tests ([#201](https://github.com/ConsenSys/gnark-crypto/issues/201))
1723
- closes [#199](https://github.com/ConsenSys/gnark-crypto/issues/199). Correct bound in eddsa key gen template
1824

19-
### Refactor & Cosmetics
25+
### Perf
26+
27+
- remove unecessary inverse in KZG-verify
28+
- faster GLV scalar decompostion
29+
30+
### Refactor & Docs
2031

32+
- moved consensys/goff into field/goff ([#204](https://github.com/ConsenSys/gnark-crypto/issues/204))
2133
- clean comments in curves ([#193](https://github.com/ConsenSys/gnark-crypto/issues/193))
22-
- replace modulus generated by constants ([#194](https://github.com/ConsenSys/gnark-crypto/issues/194))
34+
- remove dead code ([#230](https://github.com/ConsenSys/gnark-crypto/issues/230))
35+
- cosmetic changes ([#197](https://github.com/ConsenSys/gnark-crypto/issues/197))
36+
- replace modulus generated by constants, add zero-alloc SetRandom ([#194](https://github.com/ConsenSys/gnark-crypto/issues/194))
2337
- remove uneeded x86 asm and files ([#192](https://github.com/ConsenSys/gnark-crypto/issues/192))
24-
- code cleaning & cosmetic changes ([#197](https://github.com/ConsenSys/gnark-crypto/issues/197))
25-
- clean HashToCurve APIs ([#188](https://github.com/ConsenSys/gnark-crypto/pull/188))
38+
- polish readme.md with updated godoc subpackage links ([#235](https://github.com/ConsenSys/gnark-crypto/issues/235))
39+
- acknowledge that inv(0)==0 in comments as a convention ([#233](https://github.com/ConsenSys/gnark-crypto/issues/233))
40+
- added note in pairing godoc - doesn't check inputs are in correct subgroup ([#231](https://github.com/ConsenSys/gnark-crypto/issues/231))
41+
- add security estimates of implemented curves in comments
42+
43+
### Test
44+
45+
- fix [#205](https://github.com/ConsenSys/gnark-crypto/issues/205) - msm bench with different bases ([#206](https://github.com/ConsenSys/gnark-crypto/issues/206))
46+
- vectors generated using <https://github.com/armfazh/h2c-go-ref>
47+
- **all curves:** compress/decompress pairing result
2648

2749
### Pull Requests
2850

51+
- Merge pull request [#232](https://github.com/ConsenSys/gnark-crypto/issues/232) from ConsenSys/docs/comments
52+
- Merge pull request [#229](https://github.com/ConsenSys/gnark-crypto/issues/229) from ConsenSys/update_deps
53+
- Merge pull request [#227](https://github.com/ConsenSys/gnark-crypto/issues/227) from ConsenSys/fix/element_setstring
54+
- Merge pull request [#228](https://github.com/ConsenSys/gnark-crypto/issues/228) from ConsenSys/fix/race/test
55+
- Merge pull request [#224](https://github.com/ConsenSys/gnark-crypto/issues/224) from ConsenSys/refactor/scalarmul
56+
- Merge pull request [#220](https://github.com/ConsenSys/gnark-crypto/issues/220) from ConsenSys/perf/kzg-verify
57+
- Merge pull request [#223](https://github.com/ConsenSys/gnark-crypto/issues/223) from ConsenSys/doc/security-estimates-curves
58+
- Merge pull request [#216](https://github.com/ConsenSys/gnark-crypto/issues/216) from ConsenSys/feat/poly
59+
- Merge pull request [#217](https://github.com/ConsenSys/gnark-crypto/issues/217) from ConsenSys/string-utils
60+
- Merge pull request [#213](https://github.com/ConsenSys/gnark-crypto/issues/213) from ConsenSys/perf/glv
61+
- Merge pull request [#129](https://github.com/ConsenSys/gnark-crypto/issues/129) from ConsenSys/feat/GT-compression
62+
- Merge pull request [#209](https://github.com/ConsenSys/gnark-crypto/issues/209) from ConsenSys/codegen/svdw-not-e4
63+
- Merge pull request [#203](https://github.com/ConsenSys/gnark-crypto/issues/203) from ConsenSys/tests/bn254-vectors
64+
- Merge pull request [#196](https://github.com/ConsenSys/gnark-crypto/issues/196) from ConsenSys/patch/hashToFpGeneric
2965
- Merge pull request [#202](https://github.com/ConsenSys/gnark-crypto/issues/202) from ConsenSys/gbotrel/issue199
3066
- Merge pull request [#200](https://github.com/ConsenSys/gnark-crypto/issues/200) from tyGavinZJU/develop
3167
- Merge pull request [#85](https://github.com/ConsenSys/gnark-crypto/issues/85) from ConsenSys/feat/fri
3268

69+
3370
<a name="v0.7.0"></a>
3471
## [v0.7.0] - 2022-03-24
3572

README.md

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,33 @@
22

33
[![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/gnark_team.svg?style=social&label=Follow%20%40gnark_team)](https://twitter.com/gnark_team) [![License](https://img.shields.io/badge/license-Apache%202-blue)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/ConsenSys/gnark-crypto)](https://goreportcard.com/badge/github.com/ConsenSys/gnark-crypto) [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/consensys/gnark-crypto)](https://pkg.go.dev/mod/github.com/consensys/gnark-crypto) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5815453.svg)](https://doi.org/10.5281/zenodo.5815453)
44

5-
`gnark-crypto` provides:
6-
* [Elliptic curve cryptography](ecc/ecc.md) (+pairing) on BN254, BLS12-381, BLS12-377, BW6-761, BLS24-315, BLS24-317, BW6-633, BLS12-378 and BW6-756
7-
* [Finite field arithmetic](field/field.md) (fast big.Int)
8-
* FFT
9-
* Polynomial commitment schemes
10-
* MiMC
11-
* EdDSA (on the "companion" twisted edwards curves)
5+
`gnark-crypto` provides efficient cryptographic primitives, in Go:
6+
7+
* Elliptic curve cryptography & **Pairing** on:
8+
* [`bn254`] ([audit report]())
9+
* [`bls12-381`] ([audit report]())
10+
* [`bls24-317`]
11+
* [`bls12-377`] / [`bw6-761`]
12+
* [`bls24-315`] / [`bw6-633`]
13+
* [`bls12-378`] / [`bw6-756`]
14+
* Each of these curve has a [`twistededwards`] sub-package with its companion curve which allow efficient elliptic curve cryptography inside zkSNARK circuits.
15+
* [`field/goff`] - Finite field arithmetic code generator (blazingly fast big.Int)
16+
* [`fft`] - Fast Fourier Transform
17+
* [`fri`] - FRI (multiplicative) commitment scheme
18+
* [`fiatshamir`] - Fiat-Shamir transcript builder
19+
* [`mimc`] - MiMC hash function using Miyaguchi-Preneel construction
20+
* [`kzg`] - KZG commitment scheme
21+
* [`permutation`] - Permutation proofs
22+
* [`plookup`] - Plookup proofs
23+
* [`eddsa`] - EdDSA signatures (on the companion [`twistededwards`] curves)
1224

1325
`gnark-crypto` is actively developed and maintained by the team (gnark@consensys.net | [HackMD](https://hackmd.io/@gnark)) behind:
14-
* [`gnark`: a framework to execute (and verify) algorithms in zero-knowledge](https://github.com/consensys/gnark)
26+
27+
* [`gnark`: a framework to execute (and verify) algorithms in zero-knowledge](https://github.com/consensys/gnark)
1528

1629
## Warning
17-
**`gnark-crypto` has not been audited and is provided as-is, use at your own risk. In particular, `gnark-crypto` makes no security guarantees such as constant time implementation or side-channel attack resistance.**
30+
31+
**`gnark-crypto` is not fully audited and is provided as-is, use at your own risk. In particular, `gnark-crypto` makes no security guarantees such as constant time implementation or side-channel attack resistance.**
1832

1933
**To report a security bug, please refer to [`gnark` Security Policy](https://github.com/ConsenSys/gnark/blob/master/SECURITY.md).**
2034

@@ -24,7 +38,7 @@
2438

2539
### Go version
2640

27-
`gnark-crypto` is tested with the last 2 major releases of Go (1.16 and 1.17).
41+
`gnark-crypto` is tested with the last 2 major releases of Go (1.17 and 1.18).
2842

2943
### Install `gnark-crypto`
3044

@@ -34,24 +48,19 @@ go get github.com/consensys/gnark-crypto
3448

3549
Note if that if you use go modules, in `go.mod` the module path is case sensitive (use `consensys` and not `ConsenSys`).
3650

37-
### Documentation
38-
39-
[![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/consensys/gnark-crypto)](https://pkg.go.dev/mod/github.com/consensys/gnark-crypto)
40-
41-
The APIs are consistent accross the curves. For example, [here is `bn254` godoc](https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254#pkg-overview).
42-
4351
### Development
4452

4553
Most (but not all) of the code is generated from the templates in `internal/generator`.
4654

47-
The generated code contains little to no interfaces and is strongly typed with a base field (generated by the `gnark-crypto/field`). The two main factors driving this design choice are:
55+
The generated code contains little to no interfaces and is strongly typed with a field (generated by the `gnark-crypto/field` package). The two main factors driving this design choice are:
4856

4957
1. Performance: `gnark-crypto` algorithms manipulates millions (if not billions) of field elements. Interface indirection at this level, plus garbage collection indexing takes a heavy toll on perf.
50-
2. No generics in Go: need to derive (mostly) identical code for various moduli and curves, with consistent APIs
58+
2. Need to derive (mostly) identical code for various moduli and curves, with consistent APIs. Generics introduce significant performance overhead and are not yet suited for high performance computing.
5159

5260
To regenerate the files, see `internal/generator/main.go`. Run:
53-
```
54-
go generate ./internal/...
61+
62+
```bash
63+
go generate ./...
5564
```
5665

5766
## Benchmarks
@@ -86,7 +95,26 @@ Please use the following BibTeX to cite the most recent release.
8695

8796
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/consensys/gnark-crypto/tags).
8897

89-
9098
## License
9199

92-
This project is licensed under the Apache 2 License - see the [LICENSE](LICENSE) file for details
100+
This project is licensed under the Apache 2 License - see the [LICENSE](LICENSE) file for details.
101+
102+
[`field/goff`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/field/goff
103+
[`bn254`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254
104+
[`bls12-381`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls12-381
105+
[`bls24-317`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls24-317
106+
[`bls12-377`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls12-377
107+
[`bls24-315`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls24-315
108+
[`bls12-378`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bls12-378
109+
[`bw6-761`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bw6-761
110+
[`bw6-633`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bw6-633
111+
[`bw6-756`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bw6-756
112+
[`twistededwards`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/twistededwards
113+
[`eddsa`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/twistededwards/eddsa
114+
[`fft`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/fft
115+
[`fri`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/fri
116+
[`mimc`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc
117+
[`kzg`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/kzg
118+
[`plookup`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/plookup
119+
[`permutation`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254/fr/permutation
120+
[`fiatshamir`]: https://pkg.go.dev/github.com/consensys/gnark-crypto/fiat-shamir

ecc/bls12-377/bls12-377.go

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
// Package bls12377 efficient elliptic curve, pairing and hash to curve implementation for bls12-377.
2+
//
3+
// bls12-377: A Barreto--Lynn--Scott curve with
4+
// embedding degree k=12
5+
// seed x₀=9586122913090633729
6+
// 𝔽r: r=8444461749428370424248824938781546531375899335154063827935233455917409239041 (x₀⁴-x₀²+1)
7+
// 𝔽p: p=258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177 ((x₀-1)² ⋅ r(x₀)/3+x₀)
8+
// (E/𝔽p): Y²=X³+1
9+
// (Eₜ/𝔽p²): Y² = X³+1/u (D-type twist)
10+
// r ∣ #E(Fp) and r ∣ #Eₜ(𝔽p²)
11+
// Extension fields tower:
12+
// 𝔽p²[u] = 𝔽p/u²+5
13+
// 𝔽p⁶[v] = 𝔽p²/v³-u
14+
// 𝔽p¹²[w] = 𝔽p⁶/w²-v
15+
// optimal Ate loop size:
16+
// x₀
17+
// Security: estimated 126-bit level following [https://eprint.iacr.org/2019/885.pdf]
18+
// (r is 253 bits and p¹² is 4521 bits)
19+
//
20+
// Warning
21+
//
22+
// This code has not been audited and is provided as-is. In particular, there is no security guarantees such as constant time implementation or side-channel attack resistance.
123
package bls12377
224

325
import (
@@ -9,18 +31,6 @@ import (
931
"github.com/consensys/gnark-crypto/ecc/bls12-377/internal/fptower"
1032
)
1133

12-
// BLS12-377: A Barreto--Lynn--Scott curve of embedding degree k=12 with seed x₀=9586122913090633729
13-
// 𝔽r: r=8444461749428370424248824938781546531375899335154063827935233455917409239041 (x₀⁴-x₀²+1)
14-
// 𝔽p: p=258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177 ((x₀-1)² ⋅ r(x₀)/3+x₀)
15-
// (E/𝔽p): Y²=X³+1
16-
// (Eₜ/𝔽p²): Y² = X³+1/u (D-type twist)
17-
// r ∣ #E(Fp) and r ∣ #Eₜ(𝔽p²)
18-
// Extension fields tower:
19-
// 𝔽p²[u] = 𝔽p/u²+5
20-
// 𝔽p⁶[v] = 𝔽p²/v³-u
21-
// 𝔽p¹²[w] = 𝔽p⁶/w²-v
22-
// optimal Ate loop size: x₀
23-
2434
// ID bls377 ID
2535
const ID = ecc.BLS12_377
2636

@@ -89,7 +99,7 @@ func init() {
8999

90100
g1Gen.X.SetString("81937999373150964239938255573465948239988671502647976594219695644855304257327692006745978603320413799295628339695")
91101
g1Gen.Y.SetString("241266749859715473739788878240585681733927191168601896383759122102112907357779751001206799952863815012735208165030")
92-
g1Gen.Z.SetString("1")
102+
g1Gen.Z.SetOne()
93103

94104
g2Gen.X.SetString("233578398248691099356572568220835526895379068987715365179118596935057653620464273615301663571204657964920925606294",
95105
"140913150380207355837477652521042157274541796891053068589147167627541651775299824604154852141315666357241556069118")

ecc/bls12-377/doc.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

ecc/bls12-377/fp/element.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecc/bls12-377/fr/element.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecc/bls12-377/fr/kzg/kzg.go

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)