lotus-sdk
Version:
Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem
44 lines • 1.72 kB
TypeScript
import type { IProtocolValidator, P2PMessage, PeerInfo } from '../types.js';
export interface MuSig2SecurityConfig {
minSigners?: number;
maxSigners?: number;
maxSessionDuration?: number;
requireValidPublicKeys?: boolean;
maxMessageSize?: number;
maxTimestampSkew?: number;
maxInvalidMessagesPerPeer?: number;
enableValidationSecurity?: boolean;
trackValidationViolations?: boolean;
}
export declare const DEFAULT_MUSIG2_SECURITY: Required<MuSig2SecurityConfig>;
export declare class MuSig2SecurityValidator implements IProtocolValidator {
private readonly config;
private validationViolations;
private blockedPeers;
constructor(config?: MuSig2SecurityConfig);
validateResourceAnnouncement(resourceType: string, resourceId: string, data: unknown, peerId: string): Promise<boolean>;
validateMessage(message: P2PMessage, from: PeerInfo): Promise<boolean>;
private _isMessageTooLarge;
private _trackValidationViolation;
canAnnounceResource(resourceType: string, peerId: string): Promise<boolean>;
getSecurityStatus(): {
blockedPeers: string[];
blockedPeerCount: number;
validationViolations: {
[k: string]: number;
};
totalViolations: number;
config: {
maxMessageSize: number;
maxTimestampSkew: number;
maxInvalidMessagesPerPeer: number;
enableValidationSecurity: boolean;
trackValidationViolations: boolean;
};
};
isPeerBlocked(peerId: string): boolean;
getViolationCount(peerId: string): number;
unblockPeer(peerId: string): boolean;
clearViolations(): void;
}
//# sourceMappingURL=security.d.ts.map