Skip to content

Conversation

@yelhousni
Copy link
Collaborator

@yelhousni yelhousni commented Jan 18, 2023

Adds ECDSA scheme using gnark-crypto primitives on all curves. This follows "crypto/ecdsa", FIPS 186-4 and SEC1 v2.

todos:

  • use fr.Inverse() instead of bigInt.ModInverse() (experimented speedup is just ~1-2% so need to dig more why)
  • Implement Strauss-Shamir trick [a]P + [b]Q for fast verification (might also look into JSF encoding of scalars if perf is critical)

@yelhousni
Copy link
Collaborator Author

  • Strauss-Shamir trick (without GLV)

Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think you should copy input scalars to JointScalarMultiplication. In usual ScalarMul, you get the scalars from GLV decomposition and they are safe to modify locally. For ECDSA it is safe as you create big.Int inputs freshly, but if anyone would use JointScalarMul separately, then it would mutate its inputs.

Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To record conversation - maybe it is better to use fr.Element in Signature and PrivateKey types.

Also, it seems params type isn't strictly necessary - we have all the information in the curve template anyway. And add add signature/ecdsa package which calls the actual implementation depending on the curve.

@yelhousni yelhousni requested a review from ivokub January 24, 2023 11:46
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yelhousni yelhousni merged commit 9b7bfdb into develop Jan 25, 2023
@yelhousni yelhousni deleted the feat/ecdsa branch January 25, 2023 16:37
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.

4 participants