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

v2.1: SIMD-0075: Precompile for Secp256r1 (backport of #3152) #3662

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Nov 15, 2024

Problem

There currently isn't support for signature verification of signatures on the NIST-P256 curve (primary curve used by Passkeys). Motivation and details can be found in SIMD-0075

Summary of Changes

  • Adds a precompile for secp256r1 signature verification that implements the structure defined in SIMD-0075 and that abides by the rules set forth in SIMD-0152
  • Adds a separate secp256r1 crate to avoid further bloat of solana_sdk
  • Adds tests to check functionality of the precompile, as well as the computed curve order values

This is an automatic backport of pull request #3152 done by [Mergify](https://mergify.com).

* feat: secp256r1 precompile

* add: num_signatures == 0 check from SIMD-0152

* rm: unnecessary comment

* fix: legacy numeric constant

* CI/fix: compilation for wasm32 target

* Extract secp256r1 crate

* rm: unnecessary import

* update: sbf/Cargo.lock

* rm: unnecesary re-exports

* add: secp256r1 precompile to docs

* add: docs/description to sdk/program/src/lib.rs

* fix: alpha sort deps

* fixes

* docs fixes

* add: solana-instruction std feature to deps

* fix: lockfile from rebase

* fix: target architecture

* fix: workflow for client_target android

* add: sudo to workflow perl install

* fix: Cargo toml workspace member

* modify: ranlib path in client-targets.yaml

* fix: secp256r1/Cargo.toml formatting

* add: openssl feature

* fixes

* add: precompile signature range error

* more adjustments

* change: feature id

* fix: cargo format

* Revert "add: precompile signature range error"

This reverts commit fdf7673.

* fix: cargo sanity

* fix: client target openssl dep

* fix: 31 byte r,s support in new_secp256r1_instruction

* update: Cargo.lock

* fix: unchecked math in new_secp256r1_instruction

* fixes & increased test coverage

* add: solana-sdk/openssl to all release binaries

* update: comment to make openssl feature more clear

* add: solana-sdk/openssl feature to dependencies

* add: solana-sdk/openssl feature to dependencies

* merge: master into secp256r1-precompile

* fix: test-validator formatting

* Revert "add: solana-sdk/openssl to all release binaries"

This reverts commit 5c66b50.

* add: reserved key for secp256r1 program

* modify: client-targets.yaml

* modify: client/Cargo.toml solana-sdk dep

* modify: ledger-tool/Cargo.toml solana-sdk

* modify: test-validator/Cargo.toml solana-sdk dep

* modify: validator/Cargo.toml solana-sdk dep

* change: openssl feature to openssl-vendored

* remove: solana-sdk dep from sdk/program

* refactor: secp256r1 directory name

* fmt

* cargo.lock files

* revert: rustc-demangle bump

* cargo lock sanity

* fix: faulty feature-set merge

* fix: reserved keys pending feature id

---------

Co-authored-by: Iceomatic <89707822+iceomatic@users.noreply.github.com>
(cherry picked from commit da4f55e)

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	ledger-tool/Cargo.toml
#	programs/sbf/Cargo.lock
#	sdk/Cargo.toml
#	sdk/feature-set/src/lib.rs
#	sdk/reserved-account-keys/Cargo.toml
#	sdk/src/reserved_account_keys.rs
@mergify mergify bot requested a review from a team as a code owner November 15, 2024 12:22
@mergify mergify bot added the conflicts label Nov 15, 2024
Copy link
Author

mergify bot commented Nov 15, 2024

Cherry-pick of da4f55e has failed:

On branch mergify/bp/v2.1/pr-3152
Your branch is up to date with 'origin/v2.1'.

You are currently cherry-picking commit da4f55ef4e.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   .github/workflows/client-targets.yml
	modified:   client/Cargo.toml
	modified:   docs/src/runtime/programs.md
	new file:   sdk/secp256r1-program/Cargo.toml
	new file:   sdk/secp256r1-program/src/lib.rs
	modified:   sdk/src/precompiles.rs
	modified:   test-validator/Cargo.toml
	modified:   validator/Cargo.toml

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   Cargo.lock
	both modified:   Cargo.toml
	both modified:   ledger-tool/Cargo.toml
	both modified:   programs/sbf/Cargo.lock
	both modified:   sdk/Cargo.toml
	both modified:   sdk/feature-set/src/lib.rs
	deleted by us:   sdk/reserved-account-keys/Cargo.toml
	both modified:   sdk/src/reserved_account_keys.rs

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

Approved

@samkim-crypto samkim-crypto merged commit adeac02 into v2.1 Nov 15, 2024
29 checks passed
@samkim-crypto samkim-crypto deleted the mergify/bp/v2.1/pr-3152 branch November 15, 2024 22:28
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.

6 participants