-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblindSigJS.js
3 lines (3 loc) · 20.2 KB
/
blindSigJS.js
1
2
3
/*! For license information please see main.js.LICENSE.txt */
var blindSigJS;
(()=>{var t,e,r={856:()=>{}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&r;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach((t=>a[t]=()=>r[t]));return a.default=()=>r,i.d(o,a),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t=i(856),e=i.t(t,2);const r=BigInt(0),n=BigInt(1),o=BigInt(2),a=BigInt(3),s=BigInt(8),f=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),c=(t,e)=>(t+e/o)/e,u={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=f,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,s=BigInt("0x100000000000000000000000000000000"),u=c(a*t,e),l=c(-i*t,e);let h=z(t-u*r-l*o,e),d=z(-u*i-l*a,e);const y=h>s,p=d>s;if(y&&(h=e-h),p&&(d=e-d),h>s||d>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:y,k1:h,k2neg:p,k2:d}}};function l(t){const{a:e,b:r}=f,n=z(t*t),i=z(n*t);return z(i+e*t+r)}const h=f.a===r;class d extends Error{constructor(t){super(t)}}function y(t){if(!(t instanceof p))throw new TypeError("JacobianPoint expected")}class p{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof b))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(b.ZERO)?p.ZERO:new p(t.x,t.y,n)}static toAffineBatch(t){const e=function(t,e=f.P){const i=new Array(t.length),o=$(t.reduce(((t,n,o)=>n===r?t:(i[o]=t,z(t*n,e))),n),e);return t.reduceRight(((t,n,o)=>n===r?t:(i[o]=z(t*i[o],e),z(t*n,e))),o),i}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return p.toAffineBatch(t).map(p.fromAffine)}equals(t){y(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,s=z(n*n),f=z(a*a),c=z(e*f),u=z(i*s),l=z(z(r*a)*f),h=z(z(o*n)*s);return c===u&&l===h}negate(){return new p(this.x,z(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=z(t*t),i=z(e*e),f=z(i*i),c=t+i,u=z(o*(z(c*c)-n-f)),l=z(a*n),h=z(l*l),d=z(h-o*u),y=z(l*(u-d)-s*f),w=z(o*e*r);return new p(d,y,w)}add(t){y(t);const{x:e,y:n,z:i}=this,{x:a,y:s,z:f}=t;if(a===r||s===r)return this;if(e===r||n===r)return t;const c=z(i*i),u=z(f*f),l=z(e*u),h=z(a*c),d=z(z(n*f)*u),w=z(z(s*i)*c),g=z(h-l),b=z(w-d);if(g===r)return b===r?this.double():p.ZERO;const m=z(g*g),v=z(g*m),x=z(l*m),E=z(b*b-v-o*x),A=z(b*(x-E)-d*v),B=z(i*f*g);return new p(E,A,B)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=p.ZERO;if("bigint"==typeof t&&t===r)return e;let i=O(t);if(i===n)return this;if(!h){let t=e,o=this;for(;i>r;)i&n&&(t=t.add(o)),o=o.double(),i>>=n;return t}let{k1neg:o,k1:a,k2neg:s,k2:f}=u.splitScalar(i),c=e,l=e,d=this;for(;a>r||f>r;)a&n&&(c=c.add(d)),f&n&&(l=l.add(d)),d=d.double(),a>>=n,f>>=n;return o&&(c=c.negate()),s&&(l=l.negate()),l=new p(z(l.x*u.beta),l.y,l.z),c.add(l)}precomputeWindow(t){const e=h?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(p.BASE)&&(e=b.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=e&&g.get(e);i||(i=this.precomputeWindow(r),e&&1!==r&&(i=p.normalizeZ(i),g.set(e,i)));let o=p.ZERO,a=p.BASE;const s=1+(h?128/r:256/r),f=2**(r-1),c=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let e=0;e<s;e++){const r=e*f;let s=Number(t&c);t>>=l,s>f&&(s-=u,t+=n);const h=r,d=r+Math.abs(s)-1,y=e%2!=0,p=s<0;0===s?a=a.add(w(y,i[h])):o=o.add(w(p,i[d]))}return{p:o,f:a}}multiply(t,e){let r,n,i=O(t);if(h){const{k1neg:t,k1:o,k2neg:a,k2:s}=u.splitScalar(i);let{p:f,f:c}=this.wNAF(o,e),{p:l,f:h}=this.wNAF(s,e);f=w(t,f),l=w(a,l),l=new p(z(l.x*u.beta),l.y,l.z),r=f.add(l),n=c.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return p.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:i}=this,o=this.equals(p.ZERO);null==t&&(t=o?s:$(i));const a=t,f=z(a*a),c=z(f*a),u=z(e*f),l=z(r*c),h=z(i*a);if(o)return b.ZERO;if(h!==n)throw new Error("invZ was invalid");return new b(u,l)}}function w(t,e){const r=e.negate();return t?r:e}p.BASE=new p(f.Gx,f.Gy,n),p.ZERO=new p(r,n,r);const g=new WeakMap;class b{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,g.delete(this)}hasEvenY(){return this.y%o===r}static fromCompressedHex(t){const e=32===t.length,r=U(e?t:t.subarray(1));if(!j(r))throw new Error("Point is not on curve");let i=function(t){const{P:e}=f,r=BigInt(6),n=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),u=BigInt(88),l=t*t*t%e,h=l*l*t%e,d=_(h,a)*h%e,y=_(d,a)*h%e,p=_(y,o)*l%e,w=_(p,n)*p%e,g=_(w,i)*w%e,b=_(g,c)*g%e,m=_(b,u)*b%e,v=_(m,c)*g%e,x=_(v,a)*h%e,E=_(x,s)*w%e,A=_(E,r)*l%e,B=_(A,o);if(B*B%e!==t)throw new Error("Cannot find square root");return B}(l(r));const s=(i&n)===n;e?s&&(i=z(-i)):1==(1&t[0])!==s&&(i=z(-i));const c=new b(r,i);return c.assertValidity(),c}static fromUncompressedHex(t){const e=U(t.subarray(1,33)),r=U(t.subarray(33,65)),n=new b(e,r);return n.assertValidity(),n}static fromHex(t){const e=T(t),r=e.length,n=e[0];if(32===r)return this.fromCompressedHex(e);if(33===r&&(2===n||3===n))return this.fromCompressedHex(e);if(65===r&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return b.BASE.multiply(K(t))}static fromSignature(t,e,r){const{r:n,s:i}=function(t){if(t instanceof x)return t.assertValidity(),t;try{return x.fromDER(t)}catch(e){return x.fromCompact(t)}}(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=function(t,e=!1){const r=function(t){const e=8*t.length-256,r=U(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=f;return r>=n?r-n:r}(T(t)),{n:a}=f,s=2===r||3===r?n+a:n,c=$(s,a),u=z(-o*c,a),l=z(i*c,a),h=1&r?"03":"02",d=b.fromHex(h+I(s)),y=b.BASE.multiplyAndAddUnsafe(d,u,l);if(!y)throw new Error("Cannot recover signature: point at infinify");return y.assertValidity(),y}toRawBytes(t=!1){return R(this.toHex(t))}toHex(t=!1){const e=I(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${I(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:n}=this;if(!j(e)||!j(n))throw new Error(t);const i=z(n*n);if(z(i-l(e))!==r)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new b(this.x,z(-this.y))}double(){return p.fromAffine(this).double().toAffine()}add(t){return p.fromAffine(this).add(p.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return p.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,i){const o=p.fromAffine(this),a=e===r||e===n||this!==b.BASE?o.multiplyUnsafe(e):o.multiply(e),s=p.fromAffine(t).multiplyUnsafe(i),f=a.add(s);return f.equals(p.ZERO)?void 0:f.toAffine()}}function m(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function v(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${B(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:U(r),left:t.subarray(e+2)}}b.BASE=new b(f.Gx,f.Gy),b.ZERO=new b(r,r);class x{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?B(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new x(k(n.slice(0,64)),k(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${B(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=v(t.subarray(2)),{data:n,left:i}=v(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${B(i)}`);return{r:e,s:n}}(e?t:R(t));return new x(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!Z(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Z(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=f.n>>n;return this.s>t}normalizeS(){return this.hasHighS()?new x(this.r,z(-this.s,f.n)):this}toDERRawBytes(){return R(this.toDERHex())}toDERHex(){const t=m(H(this.s)),e=m(H(this.r)),r=t.length/2,n=e.length/2,i=H(r),o=H(n);return`30${H(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return R(this.toCompactHex())}toCompactHex(){return I(this.r)+I(this.s)}}function E(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const A=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function B(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=A[t[r]];return e}const S=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function I(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(r<=t&&t<S))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function P(t){const e=R(I(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function H(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function k(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function R(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function U(t){return k(B(t))}function T(t){return t instanceof Uint8Array?Uint8Array.from(t):R(t)}function O(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&Z(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function z(t,e=f.P){const n=t%e;return n>=r?n:e+n}function _(t,e){const{P:n}=f;let i=t;for(;e-- >r;)i*=i,i%=n;return i}function $(t,e=f.P){if(t===r||e<=r)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let i=z(t,e),o=e,a=r,s=n,c=n,u=r;for(;i!==r;){const t=o/i,e=o%i,r=a-c*t,n=s-u*t;o=i,i=e,a=c,s=u,c=r,u=n}if(o!==n)throw new Error("invert: does not exist");return z(a,e)}let C,N;function Z(t){return r<t&&t<f.n}function j(t){return r<t&&t<f.P}function K(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private key");e=k(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==t.length)throw new Error("Expected 32 bytes of private key");e=U(t)}if(!Z(e))throw new Error("Expected private key: 0 < key < n");return e}b.BASE._setWindowSize(8);const M={node:e,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},D={},G={bytesToHex:B,hexToBytes:R,concatBytes:E,mod:z,invert:$,isValidPrivateKey(t){try{return K(t),!0}catch(t){return!1}},_bigintTo32Bytes:P,_normalizePrivateKey:K,hashToPrivateKey:t=>{if((t=T(t)).length<40||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return P(z(U(t),f.n-n)+n)},randomBytes:(t=32)=>{if(M.web)return M.web.getRandomValues(new Uint8Array(t));if(M.node){const{randomBytes:e}=M.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>G.hashToPrivateKey(G.randomBytes(40)),precompute(t=8,e=b.BASE){const r=e===b.BASE?e:new b(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(M.web){const e=await M.web.subtle.digest("SHA-256",E(...t));return new Uint8Array(e)}if(M.node){const{createHash:e}=M.node,r=e("sha256");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(M.web){const r=await M.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=E(...e),i=await M.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(M.node){const{createHmac:r}=M.node,n=r("sha256",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...e)=>{let r=D[t];if(void 0===r){const e=await G.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=E(e,e),D[t]=r}return G.sha256(r,...e)},taggedHashSync:(t,...e)=>{if("function"!=typeof C)throw new d("sha256Sync is undefined, you need to set it");let r=D[t];if(void 0===r){const e=C(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=E(e,e),D[t]=r}return C(r,...e)},_JacobianPoint:p};Object.defineProperties(G,{sha256Sync:{configurable:!1,get:()=>C,set(t){C||(C=t)}},hmacSha256Sync:{configurable:!1,get:()=>N,set(t){N||(N=t)}}});function V(t){return e=this,r=void 0,i=function(){var e,r,n,i;return function(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(f){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,f])}}}(this,(function(o){switch(o.label){case 0:return e?[3,6]:[4,G.sha256(t)];case 1:r=o.sent(),n=G.bytesToHex(r),i="02"+n,o.label=2;case 2:return o.trys.push([2,3,,5]),e=b.fromHex(i),[3,5];case 3:return o.sent(),[4,G.sha256(t)];case 4:return t=o.sent(),[3,5];case 5:return[3,0];case 6:return[2,e]}}))},new((n=void 0)||(n=Promise))((function(t,o){function a(t){try{f(i.next(t))}catch(t){o(t)}}function s(t){try{f(i.throw(t))}catch(t){o(t)}}function f(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(t){t(r)}))).then(a,s)}f((i=i.apply(e,r||[])).next())}));var e,r,n,i}function W(t){return function(t){try{return BigInt("0x".concat(t))}catch(e){throw new Error("could not create BigInt from string: "+t)}}(G.bytesToHex(t))}var q=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{f(n.next(t))}catch(t){o(t)}}function s(t){try{f(n.throw(t))}catch(t){o(t)}}function f(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}f((n=n.apply(t,e||[])).next())}))},F=function(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(f){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,f])}}},J=function(){function t(){}return t.prototype.createBlindedMessage=function(t){return q(this,void 0,void 0,(function(){var e;return F(this,(function(r){switch(r.label){case 0:return this.secret=t,e=this,[4,V(this.secret)];case 1:return e.Y=r.sent(),this.r=W(G.randomPrivateKey()),this.rG=b.BASE.multiply(this.r),this.B_=this.Y.add(this.rG),[2,this.B_]}}))}))},t.prototype.createBlindedMessageFromString=function(t){return q(this,void 0,void 0,(function(){var e;return F(this,(function(r){switch(r.label){case 0:return e=new TextEncoder,this.secret=e.encode(t),[4,this.createBlindedMessage(this.secret)];case 1:return[2,r.sent()]}}))}))},t.prototype.unblindSignature=function(t,e){return{C:t.subtract(e.multiply(this.r)),secret:this.secret}},t}(),Y=function(){function t(t){this.privateKey=t||G.randomPrivateKey(),this.publicKey=b.BASE.multiply(W(this.privateKey))}return t.prototype.createBlindSignature=function(t){return t.multiply(W(this.privateKey))},t.prototype.calculateCVerify=function(t){return e=this,r=void 0,i=function(){return function(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(f){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,f])}}}(this,(function(e){switch(e.label){case 0:return[4,V(t)];case 1:return[2,e.sent().multiply(W(this.privateKey))]}}))},new((n=void 0)||(n=Promise))((function(t,o){function a(t){try{f(i.next(t))}catch(t){o(t)}}function s(t){try{f(i.throw(t))}catch(t){o(t)}}function f(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(t){t(r)}))).then(a,s)}f((i=i.apply(e,r||[])).next())}));var e,r,n,i},t.prototype.verify=function(t,e){return t.equals(e)},t}();G.randomPrivateKey,G.randomBytes,blindSigJS={getRand:t=>window.crypto.getRandomValues(new Uint8Array(t)),ecPointToHex:function(t){return t.toHex()},bsjMint:Y,bsjMsg:J}})()})();