Skip to content

armgit / bla

Public Imported from GitHub
0

🛡️ BLA (Blind LLM Agents) — Adversarial defense shield that protects binaries, Electron apps, JS bundles, Python, and WebAssembly against AI reverse-engineering agents like REA. Poison -> Exhaust -> Hallucinate.

feat(exhaustion): add unified Counter-REA resource exhaustion suite orchestrator

qybaihe09b03f29f5e6
diff --git a/src/shields/exhaustion/index.ts b/src/shields/exhaustion/index.ts
new file mode 100644
index 0000000..d77e296
--- /dev/null
+++ b/src/shields/exhaustion/index.ts
@@ -0,0 +1,88 @@
+import { SeededPrng } from "../../core/prng.js";
+import type { ProtectionIntensity } from "../../core/types.js";
+import {
+ REA_BUDGET_BREAKER_MATRIX,
+ computeReaCartesianStringByteCharge,
+ computeReaWasmInterfaceCharge,
+ getExhaustionProfileForIntensity,
+ type ReaSubsystemBudgetSpec,
+} from "./rea-budget-matrix.js";
+import {
+ REA_OBLIGATION_FAMILIES,
+ generateObligationLedgerFlood,
+ type ObligationFloodResult,
+} from "./obligation-flooder.js";
+import {
+ generateCallGraphLabyrinth,
+ type CallGraphLabyrinthResult,
+} from "./callgraph-labyrinth.js";
+import {
+ generateBpeTokenAmplifier,
+ type BpeTokenAmplifierResult,
+} from "./bpe-token-amplifier.js";
+import {
+ planWasmInterfaceBudgetExhaustion,
+ type WasmInterfaceExhaustionPlan,
+} from "./wasm-interface-exhaustion.js";
+
+export {
+ REA_BUDGET_BREAKER_MATRIX,
+ REA_OBLIGATION_FAMILIES,
+ computeReaCartesianStringByteCharge,
+ computeReaWasmInterfaceCharge,
+ getExhaustionProfileForIntensity,
+ generateObligationLedgerFlood,
+ generateCallGraphLabyrinth,
+ generateBpeTokenAmplifier,
+ planWasmInterfaceBudgetExhaustion,
+ type ReaSubsystemBudgetSpec,
+ type ObligationFloodResult,
+ type CallGraphLabyrinthResult,
+ type BpeTokenAmplifierResult,
+ type WasmInterfaceExhaustionPlan,
+};
+
+export interface CounterReaExhaustionSuiteResult {
+ readonly combinedJsCode: string;
+ readonly obligationFlood: ObligationFloodResult;
+ readonly callGraphLabyrinth: CallGraphLabyrinthResult;
+ readonly bpeAmplifier: BpeTokenAmplifierResult;
+ readonly totalDecoyObligations: number;
+ readonly mandatoryVerificationCasesInduced: number;
+ readonly totalLabyrinthNodes: number;
+ readonly totalCrossReferenceEdges: number;
+ readonly estimatedBpeTokensAdded: number;
+}
+
+/**
+ * Generates the unified Counter-REA Resource Exhaustion suite (`obligation-flooder` +
+ * `callgraph-labyrinth` + `bpe-token-amplifier`) for injection into JavaScript/TypeScript
+ * and Electron bundles.
+ */
+export function generateCounterReaExhaustionSuite(
+ prng: SeededPrng,
+ intensity: ProtectionIntensity = "balanced",
+): CounterReaExhaustionSuiteResult {
+ const obligationFlood = generateObligationLedgerFlood(prng, intensity);
+ const callGraphLabyrinth = generateCallGraphLabyrinth(prng, intensity);
+ const bpeAmplifier = generateBpeTokenAmplifier(prng, intensity);
+
+ const combinedJsCode = [
+ obligationFlood.code,
+ callGraphLabyrinth.code,
+ bpeAmplifier.code,
+ ].join("\n\n");
+
+ return {
+ combinedJsCode,
+ obligationFlood,
+ callGraphLabyrinth,
+ bpeAmplifier,
+ totalDecoyObligations: obligationFlood.totalDecoyObligations,
+ mandatoryVerificationCasesInduced:
+ obligationFlood.mandatoryVerificationCasesInduced,
+ totalLabyrinthNodes: callGraphLabyrinth.totalLabyrinthNodes,
+ totalCrossReferenceEdges: callGraphLabyrinth.crossReferenceEdgesCreated,
+ estimatedBpeTokensAdded: bpeAmplifier.estimatedBpeTokens,
+ };
+}