Skip to content

Conversation

@marcelofeitoza
Copy link

Summary

Adds a new example demonstrating how to use the sp1-solana verifier library within an Anchor framework-based Solana program. This example provides an alternative implementation to the existing native Solana program examples, showcasing integration with the popular Anchor development framework.

What's Changed

  • New Anchor-based example: Added complete Anchor project structure under example/anchor/
  • SP1 proof verification: Implements the same Fibonacci proof verification logic as existing examples but using Anchor's declarative syntax
  • Test suite: Includes comprehensive TypeScript tests for the Anchor program
  • Project configuration: Added proper Anchor.toml, package.json, and workspace configuration

Key Features

  • Framework compatibility: Demonstrates sp1-solana works seamlessly with Anchor programs
  • Consistent verification logic: Verifies SP1 Groth16 proofs for the Fibonacci sequence using the same verification key hash as other examples
  • Public input parsing: Extracts and logs the first three public inputs (n, a, b) as little-endian u32 values
  • Error handling: Proper validation of instruction data length (320 bytes) and proof verification results
  • Testing: Complete test coverage including edge cases and error scenarios

Technical Details

  • Uses Anchor v0.31.1 framework
  • Maintains compatibility with existing sp1-solana verifier library
  • Implements the same 320-byte instruction data format (256 bytes proof + 64 bytes public inputs)
  • Uses SP1 v5.0.0 verification key bytes (GROTH16_VK_5_0_0_BYTES)

Testing

The example includes comprehensive tests covering:

  • Instruction data parsing and structure validation
  • Invalid data handling and error cases
  • Valid proof structure processing
  • Verification key hash constant validation

This addition makes the sp1-solana library more accessible to developers already familiar with the Anchor framework while maintaining full compatibility with the core verification functionality.

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.

1 participant