#solana #solana-sdk #secp256r1 #com #facilities #developing #programs

solana-secp256r1-program

Precompile implementation for the secp256r1 elliptic curve

22 stable releases

2.2.2 Mar 26, 2025
2.2.1 Feb 12, 2025
2.1.21 Apr 18, 2025
2.1.16 Mar 15, 2025
0.0.2 Nov 19, 2024

#290 in Magic Beans

Download history 3875/week @ 2024-12-28 5487/week @ 2025-01-04 8144/week @ 2025-01-11 9717/week @ 2025-01-18 9393/week @ 2025-01-25 13284/week @ 2025-02-01 28857/week @ 2025-02-08 25955/week @ 2025-02-15 28468/week @ 2025-02-22 32205/week @ 2025-03-01 37408/week @ 2025-03-08 36060/week @ 2025-03-15 41835/week @ 2025-03-22 33978/week @ 2025-03-29 37539/week @ 2025-04-05 55556/week @ 2025-04-12

173,832 downloads per month
Used in 351 crates (5 directly)

Apache-2.0

33KB
583 lines

Instructions for the [secp256r1 native program][np]. [np]: https://docs.solana.com/developing/runtime-facilities/programs#secp256r1-program

Note on Signature Malleability: This precompile requires low-S values in signatures (s <= half_curve_order) to prevent signature malleability. Signature malleability means that for a valid signature (r,s), (r, order-s) is also valid for the same message and public key.

This property can be problematic for developers who assume each signature is unique. Without enforcing low-S values, the same message and key can produce two different valid signatures, potentially breaking replay protection schemes that rely on signature uniqueness.


Solana crate Solana documentation

solana-sdk

Rust SDK for the Solana blockchain, used by on-chain programs and the Agave validator.

Building

1. Install rustc, cargo and rustfmt.

curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustup component add rustfmt

2. Download the source code.

git clone https://github.com/anza-xyz/solana-sdk.git
cd solana-sdk

When building the master branch, please make sure you are using the version specified in the repo's rust-toolchain.toml by running:

rustup show

This command will download the toolchain if it is missing in the system.

3. Test.

cargo test

For Agave Developers

Patching a local solana-sdk repository

If your change to Agave also entails changes to the SDK, you will need to patch your Agave repo to use a local checkout of solana-sdk crates.

To patch all of the crates in this repo for Agave, just run:

./scripts/patch-crates-no-header.sh <AGAVE_PATH> <SOLANA_SDK_PATH>

Publishing a crate from this repository

Unlike Agave, the solana-sdk crates are versioned independently, and published as needed.

If you need to publish a crate, you can use the "Publish Crate" GitHub Action. Simply type in the path to the crate directory you want to release, ie. program-entrypoint, along with the kind of release, either patch, minor, major, or a specific version string.

The publish job will run checks, bump the crate version, commit and tag the bump, publish the crate to crates.io, and finally create GitHub Release with a simple changelog of all commits to the crate since the previous release.

Testing

Certain tests, such as rustfmt and clippy, require the nightly rustc configured on the repository. To easily install it, use the ./cargo helper script in the root of the repository:

./cargo nightly tree

Basic testing

Run the test suite:

cargo test

Alternatively, there is a helper script:

./scripts/test-stable.sh

Formatting

Format code for rustfmt check:

./cargo nightly fmt --all

The check can be run with a helper script:

./scripts/check-fmt.sh

Clippy / Linting

To check the clippy lints:

./scripts/check-clippy.sh

Benchmarking

Run the benchmarks:

./scripts/test-bench.sh

Code coverage

To generate code coverage statistics:

./scripts/test-coverage.sh
$ open target/cov/lcov-local/index.html

Code coverage requires llvm-tools-preview for the configured nightly toolchain. To install the component, run the command output by the script if it fails to find the component:

rustup component add llvm-tools-preview --toolchain=<NIGHTLY_TOOLCHAIN>

Dependencies

~2.4–9MB
~92K SLoC