Skip to content

[program] Clean up secp256k1 interface#11

Merged
samkim-crypto merged 3 commits into
solana-program:mainfrom
samkim-crypto:secp256k1-interface
Jul 8, 2026
Merged

[program] Clean up secp256k1 interface#11
samkim-crypto merged 3 commits into
solana-program:mainfrom
samkim-crypto:secp256k1-interface

Conversation

@samkim-crypto

@samkim-crypto samkim-crypto commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

We are going to deprecate the precompiles, so we don't need our program to be backwards compatible with the existing precompiles any more.

I removed the lengthy offset parsing logic in the program and simplified the tests. The program is now just one file that interprets the pubkey, signatures, and message from the instruction data and just verifies the program.

I also used pinocchio framework for the program, so it should be pretty light weight.

It seems like the program is using about 25,352k CUs for a single verification. The secp256k1-recover syscall itself requires 25,000 CUs (here, so this is pretty close to the theoretical limit. In follow-up PRs, let me double check if we can shave off a little more from the 352 CUs.

I also need to update the README for the repository, but I'll do this in a follow-up PR.

@samkim-crypto samkim-crypto force-pushed the secp256k1-interface branch from f2a119d to 43f5648 Compare July 6, 2026 09:27
@samkim-crypto samkim-crypto force-pushed the secp256k1-interface branch 2 times, most recently from 1dc26f5 to ecf08b7 Compare July 6, 2026 09:57
mod verify;

#[cfg(any(target_os = "solana", target_arch = "bpf"))]
mod syscall;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not completely sure if we need this module or not yet. If I invoke syscalls using the syscall wrapper crates from the sdk, I keep getting a jump offset error. For now, I created a syscall module and invoke the syscalls directly within, but I'll dig into why this is causing the issue and address it in a follow-up.

@samkim-crypto samkim-crypto marked this pull request as ready for review July 7, 2026 09:04
@samkim-crypto samkim-crypto requested a review from zz-sol July 7, 2026 09:04

@zz-sol zz-sol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@samkim-crypto samkim-crypto merged commit 86f5cd9 into solana-program:main Jul 8, 2026

@joncinque joncinque left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a couple of fly-by suggestions, looks great overall

Comment thread program/src/lib.rs
HASHED_PUBKEY_SERIALIZED_SIZE, SECP256K1_PRIVATE_KEY_SIZE, SECP256K1_PUBKEY_SIZE,
SECP256K1_UNCOMPRESSED_PUBKEY_SIZE, SIGNATURE_OFFSETS_SERIALIZED_SIZE,
SIGNATURE_SERIALIZED_SIZE,
#![cfg_attr(any(target_os = "solana", target_arch = "bpf"), no_std)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We should be able to make this no-std in all situations, no?

Comment thread program/Cargo.toml
@@ -9,31 +9,20 @@ crate-type = ["cdylib", "rlib"]
[features]
default = []
no-entrypoint = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can be fixed in a follow-up, but this isn't currently used, so I don't think anyone can actually import this crate.

Either way, maybe we should just include the instruction creator in solana-secp256k1-verify?

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.

3 participants