Ed/swi 66 implement offchain signing instruction per new srfc#138
Open
Ed/swi 66 implement offchain signing instruction per new srfc#138
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements SIWS (Sign-In With Solana) challenge validation for off-chain authentication flows in the Swig wallet program. The implementation follows the SIWS specification and enables verifying that a role authority can sign a challenge payload and has the requested permissions, intended primarily for off-chain transaction simulation.
Changes:
- Added comprehensive SIWS challenge payload support with ABNF-compliant message serialization and parsing
- Implemented
IsValidSignatureinstruction for validating signatures against SIWS challenges across multiple authority types (Ed25519, Secp256k1, Secp256r1, and program execution authorities) - Improved error handling by replacing
.unwrap()calls with proper error propagation in instruction building code
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| program/tests/is_valid_signature_test.rs | Comprehensive test suite covering happy path, permission denial, role mismatch, and malformed challenge scenarios |
| program/src/instruction.rs | Added IsValidSignature instruction variant (discriminant 16) with account definitions |
| program/src/actions/mod.rs | Integrated new instruction modules and dispatch logic for IsValidSignature |
| program/src/actions/is_valid_signature_abnf.rs | ABNF parser for SIWS challenge format with strict validation of field ordering and content |
| program/src/actions/is_valid_signature.rs | Core validation logic for authenticating authorities, verifying resource bindings, and checking scope permissions |
| program/idl.json | Updated IDL with IsValidSignature instruction schema |
| interface/src/lib.rs | Added SiwsChallengeV1 struct with message serialization and instruction builder methods for all authority types; improved error handling |
| .gitignore | Added .idea/ for JetBrains IDE configuration files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tracy-codes
requested changes
Feb 25, 2026
tracy-codes
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for SIWS (Sign-In With Solana) challenge payloads and signature validation instructions in the
interfacecrate, along with improved error handling for argument serialization. The main focus is on enabling and verifying SIWS-based authentication flows, including support for various authority types (Ed25519, Secp256k1, Secp256r1, and program execution authorities).The most important changes are:
SIWS Challenge Support:
SiwsChallengeV1struct, which models the SIWS challenge payload, including serialization to message strings/bytes and a corresponding test to ensure correct formatting. (interface/src/lib.rs)Signature Validation Instructions:
IsValidSignatureInstructionstruct with methods to construct signature validation instructions for Ed25519, Secp256k1, Secp256r1, and program execution authorities, using the SIWS challenge. (interface/src/lib.rs)IsValidSignatureArgsto the imports for use in signature validation. (interface/src/lib.rs)IsValidSignatureinstruction with its required accounts. (program/idl.json)Error Handling Improvements:
.unwrap()calls with explicit error propagation usingmap_errandanyhow. (interface/src/lib.rs) [1] [2] [3] [4]These changes collectively enable robust SIWS authentication flows and improve code safety by handling serialization errors more gracefully.