mirror of
https://github.com/PR0M3TH3AN/Artstr-Studio.git
synced 2026-10-27 08:40:39 +00:00
First piece of PREMIUM_DESIGNS_FEATURE.md §6. Adds the static
client-side decryption layer for premium designs: HKDF-SHA256 over
an obfuscated per-epoch pepper + a per-design public salt, then
AES-256-GCM with the event coordinate as additional-authenticated-
data so ciphertext can't be copy-pasted to a different event.
noble bundle
- Add @noble/hashes/hkdf to the bundle entry; expose as
window.ArtstrNoble.hkdf and .hmac. Bundle size 14.0 KB → 16.5 KB.
Premium IIFE (new section in index.html)
- _softGatePepperParts — per-epoch lookup of 4x8-byte fragments
("palette seed I..IV"). For epoch 2026-05. Sub-strings don't
look like a "premium key"; reconstruction concats at use time.
Comment explicitly calls this obfuscation, not security, per
PREMIUM_DESIGNS_FEATURE.md §2 / §6.3.
- SUPPORTED_EPOCHS / CURRENT_EPOCH — adding a future epoch is
one entry in the parts table.
- pepperBytesForEpoch(epoch) — reconstructs the 32-byte pepper.
- deriveKey({ epoch, creatorPubkey, premiumAddress, schemaVersion,
publicDesignSalt, puzzleNonce }) -> 32 bytes via HKDF-SHA256
with the pepper as IKM, salt = publicDesignSalt, info =
"artstr-softgate-v1|<epoch>|<creator>|<addr>|v<schema>" (and an
optional "|p<nonce>" for the §6.7 CPU-puzzle hook).
- encodeAad(creatorPubkey, dTag) -> UTF-8 of
"30078:<creator>:<dTag>" so AES-GCM authenticates the
coordinate.
- encryptPayload(payloadObj, coord, { epoch? }) — random
32-byte salt + 12-byte IV; returns the spec §5.2 envelope
(base64 fields, softgate metadata, etc.).
- decryptPayload(envelope, coord) — reverses the above.
- Self-test runs on every load: round-trip a known payload AND
verify AAD/creator/schema mismatches all reject the decrypt
(event-coordinate binding). Single console.warn on failure.
Tested via CDP — all green:
- Round-trip with random keypair: ok
- AAD mismatch (different dTag) -> AES-GCM rejects: ok
- Creator pubkey mismatch -> KDF info changes -> rejects: ok
- Schema version mismatch -> KDF info changes -> rejects: ok
- KDF deterministic with identical inputs: ok
- Output length = 32 bytes (AES-256): ok
- Pepper reconstruction = 32 bytes: ok
- Envelope size for tiny payload = 577 bytes; ~63 KB headroom
under typical relay limits, plenty for an embedded preview
JPEG in step 2.
- Regression: NWC crypto self-test still passes; existing editor
still loads and renders layers.
Code only; nothing in the publish/feed flow uses this yet. Next
step (PREMIUM_DESIGNS_FEATURE.md §19 item 2) is the watermarked
preview pipeline.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
7 lines
17 KiB
JavaScript
7 lines
17 KiB
JavaScript
(()=>{var de=Object.defineProperty;var le=(t,e,n)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var l=(t,e,n)=>le(t,typeof e!="symbol"?e+"":e,n);var Lt=Object.freeze({p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,h:1n,a:0n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n}),{p:v,n:P,Gx:xe,Gy:be,b:Ut}=Lt,w=32,K=64,z={publicKey:w+1,publicKeyUncompressed:K+1,signature:K,seed:w+w/2},b=(t="",e=Error)=>{let n=new e(t),{captureStackTrace:s}=Error;throw typeof s=="function"&&s(n,b),n},ye=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&t.BYTES_PER_ELEMENT===1,E=(t,e,n="")=>{let s=ye(t),r=t?.length,o=e!==void 0;if(!s||o&&r!==e){let c=n&&`"${n}" `,i=o?` of length ${e}`:"",a=s?`length=${r}`:`type=${typeof t}`,h=c+"expected Uint8Array"+i+", got "+a;return s?b(h,RangeError):b(h,TypeError)}return t},j=t=>new Uint8Array(t),_t=(t,e)=>t.toString(16).padStart(e,"0"),Tt=t=>{let e="";for(let n of E(t))e+=_t(n,2);return e},_={_0:48,_9:57,A:65,F:70,a:97,f:102},gt=t=>t>=_._0&&t<=_._9?t-_._0:t>=_.A&&t<=_.F?t-(_.A-10):t>=_.a&&t<=_.f?t-(_.a-10):void 0,It=t=>{let e="hex invalid";if(typeof t!="string")return b(e);let n=t.length,s=n/2;if(n%2)return b(e);let r=j(s);for(let o=0,c=0;o<s;o++,c+=2){let i=gt(t.charCodeAt(c)),a=gt(t.charCodeAt(c+1));if(i===void 0||a===void 0)return b(e);r[o]=i*16+a}return r},mt=()=>globalThis?.crypto?.subtle??b("crypto.subtle must be defined, consider polyfill"),N=(...t)=>{let e=0;for(let r of t)e+=E(r).length;let n=j(e),s=0;for(let r of t)n.set(r,s),s+=r.length;return n},dt=(t=w)=>(globalThis?.crypto).getRandomValues(j(t)),ft=BigInt,D=(t,e,n,s="bad number: out of range")=>typeof t!="bigint"?b(s,TypeError):e<=t&&t<n?t:b(s,RangeError),f=(t,e=v)=>{let n=t%e;return n>=0n?n:e+n},J=t=>f(t,P),pe=(t,e)=>{(t===0n||e<=0n)&&b("no inverse n="+t+" mod="+e);let n=f(t,e),s=e,r=0n,o=1n,c=1n,i=0n;for(;n!==0n;){let a=s/n,h=s%n,d=r-c*a,u=o-i*a;s=n,n=h,r=c,o=i,c=d,i=u}return s===1n?f(r,e):b("no inverse")},kt=t=>{let e=et[t];return typeof e!="function"&&b("hashes."+t+" not set"),e},wt=(t,e,n)=>E(kt(t)(e,n),w,"digest"),At=(t,e,n)=>Promise.resolve(kt(t)(e,n)).then(s=>E(s,w,"digest"));var it=t=>t instanceof L?t:b("Point expected"),Ct=t=>f(f(t*t)*t+Ut),Et=t=>D(t,0n,v),$=t=>D(t,1n,v),ge=t=>D(t,1n,P),Q=t=>!(t&1n),vt=t=>Uint8Array.of(t),me=t=>vt(Q(t)?2:3),Ft=t=>{let e=Ct($(t)),n=1n;for(let s=e,r=(v+1n)/4n;r>0n;r>>=1n)r&1n&&(n=n*s%v),s=s*s%v;return f(n*n)!==e&&b("sqrt invalid"),Q(n)?n:f(-n)};var B=class B{constructor(e,n,s){l(this,"X");l(this,"Y");l(this,"Z");this.X=Et(e),this.Y=$(n),this.Z=Et(s),Object.freeze(this)}static CURVE(){return Lt}static fromAffine(e){let{x:n,y:s}=e;return n===0n&&s===0n?G:new B(n,s,1n)}static fromBytes(e){E(e);let{publicKey:n,publicKeyUncompressed:s}=z,r,o=e.length,c=e[0],i=e.subarray(1),a=W(i,0,w);if(o===n&&(c===2||c===3)){let h=Ft(a);c===3&&(h=f(-h)),r=new B(a,h,1n)}return o===s&&c===4&&(r=new B(a,W(i,w,K),1n)),r?r.assertValidity():b("bad point: not on curve")}static fromHex(e){return B.fromBytes(It(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(e){let{X:n,Y:s,Z:r}=this,{X:o,Y:c,Z:i}=it(e),a=f(n*i),h=f(o*r),d=f(s*i),u=f(c*r);return a===h&&d===u}is0(){return this.equals(G)}negate(){return new B(this.X,f(-this.Y),this.Z)}double(){return this.add(this)}add(e){let{X:n,Y:s,Z:r}=this,{X:o,Y:c,Z:i}=it(e),a=0n,h=Ut,d=0n,u=0n,x=0n,y=f(h*3n),p=f(n*o),g=f(s*c),A=f(r*i),R=f(n+s),m=f(o+c);R=f(R*m),m=f(p+g),R=f(R-m),m=f(n+r);let S=f(o+i);return m=f(m*S),S=f(p+A),m=f(m-S),S=f(s+r),d=f(c+i),S=f(S*d),d=f(g+A),S=f(S-d),x=f(a*m),d=f(y*A),x=f(d+x),d=f(g-x),x=f(g+x),u=f(d*x),g=f(p+p),g=f(g+p),A=f(a*A),m=f(y*m),g=f(g+A),A=f(p-A),A=f(a*A),m=f(m+A),p=f(g*m),u=f(u+p),p=f(S*m),d=f(R*d),d=f(d-p),p=f(R*g),x=f(S*x),x=f(x+p),new B(d,u,x)}subtract(e){return this.add(it(e).negate())}multiply(e,n=!0){if(!n&&e===0n)return G;if(ge(e),e===1n)return this;if(this.equals(F))return ke(e).p;let s=G,r=F;for(let o=this;e>0n;o=o.double(),e>>=1n)e&1n?s=s.add(o):n&&(r=r.add(o));return s}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:n,Z:s}=this;if(this.equals(G))return{x:0n,y:0n};if(s===1n)return{x:e,y:n};let r=pe(s,v);return f(s*r)!==1n&&b("inverse invalid"),{x:f(e*r),y:f(n*r)}}assertValidity(){let{x:e,y:n}=this.toAffine();return $(e),$(n),f(n*n)===Ct(e)?this:b("bad point: not on curve")}toBytes(e=!0){let{x:n,y:s}=this.assertValidity().toAffine(),r=U(n);return e?N(me(s),r):N(vt(4),r,U(s))}toHex(e){return Tt(this.toBytes(e))}};l(B,"BASE"),l(B,"ZERO");var L=B,F=new L(xe,be,1n),G=new L(0n,1n,0n);L.BASE=F;L.ZERO=G;var we=(t,e,n)=>F.multiply(e,!1).add(t.multiply(n,!1)).assertValidity(),O=t=>ft("0x"+(Tt(t)||"0")),W=(t,e,n)=>O(t.subarray(e,n)),Ae=2n**256n,U=t=>It(_t(D(t,0n,Ae),K)),tt=t=>{let e=O(E(t,w,"secret key"));return D(e,1n,P,"invalid secret key: outside of range")};var Vt=(t,e=!0)=>F.multiply(tt(t)).toBytes(e),Ee=t=>{try{return!!tt(t)}catch{return!1}},He=(t,e)=>{let{publicKey:n,publicKeyUncompressed:s}=z;try{let r=t.length;return e===!0&&r!==n||e===!1&&r!==s?!1:!!L.fromBytes(t)}catch{return!1}};var Ht="SHA-256",et={hmacSha256Async:async(t,e)=>{let n=mt(),s="HMAC",r=await n.importKey("raw",t,{name:s,hash:{name:Ht}},!1,["sign"]);return j(await n.sign(s,r,e))},hmacSha256:void 0,sha256Async:async t=>j(await mt().digest(Ht,t)),sha256:void 0};var Gt=(t,e,n=!0)=>L.fromBytes(e).multiply(tt(t)).toBytes(n),Dt=t=>{if(t=t===void 0?dt(z.seed):t,E(t),t.length<z.seed||t.length>1024)return b("expected 48-1024b",RangeError);let e=f(O(t),P-1n);return U(e+1n)},Se=t=>e=>{let n=Dt(e);return{secretKey:n,publicKey:t(n)}};var Ot=Object.freeze({isValidSecretKey:Ee,isValidPublicKey:He,randomSecretKey:Dt}),Rt=t=>Uint8Array.from("BIP0340/"+t,e=>e.charCodeAt(0)),Kt="aux",Nt="nonce",Mt="challenge",at=(t,...e)=>{let n=wt("sha256",Rt(t));return wt("sha256",N(n,n,...e))},ut=(t,...e)=>At("sha256Async",Rt(t)).then(n=>At("sha256Async",N(n,n,...e))),lt=t=>{let e=tt(t),n=F.multiply(e),{x:s,y:r}=n.assertValidity().toAffine(),o=Q(r)?e:J(-e),c=U(s);return{d:o,px:c}},xt=t=>J(O(t)),Xt=(...t)=>xt(at(Mt,...t)),jt=async(...t)=>xt(await ut(Mt,...t)),Pt=t=>lt(t).px,Be=Se(Pt),Yt=(t,e,n)=>{let{px:s,d:r}=lt(e);return{m:E(t),px:s,d:r,a:E(n,w)}},Zt=t=>{let e=xt(t);e===0n&&b("sign failed: k is zero");let{px:n,d:s}=lt(U(e));return{rx:n,k:s}},$t=(t,e,n,s)=>N(e,U(J(t+n*s))),zt="invalid signature produced",Le=(t,e,n=dt(w))=>{let{m:s,px:r,d:o,a:c}=Yt(t,e,n),i=at(Kt,c),a=U(o^O(i)),h=at(Nt,a,r,s),{rx:d,k:u}=Zt(h),x=Xt(d,r,s),y=$t(u,d,x,o);return qt(y,s,r)||b(zt),y},Ue=async(t,e,n=dt(w))=>{let{m:s,px:r,d:o,a:c}=Yt(t,e,n),i=await ut(Kt,c),a=U(o^O(i)),h=await ut(Nt,a,r,s),{rx:d,k:u}=Zt(h),x=await jt(d,r,s),y=$t(u,d,x,o);return await Jt(y,s,r)||b(zt),y},_e=(t,e)=>t instanceof Promise?t.then(e):e(t),Wt=(t,e,n,s)=>{let r=E(t,K,"signature"),o=E(e,void 0,"message"),c=E(n,w,"publicKey");try{let i=O(c),a=Ft(i),h=new L(i,a,1n).assertValidity(),d=U(h.toAffine().x),u=W(r,0,w);D(u,1n,v);let x=W(r,w,K);D(x,1n,P);let y=N(U(u),d,o);return _e(s(y),p=>{let{x:g,y:A}=we(h,x,J(-p)).toAffine();return!(!Q(A)||g!==u)})}catch{return!1}},qt=(t,e,n)=>Wt(t,e,n,Xt),Jt=async(t,e,n)=>Wt(t,e,n,jt),Qt=Object.freeze({keygen:Be,getPublicKey:Pt,sign:Le,verify:qt,signAsync:Ue,verifyAsync:Jt}),q=8,Te=256,te=Math.ceil(Te/q)+1,ht=2**(q-1),Ie=()=>{let t=[],e=F,n=e;for(let s=0;s<te;s++){n=e,t.push(n);for(let r=1;r<ht;r++)n=n.add(e),t.push(n);e=n.double()}return t},St,Bt=(t,e)=>{let n=e.negate();return t?n:e},ke=t=>{let e=St||(St=Ie()),n=G,s=F,r=2**q,o=r,c=ft(r-1),i=ft(q);for(let a=0;a<te;a++){let h=Number(t&c);t>>=i,h>ht&&(h-=o,t+=1n);let d=a*ht,u=d,x=d+Math.abs(h)-1,y=a%2!==0,p=h<0;h===0?s=s.add(Bt(y,e[u])):n=n.add(Bt(p,e[x]))}return t!==0n&&b("invalid wnaf"),{p:n,f:s}};function Ce(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function Y(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(`${n}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let n=e&&`"${e}" `;throw new RangeError(`${n}expected integer >= 0, got ${t}`)}}function I(t,e,n=""){let s=Ce(t),r=t?.length,o=e!==void 0;if(!s||o&&r!==e){let c=n&&`"${n}" `,i=o?` of length ${e}`:"",a=s?`length=${r}`:`type=${typeof t}`,h=c+"expected Uint8Array"+i+", got "+a;throw s?new RangeError(h):new TypeError(h)}return t}function Z(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Y(t.outputLen),Y(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function M(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function nt(t,e){I(t,void 0,"digestInto() output");let n=e.outputLen;if(t.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}function k(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function st(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function H(t,e){return t<<32-e|t>>>e}var ne=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ve=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function se(t){if(I(t),ne)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=ve[t[n]];return e}var T={_0:48,_9:57,A:65,F:70,a:97,f:102};function ee(t){if(t>=T._0&&t<=T._9)return t-T._0;if(t>=T.A&&t<=T.F)return t-(T.A-10);if(t>=T.a&&t<=T.f)return t-(T.a-10)}function re(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(ne)try{return Uint8Array.fromHex(t)}catch(r){throw r instanceof SyntaxError?new RangeError(r.message):r}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let s=new Uint8Array(n);for(let r=0,o=0;r<n;r++,o+=2){let c=ee(t.charCodeAt(o)),i=ee(t.charCodeAt(o+1));if(c===void 0||i===void 0){let a=t[o]+t[o+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+o)}s[r]=c*16+i}return s}function oe(t,e={}){let n=(r,o)=>t(o).update(r).digest(),s=t(void 0);return n.outputLen=s.outputLen,n.blockLen=s.blockLen,n.canXOF=s.canXOF,n.create=r=>t(r),Object.assign(n,e),Object.freeze(n)}function ce(t=32){Y(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ie=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function fe(t,e,n){return t&e^~t&n}function ae(t,e,n){return t&e^t&n^e&n}var rt=class{constructor(e,n,s,r){l(this,"blockLen");l(this,"outputLen");l(this,"canXOF",!1);l(this,"padOffset");l(this,"isLE");l(this,"buffer");l(this,"view");l(this,"finished",!1);l(this,"length",0);l(this,"pos",0);l(this,"destroyed",!1);this.blockLen=e,this.outputLen=n,this.padOffset=s,this.isLE=r,this.buffer=new Uint8Array(e),this.view=st(this.buffer)}update(e){M(this),I(e);let{view:n,buffer:s,blockLen:r}=this,o=e.length;for(let c=0;c<o;){let i=Math.min(r-this.pos,o-c);if(i===r){let a=st(e);for(;r<=o-c;c+=r)this.process(a,c);continue}s.set(e.subarray(c,c+i),this.pos),this.pos+=i,c+=i,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){M(this),nt(e,this),this.finished=!0;let{buffer:n,view:s,blockLen:r,isLE:o}=this,{pos:c}=this;n[c++]=128,k(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(s,0),c=0);for(let u=c;u<r;u++)n[u]=0;s.setBigUint64(r-8,BigInt(this.length*8),o),this.process(s,0);let i=st(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let h=a/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)i.setUint32(4*u,d[u],o)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let s=e.slice(0,n);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:s,length:r,finished:o,destroyed:c,pos:i}=this;return e.destroyed=c,e.finished=o,e.length=r,e.pos=i,r%n&&e.buffer.set(s),e}clone(){return this._cloneInto()}},C=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Fe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),V=new Uint32Array(64),bt=class extends rt{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:n,C:s,D:r,E:o,F:c,G:i,H:a}=this;return[e,n,s,r,o,c,i,a]}set(e,n,s,r,o,c,i,a){this.A=e|0,this.B=n|0,this.C=s|0,this.D=r|0,this.E=o|0,this.F=c|0,this.G=i|0,this.H=a|0}process(e,n){for(let u=0;u<16;u++,n+=4)V[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){let x=V[u-15],y=V[u-2],p=H(x,7)^H(x,18)^x>>>3,g=H(y,17)^H(y,19)^y>>>10;V[u]=g+V[u-7]+p+V[u-16]|0}let{A:s,B:r,C:o,D:c,E:i,F:a,G:h,H:d}=this;for(let u=0;u<64;u++){let x=H(i,6)^H(i,11)^H(i,25),y=d+x+fe(i,a,h)+Fe[u]+V[u]|0,g=(H(s,2)^H(s,13)^H(s,22))+ae(s,r,o)|0;d=h,h=a,a=i,i=c+y|0,c=o,o=r,r=s,s=y+g|0}s=s+this.A|0,r=r+this.B|0,o=o+this.C|0,c=c+this.D|0,i=i+this.E|0,a=a+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(s,r,o,c,i,a,h,d)}roundClean(){k(V)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),k(this.buffer)}},yt=class extends bt{constructor(){super(32);l(this,"A",C[0]|0);l(this,"B",C[1]|0);l(this,"C",C[2]|0);l(this,"D",C[3]|0);l(this,"E",C[4]|0);l(this,"F",C[5]|0);l(this,"G",C[6]|0);l(this,"H",C[7]|0)}};var ot=oe(()=>new yt,ie(1));var ct=class{constructor(e,n){l(this,"oHash");l(this,"iHash");l(this,"blockLen");l(this,"outputLen");l(this,"canXOF",!1);l(this,"finished",!1);l(this,"destroyed",!1);if(Z(e),I(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,r=new Uint8Array(s);r.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<r.length;o++)r[o]^=54;this.iHash.update(r),this.oHash=e.create();for(let o=0;o<r.length;o++)r[o]^=106;this.oHash.update(r),k(r)}update(e){return M(this),this.iHash.update(e),this}digestInto(e){M(this),nt(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:n,iHash:s,finished:r,destroyed:o,blockLen:c,outputLen:i}=this;return e=e,e.finished=r,e.destroyed=o,e.blockLen=c,e.outputLen=i,e.oHash=n._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},X=(()=>{let t=((e,n,s)=>new ct(e,n).update(s).digest());return t.create=(e,n)=>new ct(e,n),t})();function Ve(t,e,n){return Z(t),n===void 0&&(n=new Uint8Array(t.outputLen)),X(t,n,e)}var pt=Uint8Array.of(0),ue=Uint8Array.of();function Ge(t,e,n,s=32){Z(t),Y(s,"length"),I(e,void 0,"prk");let r=t.outputLen;if(e.length<r)throw new Error('"prk" must be at least HashLen octets');if(s>255*r)throw new Error("Length must be <= 255*HashLen");let o=Math.ceil(s/r);n===void 0?n=ue:I(n,void 0,"info");let c=new Uint8Array(o*r),i=X.create(t,e),a=i._cloneInto(),h=new Uint8Array(i.outputLen);for(let d=0;d<o;d++)pt[0]=d+1,a.update(d===0?ue:h).update(n).update(pt).digestInto(h),c.set(h,r*d),i._cloneInto(a);return i.destroy(),a.destroy(),k(h,pt),c.slice(0,s)}var he=(t,e,n,s,r)=>Ge(t,Ve(t,e,n),s,r);et.sha256=ot;et.hmacSha256=(t,...e)=>X(ot,t,e.length===1?e[0]:(()=>{let n=e.reduce((o,c)=>o+c.length,0),s=new Uint8Array(n),r=0;for(let o of e)s.set(o,r),r+=o.length;return s})());window.ArtstrNoble={schnorr:Qt,getPublicKey:Vt,getSharedSecret:Gt,sha256:ot,hkdf:he,hmac:X,hexToBytes:re,bytesToHex:se,randomBytes:ce,secpUtils:Ot};})();
|
|
/*! Bundled license information:
|
|
|
|
@noble/secp256k1/index.js:
|
|
(*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
*/
|