@syferit/llvm 0.4.6 → 1.0.1

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -12
  2. package/package.json +9 -4
package/dist/index.js CHANGED
@@ -1,15 +1,20 @@
1
1
  // [Protected by Soltrix Studios | Syferit Code Defense Engine | https://syferit.soltrixstudios.com]
2
- import{SeededPRNG as M,MBASynthesizer as lt,buildPolymorphicDictionary as dt}from"@syferit/core";var j=class{options;prng;mba;seed;constructor(t={}){this.options=t,this.seed=typeof t.seed=="number"?t.seed:typeof t.seed=="string"&&t.seed.trim()!==""?M.hashString(t.seed):M.generateCryptoSeed(),this.prng=new M(this.seed),this.mba=new lt(this.prng)}transform(t){if(this.options.mode==="development")return{code:t,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let o=t.replace(/^\s*;.*$/gm,""),u=[],F=/define\s+[^@]*@([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,r;for(;(r=F.exec(o))!==null;)r[1]&&r[1].length>=4&&u.push(r[1]);let a=dt(this.options.domainProfile??"saas",this.prng,u,this.options.customDictionary??[]),v=this.prng.pick(a.legalInoculations),E=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,$=`${v} [ATTESTATION_ID:${E}]`,s=(this.prng.nextUint32()&65535).toString(16),p=`${this.prng.pick(a.symbols)}_${s}`,h=`${this.prng.pick(a.stateKeys)}_${s}`,l=this.prng.nextUint32()&2147483646|1,_=this.mba.computeStringKey($,l),g=_>>>4&15,c=0,I=1,x=o.replace(/(define\s+[^@{]+@[a-zA-Z0-9_$.]+\s*\([^)]*\)[^{]*\{)([\s\S]*?)(\n\})/g,(q,O,L,H)=>{c++;let K=`%${h}_k${c}`,G=L.match(/^(\s*[a-zA-Z0-9_$.]+:\s*\n)/),X=`
3
- ${K} = call i32 @${p}(i32 ${l})
4
- `,Q=L.replace(/^(\s*)(%[a-zA-Z0-9_$.]+)\s*=\s*(add|sub|xor)(?:\s+nsw|\s+nuw)*\s+i32\s+([^,\n]+),\s*([^\n]+)$/gm,(B,n,Y,J,_t,ct)=>{let y=_t.trim(),d=ct.trim(),i=I++,e=[];if(/^-?\d+$/.test(d)){let S=parseInt(d,10)|0,m=this.prng.nextUint32()&2147483646|1,b=S^m|0,k=m^_|0,z=`%_m_kxor_${i}`,A=`%_m_const_${i}`;e.push(`${n}${z} = xor i32 ${K}, ${k}`),e.push(`${n}${A} = xor i32 ${b}, ${z}`),d=A}if(J==="add"){let S=`%_m_axor_${i}`,m=`%_m_aand_${i}`,b=`%_m_ashl_${i}`,k=`%_m_abase_${i}`,z=`%_m_u0_${i}`,A=`%_m_u1_${i}`,P=`%_m_u2_${i}`,et=`%_m_u4_${i}`,nt=`%_m_q1_${i}`,st=`%_m_ko1_${i}`,it=`%_m_ko2_${i}`,ot=`%_m_zinv_${i}`,rt=this.prng.nextUint32()&2147483646|1,ut=1^rt|0,$t=rt^_|0;return e.push(`${n}${S} = xor i32 ${y}, ${d}`),e.push(`${n}${m} = and i32 ${y}, ${d}`),e.push(`${n}${b} = shl i32 ${m}, 1`),e.push(`${n}${k} = add i32 ${S}, ${b}`),e.push(`${n}${z} = xor i32 ${y}, ${K}`),e.push(`${n}${A} = or i32 ${z}, 1`),e.push(`${n}${P} = mul i32 ${A}, ${A}`),e.push(`${n}${et} = mul i32 ${P}, ${P}`),e.push(`${n}${nt} = and i32 ${et}, 15`),e.push(`${n}${st} = xor i32 ${K}, ${$t}`),e.push(`${n}${it} = xor i32 ${ut}, ${st}`),e.push(`${n}${ot} = xor i32 ${nt}, ${it}`),e.push(`${n}${Y} = add i32 ${k}, ${ot}`),e.join(`
5
- `)}if(J==="sub"){let S=`%_m_sxor_${i}`,m=`%_m_snot_${i}`,b=`%_m_sand_${i}`,k=`%_m_sshl_${i}`;return e.push(`${n}${S} = xor i32 ${y}, ${d}`),e.push(`${n}${m} = xor i32 ${y}, -1`),e.push(`${n}${b} = and i32 ${m}, ${d}`),e.push(`${n}${k} = shl i32 ${b}, 1`),e.push(`${n}${Y} = sub i32 ${S}, ${k}`),e.join(`
6
- `)}let W=`%_m_xor_or_${i}`,tt=`%_m_xor_and_${i}`;return e.push(`${n}${W} = or i32 ${y}, ${d}`),e.push(`${n}${tt} = and i32 ${y}, ${d}`),e.push(`${n}${Y} = sub i32 ${W}, ${tt}`),e.join(`
7
- `)});if(G){let B=G[1],n=Q.slice(B.length);return`${O}${B}${X}${n}${H}`}return`${O}${X}${Q}${H}`});if(c===0)return{code:t,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let D=Buffer.from($,"utf-8").length+1,C=$.replace(/\\/g,"\\\\").replace(/"/g,"\\22"),N=1511516595,R=l^N|0,f=(_|0)-R|0;return{code:`${["; [Protected by Soltrix Studios \u2014 Syferit Code Defense Engine | https://syferit.soltrixstudios.com]",`@.syferit.legal.attestation_${s} = private unnamed_addr constant [${D} x i8] c"${C}\\00", align 1`,`@llvm.compiler.used = appending global [1 x ptr] [ptr @.syferit.legal.attestation_${s}], section "llvm.metadata"`,"","declare void @llvm.trap() #0","",`define internal i32 @${p}(i32 %_tok) noinline optnone {`,"entry:",` %_att_byte = load volatile i8, ptr @.syferit.legal.attestation_${s}, align 1`," %_att_valid = icmp ne i8 %_att_byte, 0",` %_x0 = xor i32 %_tok, ${N}`,` %_key = add i32 %_x0, ${f}`," %_shr = lshr i32 %_key, 4"," %_nib = and i32 %_shr, 15",` %_nib_ok = icmp eq i32 %_nib, ${g}`," %_all_ok = and i1 %_att_valid, %_nib_ok"," br i1 %_all_ok, label %hash.ok, label %tamper.trap","","tamper.trap:"," call void @llvm.trap()"," unreachable","","hash.ok:"," ret i32 %_key","}",""].join(`
2
+ import{SeededPRNG as V,WasmMathCore as ht,buildPolymorphicDictionary as pt}from"@syferit/core";var L=class{options;prng;mathCore;seed;constructor(t={}){this.options=t,this.seed=typeof t.seed=="number"?t.seed:typeof t.seed=="string"&&t.seed.trim()!==""?V.hashString(t.seed):V.generateCryptoSeed(),this.prng=new V(this.seed),this.mathCore=ht.getInstance()}transform(t){if(this.options.mode==="development")return{code:t,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let o=t.replace(/^\s*;.*$/gm,""),$=[],U=/define\s+[^@]*@([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,r;for(;(r=U.exec(o))!==null;)r[1]&&r[1].length>=4&&$.push(r[1]);let a=pt(this.options.domainProfile??"saas",this.prng,$,this.options.customDictionary??[]),D=this.prng.pick(a.legalInoculations),R=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,d=`${D} [ATTESTATION_ID:${R}]`,s=(this.prng.nextUint32()&65535).toString(16),m=`${this.prng.pick(a.symbols)}_${s}`,g=`${this.prng.pick(a.stateKeys)}_${s}`,h=this.prng.nextUint32()&2147483646|1,_=this.mathCore.computeStringKey(d,h),c=0,x=1,F=o.replace(/(define\s+[^@{]+@[a-zA-Z0-9_$.]+\s*\([^)]*\)[^{]*\{)([\s\S]*?)(\n\})/g,(p,H,G,W)=>{c++;let Z=`%${g}_k${c}`,X=G.match(/^(\s*[a-zA-Z0-9_$.]+:\s*\n)/),Q=`
3
+ ${Z} = call i32 @${m}(i32 ${h})
4
+ `,J=G.replace(/^(\s*)(%[a-zA-Z0-9_$.]+)\s*=\s*(add|sub|xor)(?:\s+nsw|\s+nuw)*\s+i32\s+([^,\n]+),\s*([^\n]+)$/gm,(M,n,P,tt,ut,lt)=>{let I=ut.trim(),f=lt.trim(),i=x++,e=[];if(/^-?\d+$/.test(f)){let N=parseInt(f,10)|0,S=this.prng.nextUint32()&2147483646|1,T=N^S|0,A=S^_|0,j=`%_m_kxor_${i}`,v=`%_m_const_${i}`;e.push(`${n}${j} = xor i32 ${Z}, ${A}`),e.push(`${n}${v} = xor i32 ${T}, ${j}`),f=v}if(tt==="add"){let N=`%_m_axor_${i}`,S=`%_m_aand_${i}`,T=`%_m_ashl_${i}`,A=`%_m_abase_${i}`,j=`%_m_u0_${i}`,v=`%_m_u1_${i}`,B=`%_m_u2_${i}`,st=`%_m_u4_${i}`,it=`%_m_q1_${i}`,ot=`%_m_ko1_${i}`,rt=`%_m_ko2_${i}`,at=`%_m_zinv_${i}`,_t=this.prng.nextUint32()&2147483646|1,$t=1^_t|0,dt=_t^_|0;return e.push(`${n}${N} = xor i32 ${I}, ${f}`),e.push(`${n}${S} = and i32 ${I}, ${f}`),e.push(`${n}${T} = shl i32 ${S}, 1`),e.push(`${n}${A} = add i32 ${N}, ${T}`),e.push(`${n}${j} = xor i32 ${I}, ${Z}`),e.push(`${n}${v} = or i32 ${j}, 1`),e.push(`${n}${B} = mul i32 ${v}, ${v}`),e.push(`${n}${st} = mul i32 ${B}, ${B}`),e.push(`${n}${it} = and i32 ${st}, 15`),e.push(`${n}${ot} = xor i32 ${Z}, ${dt}`),e.push(`${n}${rt} = xor i32 ${$t}, ${ot}`),e.push(`${n}${at} = xor i32 ${it}, ${rt}`),e.push(`${n}${P} = add i32 ${A}, ${at}`),e.join(`
5
+ `)}if(tt==="sub"){let N=`%_m_sxor_${i}`,S=`%_m_snot_${i}`,T=`%_m_sand_${i}`,A=`%_m_sshl_${i}`;return e.push(`${n}${N} = xor i32 ${I}, ${f}`),e.push(`${n}${S} = xor i32 ${I}, -1`),e.push(`${n}${T} = and i32 ${S}, ${f}`),e.push(`${n}${A} = shl i32 ${T}, 1`),e.push(`${n}${P} = sub i32 ${N}, ${A}`),e.join(`
6
+ `)}let et=`%_m_xor_or_${i}`,nt=`%_m_xor_and_${i}`;return e.push(`${n}${et} = or i32 ${I}, ${f}`),e.push(`${n}${nt} = and i32 ${I}, ${f}`),e.push(`${n}${P} = sub i32 ${et}, ${nt}`),e.join(`
7
+ `)});if(X){let M=X[1],n=J.slice(M.length);return`${H}${M}${Q}${n}${W}`}return`${H}${Q}${J}${W}`});if(c===0)return{code:t,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0};let u=Buffer.from(d,"utf-8"),E=u.length+1,w=d.replace(/\\/g,"\\\\").replace(/"/g,"\\22"),y=h>>>0;for(let p=0;p<u.length;p++)y=Math.imul(y^u[p],16777619)>>>0;let z=(_|0)-(y|0)|0,b=[],l=F.replace(/^(source_filename|target datalayout|target triple)\s*=.*$/gm,p=>(b.push(p),"")),k=l.includes("@llvm.trap")?"":`declare void @llvm.trap()
8
+ `,K=["; [Protected by Soltrix Studios: Syferit Code Defense Engine | https://syferit.soltrixstudios.com]",`@.syferit.legal.attestation_${s} = private unnamed_addr constant [${E} x i8] c"${w}\\00", align 1`,`@llvm.compiler.used = appending global [1 x ptr] [ptr @.syferit.legal.attestation_${s}], section "llvm.metadata"`,"",k?k.trimEnd():"","",`define internal i32 @${m}(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, ${u.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, ${z|0}`," ret i32 %_key","}",""].filter(p=>p!=="").join(`
9
+ `),O="";return b.length>0?O=b.join(`
10
+ `)+`
11
+
12
+ `+K+`
13
+ `+l.trimStart():O=`${K}
14
+ ${l}`,{code:O,transformedCount:c,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:_>>>0}}};import{SeededPRNG as q,WasmMathCore as ft,buildPolymorphicDictionary as ct}from"@syferit/core";var Y=class{options;prng;mathCore;seed;constructor(t={}){this.options=t,this.seed=typeof t.seed=="number"?t.seed:typeof t.seed=="string"&&t.seed.trim()!==""?q.hashString(t.seed):q.generateCryptoSeed(),this.prng=new q(this.seed),this.mathCore=ft.getInstance()}transform(t,o="cpp"){return this.options.mode==="development"?{code:t,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0}:o==="rust"?this.transformRust(t):this.transformCCpp(t)}transformCCpp(t){let o=t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),$=[],U=/\b([a-zA-Z_][a-zA-Z0-9_]{3,20})\b/g,r;for(;(r=U.exec(o))!==null;){let l=r[1];["int","void","char","float","double","return","const","static","struct","class","public","private","uint32_t","include"].includes(l)||$.push(l)}let a=ct(this.options.domainProfile??"saas",this.prng,$,this.options.customDictionary??[]),D=this.prng.pick(a.legalInoculations),R=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,d=`${D} [ATTESTATION_ID:${R}]`,s=(this.prng.nextUint32()&65535).toString(16),m=`${this.prng.pick(a.symbols)}_${s}`,g=`${this.prng.pick(a.stateKeys)}_${s}`,h=`_fold_carry_${s}`,_=`_unmask_scalar_${s}`,c=`_verify_quorum_${s}`,x=`${this.prng.pick(a.symbols)}_decoy_${s}`,F=this.prng.nextUint32()&2147483646|1,u=this.mathCore.computeStringKey(d,F),E=u>>>4&15,w=d.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),y=0,z=o.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,l=>{y++;let k=this.prng.nextUint32()&2147483646|1,K=(1^k)>>>0,O=(k^u)>>>0;return[l,` const unsigned int ${g} = ${m}(${F}u);`,` if (${c}(${g}, ${K}u, ${O}u) == 0u) { return ${x}(${g}); }`].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}[] = "${w}";`,"",`SYFERIT_NOINLINE static unsigned int ${m}(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) != ${E}u) {`," volatile int *_trap = (volatile int *)0; *_trap = 0;"," }"," return _h;","}","",`static inline unsigned int ${_}(unsigned int _c1, unsigned int _c2, unsigned int _k) {`," return _c1 ^ (_k ^ _c2);","}","",`static inline unsigned int ${h}(unsigned int _x, unsigned int _y) {`," return (_x ^ _y) + ((_x & _y) << 1u);","}","",`static inline unsigned int ${c}(unsigned int _k, unsigned int _c1, unsigned int _c2) {`," unsigned int _u = _k | 1u;"," unsigned int _u2 = _u * _u;"," unsigned int _u4 = _u2 * _u2;",` unsigned int _expected = ${_}(_c1, _c2, _k);`," return ((_u4 & 15u) == _expected) ? 1u : 0u;","}","",`SYFERIT_NOINLINE static int ${x}(unsigned int _k) {`,` unsigned int _acc = ${h}(_k, 0x5A17E9B3u);`," return (int)(_acc ^ 0xDEADBEEFu);","}",""].join(`
8
16
  `)}
9
- ${x}`,transformedCount:c,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:_>>>0}}};import{SeededPRNG as V,MBASynthesizer as pt,buildPolymorphicDictionary as at}from"@syferit/core";var Z=class{options;prng;mba;seed;constructor(t={}){this.options=t,this.seed=typeof t.seed=="number"?t.seed:typeof t.seed=="string"&&t.seed.trim()!==""?V.hashString(t.seed):V.generateCryptoSeed(),this.prng=new V(this.seed),this.mba=new pt(this.prng)}transform(t,o="cpp"){return this.options.mode==="development"?{code:t,transformedCount:0,seedUsed:this.seed,inoculationInjected:!1,stateKeyDerived:0}:o==="rust"?this.transformRust(t):this.transformCCpp(t)}transformCCpp(t){let o=t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),u=[],F=/\b([a-zA-Z_][a-zA-Z0-9_]{3,20})\b/g,r;for(;(r=F.exec(o))!==null;){let f=r[1];["int","void","char","float","double","return","const","static","struct","class","public","private","uint32_t","include"].includes(f)||u.push(f)}let a=at(this.options.domainProfile??"saas",this.prng,u,this.options.customDictionary??[]),v=this.prng.pick(a.legalInoculations),E=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,$=`${v} [ATTESTATION_ID:${E}]`,s=(this.prng.nextUint32()&65535).toString(16),p=`${this.prng.pick(a.symbols)}_${s}`,h=`${this.prng.pick(a.stateKeys)}_${s}`,l=`_fold_carry_${s}`,_=`_unmask_scalar_${s}`,g=`_verify_quorum_${s}`,c=`${this.prng.pick(a.symbols)}_decoy_${s}`,I=this.prng.nextUint32()&2147483646|1,x=this.mba.computeStringKey($,I),U=x>>>4&15,D=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),C=0,N=o.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,f=>{C++;let w=this.prng.nextUint32()&2147483646|1,q=(1^w)>>>0,O=(w^x)>>>0;return[f,` const unsigned int ${h} = ${p}(${I}u);`,` if (${g}(${h}, ${q}u, ${O}u) == 0u) { return ${c}(${h}); }`].join(`
10
- `)});return{code:`${["/* [Protected by Soltrix Studios \u2014 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}[] = "${D}";`,"",`SYFERIT_NOINLINE static unsigned int ${p}(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) != ${U}u) {`," volatile int *_trap = (volatile int *)0; *_trap = 0;"," }"," return _h;","}","",`static inline unsigned int ${_}(unsigned int _c1, unsigned int _c2, unsigned int _k) {`," return _c1 ^ (_k ^ _c2);","}","",`static inline unsigned int ${l}(unsigned int _x, unsigned int _y) {`," return (_x ^ _y) + ((_x & _y) << 1u);","}","",`static inline unsigned int ${g}(unsigned int _k, unsigned int _c1, unsigned int _c2) {`," unsigned int _u = _k | 1u;"," unsigned int _u2 = _u * _u;"," unsigned int _u4 = _u2 * _u2;",` unsigned int _expected = ${_}(_c1, _c2, _k);`," return ((_u4 & 15u) == _expected) ? 1u : 0u;","}","",`SYFERIT_NOINLINE static int ${c}(unsigned int _k) {`,` unsigned int _acc = ${l}(_k, 0x5A17E9B3u);`," return (int)(_acc ^ 0xDEADBEEFu);","}",""].join(`
17
+ ${z}`,transformedCount:y,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:u>>>0}}transformRust(t){let o=t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),$=[],U=/\bfn\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,r;for(;(r=U.exec(o))!==null;)r[1]&&r[1].length>=4&&$.push(r[1]);let a=ct(this.options.domainProfile??"saas",this.prng,$,this.options.customDictionary??[]),D=this.prng.pick(a.legalInoculations),R=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,d=`${D} [ATTESTATION_ID:${R}]`,s=(this.prng.nextUint32()&65535).toString(16),m=`${this.prng.pick(a.symbols)}_${s}`.toLowerCase(),g=`${this.prng.pick(a.stateKeys)}_${s}`.toLowerCase(),h=`_verify_quorum_${s}`,_=`_fold_carry_${s}`,c=this.prng.nextUint32()&2147483646|1,x=this.mathCore.computeStringKey(d,c),F=x>>>4&15,u=d.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),E=0,w=o.replace(/(\b(?:pub\s+)?fn\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^{;]*\)(?:\s*->\s*[^{;]+)?\s*\{)/g,z=>{E++;let b=this.prng.nextUint32()&2147483646|1,l=(1^b)>>>0,k=(b^x)>>>0;return[z,` let ${g}: u32 = ${m}(${c}u32);`,` if !${h}(${g}, ${l}u32, ${k}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"${u}\\0";`,"","#[inline(never)]",`fn ${m}(_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) != ${F}u32 {`,' panic!("ASSERTION_INVARIANT: Attestation keyframe corrupted");'," }"," _h","}","","#[inline(always)]",`fn ${_}(_x: u32, _y: u32) -> u32 {`," (_x ^ _y).wrapping_add((_x & _y) << 1)","}","","#[inline(always)]",`fn ${h}(_k: u32, _c1: u32, _c2: u32) -> bool {`," let _u: u32 = _k | 1u32;"," let _u2: u32 = _u.wrapping_mul(_u);"," let _u4: u32 = _u2.wrapping_mul(_u2);"," let _expected: u32 = _c1 ^ (_k ^ _c2);",` (_u4 & 15u32) == ${_}(_expected, 0u32)`,"}",""].join(`
11
19
  `)}
12
- ${N}`,transformedCount:C,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:x>>>0}}transformRust(t){let o=t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(?<!:)\/\/.*$/gm,""),u=[],F=/\bfn\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,r;for(;(r=F.exec(o))!==null;)r[1]&&r[1].length>=4&&u.push(r[1]);let a=at(this.options.domainProfile??"saas",this.prng,u,this.options.customDictionary??[]),v=this.prng.pick(a.legalInoculations),E=`${this.prng.nextUint32().toString(16).padStart(8,"0")}-${this.prng.nextUint32().toString(16).padStart(8,"0")}`,$=`${v} [ATTESTATION_ID:${E}]`,s=(this.prng.nextUint32()&65535).toString(16),p=`${this.prng.pick(a.symbols)}_${s}`.toLowerCase(),h=`${this.prng.pick(a.stateKeys)}_${s}`.toLowerCase(),l=`_verify_quorum_${s}`,_=`_fold_carry_${s}`,g=this.prng.nextUint32()&2147483646|1,c=this.mba.computeStringKey($,g),I=c>>>4&15,x=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),U=0,D=o.replace(/(\b(?:pub\s+)?fn\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^{;]*\)(?:\s*->\s*[^{;]+)?\s*\{)/g,N=>{U++;let R=this.prng.nextUint32()&2147483646|1,f=(1^R)>>>0,w=(R^c)>>>0;return[N,` let ${h}: u32 = ${p}(${g}u32);`,` if !${l}(${h}, ${f}u32, ${w}u32) { panic!("ASSERTION_INVARIANT: State quorum mismatch"); }`].join(`
13
- `)});return{code:`${["// [Protected by Soltrix Studios \u2014 Syferit Code Defense Engine | https://syferit.soltrixstudios.com]","#[used]",`static _SYFERIT_ATTESTATION_${s.toUpperCase()}: &[u8] = b"${x}\\0";`,"","#[inline(never)]",`fn ${p}(_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) != ${I}u32 {`,' panic!("ASSERTION_INVARIANT: Attestation keyframe corrupted");'," }"," _h","}","","#[inline(always)]",`fn ${_}(_x: u32, _y: u32) -> u32 {`," (_x ^ _y).wrapping_add((_x & _y) << 1)","}","","#[inline(always)]",`fn ${l}(_k: u32, _c1: u32, _c2: u32) -> bool {`," let _u: u32 = _k | 1u32;"," let _u2: u32 = _u.wrapping_mul(_u);"," let _u4: u32 = _u2.wrapping_mul(_u2);"," let _expected: u32 = _c1 ^ (_k ^ _c2);",` (_u4 & 15u32) == ${_}(_expected, 0u32)`,"}",""].join(`
14
- `)}
15
- ${D}`,transformedCount:U,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:c>>>0}}};function St(T,t){return new j(t).transform(T)}function bt(T,t){let o=t?.targetLanguage??"cpp";return new Z(t).transform(T,o)}export{j as LlvmIrTransformer,Z as NativeSourceTransformer,St as protectLlvmIr,bt as protectNativeSource};
20
+ ${w}`,transformedCount:E,seedUsed:this.seed,inoculationInjected:!0,stateKeyDerived:x>>>0}}};function kt(C,t){return new L(t).transform(C)}function It(C,t){let o=t?.targetLanguage??"cpp";return new Y(t).transform(C,o)}export{L as LlvmIrTransformer,Y as NativeSourceTransformer,kt as protectLlvmIr,It as protectNativeSource};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syferit/llvm",
3
- "version": "0.4.6",
3
+ "version": "1.0.1",
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",
@@ -10,7 +10,8 @@
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js"
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
14
15
  }
15
16
  },
16
17
  "scripts": {
@@ -18,12 +19,16 @@
18
19
  "clean": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\""
19
20
  },
20
21
  "dependencies": {
21
- "@syferit/core": "^0.4.6"
22
+ "@syferit/core": "^1.0.1"
22
23
  },
23
24
  "repository": {
24
25
  "type": "git",
25
26
  "url": "git+https://github.com/soltrix-studios/syferit.git",
26
27
  "directory": "packages/llvm"
27
28
  },
28
- "homepage": "https://syferit.soltrixstudios.com"
29
+ "homepage": "https://syferit.soltrixstudios.com",
30
+ "files": [
31
+ "dist",
32
+ "README.md"
33
+ ]
29
34
  }