sov-kernel-monster / sovereign-pli /SovSNDLCheck.pli
SNAPKITTYWEST's picture
chore: push full sov-kernel-monster content from local build
9425aed verified
Raw
History Blame Contribute Delete
7.96 kB
/* ═══════════════════════════════════════════════════════════════════════════
SovSNDLCheck.pli β€” SNDL Defense Governance Gate
SOVEREIGN CONSTRAINTS:
- Fail-closed: HALT if key strength < threshold OR key is stale (replay)
- Uses WORM-attested key properties from SNDL key generation + freshness gate
- Zero external dependencies (uses existing sov_monster_kernel.f90 primitives)
- All governance events WORM-attested before state change
INTEGRATION:
- Called by SovFailClosed.pli as additional gate before quantum resource allocation
- Reads SNDL key strength + freshness from WORM chain
- Operates alongside SovZMOSCheck.pli and SovQMHESCheck.pli
SNDL Defense Mapping:
- Post-Quantum Cryptography β†’ prime_encoded_state() (PIRTM-based)
- Hybrid Encryption β†’ XOR combination in sndl_resistant_key()
- Crypto-Agility β†’ sndl_key_rotation (Ο†-decay driven)
- Harvest Now Defense β†’ WORM-attested key binding (bind_to_fixed_point)
- Decrypt Later Prevention β†’ key freshness gate (jordan_block.f90)
- Quantum Tamper Evidence β†’ [U,ρ*]=0 violation β†’ key corruption
Prior Art: SnapKitty Foundry Intel (April 14, 2026)
Original Research Lab: JAB Capital Trust (2021)
═══════════════════════════════════════════════════════════════════════════ */
dcl SovSNDLCheck entry (ptr, ptr) returns(fixed bin) external;
dcl Blake3Seal entry (char(*), char(*), ptr returns) external;
dcl WormLogGovernance entry (char(*), char(*)) external;
dcl FetchSNDLKeyStrengthFromWORM entry (ptr) returns(fixed bin) external;
dcl FetchSNDLKeyFreshnessFromWORM entry (ptr) returns(fixed bin) external;
dcl GetSNDLRotationCountFromWORM entry (ptr) returns(fixed bin) external;
dcl GetAgentEd25519Key entry returns(char(64) var) external;
dcl AgentHalt entry external;
/* ═══════════════════════════════════════════════════════════════════════════
SNDL DEFENSE GOVERNANCE GATE
Semantics: Allow quantum execution iff:
1. Key strength β‰₯ MIN_STRENGTH (128 bits β€” NIST Level 1)
2. Key is fresh (not replayed β€” freshness hash differs from last WORM entry)
3. Key rotation is current (not overdue per Ο†-decay schedule)
ALL conditions must pass (AND logic)
ANY failure β†’ WORM-attest + halt agent (fail-closed)
═══════════════════════════════════════════════════════════════════════════ */
SNDLDefenseGate: proc(options(main));
dcl KEY_PTR ptr;
dcl FRESHNESS_PTR ptr;
dcl KEY_STRENGTH fixed bin;
dcl IS_FRESH fixed bin;
dcl ROTATION_COUNT fixed bin;
dcl IS_SECURE fixed bin;
dcl MIN_STRENGTH fixed bin init(128);
dcl MAX_ROTATIONS_OVERDUE fixed bin init(3);
dcl AGENT_KEY char(64) var;
dcl DENIAL_REASON char(200) var;
KEY_PTR = GetLatestWORMSNDLKeyPtr();
FRESHNESS_PTR = GetLatestWORMFreshnessPtr();
KEY_STRENGTH = FetchSNDLKeyStrengthFromWORM(KEY_PTR);
IS_FRESH = FetchSNDLKeyFreshnessFromWORM(FRESHNESS_PTR);
ROTATION_COUNT = GetSNDLRotationCountFromWORM(KEY_PTR);
AGENT_KEY = GetAgentEd25519Key();
/* ─────────────────────────────────────────────────────────────────────
FAIL-CLOSED SNDL DEFENSE LOGIC
Default: DENIED (IS_SECURE starts at 0)
Must PROVE key strength + freshness + rotation currency
───────────────────────────────────────────────────────────────────── */
IS_SECURE = 0;
DENIAL_REASON = '';
/* Gate 1: Key strength check (NIST Level 1 minimum) */
if (KEY_STRENGTH < MIN_STRENGTH) then do;
DENIAL_REASON = 'SNDL_WEAK_KEY: Strength=' || char(KEY_STRENGTH)
|| ' Min=' || char(MIN_STRENGTH);
goto DENY_EXECUTION;
end;
/* Gate 2: Key freshness check (replay prevention) */
if (IS_FRESH = 0) then do;
DENIAL_REASON = 'SNDL_REPLAY_DETECTED: Key is stale β€” '
|| 'freshness hash matches previous WORM entry';
goto DENY_EXECUTION;
end;
/* Gate 3: Rotation currency check (crypto-agility enforcement) */
if (ROTATION_COUNT > MAX_ROTATIONS_OVERDUE) then do;
DENIAL_REASON = 'SNDL_ROTATION_OVERDUE: MissedRotations='
|| char(ROTATION_COUNT)
|| ' Max=' || char(MAX_ROTATIONS_OVERDUE);
goto DENY_EXECUTION;
end;
/* ALL gates passed β€” SNDL-defended execution allowed */
IS_SECURE = 1;
/* WORM-attest the APPROVAL (provenance for audit) */
call WormLogGovernance('SNDL_DEFENSE_APPROVED',
& 'KeyStrength=' || char(KEY_STRENGTH)
& || ' Fresh=' || char(IS_FRESH)
& || ' RotationStatus=CURRENT');
return;
/* ─────────────────────────────────────────────────────────────────────
DENY PATH: Hard fail, WORM-attest, halt agent
No state corruption possible (execution never reached)
───────────────────────────────────────────────────────────────────── */
DENY_EXECUTION:
/* WORM-attest the DENIAL (immutable audit record) */
call WormLogGovernance('SNDL_DEFENSE_DENIED', DENIAL_REASON);
/* Seal denial with agent's Ed25519 key (provable intent) */
call Blake3Seal(
'SNDL_FAIL_CLOSED:' || DENIAL_REASON,
AGENT_KEY,
null());
/* Hard halt β€” agent suspended until SNDL defense restored */
call AgentHalt();
/* Control never reaches here */
return;
end SNDLDefenseGate;
/* ═══════════════════════════════════════════════════════════════════════════
HELPER: SovSNDLCheck (Fortran-callable via C ABI)
Called by sov_monster_kernel.f90 as pre-execution gate
Reads latest WORM-attested SNDL key properties
Returns: 1 = SNDL-defended (safe), 0 = defense compromised (denied)
═══════════════════════════════════════════════════════════════════════════ */
SovSNDLCheck: proc(key_ptr, freshness_ptr) returns(fixed bin);
dcl key_ptr ptr;
dcl freshness_ptr ptr;
dcl key_strength fixed bin;
dcl is_fresh fixed bin;
dcl rotation_count fixed bin;
dcl min_strength fixed bin init(128);
dcl max_overdue fixed bin init(3);
/* Fetch WORM-attested values */
key_strength = FetchSNDLKeyStrengthFromWORM(key_ptr);
is_fresh = FetchSNDLKeyFreshnessFromWORM(freshness_ptr);
rotation_count = GetSNDLRotationCountFromWORM(key_ptr);
/* Fail-closed: default deny */
if (key_strength < min_strength) then return(0);
if (is_fresh = 0) then return(0);
if (rotation_count > max_overdue) then return(0);
/* All three gates pass β€” SNDL-defended */
return(1);
end SovSNDLCheck;