Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : security/tests/Tests/DifferentialAuditTests/DiffSupport.swift8// Module : Tests9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0412// Last Modified : 2026-12-0413//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import AuditSupport42import Foundation43import QyvoraMath4445// Helpers shared by the differential tests that talk to the Python oracle (security/tests/oracles/oracle.py).4647typealias Case = [String: Any]4849extension Dictionary where Key == String, Value == Any {50 /// Hex field decoded; nil when absent, null or not hexadecimal.51 func bytes(_ key: String) -> Bytes? {52 guard let s = self[key] as? String else { return nil }53 return Hex.decode(s)54 }5556 func string(_ key: String) -> String? { self[key] as? String }57 func bool(_ key: String) -> Bool? { self[key] as? Bool }58 var oracleError: String? { self["error"] as? String }59}6061func hex(_ b: Bytes) -> String { Hex.encode(b) }6263enum Py {64 /// Runs one batch; a failure of the oracle process itself is a test failure (never a silent pass).65 static func batch(_ op: String, _ cases: [Case]) throws -> [Case] {66 if cases.isEmpty { return [] }67 return try Oracle.pythonBatch(op: op, cases: cases)68 }6970 /// Records a campaign as NOT RUN when the Python oracle (or one of its packages) is missing.71 /// Returns true when the campaign can run.72 static func available(_ name: String, needs packages: [String] = [], rust: Bool = false) -> Bool {73 if let why = Oracle.pythonUnavailable(packages) {74 AuditRecorder.notRun(area: "differential", name: name, reason: why)75 return false76 }77 if rust, Oracle.spbDylib == nil || Oracle.pythonVersions?["spb-quantum-crypto"] == nil {78 AuditRecorder.notRun(79 area: "differential", name: name,80 reason: "Rust reference library libspb_pqc.dylib not found (security/.tools/lib or QY_SPBPQC_DYLIB)")81 return false82 }83 return true84 }8586 static var rustLabel: String {87 "spb-quantum-crypto \(Oracle.pythonVersions?["spb-quantum-crypto"] ?? "?") (Rust, FFI through ctypes)"88 }89}90