Upload documentation/INTEGRATION_GUIDE.md with huggingface_hub
Browse files
documentation/INTEGRATION_GUIDE.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Integration Guide: Adding Secure Signing to Coldstar SOL
|
| 2 |
+
|
| 3 |
+
This guide shows how to integrate the Rust secure signer into your existing Python Coldstar SOL CLI.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
The Rust signing core will replace Python-based key handling with secure, memory-locked operations. The integration is designed to be minimally invasive to your existing codebase.
|
| 8 |
+
|
| 9 |
+
## Integration Strategy
|
| 10 |
+
|
| 11 |
+
```
|
| 12 |
+
Before (Insecure):
|
| 13 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
| 14 |
+
β Python CLI β
|
| 15 |
+
β ββ Load key from file β
|
| 16 |
+
β ββ Key in Python memory (INSECURE) β
|
| 17 |
+
β ββ Sign transaction in Python β
|
| 18 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
| 19 |
+
|
| 20 |
+
After (Secure):
|
| 21 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
| 22 |
+
β Python CLI β
|
| 23 |
+
β ββ Load encrypted container β
|
| 24 |
+
β ββ Call Rust signer βββββββββββ β
|
| 25 |
+
βββββββββββββββββββββββββββββββββββΌβββββββββ
|
| 26 |
+
βΌ
|
| 27 |
+
βββββββββββββββββββββββββββ
|
| 28 |
+
β Rust Signing Core β
|
| 29 |
+
β ββ Decrypt in locked β
|
| 30 |
+
β β memory β
|
| 31 |
+
β ββ Sign transaction β
|
| 32 |
+
β ββ Zeroize & return β
|
| 33 |
+
βββββββββββββββββββββββββββ
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
## Security Checklist
|
| 38 |
+
|
| 39 |
+
After integration, verify:
|
| 40 |
+
|
| 41 |
+
- [ ] Plaintext keys are deleted (or securely backed up offline)
|
| 42 |
+
- [ ] Encrypted containers are created with strong passphrases (12+ characters)
|
| 43 |
+
- [ ] Passphrase prompts use `getpass` (not visible on screen)
|
| 44 |
+
- [ ] No plaintext keys are logged or printed
|
| 45 |
+
- [ ] File permissions on encrypted containers are restrictive (`chmod 600`)
|
| 46 |
+
- [ ] Backup encrypted containers securely
|
| 47 |
+
- [ ] Test signing with correct and incorrect passphrases
|
| 48 |
+
|
| 49 |
+
## Rollback Plan
|
| 50 |
+
|
| 51 |
+
If you need to rollback to the old system:
|
| 52 |
+
|
| 53 |
+
1. Keep your original `keypair.json` backed up (securely!)
|
| 54 |
+
2. Keep the old wallet/transaction code in a separate branch
|
| 55 |
+
3. Test thoroughly before deleting plaintext keys
|
| 56 |
+
|
| 57 |
+
## Performance Considerations
|
| 58 |
+
|
| 59 |
+
- **FFI mode**: ~0.1ms overhead per signature (negligible)
|
| 60 |
+
- **CLI mode**: ~10-50ms overhead per signature (process startup)
|
| 61 |
+
|
| 62 |
+
For production with high throughput, use FFI mode. For development or occasional use, CLI mode is fine.
|
| 63 |
+
|
| 64 |
+
## Troubleshooting
|
| 65 |
+
|
| 66 |
+
### "Secure signer not available"
|
| 67 |
+
|
| 68 |
+
The Rust library isn't built or not found. Build it:
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
cd rust_signer
|
| 72 |
+
cargo build --release
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### "Failed to lock memory"
|
| 76 |
+
|
| 77 |
+
Your system may have limits on locked memory. Increase the limit:
|
| 78 |
+
|
| 79 |
+
```bash
|
| 80 |
+
# Temporary (current session)
|
| 81 |
+
ulimit -l unlimited
|
| 82 |
+
|
| 83 |
+
# Permanent (add to /etc/security/limits.conf)
|
| 84 |
+
* soft memlock unlimited
|
| 85 |
+
* hard memlock unlimited
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### "Decryption failed"
|
| 89 |
+
|
| 90 |
+
- Check that you're using the correct passphrase
|
| 91 |
+
- Verify the encrypted container file isn't corrupted
|
| 92 |
+
- Try recreating the container from the original key
|
| 93 |
+
|
| 94 |
+
## Next Steps
|
| 95 |
+
|
| 96 |
+
1. **Integrate with UI**: Add passphrase prompts to your UI
|
| 97 |
+
2. **Key Rotation**: Implement periodic key rotation
|
| 98 |
+
3. **Multi-Sig**: Extend for multi-signature support
|
| 99 |
+
4. **Hardware Integration**: Consider HSM integration for production
|
| 100 |
+
|
| 101 |
+
## Support
|
| 102 |
+
|
| 103 |
+
For issues or questions:
|
| 104 |
+
- Check the README.md and SECURITY.md
|
| 105 |
+
- Review the example code in python_signer_example.py
|
| 106 |
+
- Open an issue with detailed logs and steps to reproduce
|