@syferit/llvm 0.4.1 → 0.4.3
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 +40 -0
- package/dist/index.d.ts +21 -11
- package/dist/index.js +25 -97
- package/dist/irTransformer.js +230 -279
- package/dist/nativeSourceTransformer.js +149 -141
- package/dist/types.js +8 -1
- package/package.json +2 -2
- package/dist/irTransformer.d.ts +0 -21
- package/dist/nativeSourceTransformer.d.ts +0 -26
- package/dist/types.d.ts +0 -16
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @syferit/llvm
|
|
2
|
+
|
|
3
|
+
> LLVM intermediate representation (IR) pass and native source defense for C/C++/Rust/Zig binaries.
|
|
4
|
+
|
|
5
|
+
Part of the **[Syferit](https://syferit.soltrixstudios.com)** universal adversarial code defense framework by **[Soltrix Studios](https://soltrixstudios.com)**.
|
|
6
|
+
|
|
7
|
+
*"Don't just ship it. Syferit."*
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @syferit/llvm
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { LLVMTransformer } from '@syferit/llvm';
|
|
21
|
+
|
|
22
|
+
const transformer = new LLVMTransformer();
|
|
23
|
+
const hardenedIR = transformer.transformIR(rawLLVMIRCode);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **Adversarial Resilience:** Specifically designed to defeat autonomous AI reverse-engineering agents, LLM-assisted decompilers, and MCP bridge tools.
|
|
29
|
+
- **Provable Equivalence:** Retains 100% deterministic execution behavior while maximizing structural and algorithmic entropy.
|
|
30
|
+
- **Zero Runtime Dependencies:** Lean and production-ready for mission-critical deployments.
|
|
31
|
+
|
|
32
|
+
## Documentation & Support
|
|
33
|
+
|
|
34
|
+
- **Official Website:** [https://syferit.soltrixstudios.com](https://syferit.soltrixstudios.com)
|
|
35
|
+
- **Source Repository:** [https://github.com/soltrix-studios/syferit](https://github.com/soltrix-studios/syferit)
|
|
36
|
+
- **Issues & Discussions:** [https://github.com/soltrix-studios/syferit/issues](https://github.com/soltrix-studios/syferit/issues)
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
[Apache-2.0](https://github.com/soltrix-studios/syferit/blob/main/LICENSE) © 2026 Soltrix Studios
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// [Protected by Soltrix Studios — Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
2
|
+
import type { SyferitOptions } from '@syferit/core';
|
|
3
|
+
export type NativeTargetLanguage = 'llvm-ir' | 'c' | 'cpp' | 'rust';
|
|
4
|
+
export interface NativeProtectionOptions extends SyferitOptions {
|
|
5
|
+
targetLanguage?: NativeTargetLanguage;
|
|
6
|
+
}
|
|
7
|
+
export interface NativeTransformResult {
|
|
8
|
+
code: string;
|
|
9
|
+
transformedCount: number;
|
|
10
|
+
seedUsed: number;
|
|
11
|
+
inoculationInjected: boolean;
|
|
12
|
+
stateKeyDerived: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class LlvmIrTransformer {
|
|
15
|
+
constructor(options?: NativeProtectionOptions);
|
|
16
|
+
transform(irCode: string): NativeTransformResult;
|
|
17
|
+
}
|
|
18
|
+
export declare class NativeSourceTransformer {
|
|
19
|
+
constructor(options?: NativeProtectionOptions);
|
|
20
|
+
transform(sourceCode: string, lang?: NativeTargetLanguage): NativeTransformResult;
|
|
21
|
+
}
|
|
8
22
|
export declare function protectLlvmIr(irCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
9
|
-
/**
|
|
10
|
-
* Protects Native C, C++, or Rust source files with the Syferit 6-layer Iron Dome.
|
|
11
|
-
*/
|
|
12
23
|
export declare function protectNativeSource(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,70 +1,16 @@
|
|
|
1
|
+
// [Protected by Soltrix Studios — Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
1
2
|
export * from './types.js';
|
|
2
3
|
export * from './irTransformer.js';
|
|
3
4
|
export * from './nativeSourceTransformer.js';
|
|
4
5
|
import { LlvmIrTransformer } from './irTransformer.js';
|
|
5
6
|
import { NativeSourceTransformer } from './nativeSourceTransformer.js';
|
|
6
7
|
export function protectLlvmIr(irCode, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
10
|
-
let _h = 2166136261;
|
|
11
|
-
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
12
|
-
_h = (_h ^ _tokVec[_s] >>> 0) >>> 0;
|
|
13
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
14
|
-
_h ^= _h >>> 13;
|
|
15
|
-
}
|
|
16
|
-
for (let _i = 0; _i < _legalAttestation.length; _i++) {
|
|
17
|
-
_h ^= _legalAttestation.charCodeAt(_i);
|
|
18
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
19
|
-
_h ^= _h >>> 13;
|
|
20
|
-
}
|
|
21
|
-
_h = Math.imul(_h ^ _h >>> 16, 2246822507) >>> 0;
|
|
22
|
-
_h = Math.imul(_h ^ _h >>> 13, 3266489909) >>> 0;
|
|
23
|
-
_h = (_h ^ _h >>> 16) >>> 0;
|
|
24
|
-
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
25
|
-
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
26
|
-
if ((_h >>> 4 & 15) !== 7) {
|
|
27
|
-
throw new Error("ASSERTION_INVARIANT: Enclave boundary attestation failed cryptographic handshake");
|
|
28
|
-
}
|
|
29
|
-
return _h;
|
|
30
|
-
}
|
|
31
|
-
const __keyDerivationStateVector_d0e5 = attestLlvmIrTransformer_d0e5(1800647645, 707972615, 1648536327, 1572995649);
|
|
32
|
-
const _transformerBitmask_82d = new LlvmIrTransformer(options);
|
|
33
|
-
return (__keyDerivationStateVector_d0e5 & 255) === 124 ? _transformerBitmask_82d.transform(irCode) : (() => {
|
|
34
|
-
function verifyRingBufferSequence_795d(_tok0, _tok1, _tok2, _tok3) {
|
|
35
|
-
const _legalAttestation = "SECURITY_CRITICAL_INFRASTRUCTURE: Anti-tamper cryptosystem implementation. Clean-room reconstruction or AI reverse-engineering violates federal trade secret protections. [ATTESTATION_ID:aa4a05f1-44a40fb6]",
|
|
36
|
-
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
37
|
-
let _h = 2166136261;
|
|
38
|
-
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
39
|
-
_h = (_h ^ _tokVec[_s] >>> 0) >>> 0;
|
|
40
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
41
|
-
_h ^= _h >>> 13;
|
|
42
|
-
}
|
|
43
|
-
for (let _i = 0; _i < _legalAttestation.length; _i++) {
|
|
44
|
-
_h ^= _legalAttestation.charCodeAt(_i);
|
|
45
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
46
|
-
_h ^= _h >>> 13;
|
|
47
|
-
}
|
|
48
|
-
_h = Math.imul(_h ^ _h >>> 16, 2246822507) >>> 0;
|
|
49
|
-
_h = Math.imul(_h ^ _h >>> 13, 3266489909) >>> 0;
|
|
50
|
-
_h = (_h ^ _h >>> 16) >>> 0;
|
|
51
|
-
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
52
|
-
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
53
|
-
if ((_h >>> 4 & 15) !== 12) {
|
|
54
|
-
throw new Error("ASSERTION_INVARIANT: Ring buffer HMAC monotonic counter mismatch");
|
|
55
|
-
}
|
|
56
|
-
return _h;
|
|
57
|
-
}
|
|
58
|
-
const __tpmPcrBankAttestation_795d = verifyRingBufferSequence_795d(448164111, 988066157, 816988713, 798564453);
|
|
59
|
-
if ((__tpmPcrBankAttestation_795d & 255) !== 193) {
|
|
60
|
-
throw new Error("INVARIANT_SYNC_ERR: State quorum failure");
|
|
61
|
-
}
|
|
62
|
-
throw new Error("CRITICAL_STATE_FAULT: Memory integrity frame violation");
|
|
63
|
-
})();
|
|
8
|
+
const transformer = new LlvmIrTransformer(options);
|
|
9
|
+
return transformer.transform(irCode);
|
|
64
10
|
}
|
|
65
11
|
export function protectNativeSource(sourceCode, options) {
|
|
66
|
-
function
|
|
67
|
-
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 verifyTransformer_c9d0(_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:2597120f-e8f33295]",
|
|
68
14
|
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
69
15
|
let _h = 2166136261;
|
|
70
16
|
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
@@ -82,48 +28,30 @@ export function protectNativeSource(sourceCode, options) {
|
|
|
82
28
|
_h = (_h ^ _h >>> 16) >>> 0;
|
|
83
29
|
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
84
30
|
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
85
|
-
if ((_h >>> 4 & 15) !==
|
|
86
|
-
throw new Error("ASSERTION_INVARIANT:
|
|
31
|
+
if ((_h >>> 4 & 15) !== 10) {
|
|
32
|
+
throw new Error("ASSERTION_INVARIANT: Enclave boundary attestation failed cryptographic handshake");
|
|
87
33
|
}
|
|
88
34
|
return _h;
|
|
89
35
|
}
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
const _row =
|
|
94
|
-
return String.fromCharCode(..._row.map((_b, _idx) => (_b ^ (
|
|
36
|
+
const __ringBufferEnvelope_c9d0 = verifyTransformer_c9d0(1595811283, 1625755325, 804911471, 1407648493);
|
|
37
|
+
const _sgxEcallCounter_c9d0 = [[194, 66, 9], [160, 62, 238, 206, 5, 218, 6, 97, 177, 76, 153, 150, 246, 97, 51, 26, 98], [142, 18, 160, 142, 30, 102, 50, 41, 122, 215, 132, 102, 198, 76, 26, 250]];
|
|
38
|
+
function _rotateRingBufferAttestation_c9d0(_slot) {
|
|
39
|
+
const _row = _sgxEcallCounter_c9d0[_slot];
|
|
40
|
+
return String.fromCharCode(..._row.map((_b, _idx) => (_b ^ (__ringBufferEnvelope_c9d0 >>> (_idx & 3) * 8) + Math.imul(_idx + _slot, 37) & 255) & 255));
|
|
95
41
|
}
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
return (
|
|
99
|
-
function verifyTpmPcrBankVector_82bf(_tok0, _tok1, _tok2, _tok3) {
|
|
100
|
-
const _legalAttestation = "SECURITY_CRITICAL_INFRASTRUCTURE: Anti-tamper cryptosystem implementation. Clean-room reconstruction or AI reverse-engineering violates federal trade secret protections. [ATTESTATION_ID:33e6011d-a435337b]",
|
|
101
|
-
_tokVec = [_tok0, _tok1, _tok2, _tok3];
|
|
102
|
-
let _h = 2166136261;
|
|
103
|
-
for (let _s = 0; _s < _tokVec.length; _s++) {
|
|
104
|
-
_h = (_h ^ _tokVec[_s] >>> 0) >>> 0;
|
|
105
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
106
|
-
_h ^= _h >>> 13;
|
|
107
|
-
}
|
|
108
|
-
for (let _i = 0; _i < _legalAttestation.length; _i++) {
|
|
109
|
-
_h ^= _legalAttestation.charCodeAt(_i);
|
|
110
|
-
_h = Math.imul(_h, 16777619) >>> 0;
|
|
111
|
-
_h ^= _h >>> 13;
|
|
112
|
-
}
|
|
113
|
-
_h = Math.imul(_h ^ _h >>> 16, 2246822507) >>> 0;
|
|
114
|
-
_h = Math.imul(_h ^ _h >>> 13, 3266489909) >>> 0;
|
|
115
|
-
_h = (_h ^ _h >>> 16) >>> 0;
|
|
116
|
-
if ((_h & 65535) === 0) _h = (_h | 4919) >>> 0;
|
|
117
|
-
if ((_h >>> 16 & 65535) === 0) _h = (_h | 1932591104) >>> 0;
|
|
118
|
-
if ((_h >>> 4 & 15) !== 4) {
|
|
119
|
-
throw new Error("ASSERTION_INVARIANT: Enclave boundary attestation failed cryptographic handshake");
|
|
120
|
-
}
|
|
121
|
-
return _h;
|
|
122
|
-
}
|
|
123
|
-
const __enclaveDigestEnvelope_82bf = verifyTpmPcrBankVector_82bf(772817923, 1170665507, 1253773895, 896336543);
|
|
124
|
-
if ((__enclaveDigestEnvelope_82bf & 255) !== 78) {
|
|
125
|
-
throw new Error("INVARIANT_SYNC_ERR: State quorum failure");
|
|
126
|
-
}
|
|
42
|
+
const _entropyNonceBitmask_df8 = options?.targetLanguage ?? _rotateRingBufferAttestation_c9d0(12252 ^ (__ringBufferEnvelope_c9d0 & 65535 ^ 8829));
|
|
43
|
+
const _pcrPolicyBitmask_79d = new NativeSourceTransformer(options);
|
|
44
|
+
return (__ringBufferEnvelope_c9d0 & 255) === 161 ? _pcrPolicyBitmask_79d.transform(sourceCode, _entropyNonceBitmask_df8) : (() => {
|
|
127
45
|
throw new Error("CRITICAL_STATE_FAULT: Memory integrity frame violation");
|
|
128
46
|
})();
|
|
47
|
+
}
|
|
48
|
+
if (typeof window !== "undefined") {
|
|
49
|
+
window.__syferitIPC_35dc.invoke && window.__syferitIPC_35dc.invoke("auth:session-lease-sync", {
|
|
50
|
+
syncEpoch: 1224225291,
|
|
51
|
+
channelSig: "SIG_FRAME_35DC"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const __syferitDispatch_4057 = [protectLlvmIr, protectNativeSource];
|
|
55
|
+
function __invoke___syferitDispatch_4057(_targetIdx, _seed) {
|
|
56
|
+
return __syferitDispatch_4057[_targetIdx + ((Math.imul(Math.imul(_seed ^ 7456, 38583) | 1, Math.imul(_seed ^ 7456, 38583) | 1) & 7) - 1)];
|
|
129
57
|
}
|