-
Notifications
You must be signed in to change notification settings - Fork 0
/
2330.e3e1ed58ed97e08d86ab.js
1 lines (1 loc) · 16.9 KB
/
2330.e3e1ed58ed97e08d86ab.js
1
(self.webpackChunktimeless_frontend=self.webpackChunktimeless_frontend||[]).push([[2330],{9219:(I,v,K)=>{"use strict";var l=K(55859).Buffer;I.exports=function(c){if(c.length>=255)throw new TypeError("Alphabet too long");for(var y=new Uint8Array(256),p=0;p<y.length;p++)y[p]=255;for(var t=0;t<c.length;t++){var o=c.charAt(t),i=o.charCodeAt(0);if(255!==y[i])throw new TypeError(o+" is ambiguous");y[i]=t}var r=c.length,n=c.charAt(0),e=Math.log(r)/Math.log(256),u=Math.log(256)/Math.log(r);function E(s){if("string"!=typeof s)throw new TypeError("Expected String");if(0===s.length)return l.alloc(0);for(var h=0,d=0,b=0;s[h]===n;)d++,h++;for(var A=(s.length-h)*e+1>>>0,g=new Uint8Array(A);s[h];){var m=y[s.charCodeAt(h)];if(255===m)return;for(var x=0,S=A-1;(0!==m||x<b)&&-1!==S;S--,x++)g[S]=(m+=r*g[S]>>>0)%256>>>0,m=m/256>>>0;if(0!==m)throw new Error("Non-zero carry");b=x,h++}for(var U=A-b;U!==A&&0===g[U];)U++;var P=l.allocUnsafe(d+(A-U));P.fill(0,0,d);for(var _=d;U!==A;)P[_++]=g[U++];return P}return{encode:function(s){if((Array.isArray(s)||s instanceof Uint8Array)&&(s=l.from(s)),!l.isBuffer(s))throw new TypeError("Expected Buffer");if(0===s.length)return"";for(var h=0,d=0,b=0,A=s.length;b!==A&&0===s[b];)b++,h++;for(var g=(A-b)*u+1>>>0,m=new Uint8Array(g);b!==A;){for(var x=s[b],S=0,U=g-1;(0!==x||S<d)&&-1!==U;U--,S++)m[U]=(x+=256*m[U]>>>0)%r>>>0,x=x/r>>>0;if(0!==x)throw new Error("Non-zero carry");d=S,b++}for(var P=g-d;P!==g&&0===m[P];)P++;for(var _=n.repeat(h);P<g;++P)_+=c.charAt(m[P]);return _},decodeUnsafe:E,decode:function(s){var h=E(s);if(h)return h;throw new Error("Non-base"+r+" character")}}}},10908:(I,v,K)=>{var l=K(9219);I.exports=l("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},95966:(I,v,K)=>{"use strict";var l=K(10908),w=K(55859).Buffer;I.exports=function(c){function p(i){var r=i.slice(0,-4),n=i.slice(-4),e=c(r);if(!(n[0]^e[0]|n[1]^e[1]|n[2]^e[2]|n[3]^e[3]))return r}return{encode:function(i){var r=c(i);return l.encode(w.concat([i,r],i.length+4))},decode:function(i){var n=p(l.decode(i));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:function(i){var r=l.decodeUnsafe(i);if(r)return p(r)}}}},35684:(I,v,K)=>{"use strict";var l=K(12506),w=K(95966);I.exports=w(function(y){var p=l("sha256").update(y).digest();return l("sha256").update(p).digest()})},92330:(I,v,K)=>{var l=K(33114),w=K(55859).Buffer,c=K(19726),y=K(35684),p=K(75207),t=K(58666),o=w.from("Bitcoin seed","utf8"),i=2147483648,n={private:76066276,public:76067358};function e(a){this.versions=a||n,this.depth=0,this.index=0,this._privateKey=null,this._publicKey=null,this.chainCode=null,this._fingerprint=0,this.parentFingerprint=0}function u(a,s){a._publicKey=w.from(s),a._identifier=E(s),a._fingerprint=a._identifier.slice(0,4).readUInt32BE(0),a._privateKey=null}function f(a,s,h){var d=w.allocUnsafe(78);return d.writeUInt32BE(s,0),d.writeUInt8(a.depth,4),d.writeUInt32BE(a.depth?a.parentFingerprint:0,5),d.writeUInt32BE(a.index,9),a.chainCode.copy(d,13),h.copy(d,45),d}function E(a){var s=c.createHash("sha256").update(a).digest();return(new p).update(s).digest()}Object.defineProperty(e.prototype,"fingerprint",{get:function(){return this._fingerprint}}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier}}),Object.defineProperty(e.prototype,"pubKeyHash",{get:function(){return this.identifier}}),Object.defineProperty(e.prototype,"privateKey",{get:function(){return this._privateKey},set:function(a){l.equal(a.length,32,"Private key must be 32 bytes."),l(!0===t.privateKeyVerify(a),"Invalid private key"),this._privateKey=a,this._publicKey=w.from(t.publicKeyCreate(a,!0)),this._identifier=E(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0)}}),Object.defineProperty(e.prototype,"publicKey",{get:function(){return this._publicKey},set:function(a){l(33===a.length||65===a.length,"Public key must be 33 or 65 bytes."),l(!0===t.publicKeyVerify(a),"Invalid public key"),u(this,65===a.length?t.publicKeyConvert(a,!0):a)}}),Object.defineProperty(e.prototype,"privateExtendedKey",{get:function(){return this._privateKey?y.encode(f(this,this.versions.private,w.concat([w.alloc(1,0),this.privateKey]))):null}}),Object.defineProperty(e.prototype,"publicExtendedKey",{get:function(){return y.encode(f(this,this.versions.public,this.publicKey))}}),e.prototype.derive=function(a){if("m"===a||"M"===a||"m'"===a||"M'"===a)return this;var s=a.split("/"),h=this;return s.forEach(function(d,b){if(0!==b){var A=d.length>1&&"'"===d[d.length-1],g=parseInt(d,10);l(g<i,"Invalid index"),A&&(g+=i),h=h.deriveChild(g)}else l(/^[mM]{1}/.test(d),'Path must start with "m" or "M"')}),h},e.prototype.deriveChild=function(a){var d,s=a>=i,h=w.allocUnsafe(4);if(h.writeUInt32BE(a,0),s){l(this.privateKey,"Could not derive hardened child key");var b=this.privateKey,A=w.alloc(1,0);b=w.concat([A,b]),d=w.concat([b,h])}else d=w.concat([this.publicKey,h]);var g=c.createHmac("sha512",this.chainCode).update(d).digest(),m=g.slice(0,32),x=g.slice(32),S=new e(this.versions);if(this.privateKey)try{S.privateKey=w.from(t.privateKeyTweakAdd(w.from(this.privateKey),m))}catch{return this.deriveChild(a+1)}else try{S.publicKey=w.from(t.publicKeyTweakAdd(w.from(this.publicKey),m,!0))}catch{return this.deriveChild(a+1)}return S.chainCode=x,S.depth=this.depth+1,S.parentFingerprint=this.fingerprint,S.index=a,S},e.prototype.sign=function(a){return w.from(t.ecdsaSign(Uint8Array.from(a),Uint8Array.from(this.privateKey)).signature)},e.prototype.verify=function(a,s){return t.ecdsaVerify(Uint8Array.from(s),Uint8Array.from(a),Uint8Array.from(this.publicKey))},e.prototype.wipePrivateData=function(){return this._privateKey&&c.randomBytes(this._privateKey.length).copy(this._privateKey),this._privateKey=null,this},e.prototype.toJSON=function(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}},e.fromMasterSeed=function(a,s){var h=c.createHmac("sha512",o).update(a).digest(),d=h.slice(0,32),b=h.slice(32),A=new e(s);return A.chainCode=b,A.privateKey=d,A},e.fromExtendedKey=function(a,s,h){h=h||!1;var d=new e(s=s||n),b=y.decode(a),A=b.readUInt32BE(0);l(A===s.private||A===s.public,"Version mismatch: does not match private or public"),d.depth=b.readUInt8(4),d.parentFingerprint=b.readUInt32BE(5),d.index=b.readUInt32BE(9),d.chainCode=b.slice(13,45);var g=b.slice(45);return 0===g.readUInt8(0)?(l(A===s.private,"Version mismatch: version does not match private"),d.privateKey=g.slice(1)):(l(A===s.public,"Version mismatch: version does not match public"),h?u(d,g):d.publicKey=g),d},e.fromJSON=function(a){return e.fromExtendedKey(a.xpriv)},e.HARDENED_OFFSET=i,I.exports=e},58666:(I,v,K)=>{I.exports=K(27919)(K(4334))},4334:(I,v,K)=>{const w=new(0,K(5247).ec)("secp256k1"),c=w.curve,y=c.n.constructor;function o(r){const n=r[0];switch(n){case 2:case 3:return 33!==r.length?null:function(r,n){let e=new y(n);if(e.cmp(c.p)>=0)return null;e=e.toRed(c.red);let u=e.redSqr().redIMul(e).redIAdd(c.b).redSqrt();return 3===r!==u.isOdd()&&(u=u.redNeg()),w.keyPair({pub:{x:e,y:u}})}(n,r.subarray(1,33));case 4:case 6:case 7:return 65!==r.length?null:function(r,n,e){let u=new y(n),f=new y(e);if(u.cmp(c.p)>=0||f.cmp(c.p)>=0||(u=u.toRed(c.red),f=f.toRed(c.red),(6===r||7===r)&&f.isOdd()!==(7===r)))return null;const E=u.redSqr().redIMul(u);return f.redSqr().redISub(E.redIAdd(c.b)).isZero()?w.keyPair({pub:{x:u,y:f}}):null}(n,r.subarray(1,33),r.subarray(33,65));default:return null}}function i(r,n){const e=n.encode(null,33===r.length);for(let u=0;u<r.length;++u)r[u]=e[u]}I.exports={contextRandomize:()=>0,privateKeyVerify(r){const n=new y(r);return n.cmp(c.n)<0&&!n.isZero()?0:1},privateKeyNegate(r){const n=new y(r),e=c.n.sub(n).umod(c.n).toArrayLike(Uint8Array,"be",32);return r.set(e),0},privateKeyTweakAdd(r,n){const e=new y(n);if(e.cmp(c.n)>=0||(e.iadd(new y(r)),e.cmp(c.n)>=0&&e.isub(c.n),e.isZero()))return 1;const u=e.toArrayLike(Uint8Array,"be",32);return r.set(u),0},privateKeyTweakMul(r,n){let e=new y(n);if(e.cmp(c.n)>=0||e.isZero())return 1;e.imul(new y(r)),e.cmp(c.n)>=0&&(e=e.umod(c.n));const u=e.toArrayLike(Uint8Array,"be",32);return r.set(u),0},publicKeyVerify:r=>null===o(r)?1:0,publicKeyCreate(r,n){const e=new y(n);return e.cmp(c.n)>=0||e.isZero()?1:(i(r,w.keyFromPrivate(n).getPublic()),0)},publicKeyConvert(r,n){const e=o(n);return null===e?1:(i(r,e.getPublic()),0)},publicKeyNegate(r,n){const e=o(n);if(null===e)return 1;const u=e.getPublic();return u.y=u.y.redNeg(),i(r,u),0},publicKeyCombine(r,n){const e=new Array(n.length);for(let f=0;f<n.length;++f)if(e[f]=o(n[f]),null===e[f])return 1;let u=e[0].getPublic();for(let f=1;f<e.length;++f)u=u.add(e[f].pub);return u.isInfinity()?2:(i(r,u),0)},publicKeyTweakAdd(r,n,e){const u=o(n);if(null===u)return 1;if((e=new y(e)).cmp(c.n)>=0)return 2;const f=u.getPublic().add(c.g.mul(e));return f.isInfinity()?2:(i(r,f),0)},publicKeyTweakMul(r,n,e){const u=o(n);return null===u?1:(e=new y(e)).cmp(c.n)>=0||e.isZero()?2:(i(r,u.getPublic().mul(e)),0)},signatureNormalize(r){const n=new y(r.subarray(0,32)),e=new y(r.subarray(32,64));return n.cmp(c.n)>=0||e.cmp(c.n)>=0?1:(1===e.cmp(w.nh)&&r.set(c.n.sub(e).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(r,n){const e=n.subarray(0,32),u=n.subarray(32,64);if(new y(e).cmp(c.n)>=0||new y(u).cmp(c.n)>=0)return 1;const{output:f}=r;let E=f.subarray(4,37);E[0]=0,E.set(e,1);let a=33,s=0;for(;a>1&&0===E[s]&&!(128&E[s+1]);--a,++s);if(E=E.subarray(s),128&E[0]||a>1&&0===E[0]&&!(128&E[1]))return 1;let h=f.subarray(39,72);h[0]=0,h.set(u,1);let d=33,b=0;for(;d>1&&0===h[b]&&!(128&h[b+1]);--d,++b);return h=h.subarray(b),128&h[0]||d>1&&0===h[0]&&!(128&h[1])?1:(r.outputlen=6+a+d,f[0]=48,f[1]=r.outputlen-2,f[2]=2,f[3]=E.length,f.set(E,4),f[4+a]=2,f[5+a]=h.length,f.set(h,6+a),0)},signatureImport(r,n){if(n.length<8||n.length>72||48!==n[0]||n[1]!==n.length-2||2!==n[2])return 1;const e=n[3];if(0===e||5+e>=n.length||2!==n[4+e])return 1;const u=n[5+e];if(0===u||6+e+u!==n.length||128&n[4]||e>1&&0===n[4]&&!(128&n[5])||128&n[e+6]||u>1&&0===n[e+6]&&!(128&n[e+7]))return 1;let f=n.subarray(4,4+e);if(33===f.length&&0===f[0]&&(f=f.subarray(1)),f.length>32)return 1;let E=n.subarray(6+e);if(33===E.length&&0===E[0]&&(E=E.slice(1)),E.length>32)throw new Error("S length is too long");let a=new y(f);a.cmp(c.n)>=0&&(a=new y(0));let s=new y(n.subarray(6+e));return s.cmp(c.n)>=0&&(s=new y(0)),r.set(a.toArrayLike(Uint8Array,"be",32),0),r.set(s.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(r,n,e,u,f){if(f){const s=f;f=h=>{const d=s(n,e,null,u,h);if(!(d instanceof Uint8Array&&32===d.length))throw new Error("This is the way");return new y(d)}}const E=new y(e);if(E.cmp(c.n)>=0||E.isZero())return 1;let a;try{a=w.sign(n,e,{canonical:!0,k:f,pers:u})}catch{return 1}return r.signature.set(a.r.toArrayLike(Uint8Array,"be",32),0),r.signature.set(a.s.toArrayLike(Uint8Array,"be",32),32),r.recid=a.recoveryParam,0},ecdsaVerify(r,n,e){const u={r:r.subarray(0,32),s:r.subarray(32,64)},f=new y(u.r),E=new y(u.s);if(f.cmp(c.n)>=0||E.cmp(c.n)>=0)return 1;if(1===E.cmp(w.nh)||f.isZero()||E.isZero())return 3;const a=o(e);if(null===a)return 2;const s=a.getPublic();return w.verify(n,u,s)?0:3},ecdsaRecover(r,n,e,u){const f={r:n.slice(0,32),s:n.slice(32,64)},E=new y(f.r),a=new y(f.s);if(E.cmp(c.n)>=0||a.cmp(c.n)>=0)return 1;if(E.isZero()||a.isZero())return 2;let s;try{s=w.recoverPubKey(u,f,e)}catch{return 2}return i(r,s),0},ecdh(r,n,e,u,f,E,a){const s=o(n);if(null===s)return 1;const h=new y(e);if(h.cmp(c.n)>=0||h.isZero())return 2;const d=s.getPublic().mul(h);if(void 0===f){const b=d.encode(null,!0),A=w.hash().update(b).digest();for(let g=0;g<32;++g)r[g]=A[g]}else{E||(E=new Uint8Array(32));const b=d.getX().toArray("be",32);for(let x=0;x<32;++x)E[x]=b[x];a||(a=new Uint8Array(32));const A=d.getY().toArray("be",32);for(let x=0;x<32;++x)a[x]=A[x];const g=f(E,a,u);if(!(g instanceof Uint8Array&&g.length===r.length))return 2;r.set(g)}return 0}}},27919:I=>{const v_IMPOSSIBLE_CASE="Impossible case. Please create issue.",v_TWEAK_ADD="The tweak was out of range or the resulted private key is invalid",v_TWEAK_MUL="The tweak was out of range or equal to zero",v_PUBKEY_PARSE="Public Key could not be parsed",v_PUBKEY_SERIALIZE="Public Key serialization error",v_SIG_PARSE="Signature could not be parsed";function K(p,t){if(!p)throw new Error(t)}function l(p,t,o){if(K(t instanceof Uint8Array,`Expected ${p} to be an Uint8Array`),void 0!==o)if(Array.isArray(o)){const r=`Expected ${p} to be an Uint8Array with length [${o.join(", ")}]`;K(o.includes(t.length),r)}else K(t.length===o,`Expected ${p} to be an Uint8Array with length ${o}`)}function w(p){K("Boolean"===y(p),"Expected compressed to be a Boolean")}function c(p=(o=>new Uint8Array(o)),t){return"function"==typeof p&&(p=p(t)),l("output",p,t),p}function y(p){return Object.prototype.toString.call(p).slice(8,-1)}I.exports=p=>({contextRandomize(t){if(1===(K(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&l("seed",t,32),p.contextRandomize(t)))throw new Error("Unknow error on context randomization")},privateKeyVerify:t=>(l("private key",t,32),0===p.privateKeyVerify(t)),privateKeyNegate(t){switch(l("private key",t,32),p.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(v_IMPOSSIBLE_CASE)}},privateKeyTweakAdd(t,o){switch(l("private key",t,32),l("tweak",o,32),p.privateKeyTweakAdd(t,o)){case 0:return t;case 1:throw new Error(v_TWEAK_ADD)}},privateKeyTweakMul(t,o){switch(l("private key",t,32),l("tweak",o,32),p.privateKeyTweakMul(t,o)){case 0:return t;case 1:throw new Error(v_TWEAK_MUL)}},publicKeyVerify:t=>(l("public key",t,[33,65]),0===p.publicKeyVerify(t)),publicKeyCreate(t,o=!0,i){switch(l("private key",t,32),w(o),i=c(i,o?33:65),p.publicKeyCreate(i,t)){case 0:return i;case 1:throw new Error("Private Key is invalid");case 2:throw new Error(v_PUBKEY_SERIALIZE)}},publicKeyConvert(t,o=!0,i){switch(l("public key",t,[33,65]),w(o),i=c(i,o?33:65),p.publicKeyConvert(i,t)){case 0:return i;case 1:throw new Error(v_PUBKEY_PARSE);case 2:throw new Error(v_PUBKEY_SERIALIZE)}},publicKeyNegate(t,o=!0,i){switch(l("public key",t,[33,65]),w(o),i=c(i,o?33:65),p.publicKeyNegate(i,t)){case 0:return i;case 1:throw new Error(v_PUBKEY_PARSE);case 2:throw new Error(v_IMPOSSIBLE_CASE);case 3:throw new Error(v_PUBKEY_SERIALIZE)}},publicKeyCombine(t,o=!0,i){K(Array.isArray(t),"Expected public keys to be an Array"),K(t.length>0,"Expected public keys array will have more than zero items");for(const r of t)l("public key",r,[33,65]);switch(w(o),i=c(i,o?33:65),p.publicKeyCombine(i,t)){case 0:return i;case 1:throw new Error(v_PUBKEY_PARSE);case 2:throw new Error("The sum of the public keys is not valid");case 3:throw new Error(v_PUBKEY_SERIALIZE)}},publicKeyTweakAdd(t,o,i=!0,r){switch(l("public key",t,[33,65]),l("tweak",o,32),w(i),r=c(r,i?33:65),p.publicKeyTweakAdd(r,t,o)){case 0:return r;case 1:throw new Error(v_PUBKEY_PARSE);case 2:throw new Error(v_TWEAK_ADD)}},publicKeyTweakMul(t,o,i=!0,r){switch(l("public key",t,[33,65]),l("tweak",o,32),w(i),r=c(r,i?33:65),p.publicKeyTweakMul(r,t,o)){case 0:return r;case 1:throw new Error(v_PUBKEY_PARSE);case 2:throw new Error(v_TWEAK_MUL)}},signatureNormalize(t){switch(l("signature",t,64),p.signatureNormalize(t)){case 0:return t;case 1:throw new Error(v_SIG_PARSE)}},signatureExport(t,o){l("signature",t,64);const i={output:o=c(o,72),outputlen:72};switch(p.signatureExport(i,t)){case 0:return o.slice(0,i.outputlen);case 1:throw new Error(v_SIG_PARSE);case 2:throw new Error(v_IMPOSSIBLE_CASE)}},signatureImport(t,o){switch(l("signature",t),o=c(o,64),p.signatureImport(o,t)){case 0:return o;case 1:throw new Error(v_SIG_PARSE);case 2:throw new Error(v_IMPOSSIBLE_CASE)}},ecdsaSign(t,o,i={},r){l("message",t,32),l("private key",o,32),K("Object"===y(i),"Expected options to be an Object"),void 0!==i.data&&l("options.data",i.data),void 0!==i.noncefn&&K("Function"===y(i.noncefn),"Expected options.noncefn to be a Function");const n={signature:r=c(r,64),recid:null};switch(p.ecdsaSign(n,t,o,i.data,i.noncefn)){case 0:return n;case 1:throw new Error("The nonce generation function failed, or the private key was invalid");case 2:throw new Error(v_IMPOSSIBLE_CASE)}},ecdsaVerify(t,o,i){switch(l("signature",t,64),l("message",o,32),l("public key",i,[33,65]),p.ecdsaVerify(t,o,i)){case 0:return!0;case 3:return!1;case 1:throw new Error(v_SIG_PARSE);case 2:throw new Error(v_PUBKEY_PARSE)}},ecdsaRecover(t,o,i,r=!0,n){switch(l("signature",t,64),K("Number"===y(o)&&o>=0&&o<=3,"Expected recovery id to be a Number within interval [0, 3]"),l("message",i,32),w(r),n=c(n,r?33:65),p.ecdsaRecover(n,t,o,i)){case 0:return n;case 1:throw new Error(v_SIG_PARSE);case 2:throw new Error("Public key could not be recover");case 3:throw new Error(v_IMPOSSIBLE_CASE)}},ecdh(t,o,i={},r){switch(l("public key",t,[33,65]),l("private key",o,32),K("Object"===y(i),"Expected options to be an Object"),void 0!==i.data&&l("options.data",i.data),void 0!==i.hashfn?(K("Function"===y(i.hashfn),"Expected options.hashfn to be a Function"),void 0!==i.xbuf&&l("options.xbuf",i.xbuf,32),void 0!==i.ybuf&&l("options.ybuf",i.ybuf,32),l("output",r)):r=c(r,32),p.ecdh(r,t,o,i.data,i.hashfn,i.xbuf,i.ybuf)){case 0:return r;case 1:throw new Error(v_PUBKEY_PARSE);case 2:throw new Error("Scalar was invalid (zero or overflow)")}}})}}]);