@syferit/llvm 1.0.2 → 2.0.0
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 +29 -9
- package/dist/index.d.ts +6 -1
- package/dist/index.js +65 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://syferit.soltrixstudios.com">
|
|
3
|
-
<img src="
|
|
3
|
+
<img src="https://syferit.soltrixstudios.com/icon.png" alt="Syferit Logo" width="80" height="80" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<h1 align="center">@syferit/llvm</h1>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<strong>Native C/C++/Rust/
|
|
10
|
+
<strong>Native C/C++/Rust, C# (.NET/Unity), Mobile (Android/iOS/Flutter) & LLVM IR Defense Engine (v2.0.0)</strong><br>
|
|
11
11
|
<em>“Don't Just Ship it. Syferit.”</em>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
@@ -18,23 +18,43 @@
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
npm i @syferit/llvm
|
|
21
|
+
npm i -D @syferit/llvm
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Quickstart
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
protectLlvmIr,
|
|
29
|
+
protectNativeSource,
|
|
30
|
+
protectCSharp,
|
|
31
|
+
protectKotlin,
|
|
32
|
+
protectJava,
|
|
33
|
+
protectSwift,
|
|
34
|
+
protectDart
|
|
35
|
+
} from '@syferit/llvm';
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
const
|
|
37
|
+
// 1. Protect LLVM IR (.ll)
|
|
38
|
+
const hardenedIr = protectLlvmIr(rawLlvmIr, { domainProfile: 'fintech' });
|
|
39
|
+
|
|
40
|
+
// 2. Protect C / C++ / Rust / Objective-C source files
|
|
41
|
+
const hardenedCpp = protectNativeSource(cppSource, {
|
|
42
|
+
targetLanguage: 'cpp',
|
|
43
|
+
domainProfile: 'security'
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// 3. Protect C# (.NET / Unity), Android (Kotlin / Java), iOS (Swift), Flutter (Dart)
|
|
47
|
+
const hardenedCs = protectCSharp(csSource, { domainProfile: 'gaming' });
|
|
48
|
+
const hardenedKt = protectKotlin(kotlinSource, { domainProfile: 'fintech' });
|
|
49
|
+
const hardenedSwift = protectSwift(swiftSource, { domainProfile: 'saas' });
|
|
50
|
+
const hardenedDart = protectDart(dartSource, { domainProfile: 'saas' });
|
|
31
51
|
```
|
|
32
52
|
|
|
33
53
|
## Features
|
|
34
54
|
|
|
35
|
-
- **
|
|
36
|
-
- **
|
|
37
|
-
- **Zero Runtime Dependencies:**
|
|
55
|
+
- **Decompiler & SMT Solver Resistance:** Neutralizes NSA Ghidra, IDA Pro, ILSpy, dnSpy, JADX, and Z3/Bitwuzla with non-linear RNS-ARX entanglement and temporal anti-debug guards.
|
|
56
|
+
- **Load-Bearing Trade-Secret Attestation:** Cryptographically binds statutory legal markers into `.rodata` / `.rdata` and static enclave objects.
|
|
57
|
+
- **Zero Runtime Dependencies:** Produces 100% standard, compiler-ready source and SSA IR modules.
|
|
38
58
|
|
|
39
59
|
## Documentation & Support
|
|
40
60
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// [Protected by Soltrix Studios | Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
2
2
|
import type { SyferitOptions } from '@syferit/core';
|
|
3
|
-
export type NativeTargetLanguage = 'llvm-ir' | 'c' | 'cpp' | 'rust';
|
|
3
|
+
export type NativeTargetLanguage = 'llvm-ir' | 'c' | 'cpp' | 'rust' | 'csharp' | 'kotlin' | 'java' | 'swift' | 'dart';
|
|
4
4
|
export interface NativeProtectionOptions extends SyferitOptions {
|
|
5
5
|
targetLanguage?: NativeTargetLanguage;
|
|
6
6
|
}
|
|
@@ -21,3 +21,8 @@ export declare class NativeSourceTransformer {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function protectLlvmIr(irCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
23
23
|
export declare function protectNativeSource(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
24
|
+
export declare function protectCSharp(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
25
|
+
export declare function protectKotlin(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
26
|
+
export declare function protectJava(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
27
|
+
export declare function protectSwift(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
|
28
|
+
export declare function protectDart(sourceCode: string, options?: NativeProtectionOptions): NativeTransformResult;
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,70 @@
|
|
|
1
1
|
// [Protected by Soltrix Studios | Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
2
|
-
import{SeededPRNG as
|
|
3
|
-
${
|
|
4
|
-
`,
|
|
5
|
-
`)}if(
|
|
6
|
-
`)}let
|
|
7
|
-
`)});if(
|
|
8
|
-
`,
|
|
9
|
-
`),
|
|
2
|
+
import{SeededPRNG as ot,WasmMathCore as yt,buildPolymorphicDictionary as bt}from"@syferit/core";var nt=class{options;prng;mathCore;seed;constructor(n={}){this.options=n,this.seed=typeof n.seed=="number"?n.seed:typeof n.seed=="string"&&n.seed.trim()!==""?ot.hashString(n.seed):ot.generateCryptoSeed(),this.prng=new ot(this.seed),this.mathCore=yt.getInstance()}transform(n){if(this.options.mode==="development")return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let l=n.replace(/^\s*;.*$/gm,""),U=[],z=/define\s+[^@]*@([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,m;for(;(m=z.exec(l))!==null;)m[1]&&m[1].length>=4&&U.push(m[1]);let $=bt(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),S=this.prng.pick($.legalInoculations),Z=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,D=`${S} [ATTESTATION_ID:${Z}]`,s=(this.prng.nextUint32()&65535).toString(16),i=`${this.prng.pick($.symbols)}_${s}`,F=`${this.prng.pick($.stateKeys)}_${s}`,I=this.prng.nextUint32()&2147483646|1,v=this.mathCore.computeStringKey(D,I),w=0,A=1,j=l.replace(/(define\s+[^@{]+@[a-zA-Z0-9_$.]+\s*\([^)]*\)[^{]*\{)([\s\S]*?)(\n\})/g,(T,P,B,q)=>{w++;let O=`%${F}_k${w}`,V=B.match(/^(\s*[a-zA-Z0-9_$.]+:\s*\n)/),f=`
|
|
3
|
+
${O} = call i32 @${i}(i32 ${I})
|
|
4
|
+
`,h=B.replace(/^(\s*)(%[a-zA-Z0-9_$.]+)\s*=\s*(add|sub|xor)(?:\s+nsw|\s+nuw)*\s+i32\s+([^,\n]+),\s*([^\n]+)$/gm,(r,t,e,c,u,x)=>{let _=u.trim(),p=x.trim(),a=A++,o=[];if(/^-?\d+$/.test(p)){let W=parseInt(p,10)|0,H=this.prng.nextUint32()&2147483646|1,J=W^H|0,Q=H^v|0,tt=`%_m_kxor_${a}`,et=`%_m_const_${a}`;o.push(`${t}${tt} = xor i32 ${O}, ${Q}`),o.push(`${t}${et} = xor i32 ${J}, ${tt}`),p=et}if(c==="add"){let W=`%_m_axor_${a}`,H=`%_m_aand_${a}`,J=`%_m_ashl_${a}`,Q=`%_m_abase_${a}`,tt=`%_m_u0_${a}`,et=`%_m_u1_${a}`,st=`%_m_u2_${a}`,ct=`%_m_u4_${a}`,_t=`%_m_q1_${a}`,it=`%_m_rns_${a}`,lt=`%_m_rotl_${a}`,ut=`%_m_rotr_${a}`,rt=`%_m_arx_${a}`,ft=`%_m_rnsz_${a}`,dt=`%_m_q2_${a}`,ht=`%_m_ko1_${a}`,pt=`%_m_ko2_${a}`,$t=`%_m_zinv_${a}`,gt=this.prng.pick([251,241,239,233,229]),xt=this.prng.nextUint32()&2147483646|1,mt=1^xt|0,Ft=xt^v|0;return o.push(`${t}${W} = xor i32 ${_}, ${p}`),o.push(`${t}${H} = and i32 ${_}, ${p}`),o.push(`${t}${J} = shl i32 ${H}, 1`),o.push(`${t}${Q} = add i32 ${W}, ${J}`),o.push(`${t}${tt} = xor i32 ${_}, ${O}`),o.push(`${t}${it} = urem i32 ${tt}, ${gt}`),o.push(`${t}${lt} = shl i32 ${it}, 16`),o.push(`${t}${ut} = lshr i32 ${it}, 16`),o.push(`${t}${rt} = or i32 ${lt}, ${ut}`),o.push(`${t}${ft} = sub i32 ${rt}, ${rt}`),o.push(`${t}${et} = or i32 ${tt}, 1`),o.push(`${t}${st} = mul i32 ${et}, ${et}`),o.push(`${t}${ct} = mul i32 ${st}, ${st}`),o.push(`${t}${_t} = and i32 ${ct}, 15`),o.push(`${t}${dt} = add i32 ${_t}, ${ft}`),o.push(`${t}${ht} = xor i32 ${O}, ${Ft}`),o.push(`${t}${pt} = xor i32 ${mt}, ${ht}`),o.push(`${t}${$t} = xor i32 ${dt}, ${pt}`),o.push(`${t}${e} = add i32 ${Q}, ${$t}`),o.join(`
|
|
5
|
+
`)}if(c==="sub"){let W=`%_m_sxor_${a}`,H=`%_m_snot_${a}`,J=`%_m_sand_${a}`,Q=`%_m_sshl_${a}`;return o.push(`${t}${W} = xor i32 ${_}, ${p}`),o.push(`${t}${H} = xor i32 ${_}, -1`),o.push(`${t}${J} = and i32 ${H}, ${p}`),o.push(`${t}${Q} = shl i32 ${J}, 1`),o.push(`${t}${e} = sub i32 ${W}, ${Q}`),o.join(`
|
|
6
|
+
`)}let R=`%_m_xor_or_${a}`,G=`%_m_xor_and_${a}`;return o.push(`${t}${R} = or i32 ${_}, ${p}`),o.push(`${t}${G} = and i32 ${_}, ${p}`),o.push(`${t}${e} = sub i32 ${R}, ${G}`),o.join(`
|
|
7
|
+
`)});if(V){let r=V[1],t=h.slice(r.length);return`${P}${r}${f}${t}${q}`}return`${P}${f}${h}${q}`});if(w===0)return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let d=Buffer.from(D,"utf-8"),k=d.length+1,g=D.replace(/\\/g,"\\\\").replace(/"/g,"\\22"),y=I>>>0;for(let T=0;T<d.length;T++)y=Math.imul(y^d[T],16777619)>>>0;let M=(v|0)-(y|0)|0,K=[],E=j.replace(/^(source_filename|target datalayout|target triple)\s*=.*$/gm,T=>(K.push(T),"")),b=E.includes("@llvm.trap")?"":`declare void @llvm.trap()
|
|
8
|
+
`,N=["; [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]",`@.syferit.legal.attestation_${s} = private unnamed_addr constant [${k} x i8] c"${g}\\00", align 1`,`@llvm.compiler.used = appending global [1 x ptr] [ptr @.syferit.legal.attestation_${s}], section "llvm.metadata"`,"",b?b.trimEnd():"","",`define internal i32 @${i}(i32 %_tok) noinline optnone {`,"entry:"," br label %hash.loop","","hash.loop:"," %_idx = phi i32 [ 0, %entry ], [ %_next_idx, %hash.loop ]"," %_acc = phi i32 [ %_tok, %entry ], [ %_next_acc, %hash.loop ]",` %_gep = getelementptr inbounds i8, ptr @.syferit.legal.attestation_${s}, i32 %_idx`," %_byte = load volatile i8, ptr %_gep, align 1"," %_zbyte = zext i8 %_byte to i32"," %_x = xor i32 %_acc, %_zbyte"," %_next_acc = mul i32 %_x, 16777619"," %_next_idx = add nuw nsw i32 %_idx, 1",` %_done = icmp eq i32 %_next_idx, ${d.length}`," br i1 %_done, label %hash.check, label %hash.loop","","hash.check:",` %_match = icmp eq i32 %_next_acc, ${y|0}`," br i1 %_match, label %hash.ok, label %tamper.trap","","tamper.trap:"," call void @llvm.trap()"," unreachable","","hash.ok:",` %_key = add i32 %_next_acc, ${M|0}`," ret i32 %_key","}",""].filter(T=>T!=="").join(`
|
|
9
|
+
`),C="";return K.length>0?C=K.join(`
|
|
10
10
|
`)+`
|
|
11
11
|
|
|
12
|
-
`+
|
|
13
|
-
`+
|
|
14
|
-
${
|
|
15
|
-
`)});return{code:`${["/* [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com] */","#if defined(__GNUC__) || defined(__clang__)"," #define SYFERIT_USED __attribute__((used))"," #define SYFERIT_NOINLINE __attribute__((noinline))","#elif defined(_MSC_VER)"," #define SYFERIT_USED"," #define SYFERIT_NOINLINE __declspec(noinline)","#else"," #define SYFERIT_USED"," #define SYFERIT_NOINLINE","#endif","",`SYFERIT_USED static const char _syferit_attestation_${s}[] = "${
|
|
12
|
+
`+N+`
|
|
13
|
+
`+E.trimStart():C=`${N}
|
|
14
|
+
${E}`,{code:C,transformedCount:w,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:v>>>0}}};import{SeededPRNG as at,WasmMathCore as St,buildPolymorphicDictionary as X}from"@syferit/core";var Y=class{options;prng;mathCore;seed;constructor(n={}){this.options=n,this.seed=typeof n.seed=="number"?n.seed:typeof n.seed=="string"&&n.seed.trim()!==""?at.hashString(n.seed):at.generateCryptoSeed(),this.prng=new at(this.seed),this.mathCore=St.getInstance()}transform(n,l="cpp"){return this.options.mode==="development"?{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0}:l==="rust"?this.transformRust(n):l==="csharp"?this.transformCSharp(n):l==="kotlin"?this.transformKotlin(n):l==="java"?this.transformJava(n):l==="swift"?this.transformSwift(n):l==="dart"?this.transformDart(n):this.transformCCpp(n)}transformCCpp(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\b([a-zA-Z_][a-zA-Z0-9_]{3,20})\b/g,m;for(;(m=z.exec(l))!==null;){let E=m[1];["int","void","char","float","double","return","const","static","struct","class","public","private","uint32_t","include"].includes(E)||U.push(E)}let $=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),S=this.prng.pick($.legalInoculations),Z=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,D=`${S} [ATTESTATION_ID:${Z}]`,s=(this.prng.nextUint32()&65535).toString(16),i=`${this.prng.pick($.symbols)}_${s}`,F=`${this.prng.pick($.stateKeys)}_${s}`,I=`_fold_carry_${s}`,v=`_unmask_scalar_${s}`,w=`_verify_quorum_${s}`,A=`${this.prng.pick($.symbols)}_decoy_${s}`,j=this.prng.nextUint32()&2147483646|1,d=this.mathCore.computeStringKey(D,j),k=d>>>4&15,g=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),y=0,M=l.replace(/(\b(?:int|long|short|unsigned|uint32_t|int32_t|uint64_t|int64_t|double|float|bool|auto)\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^;{}]*\)\s*\{)/g,E=>{y++;let b=this.prng.nextUint32()&2147483646|1,N=(1^b)>>>0,C=(b^d)>>>0;return[E,` const unsigned int ${F} = ${i}(${j}u);`,` if (${w}(${F}, ${N}u, ${C}u) == 0u) { return ${A}(${F}); }`].join(`
|
|
15
|
+
`)});return{code:`${["/* [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com] */","#if defined(__GNUC__) || defined(__clang__)"," #define SYFERIT_USED __attribute__((used))"," #define SYFERIT_NOINLINE __attribute__((noinline))","#elif defined(_MSC_VER)"," #define SYFERIT_USED"," #define SYFERIT_NOINLINE __declspec(noinline)","#else"," #define SYFERIT_USED"," #define SYFERIT_NOINLINE","#endif","",`SYFERIT_USED static const char _syferit_attestation_${s}[] = "${g}";`,"",`SYFERIT_NOINLINE static unsigned int ${i}(unsigned int _tok) {`," unsigned int _h = (2166136261u ^ _tok);",` for (unsigned int _i = 0; _syferit_attestation_${s}[_i] != '\\0'; ++_i) {`,` _h ^= (unsigned char)_syferit_attestation_${s}[_i];`," _h *= 16777619u;"," _h ^= (_h >> 13);"," }"," _h = (_h ^ (_h >> 16)) * 2246822507u;"," _h = (_h ^ (_h >> 13)) * 3266489909u;"," _h = (_h ^ (_h >> 16));"," if ((_h & 0xFFFFu) == 0u) _h |= 0x1337u;"," if (((_h >> 16) & 0xFFFFu) == 0u) _h |= 0x73310000u;",` if (((_h >> 4) & 0xFu) != ${k}u) {`," volatile int *_trap = (volatile int *)0; *_trap = 0;"," }"," return _h;","}","",`static inline unsigned int ${v}(unsigned int _c1, unsigned int _c2, unsigned int _k) {`," return _c1 ^ (_k ^ _c2);","}","",`static inline unsigned int ${I}(unsigned int _x, unsigned int _y) {`," return (_x ^ _y) + ((_x & _y) << 1u);","}","",`static inline unsigned int ${w}(unsigned int _k, unsigned int _c1, unsigned int _c2) {`," unsigned int _r0 = _k % 251u, _r1 = _k % 241u, _r2 = _k % 239u;"," unsigned int _arx = ((_r0 + _r1) << 16u) | ((_r0 + _r1) >> 16u) ^ _r2;"," unsigned int _u = (_k ^ (_arx - _arx)) | 1u;"," unsigned int _u2 = _u * _u;"," unsigned int _u4 = _u2 * _u2;",` unsigned int _expected = ${v}(_c1, _c2, _k);`," return ((_u4 & 15u) == _expected) ? 1u : 0u;","}","",`SYFERIT_NOINLINE static int ${A}(unsigned int _k) {`,` unsigned int _acc = ${I}(_k, 0x5A17E9B3u);`," return (int)(_acc ^ 0xDEADBEEFu);","}",""].join(`
|
|
16
16
|
`)}
|
|
17
|
-
${
|
|
18
|
-
`)});return{code:`${["// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]","#[used]",`static _SYFERIT_ATTESTATION_${s.toUpperCase()}: &[u8] = b"${
|
|
17
|
+
${M}`,transformedCount:y,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:d>>>0}}transformRust(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\bfn\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,m;for(;(m=z.exec(l))!==null;)m[1]&&m[1].length>=4&&U.push(m[1]);let $=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),S=this.prng.pick($.legalInoculations),Z=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,D=`${S} [ATTESTATION_ID:${Z}]`,s=(this.prng.nextUint32()&65535).toString(16),i=`${this.prng.pick($.symbols)}_${s}`.toLowerCase(),F=`${this.prng.pick($.stateKeys)}_${s}`.toLowerCase(),I=`_verify_quorum_${s}`,v=`_fold_carry_${s}`,w=this.prng.nextUint32()&2147483646|1,A=this.mathCore.computeStringKey(D,w),j=A>>>4&15,d=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),k=0,g=l.replace(/(\b(?:pub\s+)?fn\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^{;]*\)(?:\s*->\s*[^{;]+)?\s*\{)/g,M=>{k++;let K=this.prng.nextUint32()&2147483646|1,E=(1^K)>>>0,b=(K^A)>>>0;return[M,` let ${F}: u32 = ${i}(${w}u32);`,` if !${I}(${F}, ${E}u32, ${b}u32) { panic!("ASSERTION_INVARIANT: State quorum mismatch"); }`].join(`
|
|
18
|
+
`)});return{code:`${["// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]","#[used]",`static _SYFERIT_ATTESTATION_${s.toUpperCase()}: &[u8] = b"${d}\\0";`,"","#[inline(never)]",`fn ${i}(_tok: u32) -> u32 {`," let mut _h: u32 = 2166136261u32 ^ _tok;"," let mut _i: usize = 0;",` while _i + 1 < _SYFERIT_ATTESTATION_${s.toUpperCase()}.len() {`,` _h ^= _SYFERIT_ATTESTATION_${s.toUpperCase()}[_i] as u32;`," _h = _h.wrapping_mul(16777619u32);"," _h ^= _h >> 13;"," _i += 1;"," }"," _h = (_h ^ (_h >> 16)).wrapping_mul(2246822507u32);"," _h = (_h ^ (_h >> 13)).wrapping_mul(3266489909u32);"," _h = _h ^ (_h >> 16);"," if (_h & 0xFFFFu32) == 0 { _h |= 0x1337u32; }"," if ((_h >> 16) & 0xFFFFu32) == 0 { _h |= 0x73310000u32; }",` if ((_h >> 4) & 0xFu32) != ${j}u32 {`,' panic!("ASSERTION_INVARIANT: Attestation keyframe corrupted");'," }"," _h","}","","#[inline(always)]",`fn ${v}(_x: u32, _y: u32) -> u32 {`," (_x ^ _y).wrapping_add((_x & _y) << 1)","}","","#[inline(always)]",`fn ${I}(_k: u32, _c1: u32, _c2: u32) -> bool {`," let _r0: u32 = _k % 251u32;"," let _r1: u32 = _k % 241u32;"," let _arx: u32 = (_r0.wrapping_add(_r1)).rotate_left(16);"," let _u: u32 = (_k ^ _arx.wrapping_sub(_arx)) | 1u32;"," let _u2: u32 = _u.wrapping_mul(_u);"," let _u4: u32 = _u2.wrapping_mul(_u2);"," let _expected: u32 = _c1 ^ (_k ^ _c2);",` (_u4 & 15u32) == ${v}(_expected, 0u32)`,"}",""].join(`
|
|
19
19
|
`)}
|
|
20
|
-
${
|
|
20
|
+
${g}`,transformedCount:k,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:A>>>0}}transformCSharp(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\b([a-zA-Z_][a-zA-Z0-9_]{3,20})\b/g,m,$=new Set(["using","namespace","class","struct","interface","public","private","protected","internal","static","readonly","const","void","int","uint","long","ulong","short","ushort","byte","bool","string","float","double","decimal","var","return","if","else","for","foreach","while","switch","case","break","new","true","false","null","this","base","virtual","override","async","await"]);for(;(m=z.exec(l))!==null;){let e=m[1];$.has(e)||U.push(e)}let S=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),Z=this.prng.pick(S.legalInoculations),D=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,s=`${Z} [ATTESTATION_ID:${D}]`,i=(this.prng.nextUint32()&65535).toString(16),F=`_SyferitEnclave_${i}`,I=`_syferit_attestation_${i}`,v=`_enclave_matrix_${i}`,w=`${this.prng.pick(S.symbols)}_${i}`,A=`_unseal_slot_${i}`,j=`_verify_quorum_${i}`,d=`_fold_carry_${i}`,k=`_${this.prng.pick(S.stateKeys).replace(/^_+/,"")}_${i}`,g=this.prng.nextUint32()&2147483646|1,y=this.mathCore.computeStringKey(s,g),M=y>>>4&15,K=this.prng.pick(S.assertions),E=s.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),b=K.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),N=[],C=e=>{let c=N.length,u=e.split("").map((o,R)=>{let G=(y>>>(R&3)*8)+Math.imul(R+c,37)&255;return(o.charCodeAt(0)^G)&255});N.push(u);let x=(y&65535)>>>0,_=x^this.prng.nextRange(256,32767),p=c^_,a=_^x;return`${F}.${A}((int)(${p}u ^ ((${k} & 0xFFFFu) ^ ${a}u)), ${k})`},T=0,P=/(\b(?:public|private|protected|internal|static|virtual|override|sealed|extern|unsafe|new|\s)+\s+(?:int|uint|long|ulong|short|ushort|byte|bool|string|float|double|decimal|void|object|[A-Z][a-zA-Z0-9_<>[\]]*)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^;{}]*\)\s*\{)/g,B=l.replace(P,(e,c,u)=>{if($.has(u))return e;T++;let x=this.prng.nextUint32()&2147483646|1,_=(1^x)>>>0,p=(x^y)>>>0;return[e,` uint ${k} = ${F}.${w}(${g}u);`,` if (!${F}.${j}(${k}, ${_}u, ${p}u)) { throw new System.InvalidOperationException("${b}"); }`].join(`
|
|
21
|
+
`)});if(T===0)return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let O=B.split(/\r?\n/).map(e=>{let c=e.trim();if(c.startsWith("using ")||c.startsWith("[")||c.startsWith("namespace ")||c.includes("class ")||c.includes(F)||c.includes("const ")||c.includes("case "))return e;let u=e;return u=u.replace(/(?<![$@])"([^"\\\n]{3,40})"/g,(x,_)=>C(_)),u=u.replace(/(\breturn\s+|\s=\s*|\s\+\s*|\s-\s*|\s\*\s*)([1-9]\d{0,6})\b(?!\s*[.fFdDmMuUlL])/g,(x,_,p)=>{let a=parseInt(p,10),o=(y&65535)>>>0,R=o^this.prng.nextRange(256,32767),G=a^R,W=R^o;return`${_}((int)(${G}u ^ ((${k} & 0xFFFFu) ^ ${W}u)))`}),u});if(N.length<4)for(let e of S.decoyTierStrings.slice(0,2))C(e);let V=N.map(e=>` new byte[] { ${e.join(", ")} }`).join(`,
|
|
22
|
+
`),f=[`internal static class ${F}`,"{",` public static readonly string ${I} = "${E}";`,` private static readonly byte[][] ${v} = new byte[][]`," {",V," };",""," [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]",` public static uint ${w}(uint _tok)`," {"," unchecked"," {"," long _t0 = System.Diagnostics.Stopwatch.GetTimestamp();"," uint _h = 2166136261u ^ _tok;",` string _att = ${I};`," for (int _i = 0; _i < _att.Length; _i++)"," {"," _h ^= (uint)_att[_i];"," _h *= 16777619u;"," _h ^= (_h >> 13);"," }"," _h = (_h ^ (_h >> 16)) * 2246822507u;"," _h = (_h ^ (_h >> 13)) * 3266489909u;"," _h = _h ^ (_h >> 16);"," if ((_h & 0xFFFFu) == 0u) _h |= 0x1337u;"," if (((_h >> 16) & 0xFFFFu) == 0u) _h |= 0x73310000u;"," long _dt = System.Diagnostics.Stopwatch.GetTimestamp() - _t0;"," if (_dt > System.Diagnostics.Stopwatch.Frequency * 3L) _h ^= 0x5A17E9B3u;",` if (((_h >> 4) & 0xFu) != ${M}u)`," {",` throw new System.InvalidOperationException("${b}");`," }"," return _h;"," }"," }","",` public static uint ${d}(uint _x, uint _y)`," {"," unchecked { return (_x ^ _y) + ((_x & _y) << 1); }"," }","",` public static bool ${j}(uint _k, uint _c1, uint _c2)`," {"," unchecked"," {"," uint _r0 = _k % 251u, _r1 = _k % 241u, _r2 = _k % 239u;"," uint _sum = _r0 + _r1;"," uint _arx = ((_sum << 16) | (_sum >> 16)) ^ _r2;"," uint _u = (_k ^ (_arx - _arx)) | 1u;"," uint _u2 = _u * _u;"," uint _u4 = _u2 * _u2;"," uint _expected = _c1 ^ (_k ^ _c2);",` return (_u4 & 15u) == ${d}(_expected, 0u);`," }"," }","",` public static string ${A}(int _slot, uint _k)`," {"," unchecked"," {",` byte[] _row = ${v}[_slot];`," char[] _chars = new char[_row.Length];"," for (int _idx = 0; _idx < _row.Length; _idx++)"," {"," uint _byteKey = ((_k >> ((_idx & 3) * 8)) + (uint)((_idx + _slot) * 37)) & 0xFFu;"," _chars[_idx] = (char)((_row[_idx] ^ _byteKey) & 0xFFu);"," }"," return new string(_chars);"," }"," }","}"].join(`
|
|
23
|
+
`),h=O.join(`
|
|
24
|
+
`),r="// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]",t;if(/\bnamespace\s+[a-zA-Z0-9_.]+\s*\{/.test(h)){let e=h.lastIndexOf("}");e!==-1?t=`${r}
|
|
25
|
+
${h.slice(0,e)}
|
|
26
|
+
${f}
|
|
27
|
+
}
|
|
28
|
+
`:t=`${r}
|
|
29
|
+
${h}
|
|
30
|
+
${f}
|
|
31
|
+
`}else t=`${r}
|
|
32
|
+
${h}
|
|
33
|
+
|
|
34
|
+
${f}
|
|
35
|
+
`;return{code:t,transformedCount:T,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:y>>>0}}transformKotlin(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\bfun\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,m;for(;(m=z.exec(l))!==null;)m[1]&&m[1].length>=4&&U.push(m[1]);let $=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),S=this.prng.pick($.legalInoculations),Z=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,D=`${S} [ATTESTATION_ID:${Z}]`,s=(this.prng.nextUint32()&65535).toString(16),i=`_SyferitEnclave_${s}`,F=`_syferit_attestation_${s}`,I=`_enclave_matrix_${s}`,v=`${this.prng.pick($.symbols)}_${s}`,w=`_unseal_slot_${s}`,A=`_verify_quorum_${s}`,j=`_fold_carry_${s}`,d=`_${this.prng.pick($.stateKeys).replace(/^_+/,"")}_${s}`,k=this.prng.nextUint32()&2147483646|1,g=this.mathCore.computeStringKey(D,k),y=g>>>4&15,M=this.prng.pick($.assertions),K=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),E=M.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),b=[],N=f=>{let h=b.length,r=f.split("").map((x,_)=>{let p=(g>>>(_&3)*8)+Math.imul(_+h,37)&255;return(x.charCodeAt(0)^p)&255});b.push(r);let t=(g&65535)>>>0,e=t^this.prng.nextRange(256,32767),c=h^e,u=e^t;return`${i}.${w}((${c}u xor ((${d} and 0xFFFFu) xor ${u}u)).toInt(), ${d})`},C=0,T=l.replace(/(\b(?:public|private|internal|protected|override|suspend|inline|\s)*\bfun\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^{;]*\)(?:\s*:\s*[^{;=]+)?\s*\{)/g,f=>{C++;let h=this.prng.nextUint32()&2147483646|1,r=(1^h)>>>0,t=(h^g)>>>0;return[f,` val ${d}: UInt = ${i}.${v}(${k}u)`,` if (!${i}.${A}(${d}, ${r}u, ${t}u)) { throw IllegalStateException("${E}") }`].join(`
|
|
36
|
+
`)});if(C===0)return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let B=T.split(/\r?\n/).map(f=>{let h=f.trim();if(h.startsWith("package ")||h.startsWith("import ")||h.startsWith("@")||h.includes(i)||h.startsWith("const "))return f;let r=f;return r=r.replace(/"([^"\\$\n]{3,40})"/g,(t,e)=>N(e)),r=r.replace(/(\breturn\s+|\s=\s*|\s\+\s*|\s-\s*|\s\*\s*)([1-9]\d{0,6})\b(?!\s*[.fFuUlL])/g,(t,e,c)=>{let u=parseInt(c,10),x=(g&65535)>>>0,_=x^this.prng.nextRange(256,32767),p=u^_,a=_^x;return`${e}((${p}u xor ((${d} and 0xFFFFu) xor ${a}u)).toInt())`}),r});if(b.length<4)for(let f of $.decoyTierStrings.slice(0,2))N(f);let q=b.map(f=>` intArrayOf(${f.join(", ")})`).join(`,
|
|
37
|
+
`),O=[`internal object ${i} {`,` const val ${F}: String = "${K}"`,` private val ${I}: Array<IntArray> = arrayOf(`,q," )","",` fun ${v}(_tok: UInt): UInt {`," val _t0 = System.nanoTime()"," var _h: UInt = 2166136261u xor _tok",` for (_ch in ${F}) {`," _h = _h xor _ch.code.toUInt()"," _h = _h * 16777619u"," _h = _h xor (_h shr 13)"," }"," _h = (_h xor (_h shr 16)) * 2246822507u"," _h = (_h xor (_h shr 13)) * 3266489909u"," _h = _h xor (_h shr 16)"," if ((_h and 0xFFFFu) == 0u) _h = _h or 0x1337u"," if (((_h shr 16) and 0xFFFFu) == 0u) _h = _h or 0x73310000u"," if (System.nanoTime() - _t0 > 3000000000L) _h = _h xor 0x5A17E9B3u",` if (((_h shr 4) and 0xFu) != ${y}u) {`,` throw IllegalStateException("${E}")`," }"," return _h"," }","",` fun ${j}(_x: UInt, _y: UInt): UInt = (_x xor _y) + ((_x and _y) shl 1)`,"",` fun ${A}(_k: UInt, _c1: UInt, _c2: UInt): Boolean {`," val _r0 = _k % 251u"," val _r1 = _k % 241u"," val _r2 = _k % 239u"," val _sum = _r0 + _r1"," val _arx = ((_sum shl 16) or (_sum shr 16)) xor _r2"," val _u = (_k xor (_arx - _arx)) or 1u"," val _u2 = _u * _u"," val _u4 = _u2 * _u2"," val _expected = _c1 xor (_k xor _c2)",` return (_u4 and 15u) == ${j}(_expected, 0u)`," }","",` fun ${w}(_slot: Int, _k: UInt): String {`,` val _row = ${I}[_slot]`," val _chars = CharArray(_row.size)"," for (_idx in _row.indices) {"," val _byteKey = (((_k shr ((_idx and 3) * 8)) + ((_idx + _slot).toUInt() * 37u)) and 0xFFu).toInt()"," _chars[_idx] = ((_row[_idx] xor _byteKey) and 0xFF).toChar()"," }"," return String(_chars)"," }","}"].join(`
|
|
38
|
+
`);return{code:`// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
39
|
+
${B.join(`
|
|
40
|
+
`)}
|
|
41
|
+
|
|
42
|
+
${O}
|
|
43
|
+
`,transformedCount:C,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:g>>>0}}transformJava(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\b([a-zA-Z_][a-zA-Z0-9_]{3,20})\b/g,m,$=new Set(["package","import","public","private","protected","static","final","abstract","synchronized","volatile","native","class","interface","enum","extends","implements","void","int","long","short","byte","boolean","char","float","double","String","Object","return","if","else","for","while","switch","case","break","new","true","false","null","this","super","try","catch","finally","throw","throws"]);for(;(m=z.exec(l))!==null;){let e=m[1];$.has(e)||U.push(e)}let S=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),Z=this.prng.pick(S.legalInoculations),D=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,s=`${Z} [ATTESTATION_ID:${D}]`,i=(this.prng.nextUint32()&65535).toString(16),F=`_syferit_attestation_${i}`,I=`_enclave_matrix_${i}`,v=`${this.prng.pick(S.symbols)}_${i}`,w=`_unseal_slot_${i}`,A=`_verify_quorum_${i}`,j=`_fold_carry_${i}`,d=`_${this.prng.pick(S.stateKeys).replace(/^_+/,"")}_${i}`,k=this.prng.nextUint32()&2147483646|1,g=this.mathCore.computeStringKey(s,k),y=g>>>4&15,M=this.prng.pick(S.assertions),K=s.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),E=M.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),b=[],N=e=>{let c=b.length,u=e.split("").map((o,R)=>{let G=(g>>>(R&3)*8)+Math.imul(R+c,37)&255;return(o.charCodeAt(0)^G)&255});b.push(u);let x=(g&65535)>>>0,_=x^this.prng.nextRange(256,32767),p=c^_,a=_^x;return`${w}(${p} ^ ((${d} & 0xFFFF) ^ ${a}), ${d})`},C=0,T=/(\b(?:public|private|protected|static|final|synchronized|\s)+\s+(?:int|long|short|byte|boolean|char|float|double|void|String|Object|[A-Z][a-zA-Z0-9_<>[\]]*)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^;{}]*\)\s*(?:throws\s+[a-zA-Z0-9_,\s]+)?\{)/g,P=l.replace(T,(e,c,u)=>{if($.has(u))return e;C++;let x=this.prng.nextUint32()&2147483646|1,_=1^x|0,p=x^g|0;return[e,` final int ${d} = ${v}(${k|0});`,` if (!${A}(${d}, ${_}, ${p})) { throw new IllegalStateException("${E}"); }`].join(`
|
|
44
|
+
`)});if(C===0)return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let q=P.split(/\r?\n/).map(e=>{let c=e.trim();if(c.startsWith("package ")||c.startsWith("import ")||c.startsWith("@")||c.includes("class ")||c.includes(v)||c.includes(A)||c.includes("final "))return e;let u=e;return u=u.replace(/"([^"\\\n]{3,40})"/g,(x,_)=>N(_)),u=u.replace(/(\breturn\s+|\s=\s*|\s\+\s*|\s-\s*|\s\*\s*)([1-9]\d{0,6})\b(?!\s*[.fFdDlL])/g,(x,_,p)=>{let a=parseInt(p,10),o=(g&65535)>>>0,R=o^this.prng.nextRange(256,32767),G=a^R,W=R^o;return`${_}(${G} ^ ((${d} & 0xFFFF) ^ ${W}))`}),u});if(b.length<4)for(let e of S.decoyTierStrings.slice(0,2))N(e);let O=b.map(e=>` { ${e.join(", ")} }`).join(`,
|
|
45
|
+
`),V=[` public static final String ${F} = "${K}";`,` private static final int[][] ${I} = new int[][] {`,O," };","",` public static int ${v}(int _tok) {`," long _t0 = System.nanoTime();"," int _h = (-2128831035 ^ _tok);",` String _att = ${F};`," for (int _i = 0; _i < _att.length(); _i++) {"," _h ^= (int)_att.charAt(_i);"," _h *= 16777619;"," _h ^= (_h >>> 13);"," }"," _h = (_h ^ (_h >>> 16)) * -2048144789;"," _h = (_h ^ (_h >>> 13)) * -1028477387;"," _h = _h ^ (_h >>> 16);"," if ((_h & 0xFFFF) == 0) _h |= 0x1337;"," if (((_h >>> 16) & 0xFFFF) == 0) _h |= 0x73310000;"," if (System.nanoTime() - _t0 > 3000000000L) _h ^= 0x5A17E9B3;",` if (((_h >>> 4) & 0xF) != ${y}) {`,` throw new IllegalStateException("${E}");`," }"," return _h;"," }","",` public static int ${j}(int _x, int _y) {`," return (_x ^ _y) + ((_x & _y) << 1);"," }","",` public static boolean ${A}(int _k, int _c1, int _c2) {`," int _r0 = Integer.remainderUnsigned(_k, 251);"," int _r1 = Integer.remainderUnsigned(_k, 241);"," int _r2 = Integer.remainderUnsigned(_k, 239);"," int _arx = Integer.rotateLeft(_r0 + _r1, 16) ^ _r2;"," int _u = (_k ^ (_arx - _arx)) | 1;"," int _u2 = _u * _u;"," int _u4 = _u2 * _u2;"," int _expected = _c1 ^ (_k ^ _c2);",` return (_u4 & 15) == ${j}(_expected, 0);`," }","",` public static String ${w}(int _slot, int _k) {`,` int[] _row = ${I}[_slot];`," char[] _chars = new char[_row.length];"," for (int _idx = 0; _idx < _row.length; _idx++) {"," int _byteKey = ((_k >>> ((_idx & 3) * 8)) + ((_idx + _slot) * 37)) & 0xFF;"," _chars[_idx] = (char)((_row[_idx] ^ _byteKey) & 0xFF);"," }"," return new String(_chars);"," }"].join(`
|
|
46
|
+
`),f=q.join(`
|
|
47
|
+
`),h="// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]",r=f.lastIndexOf("}");return{code:r!==-1?`${h}
|
|
48
|
+
${f.slice(0,r)}
|
|
49
|
+
${V}
|
|
50
|
+
}
|
|
51
|
+
`:`${h}
|
|
52
|
+
${f}
|
|
53
|
+
${V}
|
|
54
|
+
`,transformedCount:C,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:g>>>0}}transformSwift(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\bfunc\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,m;for(;(m=z.exec(l))!==null;)m[1]&&m[1].length>=4&&U.push(m[1]);let $=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),S=this.prng.pick($.legalInoculations),Z=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,D=`${S} [ATTESTATION_ID:${Z}]`,s=(this.prng.nextUint32()&65535).toString(16),i=`_SyferitEnclave_${s}`,F=`_syferit_attestation_${s}`,I=`_enclave_matrix_${s}`,v=`${this.prng.pick($.symbols)}_${s}`,w=`_unseal_slot_${s}`,A=`_verify_quorum_${s}`,j=`_fold_carry_${s}`,d=`_${this.prng.pick($.stateKeys).replace(/^_+/,"")}_${s}`,k=this.prng.nextUint32()&2147483646|1,g=this.mathCore.computeStringKey(D,k),y=g>>>4&15,M=this.prng.pick($.assertions),K=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),E=M.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),b=[],N=f=>{let h=b.length,r=f.split("").map((x,_)=>{let p=(g>>>(_&3)*8)+Math.imul(_+h,37)&255;return(x.charCodeAt(0)^p)&255});b.push(r);let t=(g&65535)>>>0,e=t^this.prng.nextRange(256,32767),c=h^e,u=e^t;return`${i}.${w}(Int(${c} ^ ((${d} & 0xFFFF) ^ ${u})), ${d})`},C=0,T=l.replace(/(\b(?:public|private|internal|fileprivate|open|static|class|mutating|\s)*\bfunc\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^{;]*\)(?:\s*(?:throws\s*)?->\s*[^{;]+)?\s*\{)/g,f=>{C++;let h=this.prng.nextUint32()&2147483646|1,r=(1^h)>>>0,t=(h^g)>>>0;return[f,` let ${d}: UInt32 = ${i}.${v}(${k})`,` if !${i}.${A}(${d}, ${r}, ${t}) { fatalError("${E}") }`].join(`
|
|
55
|
+
`)});if(C===0)return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let B=T.split(/\r?\n/).map(f=>{let h=f.trim();if(h.startsWith("import ")||h.startsWith("@")||h.includes(i))return f;let r=f;return r=r.replace(/"([^"\\\n]{3,40})"/g,(t,e)=>N(e)),r=r.replace(/(\breturn\s+|\s=\s*|\s\+\s*|\s-\s*|\s\*\s*)([1-9]\d{0,6})\b(?!\s*\.)/g,(t,e,c)=>{let u=parseInt(c,10),x=(g&65535)>>>0,_=x^this.prng.nextRange(256,32767),p=u^_,a=_^x;return`${e}Int(${p} ^ ((${d} & 0xFFFF) ^ ${a}))`}),r});if(b.length<4)for(let f of $.decoyTierStrings.slice(0,2))N(f);let q=b.map(f=>` [${f.join(", ")}]`).join(`,
|
|
56
|
+
`),O=[`fileprivate enum ${i} {`,` static let ${F}: String = "${K}"`,` static let ${I}: [[UInt8]] = [`,q," ]",""," @inline(never)",` static func ${v}(_ _tok: UInt32) -> UInt32 {`," var _h: UInt32 = 2166136261 ^ _tok",` for _b in ${F}.utf8 {`," _h ^= UInt32(_b)"," _h = _h &* 16777619"," _h ^= (_h >> 13)"," }"," _h = (_h ^ (_h >> 16)) &* 2246822507"," _h = (_h ^ (_h >> 13)) &* 3266489909"," _h = _h ^ (_h >> 16)"," if (_h & 0xFFFF) == 0 { _h |= 0x1337 }"," if ((_h >> 16) & 0xFFFF) == 0 { _h |= 0x73310000 }",` if ((_h >> 4) & 0xF) != ${y} {`,` fatalError("${E}")`," }"," return _h"," }",""," @inline(__always)",` static func ${j}(_ _x: UInt32, _ _y: UInt32) -> UInt32 {`," return (_x ^ _y) &+ ((_x & _y) << 1)"," }",""," @inline(__always)",` static func ${A}(_ _k: UInt32, _ _c1: UInt32, _ _c2: UInt32) -> Bool {`," let _r0: UInt32 = _k % 251"," let _r1: UInt32 = _k % 241"," let _r2: UInt32 = _k % 239"," let _sum: UInt32 = _r0 &+ _r1"," let _arx: UInt32 = ((_sum << 16) | (_sum >> 16)) ^ _r2"," let _u: UInt32 = (_k ^ (_arx &- _arx)) | 1"," let _u2: UInt32 = _u &* _u"," let _u4: UInt32 = _u2 &* _u2"," let _expected: UInt32 = _c1 ^ (_k ^ _c2)",` return (_u4 & 15) == ${j}(_expected, 0)`," }","",` static func ${w}(_ _slot: Int, _ _k: UInt32) -> String {`,` let _row = ${I}[_slot]`," var _out: [UInt8] = []"," _out.reserveCapacity(_row.count)"," for (_idx, _b) in _row.enumerated() {"," let _shift = UInt32((_idx & 3) * 8)"," let _byteKey = UInt8(((_k >> _shift) &+ UInt32((_idx + _slot) * 37)) & 0xFF)"," _out.append(_b ^ _byteKey)"," }",' return String(bytes: _out, encoding: .utf8) ?? ""'," }","}"].join(`
|
|
57
|
+
`);return{code:`// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
58
|
+
${B.join(`
|
|
59
|
+
`)}
|
|
60
|
+
|
|
61
|
+
${O}
|
|
62
|
+
`,transformedCount:C,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:g>>>0}}transformDart(n){let l=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),U=[],z=/\b([a-zA-Z_][a-zA-Z0-9_]{3,20})\b/g,m,$=new Set(["import","export","library","part","class","mixin","extension","enum","typedef","void","int","double","num","bool","String","List","Map","Set","Future","Stream","dynamic","Object","var","final","const","late","static","return","if","else","for","while","do","switch","case","break","continue","new","true","false","null","this","super","async","await","yield","try","catch","finally","throw","override"]);for(;(m=z.exec(l))!==null;){let r=m[1];$.has(r)||U.push(r)}let S=X(this.options.domainProfile??"saas",this.prng,U,this.options.customDictionary??[]),Z=this.prng.pick(S.legalInoculations),D=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,s=`${Z} [ATTESTATION_ID:${D}]`,i=(this.prng.nextUint32()&65535).toString(16),F=`_SyferitEnclave_${i}`,I=`_syferit_attestation_${i}`,v=`_enclave_matrix_${i}`,w=`${this.prng.pick(S.symbols)}_${i}`,A=`_unseal_slot_${i}`,j=`_verify_quorum_${i}`,d=`_fold_carry_${i}`,k=`_${this.prng.pick(S.stateKeys).replace(/^_+/,"")}_${i}`,g=this.prng.nextUint32()&2147483646|1,y=this.mathCore.computeStringKey(s,g),M=y>>>4&15,K=this.prng.pick(S.assertions),E=s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$"),b=K.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$"),N=[],C=r=>{let t=N.length,e=r.split("").map((p,a)=>{let o=(y>>>(a&3)*8)+Math.imul(a+t,37)&255;return(p.charCodeAt(0)^o)&255});N.push(e);let c=(y&65535)>>>0,u=c^this.prng.nextRange(256,32767),x=t^u,_=u^c;return`${F}.${A}(${x} ^ ((${k} & 0xFFFF) ^ ${_}), ${k})`},T=0,P=/(\b(?:static\s+)?(?:int|double|num|bool|String|void|dynamic|Object|Future<[^>]+>|List<[^>]+>|Map<[^>]+>)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^{;]*\)\s*(?:async\s*)?\{)/g,B=l.replace(P,(r,t,e)=>{if($.has(e))return r;T++;let c=this.prng.nextUint32()&2147483646|1,u=(1^c)>>>0,x=(c^y)>>>0;return[r,` final int ${k} = ${F}.${w}(${g});`,` if (!${F}.${j}(${k}, ${u}, ${x})) { throw StateError("${b}"); }`].join(`
|
|
63
|
+
`)});if(T===0)return{code:n,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let O=B.split(/\r?\n/).map(r=>{let t=r.trim();if(t.startsWith("import ")||t.startsWith("export ")||t.startsWith("part ")||t.startsWith("library ")||t.startsWith("@")||t.includes(F)||t.includes("const "))return r;let e=r;return e=e.replace(/"([^"\\$\n]{3,40})"/g,(c,u)=>C(u)),e=e.replace(/(\breturn\s+|\s=\s*|\s\+\s*|\s-\s*|\s\*\s*)([1-9]\d{0,6})\b(?!\s*\.)/g,(c,u,x)=>{let _=parseInt(x,10),p=(y&65535)>>>0,a=p^this.prng.nextRange(256,32767),o=_^a,R=a^p;return`${u}(${o} ^ ((${k} & 0xFFFF) ^ ${R}))`}),e});if(N.length<4)for(let r of S.decoyTierStrings.slice(0,2))C(r);let V=N.map(r=>` <int>[${r.join(", ")}]`).join(`,
|
|
64
|
+
`),f=[`class ${F} {`,` static const String ${I} = "${E}";`,` static const List<List<int>> ${v} = <List<int>>[`,V," ];","",` static int ${w}(int _tok) {`," final Stopwatch _sw = Stopwatch()..start();"," int _h = (0x811C9DC5 ^ (_tok & 0xFFFFFFFF)) & 0xFFFFFFFF;",` for (int _i = 0; _i < ${I}.length; _i++) {`,` _h = (_h ^ ${I}.codeUnitAt(_i)) & 0xFFFFFFFF;`," _h = (_h * 0x01000193) & 0xFFFFFFFF;"," _h = (_h ^ (_h >> 13)) & 0xFFFFFFFF;"," }"," _h = (((_h ^ (_h >> 16)) * 0x85EBCA6B) & 0xFFFFFFFF);"," _h = (((_h ^ (_h >> 13)) * 0xC2B2AE35) & 0xFFFFFFFF);"," _h = (_h ^ (_h >> 16)) & 0xFFFFFFFF;"," if ((_h & 0xFFFF) == 0) _h = (_h | 0x1337) & 0xFFFFFFFF;"," if (((_h >> 16) & 0xFFFF) == 0) _h = (_h | 0x73310000) & 0xFFFFFFFF;"," if (_sw.elapsedMilliseconds > 2500) _h = (_h ^ 0x5A17E9B3) & 0xFFFFFFFF;",` if (((_h >> 4) & 0xF) != ${M}) {`,` throw StateError("${b}");`," }"," return _h;"," }","",` static int ${d}(int _x, int _y) => (((_x ^ _y) + ((_x & _y) << 1)) & 0xFFFFFFFF);`,"",` static bool ${j}(int _k, int _c1, int _c2) {`," final int _r0 = (_k & 0xFFFFFFFF) % 251;"," final int _r1 = (_k & 0xFFFFFFFF) % 241;"," final int _r2 = (_k & 0xFFFFFFFF) % 239;"," final int _sum = (_r0 + _r1) & 0xFFFFFFFF;"," final int _arx = ((((_sum << 16) | (_sum >> 16)) ^ _r2) & 0xFFFFFFFF);"," final int _u = ((_k ^ (_arx - _arx)) | 1) & 0xFFFFFFFF;"," final int _u2 = (_u * _u) & 0xFFFFFFFF;"," final int _u4 = (_u2 * _u2) & 0xFFFFFFFF;"," final int _expected = (_c1 ^ (_k ^ _c2)) & 0xFFFFFFFF;",` return (_u4 & 15) == ${d}(_expected, 0);`," }","",` static String ${A}(int _slot, int _k) {`,` final List<int> _row = ${v}[_slot];`," final List<int> _codes = List<int>.filled(_row.length, 0);"," for (int _idx = 0; _idx < _row.length; _idx++) {"," final int _byteKey = (((_k >> ((_idx & 3) * 8)) + ((_idx + _slot) * 37)) & 0xFF);"," _codes[_idx] = (_row[_idx] ^ _byteKey) & 0xFF;"," }"," return String.fromCharCodes(_codes);"," }","}"].join(`
|
|
65
|
+
`);return{code:`// [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
|
|
66
|
+
${O.join(`
|
|
67
|
+
`)}
|
|
68
|
+
|
|
69
|
+
${f}
|
|
70
|
+
`,transformedCount:T,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:y>>>0}}};function Et(L,n){return new nt(n).transform(L)}function Nt(L,n){let l=n?.targetLanguage??"cpp";return new Y(n).transform(L,l)}function Ct(L,n){return new Y({...n,targetLanguage:"csharp"}).transform(L,"csharp")}function Tt(L,n){return new Y({...n,targetLanguage:"kotlin"}).transform(L,"kotlin")}function Dt(L,n){return new Y({...n,targetLanguage:"java"}).transform(L,"java")}function jt(L,n){return new Y({...n,targetLanguage:"swift"}).transform(L,"swift")}function Kt(L,n){return new Y({...n,targetLanguage:"dart"}).transform(L,"dart")}export{nt as LlvmIrTransformer,Y as NativeSourceTransformer,Ct as protectCSharp,Kt as protectDart,Dt as protectJava,Tt as protectKotlin,Et as protectLlvmIr,Nt as protectNativeSource,jt as protectSwift};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syferit/llvm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Portable LLVM IR (.ll) and Native C/C++/Rust adversarial protection engine for Syferit",
|
|
5
5
|
"author": "Soltrix Studios",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"clean": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\""
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@syferit/core": "^
|
|
22
|
+
"@syferit/core": "^2.0.0"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|