From 0f8680c54a1356183f10dc2947d50cd7c786215b Mon Sep 17 00:00:00 2001 From: zz-sol Date: Mon, 27 Jul 2026 19:13:30 -0400 Subject: [PATCH 1/2] address comments --- .config/spellcheck.dic | 3 +-- ed25519-verify/src/config.rs | 6 ------ ed25519-verify/tests/verify_instruction.rs | 4 ---- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/.config/spellcheck.dic b/.config/spellcheck.dic index 9e8c8ce..7eacefe 100644 --- a/.config/spellcheck.dic +++ b/.config/spellcheck.dic @@ -16,8 +16,7 @@ cofactor cofactored cofactorless cryptographic -dalek -dalek's +dalek/P de deserializes ed25519 diff --git a/ed25519-verify/src/config.rs b/ed25519-verify/src/config.rs index c55c0e5..6e29b3c 100644 --- a/ed25519-verify/src/config.rs +++ b/ed25519-verify/src/config.rs @@ -103,9 +103,3 @@ impl VerificationCriteria { } } } - -impl Default for VerificationCriteria { - fn default() -> Self { - Self::zip215() - } -} diff --git a/ed25519-verify/tests/verify_instruction.rs b/ed25519-verify/tests/verify_instruction.rs index 40de922..3b000a3 100644 --- a/ed25519-verify/tests/verify_instruction.rs +++ b/ed25519-verify/tests/verify_instruction.rs @@ -214,10 +214,6 @@ fn new_uses_zip215_criteria() { Ed25519Verifier::new().criteria(), VerificationCriteria::zip215() ); - assert_eq!( - VerificationCriteria::default(), - VerificationCriteria::zip215() - ); } #[test] From 19ce168ce7b9e8e9ffd3a514725b21e162d7f92a Mon Sep 17 00:00:00 2001 From: zz-sol Date: Mon, 27 Jul 2026 19:35:24 -0400 Subject: [PATCH 2/2] address comments --- .config/spellcheck.dic | 5 +++-- Cargo.lock | 4 ++-- Cargo.toml | 2 +- README.md | 3 +-- ed25519-verify/Cargo.toml | 2 +- ed25519-verify/src/{program.rs => instruction.rs} | 4 +--- ed25519-verify/src/lib.rs | 4 ++-- ed25519-verify/src/verifier.rs | 8 +++++++- ed25519-verify/tests/verify_instruction.rs | 4 ++-- program/Cargo.toml | 2 +- program/src/lib.rs | 9 ++++----- program/tests/mollusk.rs | 8 +++----- 12 files changed, 28 insertions(+), 27 deletions(-) rename ed25519-verify/src/{program.rs => instruction.rs} (94%) diff --git a/.config/spellcheck.dic b/.config/spellcheck.dic index 7eacefe..36736b2 100644 --- a/.config/spellcheck.dic +++ b/.config/spellcheck.dic @@ -1,4 +1,4 @@ -33 +34 19AM CPI Cofactorless @@ -16,9 +16,10 @@ cofactor cofactored cofactorless cryptographic -dalek/P +dalek/M de deserializes +doublings ed25519 encodings entrypoint diff --git a/Cargo.lock b/Cargo.lock index fc230f1..07ea87a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2213,7 +2213,7 @@ checksum = "21e14a4f604117f379840956a8fc8695e4c84f5b0ebed192f31f60d9b85d581d" [[package]] name = "solana-ed25519-program" -version = "4.0.0" +version = "0.1.0" dependencies = [ "ed25519-dalek", "mollusk-svm", @@ -2228,7 +2228,7 @@ dependencies = [ [[package]] name = "solana-ed25519-verify" -version = "4.0.0" +version = "0.1.0" dependencies = [ "ed25519-dalek", "solana-curve25519", diff --git a/Cargo.toml b/Cargo.toml index 27f3676..ffb3561 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ serde = { version = "1.0.228", default-features = false } serde_derive = "1.0.228" solana-account = "3.4.0" solana-curve25519 = "4.0.1" -solana-ed25519-verify = { path = "ed25519-verify", version = "4.0.0", default-features = false } +solana-ed25519-verify = { path = "ed25519-verify", version = "0.1.0", default-features = false } solana-instruction = "3.3.0" solana-program-error = "3.0.1" solana-program-runtime = { version = "4.0.0", features = ["agave-unstable-api"] } diff --git a/README.md b/README.md index d78530c..b1b6050 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ The program verifies a single signature. Instruction data is: [96 ..] message ``` -The `ed25519_verify_instruction` helper in `solana-ed25519-verify` builds this -layout. +The `verify` helper in `solana-ed25519-verify` builds this layout. ### Constraints diff --git a/ed25519-verify/Cargo.toml b/ed25519-verify/Cargo.toml index c912c53..3fd07a3 100644 --- a/ed25519-verify/Cargo.toml +++ b/ed25519-verify/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-ed25519-verify" -version = "4.0.0" +version = "0.1.0" edition = "2021" [lib] diff --git a/ed25519-verify/src/program.rs b/ed25519-verify/src/instruction.rs similarity index 94% rename from ed25519-verify/src/program.rs rename to ed25519-verify/src/instruction.rs index c6796bd..2fabf8d 100644 --- a/ed25519-verify/src/program.rs +++ b/ed25519-verify/src/instruction.rs @@ -1,5 +1,3 @@ -extern crate alloc; - use { crate::{PUBKEY_SERIALIZED_SIZE, SIGNATURE_SERIALIZED_SIZE}, alloc::{vec, vec::Vec}, @@ -13,7 +11,7 @@ use { /// verifies the signature under the [ZIP-215] criteria. /// /// [ZIP-215]: crate::VerificationCriteria::zip215 -pub fn ed25519_verify_instruction( +pub fn verify( program_id: &Pubkey, public_key: &[u8; PUBKEY_SERIALIZED_SIZE], signature: &[u8; SIGNATURE_SERIALIZED_SIZE], diff --git a/ed25519-verify/src/lib.rs b/ed25519-verify/src/lib.rs index 5b7da8e..3729d08 100644 --- a/ed25519-verify/src/lib.rs +++ b/ed25519-verify/src/lib.rs @@ -15,13 +15,13 @@ extern crate alloc; mod config; #[cfg(feature = "instruction")] -pub mod program; +pub mod instruction; mod scalar; mod verifier; pub use config::VerificationCriteria; #[cfg(feature = "instruction")] -pub use program::ed25519_verify_instruction; +pub use instruction::verify; pub use verifier::Ed25519Verifier; pub const PUBKEY_SERIALIZED_SIZE: usize = 32; diff --git a/ed25519-verify/src/verifier.rs b/ed25519-verify/src/verifier.rs index 7f06978..b901b3d 100644 --- a/ed25519-verify/src/verifier.rs +++ b/ed25519-verify/src/verifier.rs @@ -24,11 +24,17 @@ const EDWARDS_IDENTITY_COMPRESSED: PodEdwardsPoint = /// The verification behavior is selected by [`VerificationCriteria`]. A verifier /// created with [`Ed25519Verifier::new`] uses the [`VerificationCriteria::zip215`] /// preset, matching this crate's historical behavior. -#[derive(Debug, Clone, Copy, Default)] +#[derive(Debug, Clone, Copy)] pub struct Ed25519Verifier { criteria: VerificationCriteria, } +impl Default for Ed25519Verifier { + fn default() -> Self { + Self::new() + } +} + impl Ed25519Verifier { /// Initializes a verifier using the default [ZIP-215] criteria. /// diff --git a/ed25519-verify/tests/verify_instruction.rs b/ed25519-verify/tests/verify_instruction.rs index 3b000a3..4b615d0 100644 --- a/ed25519-verify/tests/verify_instruction.rs +++ b/ed25519-verify/tests/verify_instruction.rs @@ -1,7 +1,7 @@ use { ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey}, solana_ed25519_verify::{ - ed25519_verify_instruction, Ed25519Verifier, VerificationCriteria, PUBKEY_SERIALIZED_SIZE, + verify, Ed25519Verifier, VerificationCriteria, PUBKEY_SERIALIZED_SIZE, SIGNATURE_SERIALIZED_SIZE, }, solana_program_error::ProgramError, @@ -58,7 +58,7 @@ fn constructs_program_instruction_with_direct_layout() { let message = b"hello ed25519"; let (signature, public_key) = signed_payload(message); - let instruction = ed25519_verify_instruction(&program_id, &public_key, &signature, message); + let instruction = verify(&program_id, &public_key, &signature, message); const PUBKEY_START: usize = 0; const SIGNATURE_START: usize = PUBKEY_START + PUBKEY_SERIALIZED_SIZE; diff --git a/program/Cargo.toml b/program/Cargo.toml index 35f5b7b..93c45c9 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-ed25519-program" -version = "4.0.0" +version = "0.1.0" edition = "2021" [lib] diff --git a/program/src/lib.rs b/program/src/lib.rs index 23929df..b6ca642 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -2,9 +2,6 @@ //! Pinocchio SBF wrapper for [`solana_ed25519_verify`]. -#[cfg(not(any(target_os = "solana", target_arch = "bpf")))] -extern crate std; - use { pinocchio::{ entrypoint::InstructionContext, error::ProgramError, lazy_program_entrypoint, ProgramResult, @@ -44,12 +41,14 @@ pub fn process_instruction(context: InstructionContext) -> ProgramResult { return Err(ProgramError::InvalidInstructionData); } + // Both ranges are fixed-size and in bounds after the length check above, + // so the conversions to fixed-size arrays cannot fail. let public_key = instruction_data[PUBKEY_OFFSET..SIGNATURE_OFFSET] .try_into() - .map_err(|_| ProgramError::InvalidInstructionData)?; + .unwrap(); let signature = instruction_data[SIGNATURE_OFFSET..MESSAGE_OFFSET] .try_into() - .map_err(|_| ProgramError::InvalidInstructionData)?; + .unwrap(); let message = &instruction_data[MESSAGE_OFFSET..]; Ed25519Verifier::new().verify_signature(signature, public_key, message) diff --git a/program/tests/mollusk.rs b/program/tests/mollusk.rs index 2ad43f9..e632a04 100644 --- a/program/tests/mollusk.rs +++ b/program/tests/mollusk.rs @@ -2,9 +2,7 @@ use { ed25519_dalek::{Signer, SigningKey}, mollusk_svm::Mollusk, solana_account::Account, - solana_ed25519_verify::{ - ed25519_verify_instruction, PUBKEY_SERIALIZED_SIZE, SIGNATURE_SERIALIZED_SIZE, - }, + solana_ed25519_verify::{verify, PUBKEY_SERIALIZED_SIZE, SIGNATURE_SERIALIZED_SIZE}, solana_instruction::{AccountMeta, Instruction}, solana_program_runtime::{ invoke_context::InvokeContext, @@ -155,7 +153,7 @@ fn signed_instruction(program_id: Pubkey, message: &[u8]) -> Instruction { let signature = signing_key.sign(message).to_bytes(); let public_key = signing_key.verifying_key().to_bytes(); - ed25519_verify_instruction(&program_id, &public_key, &signature, message) + verify(&program_id, &public_key, &signature, message) } #[test] @@ -186,7 +184,7 @@ fn accepts_zip215_small_order_public_key_vector_on_sbf() { let message = b"zip215 low-order public key vector"; let mut signature = [0; SIGNATURE_SERIALIZED_SIZE]; signature[..EDWARDS_IDENTITY_COMPRESSED.len()].copy_from_slice(&EDWARDS_IDENTITY_COMPRESSED); - let ix = ed25519_verify_instruction( + let ix = verify( &program_id, &SMALL_ORDER_PUBLIC_KEY_COMPRESSED, &signature,