Skip to content

feat: implement cryptographic wallet signature verification#84

Merged
SudiptaPaul-31 merged 2 commits intoLumina-eX:mainfrom
Mmesolove:feature/wallet-signature-verification
Feb 26, 2026
Merged

feat: implement cryptographic wallet signature verification#84
SudiptaPaul-31 merged 2 commits intoLumina-eX:mainfrom
Mmesolove:feature/wallet-signature-verification

Conversation

@Mmesolove
Copy link
Contributor

@Mmesolove Mmesolove commented Feb 26, 2026

Closes #74


Changes

Core Implementation

  • Signature Verification: Ed25519 signature verification using Stellar SDK
  • Nonce Management: Cryptographically random nonces with 5-minute TTL and one-time use
  • Password Derivation: HMAC-SHA256 deterministic password generation
  • Input Validation: Comprehensive validation utilities for wallet addresses and request bodies
  • Type Definitions: Complete TypeScript interfaces for authentication API

API Enhancements

  • POST /api/auth/nonce: Enhanced with validation and proper error handling
  • POST /api/auth/wallet-login: Full signature verification flow with Supabase integration

Security Features

  • ✅ Cryptographic proof of wallet ownership via Ed25519 signatures
  • ✅ Replay attack prevention through one-time nonce consumption
  • ✅ Time-limited nonces (5 minutes expiration)
  • ✅ HMAC-SHA256 password derivation with WALLET_AUTH_SECRET
  • ✅ Comprehensive error handling and security logging
  • ✅ Input validation with descriptive error messages

Testing

  • Unit tests for signature verification and nonce management
  • Test coverage for error handling and edge cases
  • Property-based test structure ready for fast-check integration

Requirements Addressed

All 9 requirements with 54 acceptance criteria:

  • Requirement 1: Cryptographic Signature Verification (1.1-1.6)
  • Requirement 2: Nonce Generation and Management (2.1-2.6)
  • Requirement 3: Replay Attack Prevention (3.1-3.6)
  • Requirement 4: JWT and Session Issuance (4.1-4.6)
  • Requirement 5: Input Validation and Error Handling (5.1-5.6)
  • Requirement 6: Security Compliance (6.1-6.6)
  • Requirement 7: Middleware Integration (7.1-7.6)
  • Requirement 8: Wallet SDK Integration (8.1-8.6)
  • Requirement 9: Testing and Verification (9.1-9.6)

Verification Checklist

  • Signature verification using Stellar SDK Ed25519
  • Nonce generation with cryptographic randomness
  • One-time nonce consumption
  • 5-minute nonce expiration
  • Deterministic password generation with HMAC-SHA256
  • Input validation for all endpoints
  • Error handling with proper status codes (400, 401, 500)
  • Security logging for authentication failures
  • TypeScript type definitions
  • Unit tests for core functionality
  • API contract preservation
  • Environment variable documentation

Setup Required

Add to your .env.local:
```bash
WALLET_AUTH_SECRET=
```

Documentation

  • Complete spec in `.kiro/specs/wallet-signature-verification/`
  • Requirements document with 9 comprehensive requirements
  • Design document with architecture and correctness properties
  • Implementation tasks with 42 sub-tasks

Breaking Changes

None - maintains backward compatibility with existing authentication flows.

Next Steps

  • Install dependencies: `npm install`
  • Set WALLET_AUTH_SECRET environment variable
  • Run tests: `npm test`
  • Verify build: `npm run build`" --base main

- Add Ed25519 signature verification using Stellar SDK
- Implement nonce generation with 5-minute TTL and one-time use
- Add deterministic password generation with HMAC-SHA256
- Enhance /api/auth/nonce endpoint with validation
- Enhance /api/auth/wallet-login with signature verification
- Add comprehensive input validation utilities
- Add TypeScript type definitions for auth API
- Add unit tests for signature verification and nonce management
- Update .env.example with WALLET_AUTH_SECRET documentation

Security features:
- Cryptographic proof of wallet ownership via Ed25519 signatures
- Replay attack prevention through one-time nonce consumption
- Time-limited nonces (5 minutes expiration)
- HMAC-SHA256 password derivation with server-side secret
- Comprehensive error handling and security logging

Requirements: 1.1-1.6, 2.1-2.6, 3.1-3.6, 4.1-4.6, 5.1-5.6, 6.1-6.6, 7.1-7.6, 8.1-8.6, 9.1-9.6
@Mmesolove
Copy link
Contributor Author

Please review and merge.

@SudiptaPaul-31
Copy link
Collaborator

@Mmesolove please resolve conflicts

@Mmesolove
Copy link
Contributor Author

please review.

@SudiptaPaul-31 SudiptaPaul-31 merged commit 495fdd1 into Lumina-eX:main Feb 26, 2026
1 check failed
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.

Server-side Wallet Signature Verification

2 participants