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/poseidon2 #553

Merged
merged 29 commits into from
Nov 22, 2024
Merged

Feat/poseidon2 #553

merged 29 commits into from
Nov 22, 2024

Conversation

ThomasPiellard
Copy link
Contributor

@ThomasPiellard ThomasPiellard commented Oct 16, 2024

Description

Implementation of poseidon2 for t=2,3 following
reference implementation
reference paper
TBD: algos 1, 2, 3 of https://tosc.iacr.org/index.php/ToSC/article/view/8913/8489 for finding internal matrices when t>3

Type of change

Please delete options that are not relevant.

  • 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 benchmarked?

Please describe the benchmarks that you ran to verify your changes.

  • Benchmark A, on Macbook pro M1, 32GB RAM

goarch: amd64
pkg: github.com/consensys/gnark-crypto/ecc/bn254/fr/poseidon2
cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
BenchmarkPoseidon2-12 163784 7035 ns/op

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

Copy link
Collaborator

@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.

I reviewed bls12-377 and the code-generated part. The other curves should be similar. I can tell it follows the paper, the spec and the reference implementation. I am not confident on my understanding on the linear layer analysis (https://tosc.iacr.org/index.php/ToSC/article/view/8913/8489) but as I said it follows the spec and other implementations so it should be good. t>=4 cases are yet to be merged here or pushed in a different PR but this one is good to go. Only one remark the Sbox can be code-generated per curve/field as in MiMC to make the code simpler. We need also to add poseidon2 to hash/hashes.go.

ecc/bls12-377/fr/poseidon2/poseidon2.go Outdated Show resolved Hide resolved
ecc/bls12-377/fr/poseidon2/poseidon2.go Show resolved Hide resolved
internal/generator/crypto/hash/poseidon2/generate.go Outdated Show resolved Hide resolved
ecc/bls12-377/fr/poseidon2/poseidon2_test.go Show resolved Hide resolved
@ThomasPiellard ThomasPiellard merged commit 03e007d into master Nov 22, 2024
5 checks passed
@ThomasPiellard ThomasPiellard deleted the feat/poseidon2 branch November 22, 2024 18:11
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