Skip to content

Conversation

@gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Mar 18, 2025

This pull request includes several changes focused on optimizing and enhancing the cryptographic operations and hash functions. The main changes involve removing redundant macros in assembly files, updating hash function parameters, and adding new test cases for interoperability.

Assembly File Optimizations:

  • Removed redundant macros MACC_0, DIV_SHIFT_0, MUL_WORD_0_0, and MUL_WORD_N_0 from ecc/bls12-381/internal/fptower/e2_amd64.s and replaced their usage with simplified macros ([[1]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-144cf2c79d11ebb4bf964e0821b507d5dbf3c5bb32bfbc3f02d8b86749aa216fL560-R572), [[2]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-144cf2c79d11ebb4bf964e0821b507d5dbf3c5bb32bfbc3f02d8b86749aa216fL677-R641), [[3]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-144cf2c79d11ebb4bf964e0821b507d5dbf3c5bb32bfbc3f02d8b86749aa216fL800-R704), [[4]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-144cf2c79d11ebb4bf964e0821b507d5dbf3c5bb32bfbc3f02d8b86749aa216fL892-R748)).

New Functions:

  • Added sumVec16_AVX512 and sumVec24_AVX512 functions to field/asm/element_31b/element_31b_amd64.s for vector summation using AVX-512 instructions ([field/asm/element_31b/element_31b_amd64.sR99-R132](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-8e2f917b06ecd74bf29565d3563a140e0cabd1d3e9c7adb9678d2c8537e1fa99R99-R132)).

Hash Function Updates:

  • Updated the number of full and partial rounds for the Poseidon2 hash function in field/babybear/poseidon2/hash.go to improve security ([field/babybear/poseidon2/hash.goL27-R43](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-ed133a4f89b9a8c80359ee0f63d73401cc3a803d8a27dacc89f02c9193c7e0d4L27-R43)).

Test Enhancements:

  • Added a new test TestPlonky3Interop in field/babybear/poseidon2/plonky3_interop_test.go to ensure compatibility with Plonky3's Poseidon2 implementation ([field/babybear/poseidon2/plonky3_interop_test.goR1-R228](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-04d598655042c203261b78a63910b43048bb427d3b70651a89c24061a6512310R1-R228)).

Miscellaneous:

  • Added AVX-512 support checks in field/babybear/poseidon2/poseidon2.go to enable optimized paths ([[1]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-ea2121f32491074cd1a6fae73054e8b1085dc0820d9ceb6bcdcc58f083afe4ddR18), [[2]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-ea2121f32491074cd1a6fae73054e8b1085dc0820d9ceb6bcdcc58f083afe4ddR51-R62), [[3]](https://github.com/Consensys/gnark-crypto/pull/665/files#diff-ea2121f32491074cd1a6fae73054e8b1085dc0820d9ceb6bcdcc58f083afe4ddR73-R74)).

@gbotrel gbotrel merged commit 53c5047 into master Mar 24, 2025
2 checks passed
@gbotrel gbotrel deleted the perf/p2_avx512_new branch March 24, 2025 20:01
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.

2 participants