Skip to content

feat: add field element based sign/verify with Poseidon2 sponge for bn254 #809

@devon1209

Description

@devon1209

Is your feature request related to a problem? Please describe.

  • gnark-crypto's off-chain EdDSA uses hash.Hash (bytes), while gnark's in-circuit EdDSA uses hash.FieldHasher (field elements). Even with the same Poseidon2 permutation, these produce different hash values - making it impossible to sign off-chain and verify in-circuit using standard library functions.

Describe the solution you'd like
Add to bn254 EdDSA:

  • FieldHasher interface (Write(...fr.Element), Sum() fr.Element, Reset()) matching gnark's in-circuit std/hash.FieldHasher
  • SignField(msg fr.Element, hFunc FieldHasher) / VerifyField(sigBin []byte, msg fr.Element, hFunc FieldHasher)- same EdDSA logic as existing Sign/Verify, but hashing field elements directly: H(R.X, R.Y, A.X, A.Y, msg)
  • Poseidon2 sponge FieldHasher implementation using existing HorizenLabs BN254 constants

Describe alternatives you've considered

  • Each project implements custom Sign/Verify

Additional context

  • Non-breaking: existing Sign/Verify untouched. BN254-only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions