Appendix : Debugging & Development Tools
Introduction
This appendix provides practical tools and techniques for debugging cryptographic code in rippled, testing implementations, and developing new cryptographic features.
Logging Cryptographic Operations
Enable Debug Logging
# Edit rippled.cfg
[rpc_startup]
{ "command": "log_level", "severity": "trace" }
# Or via RPC
./rippled log_level partition=Transaction severity=traceMonitor Signature Verification
# Watch for signature verification
./rippled --conf rippled.cfg 2>&1 | grep -i "verify\|sign\|signature"
# Watch for failures
./rippled --conf rippled.cfg 2>&1 | grep -i "tefBAD_SIGNATURE\|temINVALID"Custom Logging
Standalone Mode for Testing
Start Standalone Node
Generate Test Accounts
Test Transactions
Debugging with GDB
Compile with Debug Symbols
Basic GDB Commands
Inspect Cryptographic Data
Conditional Breakpoints
Memory Debugging with Valgrind
Check for Memory Leaks
Check for Uninitialized Memory
Unit Testing
Run Crypto Tests
Write Custom Tests
Benchmarking
Measure Performance
Compare Algorithms
Inspecting Key Material
View Public Key Details
Verify Key Pair Consistency
Testing Signature Canonicality
Check secp256k1 Canonicality
Hex Dump Utility
Address Sanitizer
Compile with AddressSanitizer
Detect Issues
Use-after-free
Heap buffer overflow
Stack buffer overflow
Memory leaks
Use of uninitialized memory
Common Debug Scenarios
Debug Signature Verification Failure
Summary
Essential debugging tools and techniques:
Logging: Enable trace logging for crypto operations
Standalone mode: Test without network complexity
GDB: Step through code, inspect variables
Valgrind: Detect memory issues
Unit tests: Verify correctness
Benchmarking: Measure performance
Inspection tools: Examine keys, signatures, addresses
Sanitizers: Catch memory errors automatically
Best practices:
Test with both ed25519 and secp256k1
Verify canonicality for secp256k1
Check key pair consistency
Use hex dumps for visual inspection
Always check error returns
Last updated

