Skip to content

refactor with pinocchio framework - #2

Merged
zz-sol merged 9 commits into
solana-program:mainfrom
zz-sol:zz/refactor
Jul 14, 2026
Merged

refactor with pinocchio framework#2
zz-sol merged 9 commits into
solana-program:mainfrom
zz-sol:zz/refactor

Conversation

@zz-sol

@zz-sol zz-sol commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This PR does the following refactoring:

  • moving the the Pinocchio framework
  • refactor into ed25519-verify lib and an example program to invoke the lib
  • simplify API for instructions (no longer compatible with precompiles)

@zz-sol
zz-sol requested a review from samkim-crypto July 9, 2026 20:09

@samkim-crypto samkim-crypto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good. Some high-level comments below to start.

Comment thread program/Cargo.toml Outdated
Comment thread README.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the API will stabilize after a couple of iterations, so let's update the README file only after the API is stabilized. In particular, I think we should move away from the offset processing and just interpret the public key, signature, and message data directly from instruction data.

Comment thread program/src/processor.rs Outdated
Comment thread ed25519-verify/src/test_utils.rs Outdated
Comment thread ed25519-verify/src/instruction.rs Outdated
Comment thread ed25519-verify/src/instruction_data.rs Outdated
Comment thread ed25519-verify/src/verifier.rs Outdated

/// Stateless, zero-allocation Ed25519 verifier.
#[derive(Debug, Clone, Copy, Default)]
pub struct Ed25519Verifier;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the future, we should add a bunch of configuration options. For example, I am thinking we should support different variations organized in https://hdevalence.ca/blog/2020-10-04-its-25519am/). But let's do this in follow-ups since this PR is already quite big.

@zz-sol
zz-sol requested a review from samkim-crypto July 13, 2026 11:12

@samkim-crypto samkim-crypto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay, looks good! I think this PR can be merged and then we can clean things up a bit in follow-up PRs.

@zz-sol
zz-sol merged commit 3407a3f into solana-program:main Jul 14, 2026
21 checks passed

@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 few post-merge comments, feel free to address whenever

Comment on lines +33 to +36
/// Initializes a new verifier.
pub const fn new() -> Self {
Self
}

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: I'm always a fan of less code rather than more code, and this doesn't seem to give very much

Comment thread ed25519-verify/Cargo.toml
@@ -0,0 +1,27 @@
[package]
name = "solana-ed25519-verify"
version = "4.0.0"

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: we can start with v1 or v0.1

Comment thread program/src/lib.rs
Comment on lines 5 to +6
#[cfg(not(any(target_os = "solana", target_arch = "bpf")))]
pub use instruction::sign_message;
#[cfg(all(
feature = "bincode",
not(any(target_os = "solana", target_arch = "bpf"))
))]
pub use instruction::{
new_ed25519_instruction_with_signature, offsets_to_ed25519_instruction,
try_new_ed25519_instruction_with_signature, try_offsets_to_ed25519_instruction,
};
pub use instruction::{
Ed25519SignatureOffsets, CURRENT_INSTRUCTION_INDEX, DATA_START, PUBKEY_SERIALIZED_SIZE,
SIGNATURE_OFFSETS_SERIALIZED_SIZE, SIGNATURE_OFFSETS_START, SIGNATURE_SERIALIZED_SIZE,
extern crate 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.

It doesn't look this is used anywhere anymore, except in tests -- can we remove it?

@@ -0,0 +1,24 @@
extern crate alloc;

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: is this line needed since it's already enabled in lib.rs?

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 call this file instruction.rs? That'll line up better with other clients

};

/// Constructs an on-chain instruction to invoke `solana-ed25519-program`.
pub fn ed25519_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: let's just call this "verify"

Comment thread program/src/lib.rs
Comment on lines +39 to +44
let public_key = instruction_data[..PUBKEY_SERIALIZED_SIZE]
.try_into()
.map_err(|_| ProgramError::InvalidInstructionData)?;
let signature = instruction_data[SIGNATURE_OFFSET..MESSAGE_OFFSET]
.try_into()
.map_err(|_| ProgramError::InvalidInstructionData)?;

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: since there's a length check already, we should be able to unwrap these

Comment thread Makefile
@@ -1,7 +1,6 @@
RUST_TOOLCHAIN_NIGHTLY = nightly-2026-01-22
SOLANA_CLI_VERSION = v3.1.10
SBF_ARCH = v2

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 for future work: v2 is getting removed, so we should use v3

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