-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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
265e0bc
to
b891aa0
Compare
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`.
Added actions ecdsak1 & ecdsar1 which verifies ECDSA-SHA256 signatures for secp256k1 and secp256r1.
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
bigint
for larger number arithmeticfp_element
which represents field element for curves over prime fieldec_curve_fp
,ec_point_fp
,ec_point_fp_proj
)