Skip to content

Security: buffedgecko/fhe-otc

Security

docs/SECURITY.md

Security Considerations

Overview

FHE-OTC implements privacy-preserving token swaps using Fully Homomorphic Encryption. This document outlines the security model and potential risks.

FHE Security Model

Data Privacy

  • All sensitive data (amounts, prices) is encrypted client-side using TFHE
  • Encrypted data remains encrypted on-chain and during computation
  • Only data owners with valid permits can decrypt their data

Permission System

  • Users must sign permits to access their encrypted data
  • Permits have time-based expiration
  • Permits can be restricted to specific contract functions

Smart Contract Security

Access Control

  • Only order makers can cancel their own orders
  • Only authorized matchers can trigger order matching
  • Settlement requires valid permits from both parties

Reentrancy Protection

  • All external functions use nonReentrant modifier
  • State changes occur before external calls

Input Validation

  • Token addresses must be valid (non-zero)
  • Token pairs must be different
  • Expiry must be within valid range (5 min - 30 days)
  • Amounts must be non-zero

Known Risks

1. FHE Computation Limitations

  • FHE operations have higher gas costs
  • Some operations may not complete if gas is insufficient
  • Mitigation: Estimate gas generously for FHE operations

2. Permit Expiration

  • Permits expire after a set time
  • Users may need to re-create permits for long operations
  • Mitigation: Frontend should handle permit renewal automatically

3. Frontend Security

  • Client-side encryption requires secure frontend environment
  • Compromised frontend could leak plaintext data
  • Mitigation: Open source code, audits, secure deployment

4. Smart Contract Bugs

  • As with any smart contract, bugs could lead to fund loss
  • Mitigation: Comprehensive testing, audits, bug bounties

Audit Recommendations

  1. Formal Verification - Verify key invariants (solvency, access control)
  2. Fuzz Testing - Extensive fuzzing of order creation and matching
  3. Integration Tests - Test full flow with CoFHE coprocessor
  4. External Audit - Professional security audit before mainnet

Responsible Disclosure

If you discover a security vulnerability, please report it to:

Please do not publicly disclose vulnerabilities until we have had time to address them.

License

MIT License - See LICENSE file for details.

There aren’t any published security advisories