Skip to content

[secp256k1-verify, program] Refactor out instruction constructor into solana-secp256k1-verify#16

Merged
samkim-crypto merged 5 commits into
solana-program:mainfrom
samkim-crypto:refactor-verify
Jul 11, 2026
Merged

[secp256k1-verify, program] Refactor out instruction constructor into solana-secp256k1-verify#16
samkim-crypto merged 5 commits into
solana-program:mainfrom
samkim-crypto:refactor-verify

Conversation

@samkim-crypto

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

Copy link
Copy Markdown
Contributor

Addressing this, this, and this comments.

I refactored out the instruction constructor to the solana-secp256k1-verify crate and made the program fully no-std.

Update: Also updated Pubkey with Address.

Comment thread secp256k1-verify/Cargo.toml Outdated
default = ["keccak"]
default = ["verify", "instruction", "keccak"]
verify = ["dep:solana-secp256k1-recover", "dep:solana-define-syscall"]
instruction = ["dep:solana-instruction", "dep:solana-pubkey"]

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.

If developers just wants to use the instruction constructor function (e.g. to CPI into the secp256k1 program) in their program, it doesn't make sense for their program to import crates like solana-secp256k1-recover, solana-keccak-hasher, etc, so I scoped the instruction constructor function behind instruction feature.

@samkim-crypto samkim-crypto marked this pull request as ready for review July 9, 2026 09:16
@samkim-crypto samkim-crypto requested review from joncinque and zz-sol July 9, 2026 09:16

@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. just two minor comments.

Comment thread secp256k1-verify/src/program.rs Outdated
Comment thread secp256k1-verify/src/verifier.rs

@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.

Looks good to me overall! Just some naming nits

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: can we put this in a file called instruction.rs instead?

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.

Done!


/// Constructs an on-chain instruction to invoke `solana-secp256k1-program`.
pub fn secp256k1_verify_instruction(
program_id: &Address,

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 we define a default program id at the top-level of the repo?

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.

Did you mean at the top of the crate or repository? Do you have an example of how it is done at the repo level 🙏 ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ah sorry, I did mean crate, sorry

Comment thread secp256k1-verify/src/program.rs Outdated
use {alloc::vec, alloc::vec::Vec, solana_address::Address, solana_instruction::Instruction};

/// Constructs an on-chain instruction to invoke `solana-secp256k1-program`.
pub fn secp256k1_verify_instruction(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: can probably just call this verify for simplicity, if it's moved into instruction.rs, the import looks pretty neat as solana_secp256k1_verify::instruction::verify

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.

Okay done!

@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.

Looks great! This can go in as is, the program id bit isn't necessary.

@samkim-crypto samkim-crypto merged commit 9981aaf into solana-program:main Jul 11, 2026
21 checks passed
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