Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions precompiles/src/secp256r1.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
use {
agave_feature_set::FeatureSet,
openssl::{
bn::{BigNum, BigNumContext},
ec::{EcGroup, EcKey, EcPoint},
nid::Nid,
pkey::PKey,
sign::Verifier,
},
solana_precompile_error::PrecompileError,
solana_secp256r1_program::{
Secp256r1SignatureOffsets, COMPRESSED_PUBKEY_SERIALIZED_SIZE, FIELD_SIZE,
Expand All @@ -15,11 +8,20 @@ use {
},
};

#[cfg(not(target_arch = "riscv32"))]
pub fn verify(
data: &[u8],
instruction_datas: &[&[u8]],
_feature_set: &FeatureSet,
) -> Result<(), PrecompileError> {
use openssl::{
bn::{BigNum, BigNumContext},
ec::{EcGroup, EcKey, EcPoint},
nid::Nid,
pkey::PKey,
sign::Verifier,
};

if data.len() < SIGNATURE_OFFSETS_START {
return Err(PrecompileError::InvalidInstructionDataSize);
}
Expand Down Expand Up @@ -139,6 +141,15 @@ pub fn verify(
Ok(())
}

#[cfg(target_arch = "riscv32")]
pub fn verify(
_data: &[u8],
_instruction_datas: &[&[u8]],
_feature_set: &FeatureSet,
) -> Result<(), PrecompileError> {
Err(PrecompileError::InvalidInstructionDataSize)
}

fn get_data_slice<'a>(
data: &'a [u8],
instruction_datas: &'a [&[u8]],
Expand Down Expand Up @@ -171,6 +182,11 @@ mod tests {
super::*,
crate::test_verify_with_alignment,
bytemuck::bytes_of,
openssl::{
bn::{BigNum, BigNumContext},
ec::{EcGroup, EcKey},
nid::Nid,
},
solana_secp256r1_program::{
new_secp256r1_instruction_with_signature, sign_message, DATA_START, SECP256R1_ORDER,
},
Expand Down