Skip to content

Conversation

@RonTuretzky
Copy link
Collaborator

Summary

This PR implements the Dynamic Security Threshold system as described in issue #12, adding adaptive risk-based verification thresholds to the OpacitySDK.

What's Changed

  • RiskAssessment Library: Core risk calculation engine that evaluates multiple factors
  • 🎯 DynamicThresholdSDK: Main SDK contract with adaptive threshold verification
  • 📊 DynamicVerificationConsumer: Example implementation with statistics tracking
  • 🧪 Comprehensive Tests: Full test suite covering all risk scenarios
  • 📚 Documentation: Complete README with usage examples and deployment instructions
  • 🚀 Deployment Script: Ready-to-use deployment script for Holesky testnet

Key Features

Risk-Based Thresholds

The system automatically adjusts required consensus from 10% to 90% based on:

  • 💰 Transaction Value (4 tiers: < 100 ETH, 100-1000 ETH, 1000-10000 ETH, > 10000 ETH)
  • 🏢 Platform Trust (Untrusted → Basic → Verified → Trusted)
  • 🔒 Resource Criticality (Trivial → Standard → Sensitive → Critical)
  • 👤 User History (Reduces risk for established users)

Risk Levels

Risk Level Score Range Required Threshold
MINIMAL 0-20 10%
LOW 21-40 30%
MEDIUM 41-60 50%
HIGH 61-80 70%
CRITICAL 81-100 90%

Benefits

  • 🚀 Resource Efficiency: Low-risk operations require fewer operators
  • 🔒 Enhanced Security: High-value operations get stronger consensus
  • ⚙️ Flexible Configuration: Admins can tune risk parameters
  • 👥 Better UX: Faster verification for routine operations
  • 💡 Economic Optimization: Better allocation of operator resources

Testing

forge test --match-path test/DynamicThreshold.t.sol -vv

Deployment

forge script script/DeployDynamicThreshold.s.sol:DeployDynamicThreshold --rpc-url holesky --broadcast

Related Issues

🤖 Generated with Claude Code

RonTuretzky and others added 2 commits August 13, 2025 18:58
Implements issue #12 - Dynamic security thresholds based on risk assessment

- Add RiskAssessment library for calculating risk scores
- Create DynamicThresholdSDK with adaptive threshold verification
- Implement risk factors: value, platform trust, resource criticality, user history
- Add DynamicVerificationConsumer example with statistics tracking
- Create deployment script for dynamic threshold system
- Add comprehensive test suite
- Include detailed documentation

Risk levels automatically adjust thresholds from 10% (minimal) to 90% (critical)
based on transaction context, providing efficient resource usage for low-risk
operations while ensuring strong consensus for high-value verifications.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Apply standardized Solidity formatting using forge fmt to ensure
consistent code style across all contract files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Add Dynamic Security Threshold Based on Risk Assessment

2 participants