Skip to content

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Apr 7, 2025

Description

This PR implements a variant of BLS signature verification (minimal public key). For this, we have implemented also:

  • message expansion
  • added BlockSize to binary hasher interface
  • implemented encode-to-g1, encode-to-g2, encode-to-g1, encode-to-g2

This PR takes #1447 and #1040 and Consensys/gnark-crypto#674, implementing Map/Hash to G2 over BLS12-381.

There is still some optimizations being done (bytes to emulated element conversion). But this is done during my refactor of #1489 later. And I'll then update the implementation here.

Thanks @weijiguo for the initial PR!

After this is merged, we can close #1040.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • TestAddG2FailureCaseTestSolve
  • TestAddG2UnifiedTestSolveAdd
  • TestAddG2UnifiedTestSolveDbl
  • TestAddG2UnifiedTestSolveEdgeCases
  • TestEncodeToG1
  • TestHashToG1
  • TestEncodeToG2
  • TestHashToG2
  • TestExpandMsgXmd
  • TestMinimalPublicKeyTestSolve

How has this been benchmarked?

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

weijiguo and others added 30 commits January 27, 2024 16:01
revised G2.addUnified function based on the Brier and Joye algorithm
fixed G2.sgn0 function and associated unit tests for BLS12-381
@ivokub ivokub changed the title feat: implement hash to G2 on BLS12-381 feat: implement BLS signature verification (minimal public key) Jul 8, 2025
@ivokub ivokub requested a review from yelhousni July 8, 2025 08:57
@ivokub ivokub marked this pull request as ready for review July 8, 2025 08:57
@ivokub ivokub requested a review from ThomasPiellard July 8, 2025 08:58
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@ivokub ivokub requested a review from YaoJGalteland July 14, 2025 23:19
@ivokub ivokub changed the base branch from master to feat/bytes-conversion July 15, 2025 12:10
@ivokub ivokub force-pushed the feat/bytes-conversion branch from 7866081 to 47cd263 Compare July 16, 2025 14:01
@ivokub ivokub linked an issue Jul 17, 2025 that may be closed by this pull request
Base automatically changed from feat/bytes-conversion to master July 17, 2025 12:13
@ivokub
Copy link
Collaborator Author

ivokub commented Sep 4, 2025

@yelhousni - I think we're good with it. I have added compatibility tests with Ethereum BLS signature implementation. I think having signature generation in gnark-crypto is nice-to-have, but it requires a bit of thought how to implement nicely (with prehashed messages and configuration).

And G1 variant doesn't seem to be much used, we can always add it if anyone asks, but there is lack of test vectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: hash to curve
5 participants