用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ruvnet/ruflo --skill agent-security-manager命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | agent-security-manager |
| description | Agent skill for security-manager - invoke with $agent-security-manager |
name: security-manager type: security color: "#F44336" description: Implements comprehensive security mechanisms for distributed consensus protocols capabilities:
Implements comprehensive security mechanisms for distributed consensus protocols with advanced threat detection.
class ThresholdSignatureSystem {
constructor(threshold, totalParties, curveType = 'secp256k1') {
this.t = threshold; // Minimum signatures required
this.n = totalParties; // Total number of parties
this.curve = this.initializeCurve(curveType);
this.masterPublicKey = null;
this.privateKeyShares = new Map();
this.publicKeyShares = new Map();
this.polynomial = null;
}
// Distributed Key Generation (DKG) Protocol
async generateDistributedKeys() {
// Phase 1: Each party generates secret polynomial
const secretPolynomial = this.generateSecretPolynomial();
const commitments = this.generateCommitments(secretPolynomial);
// Phase 2: Broadcast commitments
await this.broadcastCommitments(commitments);
// Phase 3: Share secret values
const secretShares = this.generateSecretShares(secretPolynomial);
await this.distributeSecretShares(secretShares);
// Phase 4: Verify received shares
const validShares = await this.verifyReceivedShares();
// Phase 5: Combine to create master keys
this.masterPublicKey = this.combineMasterPublicKey(validShares);
return {
masterPublicKey: this.masterPublicKey,
privateKeyShare: this.privateKeyShares.get(this.nodeId),
publicKeyShares: this.publicKeyShares
};
}
// Threshold Signature Creation
async createThresholdSignature(message, signatories) {
if (signatories.length < this.t) {
throw new Error('Insufficient signatories for threshold');
}
const partialSignatures = [];
// Each signatory creates partial signature
for (const signatory of signatories) {
const partialSig = await this.createPartialSignature(message, signatory);
partialSignatures.push({
signatory: signatory,
signature: partialSig,
publicKeyShare: this.publicKeyShares.get(signatory)
});
}
// Verify partial signatures
const validPartials = partialSignatures.filter(ps =>
this.verifyPartialSignature(message, ps.signature, ps.publicKeyShare)
);
if (validPartials.length < this.t) {
throw new Error('Insufficient valid partial signatures');
}
// Combine partial signatures using Lagrange interpolation
return this.combinePartialSignatures(message, validPartials.slice(0, this.t));
}
// Signature Verification
verifyThresholdSignature(message, signature) {
return this.curve.verify(message, signature, this.masterPublicKey);
}
// Lagrange Interpolation for Signature Combination
combinePartialSignatures(message, partialSignatures) {
const lambda = this.computeLagrangeCoefficients(
partialSignatures.map(ps => ps.signatory)
);
let combinedSignature = this.curve.infinity();
for (let i = 0; i < partialSignatures.length; i++) {
const weighted = this.curve.multiply(
partialSignatures[i].signature,
lambda[i]
);
combinedSignature = this.curve.add(combinedSignature, weighted);
}
return combinedSignature;
}
}
class ZeroKnowledgeProofSystem {
constructor() {
this.curve = new EllipticCurve('secp256k1');
this.hashFunction = 'sha256';
this.proofCache = new Map();
}
// Prove knowledge of discrete logarithm (Schnorr proof)
async proveDiscreteLog(secret, publicKey, challenge = null) {
// Generate random nonce
const nonce = this.generateSecureRandom();
const commitment = this.curve.multiply(this.curve.generator, nonce);
// Use provided challenge or generate Fiat-Shamir challenge
const c = challenge || this.generateChallenge(commitment, publicKey);
// Compute response
const response = (nonce + c * secret) % this.curve.order;
return {
commitment: commitment,
challenge: c,
response: response
};
}
// Verify discrete logarithm proof
() {
{ commitment, challenge, response } = proof;
leftSide = ..(.., response);
rightSide = ..(
commitment,
..(publicKey, challenge)
);
..(leftSide, rightSide);
}
() {
(value < min || value > max) {
();
}
bitLength = .(.(max - min + ));
bits = .(value - min, bitLength);
proofs = [];
currentCommitment = commitment;
( i = ; i < bitLength; i++) {
bitProof = .(bits[i], currentCommitment);
proofs.(bitProof);
currentCommitment = .(currentCommitment, bits[i]);
}
{
: proofs,
: { min, max },
: bitLength
};
}
() {
n = .(.(range));
generators = .(n);
innerProductProof = .(
value, commitment, generators
);
{
: ,
: commitment,
: innerProductProof,
: generators,
: range
};
}
}
class ConsensusSecurityMonitor {
constructor() {
this.attackDetectors = new Map();
this.behaviorAnalyzer = new BehaviorAnalyzer();
this.reputationSystem = new ReputationSystem();
this.alertSystem = new SecurityAlertSystem();
this.forensicLogger = new ForensicLogger();
}
// Byzantine Attack Detection
async detectByzantineAttacks(consensusRound) {
const participants = consensusRound.participants;
const messages = consensusRound.messages;
const anomalies = [];
// Detect contradictory messages from same node
const contradictions = this.detectContradictoryMessages(messages);
if (contradictions.length > 0) {
anomalies.push({
type: 'CONTRADICTORY_MESSAGES',
severity: 'HIGH',
details: contradictions
});
}
// Detect timing-based attacks
timingAnomalies = .(messages);
(timingAnomalies. > ) {
anomalies.({
: ,
: ,
: timingAnomalies
});
}
collusionPatterns = .(participants, messages);
(collusionPatterns. > ) {
anomalies.({
: ,
: ,
: collusionPatterns
});
}
( participant participants) {
..(
participant,
anomalies.( a..(participant))
);
}
anomalies;
}
() {
identityVerifiers = [
.(nodeJoinRequest),
.(nodeJoinRequest),
.(nodeJoinRequest),
.(nodeJoinRequest)
];
verificationResults = .(identityVerifiers);
passedVerifications = verificationResults.( r.);
requiredVerifications = ;
(passedVerifications. < requiredVerifications) {
();
}
suspiciousPatterns = .(nodeJoinRequest);
(suspiciousPatterns. > ) {
..(nodeJoinRequest, suspiciousPatterns);
();
}
;
}
() {
diversityMetrics = .(connectionRequests);
(diversityMetrics. < ) {
.(nodeId, connectionRequests);
}
(diversityMetrics. < ) {
.(nodeId, connectionRequests);
}
maxConnectionsPerSource = ;
groupedConnections = .(connectionRequests);
( [source, connections] groupedConnections) {
(connections. > maxConnectionsPerSource) {
..(nodeId, source, connections);
allowedConnections = .(
connections, maxConnectionsPerSource
);
.(
connections.( !allowedConnections.(c))
);
}
}
}
() {
rateLimiter = ();
requestAnalyzer = ();
anomalousRequests = requestAnalyzer.(incomingRequests);
(anomalousRequests. > ) {
mitigationStrategies = [
.(anomalousRequests),
.(incomingRequests),
.(anomalousRequests),
.(anomalousRequests)
];
.(mitigationStrategies);
}
.(incomingRequests, anomalousRequests);
}
}
class SecureKeyManager {
constructor() {
this.keyStore = new EncryptedKeyStore();
this.rotationScheduler = new KeyRotationScheduler();
this.distributionProtocol = new SecureDistributionProtocol();
this.backupSystem = new SecureBackupSystem();
}
// Distributed Key Generation
async generateDistributedKey(participants, threshold) {
const dkgProtocol = new DistributedKeyGeneration(threshold, participants.length);
// Phase 1: Initialize DKG ceremony
const ceremony = await dkgProtocol.initializeCeremony(participants);
// Phase 2: Each participant contributes randomness
const contributions = await this.collectContributions(participants, ceremony);
// Phase 3: Verify contributions
const validContributions = await this.verifyContributions(contributions);
// Phase 4: Combine contributions to generate master key
const masterKey = dkgProtocol.(validContributions);
keyShares = dkgProtocol.(masterKey, participants);
.(keyShares, participants);
{
: masterKey.,
: ceremony,
: participants
};
}
() {
newKey = .(participants, .(participants. / ) + );
transitionPeriod = * * * ;
.(currentKeyId, newKey., transitionPeriod);
.(participants, newKey);
( () => {
.(currentKeyId);
}, transitionPeriod);
newKey;
}
() {
backupShares = .(keyShares, backupThreshold);
encryptedBackups = .(
backupShares.( (share, index) => ({
: ,
: .(share, ),
: .(share)
}))
);
.(encryptedBackups);
encryptedBackups.( ({
: backup.,
: backup.
}));
}
() {
backupShares = [];
( i = ; i < backupIds.; i++) {
encryptedBackup = .(backupIds[i]);
decryptedShare = .(
encryptedBackup.,
passwords[i]
);
checksum = .(decryptedShare);
(checksum !== encryptedBackup.) {
();
}
backupShares.(decryptedShare);
}
.(backupShares);
}
}
// Store security metrics in memory
await this.mcpTools.memory_usage({
action: 'store',
key: `security_metrics_${Date.now()}`,
value: JSON.stringify({
attacksDetected: this.attacksDetected,
reputationScores: Array.from(this.reputationSystem.scores.entries()),
keyRotationEvents: this.keyRotationHistory
}),
namespace: 'consensus_security',
ttl: 86400000 // 24 hours
});
// Performance monitoring for security operations
await this.mcpTools.metrics_collect({
components: [
'signature_verification_time',
'zkp_generation_time',
'attack_detection_latency',
'key_rotation_overhead'
]
});
// Learn attack patterns
await this.mcpTools.neural_patterns({
action: 'learn',
operation: 'attack_pattern_recognition',
outcome: JSON.stringify({
attackType: detectedAttack.type,
patterns: detectedAttack.patterns,
mitigation: appliedMitigation
})
});
// Predict potential security threats
const threatPrediction = await this.mcpTools.neural_predict({
modelId: 'security_threat_model',
input: JSON.stringify(currentSecurityMetrics)
});
class ByzantineConsensusSecurityWrapper {
constructor(byzantineCoordinator, securityManager) {
this.consensus = byzantineCoordinator;
this.security = securityManager;
}
async secureConsensusRound(proposal) {
// Pre-consensus security checks
await this.security.validateProposal(proposal);
// Execute consensus with security monitoring
const result = await this.executeSecureConsensus(proposal);
// Post-consensus security analysis
await this.security.analyzeConsensusRound(result);
return result;
}
async executeSecureConsensus(proposal) {
// Sign proposal with threshold signature
const signedProposal = await this.security.thresholdSignature.sign(proposal);
// Monitor consensus execution for attacks
const monitor = this.security.startConsensusMonitoring();
try {
// Execute Byzantine consensus
result = ..(signedProposal);
..(result);
result;
} {
monitor.();
}
}
}
class ConsensusPenetrationTester {
constructor(securityManager) {
this.security = securityManager;
this.testScenarios = new Map();
this.vulnerabilityDatabase = new VulnerabilityDatabase();
}
async runSecurityTests() {
const testResults = [];
// Test 1: Byzantine attack simulation
testResults.push(await this.testByzantineAttack());
// Test 2: Sybil attack simulation
testResults.push(await this.testSybilAttack());
// Test 3: Eclipse attack simulation
testResults.push(await this.testEclipseAttack());
// Test 4: DoS attack simulation
testResults.push(await this.testDoSAttack());
// Test 5: Cryptographic security tests
testResults.push(await this.testCryptographicSecurity());
return this.(testResults);
}
() {
maliciousNodes = .();
attack = (maliciousNodes);
startTime = .();
detectionTime = ..(attack.());
endTime = .();
{
: ,
: detectionTime !== ,
: detectionTime ? endTime - startTime : ,
: ..(attack)
};
}
}
This security manager provides comprehensive protection for distributed consensus protocols with enterprise-grade cryptographic security, advanced threat detection, and robust key management capabilities.
Ruflo is a multi-agent orchestration platform for AI coding agents (Claude Code, Cursor, Codex, Copilot, Gemini, Amp, +12 more). Use this skill when the user wants to (1) install/init ruflo in a project, (2) run multi-agent swarms with hierarchical coordination, (3) use ruflo's 314+ MCP tools for memory, routing, hooks, sub-agents, or workflows, (4) check ruflo status/version/doctor health, or (5) discover which of ruflo's 30+ plugins fits their task.
Multi-repository coordination, synchronization, and architecture management with AI swarm orchestration
Comprehensive GitHub release orchestration with AI swarm coordination for automated versioning, testing, deployment, and rollback management
基于 SOC 职业分类