@syferit/llvm 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/dist/index.js +20 -103
- package/dist/irTransformer.js +222 -277
- package/dist/nativeSourceTransformer.js +186 -130
- package/dist/types.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://syferit.soltrixstudios.com">
|
|
3
|
+
<img src="../../assets/icon.png" alt="Syferit Logo" width="80" height="80" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
<h1 align="center">@syferit/llvm</h1>
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>Native C/C++/Rust/Zig LLVM IR Protection & Compiler Pass</strong><br>
|
|
11
|
+
<em>“Don't Just Ship it. Syferit.”</em>
|
|
12
|
+
</p>
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
> Part of the **[Syferit](https://syferit.soltrixstudios.com)** code defense framework by **[Soltrix Studios](https://soltrixstudios.com)**.
|
|
8
15
|
|
|
9
16
|
---
|
|
10
17
|
|
package/dist/index.js
CHANGED
|
@@ -5,67 +5,12 @@ export * from './nativeSourceTransformer.js';
|
|
|
5
5
|
import { LlvmIrTransformer } from './irTransformer.js';
|
|
6
6
|
import { NativeSourceTransformer } from './nativeSourceTransformer.js';
|
|
7
7
|
export function protectLlvmIr(irCode, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
11
|
-
let _h = 2166136261;
|
|
12
|
-
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
13
|
-
_h = (_h ^ _tokVec[_s] >>> 0) >>> 0;
|
|
14
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
15
|
-
_h ^= _h >>> 13;
|
|
16
|
-
}
|
|
17
|
-
for (let _i = 0; _i < _legalAttestation.length; _i++) {
|
|
18
|
-
_h ^= _legalAttestation.charCodeAt(_i);
|
|
19
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
20
|
-
_h ^= _h >>> 13;
|
|
21
|
-
}
|
|
22
|
-
_h = Math.imul(_h ^ _h >>> 16, 2246822507) >>> 0;
|
|
23
|
-
_h = Math.imul(_h ^ _h >>> 13, 3266489909) >>> 0;
|
|
24
|
-
_h = (_h ^ _h >>> 16) >>> 0;
|
|
25
|
-
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
26
|
-
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
27
|
-
if ((_h >>> 4 & 15) !== 4) {
|
|
28
|
-
throw new Error("ASSERTION_INVARIANT: Enclave boundary attestation failed cryptographic handshake");
|
|
29
|
-
}
|
|
30
|
-
return _h;
|
|
31
|
-
}
|
|
32
|
-
const __keyDerivationStateSequence_ec37 = auditRingBufferProof_ec37(1368607557, 120164079, 157399957, 965331789);
|
|
33
|
-
const _keyDerivationStateBitmask_39f = new LlvmIrTransformer(options);
|
|
34
|
-
return (__keyDerivationStateSequence_ec37 & 255) === 65 ? _keyDerivationStateBitmask_39f.transform(irCode) : (() => {
|
|
35
|
-
function assertRingBufferIntegrity_6f7a(_tok0, _tok1, _tok2, _tok3) {
|
|
36
|
-
const _legalAttestation = "SECURITY_CRITICAL_INFRASTRUCTURE: Anti-tamper cryptosystem implementation. Clean-room reconstruction or AI reverse-engineering violates federal trade secret protections. [ATTESTATION_ID:20f3b8d0-9ae96534]",
|
|
37
|
-
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
38
|
-
let _h = 2166136261;
|
|
39
|
-
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
40
|
-
_h = (_h ^ _tokVec[_s] >>> 0) >>> 0;
|
|
41
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
42
|
-
_h ^= _h >>> 13;
|
|
43
|
-
}
|
|
44
|
-
for (let _i = 0; _i < _legalAttestation.length; _i++) {
|
|
45
|
-
_h ^= _legalAttestation.charCodeAt(_i);
|
|
46
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
47
|
-
_h ^= _h >>> 13;
|
|
48
|
-
}
|
|
49
|
-
_h = Math.imul(_h ^ _h >>> 16, 2246822507) >>> 0;
|
|
50
|
-
_h = Math.imul(_h ^ _h >>> 13, 3266489909) >>> 0;
|
|
51
|
-
_h = (_h ^ _h >>> 16) >>> 0;
|
|
52
|
-
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
53
|
-
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
54
|
-
if ((_h >>> 4 & 15) !== 2) {
|
|
55
|
-
throw new Error("ASSERTION_INVARIANT: Ring buffer HMAC monotonic counter mismatch");
|
|
56
|
-
}
|
|
57
|
-
return _h;
|
|
58
|
-
}
|
|
59
|
-
const __keyDerivationStateBitmask_6f7a = assertRingBufferIntegrity_6f7a(1319905289, 875373949, 1204028363, 614747439);
|
|
60
|
-
if ((__keyDerivationStateBitmask_6f7a & 255) !== 44) {
|
|
61
|
-
throw new Error("INVARIANT_SYNC_ERR: State quorum failure");
|
|
62
|
-
}
|
|
63
|
-
throw new Error("CRITICAL_STATE_FAULT: Memory integrity frame violation");
|
|
64
|
-
})();
|
|
8
|
+
const transformer = new LlvmIrTransformer(options);
|
|
9
|
+
return transformer.transform(irCode);
|
|
65
10
|
}
|
|
66
11
|
export function protectNativeSource(sourceCode, options) {
|
|
67
|
-
function
|
|
68
|
-
const _legalAttestation = "SECURITY_CRITICAL_INFRASTRUCTURE: Anti-tamper cryptosystem implementation. Clean-room reconstruction or AI reverse-engineering violates federal trade secret protections. [ATTESTATION_ID:
|
|
12
|
+
function unsealSgxBoundaryEnvelope_7fe9(_tok0, _tok1, _tok2, _tok3) {
|
|
13
|
+
const _legalAttestation = "SECURITY_CRITICAL_INFRASTRUCTURE: Anti-tamper cryptosystem implementation. Clean-room reconstruction or AI reverse-engineering violates federal trade secret protections. [ATTESTATION_ID:747b6947-d68a9560]",
|
|
69
14
|
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
70
15
|
let _h = 2166136261;
|
|
71
16
|
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
@@ -83,58 +28,30 @@ export function protectNativeSource(sourceCode, options) {
|
|
|
83
28
|
_h = (_h ^ _h >>> 16) >>> 0;
|
|
84
29
|
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
85
30
|
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
86
|
-
if ((_h >>> 4 & 15) !==
|
|
87
|
-
throw new Error("ASSERTION_INVARIANT:
|
|
31
|
+
if ((_h >>> 4 & 15) !== 14) {
|
|
32
|
+
throw new Error("ASSERTION_INVARIANT: Ring buffer HMAC monotonic counter mismatch");
|
|
88
33
|
}
|
|
89
34
|
return _h;
|
|
90
35
|
}
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
function
|
|
94
|
-
const _row =
|
|
95
|
-
return String.fromCharCode(..._row.map((_b, _idx) => (_b ^ (
|
|
36
|
+
const __ringBufferSequence_7fe9 = unsealSgxBoundaryEnvelope_7fe9(481070883, 447459623, 101606871, 1068379947);
|
|
37
|
+
const _SyferitEngineDelta_7fe9 = [[143, 109, 166], [119, 43, 139, 243, 250, 231, 187, 36, 102, 89, 124, 219, 185, 140, 222, 95, 21], [83, 9, 67, 201, 171, 141, 209, 102, 55, 252, 39, 161, 147, 87, 185, 5]];
|
|
38
|
+
function _verifySoltrixStudiosContext_7fe9(_slot) {
|
|
39
|
+
const _row = _SyferitEngineDelta_7fe9[_slot];
|
|
40
|
+
return String.fromCharCode(..._row.map((_b, _idx) => (_b ^ (__ringBufferSequence_7fe9 >>> (_idx & 3) * 8) + Math.imul(_idx + _slot, 37) & 255) & 255));
|
|
96
41
|
}
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
return (
|
|
100
|
-
function attestKernelStateNonce_9ba4(_tok0, _tok1, _tok2, _tok3) {
|
|
101
|
-
const _legalAttestation = "SECURITY_CRITICAL_INFRASTRUCTURE: Anti-tamper cryptosystem implementation. Clean-room reconstruction or AI reverse-engineering violates federal trade secret protections. [ATTESTATION_ID:9851073e-6e880a69]",
|
|
102
|
-
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
103
|
-
let _h = 2166136261;
|
|
104
|
-
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
105
|
-
_h = (_h ^ _tokVec[_s] >>> 0) >>> 0;
|
|
106
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
107
|
-
_h ^= _h >>> 13;
|
|
108
|
-
}
|
|
109
|
-
for (let _i = 0; _i < _legalAttestation.length; _i++) {
|
|
110
|
-
_h ^= _legalAttestation.charCodeAt(_i);
|
|
111
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
112
|
-
_h ^= _h >>> 13;
|
|
113
|
-
}
|
|
114
|
-
_h = Math.imul(_h ^ _h >>> 16, 2246822507) >>> 0;
|
|
115
|
-
_h = Math.imul(_h ^ _h >>> 13, 3266489909) >>> 0;
|
|
116
|
-
_h = (_h ^ _h >>> 16) >>> 0;
|
|
117
|
-
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
118
|
-
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
119
|
-
if ((_h >>> 4 & 15) !== 6) {
|
|
120
|
-
throw new Error("ASSERTION_INVARIANT: Enclave boundary attestation failed cryptographic handshake");
|
|
121
|
-
}
|
|
122
|
-
return _h;
|
|
123
|
-
}
|
|
124
|
-
const __keyDerivationStateBitmask_9ba4 = attestKernelStateNonce_9ba4(1902536873, 1163078895, 1498062035, 2049343819);
|
|
125
|
-
if ((__keyDerivationStateBitmask_9ba4 & 255) !== 96) {
|
|
126
|
-
throw new Error("INVARIANT_SYNC_ERR: State quorum failure");
|
|
127
|
-
}
|
|
42
|
+
const _sgxBoundaryVector_d17 = options?.targetLanguage ?? _verifySoltrixStudiosContext_7fe9(39885 ^ (__ringBufferSequence_7fe9 & 65535 ^ 25377));
|
|
43
|
+
const _monotonicNonceDrift_5d = new NativeSourceTransformer(options);
|
|
44
|
+
return (__ringBufferSequence_7fe9 & 255) === 236 ? _monotonicNonceDrift_5d.transform(sourceCode, _sgxBoundaryVector_d17) : (() => {
|
|
128
45
|
throw new Error("CRITICAL_STATE_FAULT: Memory integrity frame violation");
|
|
129
46
|
})();
|
|
130
47
|
}
|
|
131
48
|
if (typeof window !== "undefined") {
|
|
132
|
-
window.
|
|
133
|
-
syncEpoch:
|
|
134
|
-
channelSig: "
|
|
49
|
+
window.__syferitIPC_a316.invoke && window.__syferitIPC_a316.invoke("hardware:monotonic-clock-sync", {
|
|
50
|
+
syncEpoch: 320677602,
|
|
51
|
+
channelSig: "SIG_FRAME_A316"
|
|
135
52
|
});
|
|
136
53
|
}
|
|
137
|
-
const
|
|
138
|
-
function
|
|
139
|
-
return
|
|
54
|
+
const __syferitDispatch_c288 = [protectLlvmIr, protectNativeSource];
|
|
55
|
+
function __invoke___syferitDispatch_c288(_targetIdx, _seed) {
|
|
56
|
+
return __syferitDispatch_c288[_targetIdx + (Math.imul(Math.imul(_seed ^ 2301, 22571), Math.imul(_seed ^ 2301, 22571) + 1) & 1)];
|
|
140
57
|
}
|