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=trace

Monitor 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:

  1. Logging: Enable trace logging for crypto operations

  2. Standalone mode: Test without network complexity

  3. GDB: Step through code, inspect variables

  4. Valgrind: Detect memory issues

  5. Unit tests: Verify correctness

  6. Benchmarking: Measure performance

  7. Inspection tools: Examine keys, signatures, addresses

  8. 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