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

Add basic modular & EC point arithmetic primitives && ECDSA signature verification #5

Merged
merged 21 commits into from
Mar 23, 2023

Conversation

smlu
Copy link
Member

@smlu smlu commented Mar 2, 2023

Changes

  • Added function to verify ECDSA signature for curves over prime field.
  • Implemented 2 prime curves: secp256k1 & secp256r1
  • Added class bigint for larger number arithmetic
  • Added functions for basic modular arithmetic: addition, subtraction, multiplication & division
  • Added fp_element which represents field element for curves over prime field
  • Added basic EC point arithmetic for prime field curves (ec_curve_fp, ec_point_fp, ec_point_fp_proj)

smlu added 5 commits March 2, 2023 01:30
Added functions for basic modular arithmetic (add, sub, mul, div) and struct `fp_element` which represents prime field element .
Added implementation of EC point addition, multiplication and inverse.
Added 2 elliptic curves over prime field: secp256k1 and secp256r1
Added implementation of ECDSA signature verification. 
The example contract is updated to include benchmark actions for curves secp256k1 & secp256r1.
@smlu smlu self-assigned this Mar 2, 2023
smlu added 4 commits March 3, 2023 22:38
Testing in wasm suggests that VLA is faster than __builtin_alloca & alloca.
__builtin_alloca is used where VLA array can't be used.
…ions

Changes:
  - Fixed proj. point comparison when z coords differ
  - Fixed curve point creation and verifying it's in range [0, p-1]
  - Added point function `is_valid` to verify the point is valid point generated from curve base point
  - Added proj. point functions `normalize` & `normalized` which scales point to reflect affine point (z -> 1)
  - Optimized converting proj. point to affine point when z = 1
  - Fixed proj. point doubling to return identity point when y = 0
  - Renamed point function `invert` -> `inverted`
  - Added curve function `generate_point` which generates point from scalar using base point
  - Refactored fp curve function `make_field_element` to check that the provided integer value is in range [0, p-1]
  - Added additional EC tests
@smlu smlu force-pushed the develop branch 2 times, most recently from 265e0bc to b891aa0 Compare March 16, 2023 14:07
EC GF(p) point interfaces are simplified to require only curve type for template parameter. All fp point type alias and helper function `make_ec_point_fp_proj` are removed. 
Renamed intiger type alias to `int_type` for base struct `field_element`.
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.

1 participant