Skip to content

Commit

Permalink
feat: secp256r1 precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
iceomatic committed Oct 13, 2024
1 parent 2eb3e1b commit 226eeef
Show file tree
Hide file tree
Showing 8 changed files with 603 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ full = [
"ed25519-dalek",
"ed25519-dalek-bip32",
"libsecp256k1",
"openssl",
"sha3",
"digest",
]
Expand All @@ -45,6 +46,7 @@ frozen-abi = [
"solana-short-vec/frozen-abi",
"solana-signature/frozen-abi"
]
openssl = ["dep:openssl"]

[dependencies]
bincode = { workspace = true }
Expand Down Expand Up @@ -72,6 +74,7 @@ memmap2 = { workspace = true, optional = true }
num-derive = { workspace = true }
num-traits = { workspace = true }
num_enum = { workspace = true }
openssl = { workspace = true, optional = true }
pbkdf2 = { workspace = true }
qualifier_attr = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
Expand Down
5 changes: 5 additions & 0 deletions sdk/feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ pub mod reenable_sbpf_v1_execution {
solana_program::declare_id!("TestFeature21111111111111111111111111111111");
}

pub mod enable_secp256r1_precompile {
solana_program::declare_id!("GkVUbiefEqFzzLcArWgNG7r3BCs551UUjdH2hVE5ns3E");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -1083,6 +1087,7 @@ lazy_static! {
(partitioned_epoch_rewards_superfeature::id(), "replaces enable_partitioned_epoch_reward to enable partitioned rewards at epoch boundary SIMD-0118"),
(disable_sbpf_v1_execution::id(), "Disables execution of SBPFv1 programs"),
(reenable_sbpf_v1_execution::id(), "Re-enables execution of SBPFv1 programs"),
(enable_secp256r1_precompile::id(), "Enable secp256r1 precompile SIMD-0075"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down
4 changes: 3 additions & 1 deletion sdk/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ pub mod program_error;
pub mod program_stubs;
pub mod program_utils;
pub mod secp256k1_program;
pub mod secp256r1_program;
pub mod slot_hashes;
pub mod slot_history;
pub mod stable_layout;
Expand Down Expand Up @@ -564,7 +565,7 @@ pub mod sdk_ids {
crate::{
address_lookup_table, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
config, ed25519_program, feature, incinerator, loader_v4, secp256k1_program,
solana_program::pubkey::Pubkey, stake, system_program, sysvar, vote,
secp256r1_program, solana_program::pubkey::Pubkey, stake, system_program, sysvar, vote,
},
lazy_static::lazy_static,
};
Expand All @@ -574,6 +575,7 @@ pub mod sdk_ids {
let mut sdk_ids = vec![
ed25519_program::id(),
secp256k1_program::id(),
secp256r1_program::id(),
system_program::id(),
sysvar::id(),
bpf_loader::id(),
Expand Down
5 changes: 5 additions & 0 deletions sdk/program/src/secp256r1_program.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! The [secp256r1 native program][np].
//!
//! [np]:

crate::declare_id!("Secp256r1SigVerify1111111111111111111111111");
5 changes: 3 additions & 2 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ pub use solana_program::{
epoch_rewards, epoch_schedule, fee_calculator, impl_sysvar_get, incinerator, instruction,
keccak, lamports, loader_instruction, loader_upgradeable_instruction, loader_v4,
loader_v4_instruction, message, msg, native_token, nonce, program, program_error,
program_option, program_pack, rent, secp256k1_program, serialize_utils, slot_hashes,
slot_history, stable_layout, stake, stake_history, syscalls, system_instruction,
program_option, program_pack, rent, secp256k1_program, secp256r1_program, serialize_utils,
slot_hashes, slot_history, stable_layout, stake, stake_history, syscalls, system_instruction,
system_program, sysvar, unchecked_div_by_const, vote,
};
#[cfg(feature = "borsh")]
Expand Down Expand Up @@ -95,6 +95,7 @@ pub mod reward_info;
pub mod reward_type;
pub mod rpc_port;
pub mod secp256k1_instruction;
pub mod secp256r1_instruction;
pub mod shred_version;
pub mod signature;
pub mod signer;
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ lazy_static! {
None, // always enabled
crate::ed25519_instruction::verify,
),
Precompile::new(
crate::secp256r1_program::id(),
Pubkey::try_from("GkVUbiefEqFzzLcArWgNG7r3BCs551UUjdH2hVE5ns3E").ok(),
crate::secp256r1_instruction::verify,
)
];
}

Expand Down
Loading

0 comments on commit 226eeef

Please sign in to comment.