lotusbail
Version:
WhatsApp API x Button by PL
4 lines (3 loc) • 998 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});exports.LT_HASH_ANTI_TAMPERING=void 0;const crypto_1=require("./crypto"),o=128;
class d{constructor(a){this.salt=a}add(a,b){for(const c of b)a=this._addSingle(a,c);return a}subtract(a,b){for(const c of b)a=this._subtractSingle(a,c);return a}subtractThenAdd(a,b,c){return this.add(this.subtract(a,c),b)}async _addSingle(a,b){b=(new Uint8Array(await (0,crypto_1.hkdf)(Buffer.from(b),o,{info:this.salt}))).buffer;return this.performPointwiseWithOverflow(await a,b,(c,e)=>c+e)}async _subtractSingle(a,b){b=(new Uint8Array(await (0,crypto_1.hkdf)(Buffer.from(b),o,{info:this.salt}))).buffer;
return this.performPointwiseWithOverflow(await a,b,(c,e)=>c-e)}performPointwiseWithOverflow(a,b,c){a=new DataView(a);b=new DataView(b);const e=new ArrayBuffer(a.byteLength),g=new DataView(e);for(let f=0;f<a.byteLength;f+=2)g.setUint16(f,c(a.getUint16(f,!0),b.getUint16(f,!0)),!0);return e}}exports.LT_HASH_ANTI_TAMPERING=new d("WhatsApp Patch Integrity");