Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethr-did-resolver

Package Overview
Dependencies
Maintainers
7
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethr-did-resolver - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

src/__tests__/networks-tests.js

2

dist/ethr-did-resolver.js

@@ -1,2 +0,2 @@

function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var i=t(require("ethjs-provider-http")),e=t(require("ethjs-query")),n=t(require("ethjs-abi")),r=t(require("ethjs-contract")),h=require("buffer");const s=function(){function t(){}return t.prototype.then=function(i,e){const n=new t,r=this.s;if(r){const t=1&r?i:e;if(t){try{o(n,1,t(this.v))}catch(t){o(n,2,t)}return n}return this}return this.o=function(t){try{const r=t.v;1&t.s?o(n,1,i?i(r):r):e?o(n,1,e(r)):o(n,2,r)}catch(t){o(n,2,t)}},n},t}();function o(t,i,e){if(!t.s){if(e instanceof s){if(!e.s)return void(e.o=o.bind(null,t,i));1&i&&(i=e.s),e=e.v}if(e&&e.then)return void e.then(o.bind(null,t,i),o.bind(null,t,2));t.s=i,t.v=e;const n=t.o;n&&n(t)}}function u(t){return t instanceof s&&1&t.s}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l=function(t,i){return function(t){!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var e=function(){};e.prototype=i.prototype,t.prototype=new e,t.prototype.constructor=t}function r(t,i,e){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(e=i,i=10),this._init(t||0,i||10,e||"be"))}var h;"object"==typeof t?t.exports=r:i.BN=r,r.BN=r,r.wordSize=26;try{h=function(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}().Buffer}catch(t){}function s(t,i,e){for(var n=0,r=Math.min(t.length,e),h=i;h<r;h++){var s=t.charCodeAt(h)-48;n<<=4,n|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function o(t,i,e,n){for(var r=0,h=Math.min(t.length,e),s=i;s<h;s++){var o=t.charCodeAt(s)-48;r*=n,r+=o>=49?o-49+10:o>=17?o-17+10:o}return r}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,i){return t.cmp(i)>0?t:i},r.min=function(t,i){return t.cmp(i)<0?t:i},r.prototype._init=function(t,i,n){if("number"==typeof t)return this._initNumber(t,i,n);if("object"==typeof t)return this._initArray(t,i,n);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===i?this._parseHex(t,r):this._parseBase(t,i,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initNumber=function(t,i,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initArray=function(t,i,n){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var h,s,o=0;if("be"===n)for(r=t.length-1,h=0;r>=0;r-=3)this.words[h]|=(s=t[r]|t[r-1]<<8|t[r-2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);else if("le"===n)for(r=0,h=0;r<t.length;r+=3)this.words[h]|=(s=t[r]|t[r+1]<<8|t[r+2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);return this.strip()},r.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,r,h=0;for(e=t.length-6,n=0;e>=i;e-=6)r=s(t,e,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303,(h+=24)>=26&&(h-=26,n++);e+6!==i&&(r=s(t,i,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303),this.strip()},r.prototype._parseBase=function(t,i,e){this.words=[0],this.length=1;for(var n=0,r=1;r<=67108863;r*=i)n++;r=r/i|0;for(var h=t.length-e,s=h%--n,u=Math.min(h,h-s)+e,a=0,l=e;l<u;l+=n)a=o(t,l,l+n,i),this.imuln(r),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a);if(0!==s){var m=1;for(a=o(t,l,t.length,i),l=0;l<s;l++)m*=i;this.imuln(m),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a)}},r.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},r.prototype.clone=function(){var t=new r(null);return this.copy(t),t},r.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},r.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,e){e.negative=i.negative^t.negative;var n=t.length+i.length|0;e.length=n,n=n-1|0;var r=0|t.words[0],h=0|i.words[0],s=r*h,o=s/67108864|0;e.words[0]=67108863&s;for(var u=1;u<n;u++){for(var a=o>>>26,l=67108863&o,m=Math.min(u,i.length-1),d=Math.max(0,u-t.length+1);d<=m;d++)a+=(s=(r=0|t.words[u-d|0])*(h=0|i.words[d])+l)/67108864|0,l=67108863&s;e.words[u]=0|l,o=0|a}return 0!==o?e.words[u]=0|o:e.length--,e.strip()}r.prototype.toString=function(t,i){var n;if(i=0|i||1,16===(t=t||10)||"hex"===t){n="";for(var r=0,h=0,s=0;s<this.length;s++){var o=this.words[s],m=(16777215&(o<<r|h)).toString(16);n=0!=(h=o>>>24-r&16777215)||s!==this.length-1?u[6-m.length]+m+n:m+n,(r+=2)>=26&&(r-=26,s--)}for(0!==h&&(n=h.toString(16)+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var d=a[t],f=l[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(t);n=(p=p.idivn(f)).isZero()?c+n:u[d-c.length]+c+n}for(this.isZero()&&(n="0"+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}e(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,i){return e(void 0!==h),this.toArrayLike(h,t,i)},r.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},r.prototype.toArrayLike=function(t,i,n){var r=this.byteLength(),h=n||Math.max(1,r);e(r<=h,"byte array longer than desired length"),e(h>0,"Requested array length <= 0"),this.strip();var s,o,u="le"===i,a=new t(h),l=this.clone();if(u){for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),a[o]=s;for(;o<h;o++)a[o]=0}else{for(o=0;o<h-r;o++)a[o]=0;for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),a[h-o-1]=s}return a},r.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var i=t,e=0;return i>=4096&&(e+=13,i>>>=13),i>=64&&(e+=7,i>>>=7),i>=8&&(e+=4,i>>>=4),i>=2&&(e+=2,i>>>=2),e+i},r.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,e=0;return 0==(8191&i)&&(e+=13,i>>>=13),0==(127&i)&&(e+=7,i>>>=7),0==(15&i)&&(e+=4,i>>>=4),0==(3&i)&&(e+=2,i>>>=2),0==(1&i)&&e++,e},r.prototype.bitLength=function(){var t=this._countBits(this.words[this.length-1]);return 26*(this.length-1)+t},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var e=this._zeroBits(this.words[i]);if(t+=e,26!==e)break}return t},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},r.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return 0!==this.negative},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this.strip()},r.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},r.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var e=0;e<i.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=i.length,this.strip()},r.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},r.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0;n<e.length;n++)this.words[n]=i.words[n]^e.words[n];if(this!==i)for(;n<i.length;n++)this.words[n]=i.words[n];return this.length=i.length,this.strip()},r.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},r.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),n=t%26;this._expand(i),n>0&&i--;for(var r=0;r<i;r++)this.words[r]=67108863&~this.words[r];return n>0&&(this.words[r]=~this.words[r]&67108863>>26-n),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var n=t/26|0,r=t%26;return this._expand(n+1),this.words[n]=i?this.words[n]|1<<r:this.words[n]&~(1<<r),this.strip()},r.prototype.iadd=function(t){var i,e,n;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0,h=0;h<n.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+(0|n.words[h])+r),r=i>>>26;for(;0!==r&&h<e.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+r),r=i>>>26;if(this.length=e.length,0!==r)this.words[this.length]=r,this.length++;else if(e!==this)for(;h<e.length;h++)this.words[h]=e.words[h];return this},r.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e,n,r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(e=this,n=t):(e=t,n=this);for(var h=0,s=0;s<n.length;s++)h=(i=(0|e.words[s])-(0|n.words[s])+h)>>26,this.words[s]=67108863&i;for(;0!==h&&s<e.length;s++)h=(i=(0|e.words[s])+h)>>26,this.words[s]=67108863&i;if(0===h&&s<e.length&&e!==this)for(;s<e.length;s++)this.words[s]=e.words[s];return this.length=Math.max(this.length,s),e!==this&&(this.negative=1),this.strip()},r.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,i,e){var n,r,h,s=t.words,o=i.words,u=e.words,a=0,l=0|s[0],m=8191&l,d=l>>>13,f=0|s[1],p=8191&f,c=f>>>13,y=0|s[2],v=8191&y,g=y>>>13,M=0|s[3],w=8191&M,b=M>>>13,_=0|s[4],S=8191&_,k=_>>>13,x=0|s[5],A=8191&x,B=x>>>13,R=0|s[6],q=8191&R,D=R>>>13,T=0|s[7],Z=8191&T,I=T>>>13,N=0|s[8],j=8191&N,O=N>>>13,K=0|s[9],L=8191&K,C=K>>>13,P=0|o[0],E=8191&P,z=P>>>13,V=0|o[1],F=8191&V,H=V>>>13,$=0|o[2],U=8191&$,G=$>>>13,J=0|o[3],Y=8191&J,Q=J>>>13,W=0|o[4],X=8191&W,tt=W>>>13,it=0|o[5],et=8191&it,nt=it>>>13,rt=0|o[6],ht=8191&rt,st=rt>>>13,ot=0|o[7],ut=8191&ot,at=ot>>>13,lt=0|o[8],mt=8191&lt,dt=lt>>>13,ft=0|o[9],pt=8191&ft,ct=ft>>>13;e.negative=t.negative^i.negative,e.length=19;var yt=(a+(n=Math.imul(m,E))|0)+((8191&(r=(r=Math.imul(m,z))+Math.imul(d,E)|0))<<13)|0;a=((h=Math.imul(d,z))+(r>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,E),r=(r=Math.imul(p,z))+Math.imul(c,E)|0,h=Math.imul(c,z);var vt=(a+(n=n+Math.imul(m,F)|0)|0)+((8191&(r=(r=r+Math.imul(m,H)|0)+Math.imul(d,F)|0))<<13)|0;a=((h=h+Math.imul(d,H)|0)+(r>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,E),r=(r=Math.imul(v,z))+Math.imul(g,E)|0,h=Math.imul(g,z),n=n+Math.imul(p,F)|0,r=(r=r+Math.imul(p,H)|0)+Math.imul(c,F)|0,h=h+Math.imul(c,H)|0;var gt=(a+(n=n+Math.imul(m,U)|0)|0)+((8191&(r=(r=r+Math.imul(m,G)|0)+Math.imul(d,U)|0))<<13)|0;a=((h=h+Math.imul(d,G)|0)+(r>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,E),r=(r=Math.imul(w,z))+Math.imul(b,E)|0,h=Math.imul(b,z),n=n+Math.imul(v,F)|0,r=(r=r+Math.imul(v,H)|0)+Math.imul(g,F)|0,h=h+Math.imul(g,H)|0,n=n+Math.imul(p,U)|0,r=(r=r+Math.imul(p,G)|0)+Math.imul(c,U)|0,h=h+Math.imul(c,G)|0;var Mt=(a+(n=n+Math.imul(m,Y)|0)|0)+((8191&(r=(r=r+Math.imul(m,Q)|0)+Math.imul(d,Y)|0))<<13)|0;a=((h=h+Math.imul(d,Q)|0)+(r>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(S,E),r=(r=Math.imul(S,z))+Math.imul(k,E)|0,h=Math.imul(k,z),n=n+Math.imul(w,F)|0,r=(r=r+Math.imul(w,H)|0)+Math.imul(b,F)|0,h=h+Math.imul(b,H)|0,n=n+Math.imul(v,U)|0,r=(r=r+Math.imul(v,G)|0)+Math.imul(g,U)|0,h=h+Math.imul(g,G)|0,n=n+Math.imul(p,Y)|0,r=(r=r+Math.imul(p,Q)|0)+Math.imul(c,Y)|0,h=h+Math.imul(c,Q)|0;var wt=(a+(n=n+Math.imul(m,X)|0)|0)+((8191&(r=(r=r+Math.imul(m,tt)|0)+Math.imul(d,X)|0))<<13)|0;a=((h=h+Math.imul(d,tt)|0)+(r>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(A,E),r=(r=Math.imul(A,z))+Math.imul(B,E)|0,h=Math.imul(B,z),n=n+Math.imul(S,F)|0,r=(r=r+Math.imul(S,H)|0)+Math.imul(k,F)|0,h=h+Math.imul(k,H)|0,n=n+Math.imul(w,U)|0,r=(r=r+Math.imul(w,G)|0)+Math.imul(b,U)|0,h=h+Math.imul(b,G)|0,n=n+Math.imul(v,Y)|0,r=(r=r+Math.imul(v,Q)|0)+Math.imul(g,Y)|0,h=h+Math.imul(g,Q)|0,n=n+Math.imul(p,X)|0,r=(r=r+Math.imul(p,tt)|0)+Math.imul(c,X)|0,h=h+Math.imul(c,tt)|0;var bt=(a+(n=n+Math.imul(m,et)|0)|0)+((8191&(r=(r=r+Math.imul(m,nt)|0)+Math.imul(d,et)|0))<<13)|0;a=((h=h+Math.imul(d,nt)|0)+(r>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(q,E),r=(r=Math.imul(q,z))+Math.imul(D,E)|0,h=Math.imul(D,z),n=n+Math.imul(A,F)|0,r=(r=r+Math.imul(A,H)|0)+Math.imul(B,F)|0,h=h+Math.imul(B,H)|0,n=n+Math.imul(S,U)|0,r=(r=r+Math.imul(S,G)|0)+Math.imul(k,U)|0,h=h+Math.imul(k,G)|0,n=n+Math.imul(w,Y)|0,r=(r=r+Math.imul(w,Q)|0)+Math.imul(b,Y)|0,h=h+Math.imul(b,Q)|0,n=n+Math.imul(v,X)|0,r=(r=r+Math.imul(v,tt)|0)+Math.imul(g,X)|0,h=h+Math.imul(g,tt)|0,n=n+Math.imul(p,et)|0,r=(r=r+Math.imul(p,nt)|0)+Math.imul(c,et)|0,h=h+Math.imul(c,nt)|0;var _t=(a+(n=n+Math.imul(m,ht)|0)|0)+((8191&(r=(r=r+Math.imul(m,st)|0)+Math.imul(d,ht)|0))<<13)|0;a=((h=h+Math.imul(d,st)|0)+(r>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(Z,E),r=(r=Math.imul(Z,z))+Math.imul(I,E)|0,h=Math.imul(I,z),n=n+Math.imul(q,F)|0,r=(r=r+Math.imul(q,H)|0)+Math.imul(D,F)|0,h=h+Math.imul(D,H)|0,n=n+Math.imul(A,U)|0,r=(r=r+Math.imul(A,G)|0)+Math.imul(B,U)|0,h=h+Math.imul(B,G)|0,n=n+Math.imul(S,Y)|0,r=(r=r+Math.imul(S,Q)|0)+Math.imul(k,Y)|0,h=h+Math.imul(k,Q)|0,n=n+Math.imul(w,X)|0,r=(r=r+Math.imul(w,tt)|0)+Math.imul(b,X)|0,h=h+Math.imul(b,tt)|0,n=n+Math.imul(v,et)|0,r=(r=r+Math.imul(v,nt)|0)+Math.imul(g,et)|0,h=h+Math.imul(g,nt)|0,n=n+Math.imul(p,ht)|0,r=(r=r+Math.imul(p,st)|0)+Math.imul(c,ht)|0,h=h+Math.imul(c,st)|0;var St=(a+(n=n+Math.imul(m,ut)|0)|0)+((8191&(r=(r=r+Math.imul(m,at)|0)+Math.imul(d,ut)|0))<<13)|0;a=((h=h+Math.imul(d,at)|0)+(r>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(j,E),r=(r=Math.imul(j,z))+Math.imul(O,E)|0,h=Math.imul(O,z),n=n+Math.imul(Z,F)|0,r=(r=r+Math.imul(Z,H)|0)+Math.imul(I,F)|0,h=h+Math.imul(I,H)|0,n=n+Math.imul(q,U)|0,r=(r=r+Math.imul(q,G)|0)+Math.imul(D,U)|0,h=h+Math.imul(D,G)|0,n=n+Math.imul(A,Y)|0,r=(r=r+Math.imul(A,Q)|0)+Math.imul(B,Y)|0,h=h+Math.imul(B,Q)|0,n=n+Math.imul(S,X)|0,r=(r=r+Math.imul(S,tt)|0)+Math.imul(k,X)|0,h=h+Math.imul(k,tt)|0,n=n+Math.imul(w,et)|0,r=(r=r+Math.imul(w,nt)|0)+Math.imul(b,et)|0,h=h+Math.imul(b,nt)|0,n=n+Math.imul(v,ht)|0,r=(r=r+Math.imul(v,st)|0)+Math.imul(g,ht)|0,h=h+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,r=(r=r+Math.imul(p,at)|0)+Math.imul(c,ut)|0,h=h+Math.imul(c,at)|0;var kt=(a+(n=n+Math.imul(m,mt)|0)|0)+((8191&(r=(r=r+Math.imul(m,dt)|0)+Math.imul(d,mt)|0))<<13)|0;a=((h=h+Math.imul(d,dt)|0)+(r>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,E),r=(r=Math.imul(L,z))+Math.imul(C,E)|0,h=Math.imul(C,z),n=n+Math.imul(j,F)|0,r=(r=r+Math.imul(j,H)|0)+Math.imul(O,F)|0,h=h+Math.imul(O,H)|0,n=n+Math.imul(Z,U)|0,r=(r=r+Math.imul(Z,G)|0)+Math.imul(I,U)|0,h=h+Math.imul(I,G)|0,n=n+Math.imul(q,Y)|0,r=(r=r+Math.imul(q,Q)|0)+Math.imul(D,Y)|0,h=h+Math.imul(D,Q)|0,n=n+Math.imul(A,X)|0,r=(r=r+Math.imul(A,tt)|0)+Math.imul(B,X)|0,h=h+Math.imul(B,tt)|0,n=n+Math.imul(S,et)|0,r=(r=r+Math.imul(S,nt)|0)+Math.imul(k,et)|0,h=h+Math.imul(k,nt)|0,n=n+Math.imul(w,ht)|0,r=(r=r+Math.imul(w,st)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,st)|0,n=n+Math.imul(v,ut)|0,r=(r=r+Math.imul(v,at)|0)+Math.imul(g,ut)|0,h=h+Math.imul(g,at)|0,n=n+Math.imul(p,mt)|0,r=(r=r+Math.imul(p,dt)|0)+Math.imul(c,mt)|0,h=h+Math.imul(c,dt)|0;var xt=(a+(n=n+Math.imul(m,pt)|0)|0)+((8191&(r=(r=r+Math.imul(m,ct)|0)+Math.imul(d,pt)|0))<<13)|0;a=((h=h+Math.imul(d,ct)|0)+(r>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,F),r=(r=Math.imul(L,H))+Math.imul(C,F)|0,h=Math.imul(C,H),n=n+Math.imul(j,U)|0,r=(r=r+Math.imul(j,G)|0)+Math.imul(O,U)|0,h=h+Math.imul(O,G)|0,n=n+Math.imul(Z,Y)|0,r=(r=r+Math.imul(Z,Q)|0)+Math.imul(I,Y)|0,h=h+Math.imul(I,Q)|0,n=n+Math.imul(q,X)|0,r=(r=r+Math.imul(q,tt)|0)+Math.imul(D,X)|0,h=h+Math.imul(D,tt)|0,n=n+Math.imul(A,et)|0,r=(r=r+Math.imul(A,nt)|0)+Math.imul(B,et)|0,h=h+Math.imul(B,nt)|0,n=n+Math.imul(S,ht)|0,r=(r=r+Math.imul(S,st)|0)+Math.imul(k,ht)|0,h=h+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,r=(r=r+Math.imul(w,at)|0)+Math.imul(b,ut)|0,h=h+Math.imul(b,at)|0,n=n+Math.imul(v,mt)|0,r=(r=r+Math.imul(v,dt)|0)+Math.imul(g,mt)|0,h=h+Math.imul(g,dt)|0;var At=(a+(n=n+Math.imul(p,pt)|0)|0)+((8191&(r=(r=r+Math.imul(p,ct)|0)+Math.imul(c,pt)|0))<<13)|0;a=((h=h+Math.imul(c,ct)|0)+(r>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,U),r=(r=Math.imul(L,G))+Math.imul(C,U)|0,h=Math.imul(C,G),n=n+Math.imul(j,Y)|0,r=(r=r+Math.imul(j,Q)|0)+Math.imul(O,Y)|0,h=h+Math.imul(O,Q)|0,n=n+Math.imul(Z,X)|0,r=(r=r+Math.imul(Z,tt)|0)+Math.imul(I,X)|0,h=h+Math.imul(I,tt)|0,n=n+Math.imul(q,et)|0,r=(r=r+Math.imul(q,nt)|0)+Math.imul(D,et)|0,h=h+Math.imul(D,nt)|0,n=n+Math.imul(A,ht)|0,r=(r=r+Math.imul(A,st)|0)+Math.imul(B,ht)|0,h=h+Math.imul(B,st)|0,n=n+Math.imul(S,ut)|0,r=(r=r+Math.imul(S,at)|0)+Math.imul(k,ut)|0,h=h+Math.imul(k,at)|0,n=n+Math.imul(w,mt)|0,r=(r=r+Math.imul(w,dt)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,dt)|0;var Bt=(a+(n=n+Math.imul(v,pt)|0)|0)+((8191&(r=(r=r+Math.imul(v,ct)|0)+Math.imul(g,pt)|0))<<13)|0;a=((h=h+Math.imul(g,ct)|0)+(r>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(L,Y),r=(r=Math.imul(L,Q))+Math.imul(C,Y)|0,h=Math.imul(C,Q),n=n+Math.imul(j,X)|0,r=(r=r+Math.imul(j,tt)|0)+Math.imul(O,X)|0,h=h+Math.imul(O,tt)|0,n=n+Math.imul(Z,et)|0,r=(r=r+Math.imul(Z,nt)|0)+Math.imul(I,et)|0,h=h+Math.imul(I,nt)|0,n=n+Math.imul(q,ht)|0,r=(r=r+Math.imul(q,st)|0)+Math.imul(D,ht)|0,h=h+Math.imul(D,st)|0,n=n+Math.imul(A,ut)|0,r=(r=r+Math.imul(A,at)|0)+Math.imul(B,ut)|0,h=h+Math.imul(B,at)|0,n=n+Math.imul(S,mt)|0,r=(r=r+Math.imul(S,dt)|0)+Math.imul(k,mt)|0,h=h+Math.imul(k,dt)|0;var Rt=(a+(n=n+Math.imul(w,pt)|0)|0)+((8191&(r=(r=r+Math.imul(w,ct)|0)+Math.imul(b,pt)|0))<<13)|0;a=((h=h+Math.imul(b,ct)|0)+(r>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),r=(r=Math.imul(L,tt))+Math.imul(C,X)|0,h=Math.imul(C,tt),n=n+Math.imul(j,et)|0,r=(r=r+Math.imul(j,nt)|0)+Math.imul(O,et)|0,h=h+Math.imul(O,nt)|0,n=n+Math.imul(Z,ht)|0,r=(r=r+Math.imul(Z,st)|0)+Math.imul(I,ht)|0,h=h+Math.imul(I,st)|0,n=n+Math.imul(q,ut)|0,r=(r=r+Math.imul(q,at)|0)+Math.imul(D,ut)|0,h=h+Math.imul(D,at)|0,n=n+Math.imul(A,mt)|0,r=(r=r+Math.imul(A,dt)|0)+Math.imul(B,mt)|0,h=h+Math.imul(B,dt)|0;var qt=(a+(n=n+Math.imul(S,pt)|0)|0)+((8191&(r=(r=r+Math.imul(S,ct)|0)+Math.imul(k,pt)|0))<<13)|0;a=((h=h+Math.imul(k,ct)|0)+(r>>>13)|0)+(qt>>>26)|0,qt&=67108863,n=Math.imul(L,et),r=(r=Math.imul(L,nt))+Math.imul(C,et)|0,h=Math.imul(C,nt),n=n+Math.imul(j,ht)|0,r=(r=r+Math.imul(j,st)|0)+Math.imul(O,ht)|0,h=h+Math.imul(O,st)|0,n=n+Math.imul(Z,ut)|0,r=(r=r+Math.imul(Z,at)|0)+Math.imul(I,ut)|0,h=h+Math.imul(I,at)|0,n=n+Math.imul(q,mt)|0,r=(r=r+Math.imul(q,dt)|0)+Math.imul(D,mt)|0,h=h+Math.imul(D,dt)|0;var Dt=(a+(n=n+Math.imul(A,pt)|0)|0)+((8191&(r=(r=r+Math.imul(A,ct)|0)+Math.imul(B,pt)|0))<<13)|0;a=((h=h+Math.imul(B,ct)|0)+(r>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(L,ht),r=(r=Math.imul(L,st))+Math.imul(C,ht)|0,h=Math.imul(C,st),n=n+Math.imul(j,ut)|0,r=(r=r+Math.imul(j,at)|0)+Math.imul(O,ut)|0,h=h+Math.imul(O,at)|0,n=n+Math.imul(Z,mt)|0,r=(r=r+Math.imul(Z,dt)|0)+Math.imul(I,mt)|0,h=h+Math.imul(I,dt)|0;var Tt=(a+(n=n+Math.imul(q,pt)|0)|0)+((8191&(r=(r=r+Math.imul(q,ct)|0)+Math.imul(D,pt)|0))<<13)|0;a=((h=h+Math.imul(D,ct)|0)+(r>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,ut),r=(r=Math.imul(L,at))+Math.imul(C,ut)|0,h=Math.imul(C,at),n=n+Math.imul(j,mt)|0,r=(r=r+Math.imul(j,dt)|0)+Math.imul(O,mt)|0,h=h+Math.imul(O,dt)|0;var Zt=(a+(n=n+Math.imul(Z,pt)|0)|0)+((8191&(r=(r=r+Math.imul(Z,ct)|0)+Math.imul(I,pt)|0))<<13)|0;a=((h=h+Math.imul(I,ct)|0)+(r>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,n=Math.imul(L,mt),r=(r=Math.imul(L,dt))+Math.imul(C,mt)|0,h=Math.imul(C,dt);var It=(a+(n=n+Math.imul(j,pt)|0)|0)+((8191&(r=(r=r+Math.imul(j,ct)|0)+Math.imul(O,pt)|0))<<13)|0;a=((h=h+Math.imul(O,ct)|0)+(r>>>13)|0)+(It>>>26)|0,It&=67108863;var Nt=(a+(n=Math.imul(L,pt))|0)+((8191&(r=(r=Math.imul(L,ct))+Math.imul(C,pt)|0))<<13)|0;return a=((h=Math.imul(C,ct))+(r>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=Mt,u[4]=wt,u[5]=bt,u[6]=_t,u[7]=St,u[8]=kt,u[9]=xt,u[10]=At,u[11]=Bt,u[12]=Rt,u[13]=qt,u[14]=Dt,u[15]=Tt,u[16]=Zt,u[17]=It,u[18]=Nt,0!==a&&(u[19]=a,e.length++),e};function f(t,i,e){return(new p).mulp(t,i,e)}function p(t,i){this.x=t,this.y=i}Math.imul||(d=m),r.prototype.mulTo=function(t,i){var e=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):e<63?m(this,t,i):e<1024?function(t,i,e){e.negative=i.negative^t.negative,e.length=t.length+i.length;for(var n=0,r=0,h=0;h<e.length-1;h++){var s=r;r=0;for(var o=67108863&n,u=Math.min(h,i.length-1),a=Math.max(0,h-t.length+1);a<=u;a++){var l=(0|t.words[h-a])*(0|i.words[a]),m=67108863&l;o=67108863&(m=m+o|0),r+=(s=(s=s+(l/67108864|0)|0)+(m>>>26)|0)>>>26,s&=67108863}e.words[h]=o,n=s,s=r}return 0!==n?e.words[h]=n:e.length--,e.strip()}(this,t,i):f(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),e=r.prototype._countBits(t)-1,n=0;n<t;n++)i[n]=this.revBin(n,e,t);return i},p.prototype.revBin=function(t,i,e){if(0===t||t===e-1)return t;for(var n=0,r=0;r<i;r++)n|=(1&t)<<i-r-1,t>>=1;return n},p.prototype.permute=function(t,i,e,n,r,h){for(var s=0;s<h;s++)n[s]=i[t[s]],r[s]=e[t[s]]},p.prototype.transform=function(t,i,e,n,r,h){this.permute(h,t,i,e,n,r);for(var s=1;s<r;s<<=1)for(var o=s<<1,u=Math.cos(2*Math.PI/o),a=Math.sin(2*Math.PI/o),l=0;l<r;l+=o)for(var m=u,d=a,f=0;f<s;f++){var p=e[l+f],c=n[l+f],y=e[l+f+s],v=n[l+f+s],g=m*y-d*v;v=m*v+d*y,e[l+f]=p+(y=g),n[l+f]=c+v,e[l+f+s]=p-y,n[l+f+s]=c-v,f!==o&&(g=u*m-a*d,d=u*d+a*m,m=g)}},p.prototype.guessLen13b=function(t,i){var e=1|Math.max(i,t),n=1&e,r=0;for(e=e/2|0;e;e>>>=1)r++;return 1<<r+1+n},p.prototype.conjugate=function(t,i,e){if(!(e<=1))for(var n=0;n<e/2;n++){var r=t[n];t[n]=t[e-n-1],t[e-n-1]=r,r=i[n],i[n]=-i[e-n-1],i[e-n-1]=-r}},p.prototype.normalize13b=function(t,i){for(var e=0,n=0;n<i/2;n++){var r=8192*Math.round(t[2*n+1]/i)+Math.round(t[2*n]/i)+e;t[n]=67108863&r,e=r<67108864?0:r/67108864|0}return t},p.prototype.convert13b=function(t,i,n,r){for(var h=0,s=0;s<i;s++)n[2*s]=8191&(h+=0|t[s]),n[2*s+1]=8191&(h>>>=13),h>>>=13;for(s=2*i;s<r;++s)n[s]=0;e(0===h),e(0==(-8192&h))},p.prototype.stub=function(t){for(var i=new Array(t),e=0;e<t;e++)i[e]=0;return i},p.prototype.mulp=function(t,i,e){var n=2*this.guessLen13b(t.length,i.length),r=this.makeRBT(n),h=this.stub(n),s=new Array(n),o=new Array(n),u=new Array(n),a=new Array(n),l=new Array(n),m=new Array(n),d=e.words;d.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(i.words,i.length,a,n),this.transform(s,h,o,u,n,r),this.transform(a,h,l,m,n,r);for(var f=0;f<n;f++){var p=o[f]*l[f]-u[f]*m[f];u[f]=o[f]*m[f]+u[f]*l[f],o[f]=p}return this.conjugate(o,u,n),this.transform(o,u,d,h,n,r),this.conjugate(d,h,n),this.normalize13b(d,n),e.negative=t.negative^i.negative,e.length=t.length+i.length,e.strip()},r.prototype.mul=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},r.prototype.mulf=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),f(this,t,i)},r.prototype.imul=function(t){return this.clone().mulTo(t,this)},r.prototype.imuln=function(t){e("number"==typeof t),e(t<67108864);for(var i=0,n=0;n<this.length;n++){var r=(0|this.words[n])*t,h=(67108863&r)+(67108863&i);i>>=26,i+=r/67108864|0,i+=h>>>26,this.words[n]=67108863&h}return 0!==i&&(this.words[n]=i,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),e=0;e<i.length;e++){var n=e%26;i[e]=(t.words[e/26|0]&1<<n)>>>n}return i}(t);if(0===i.length)return new r(1);for(var e=this,n=0;n<i.length&&0===i[n];n++,e=e.sqr());if(++n<i.length)for(var h=e.sqr();n<i.length;n++,h=h.sqr())0!==i[n]&&(e=e.mul(h));return e},r.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,n=t%26,r=(t-n)/26,h=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(i=0;i<this.length;i++){var o=this.words[i]&h;this.words[i]=(0|this.words[i])-o<<n|s,s=o>>>26-n}s&&(this.words[i]=s,this.length++)}if(0!==r){for(i=this.length-1;i>=0;i--)this.words[i+r]=this.words[i];for(i=0;i<r;i++)this.words[i]=0;this.length+=r}return this.strip()},r.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},r.prototype.iushrn=function(t,i,n){var r;e("number"==typeof t&&t>=0),r=i?(i-i%26)/26:0;var h=t%26,s=Math.min((t-h)/26,this.length),o=67108863^67108863>>>h<<h,u=n;if(r-=s,r=Math.max(0,r),u){for(var a=0;a<s;a++)u.words[a]=this.words[a];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,a=0;a<this.length;a++)this.words[a]=this.words[a+s];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=r);a--){var m=0|this.words[a];this.words[a]=l<<26-h|m>>>h,l=m&o}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,i,n){return e(0===this.negative),this.iushrn(t,i,n)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return!(this.length<=n||!(this.words[n]&1<<i))},r.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return e(0===this.negative,"imaskn works only with positive numbers"),this.length<=n?this:(0!==i&&n++,this.length=Math.min(n,this.length),0!==i&&(this.words[this.length-1]&=67108863^67108863>>>i<<i),this.strip())},r.prototype.maskn=function(t){return this.clone().imaskn(t)},r.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},r.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},r.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},r.prototype.addn=function(t){return this.clone().iaddn(t)},r.prototype.subn=function(t){return this.clone().isubn(t)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(t,i,n){var r,h;this._expand(t.length+n);var s=0;for(r=0;r<t.length;r++){h=(0|this.words[r+n])+s;var o=(0|t.words[r])*i;s=((h-=67108863&o)>>26)-(o/67108864|0),this.words[r+n]=67108863&h}for(;r<this.length-n;r++)s=(h=(0|this.words[r+n])+s)>>26,this.words[r+n]=67108863&h;if(0===s)return this.strip();for(e(-1===s),s=0,r=0;r<this.length;r++)s=(h=-(0|this.words[r])+s)>>26,this.words[r]=67108863&h;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,i){var e,n=this.clone(),h=t,s=0|h.words[h.length-1];0!=(e=26-this._countBits(s))&&(h=h.ushln(e),n.iushln(e),s=0|h.words[h.length-1]);var o,u=n.length-h.length;if("mod"!==i){(o=new r(null)).length=u+1,o.words=new Array(o.length);for(var a=0;a<o.length;a++)o.words[a]=0}var l=n.clone()._ishlnsubmul(h,1,u);0===l.negative&&(n=l,o&&(o.words[u]=1));for(var m=u-1;m>=0;m--){var d=67108864*(0|n.words[h.length+m])+(0|n.words[h.length+m-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(h,d,m);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(h,1,m),n.isZero()||(n.negative^=1);o&&(o.words[m]=d)}return o&&o.strip(),n.strip(),"div"!==i&&0!==e&&n.iushrn(e),{div:o||null,mod:n}},r.prototype.divmod=function(t,i,n){return e(!t.isZero()),this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,i),"mod"!==i&&(h=o.div.neg()),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:h,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),i),"mod"!==i&&(h=o.div.neg()),{div:h,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),i),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,i);var h,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var e=0!==i.div.negative?i.mod.isub(t):i.mod,n=t.ushrn(1),r=t.andln(1),h=e.cmp(n);return h<0||1===r&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},r.prototype.modn=function(t){e(t<=67108863);for(var i=(1<<26)%t,n=0,r=this.length-1;r>=0;r--)n=(i*n+(0|this.words[r]))%t;return n},r.prototype.idivn=function(t){e(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var r=(0|this.words[n])+67108864*i;this.words[n]=r/t|0,i=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h=new r(1),s=new r(0),o=new r(0),u=new r(1),a=0;i.isEven()&&n.isEven();)i.iushrn(1),n.iushrn(1),++a;for(var l=n.clone(),m=i.clone();!i.isZero();){for(var d=0,f=1;0==(i.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(h.isOdd()||s.isOdd())&&(h.iadd(l),s.isub(m)),h.iushrn(1),s.iushrn(1);for(var p=0,c=1;0==(n.words[0]&c)&&p<26;++p,c<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(o.isOdd()||u.isOdd())&&(o.iadd(l),u.isub(m)),o.iushrn(1),u.iushrn(1);i.cmp(n)>=0?(i.isub(n),h.isub(o),s.isub(u)):(n.isub(i),o.isub(h),u.isub(s))}return{a:o,b:u,gcd:n.iushln(a)}},r.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h,s=new r(1),o=new r(0),u=n.clone();i.cmpn(1)>0&&n.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var m=0,d=1;0==(n.words[0]&d)&&m<26;++m,d<<=1);if(m>0)for(n.iushrn(m);m-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);i.cmp(n)>=0?(i.isub(n),s.isub(o)):(n.isub(i),o.isub(s))}return(h=0===i.cmpn(1)?s:o).cmpn(0)<0&&h.iadd(t),h},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),e=t.clone();i.negative=0,e.negative=0;for(var n=0;i.isEven()&&e.isEven();n++)i.iushrn(1),e.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;e.isEven();)e.iushrn(1);var r=i.cmp(e);if(r<0){var h=i;i=e,e=h}else if(0===r||0===e.cmpn(1))break;i.isub(e)}return e.iushln(n)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,n=(t-i)/26,r=1<<i;if(this.length<=n)return this._expand(n+1),this.words[n]|=r,this;for(var h=r,s=n;0!==h&&s<this.length;s++){var o=0|this.words[s];h=(o+=h)>>>26,this.words[s]=o&=67108863}return 0!==h&&(this.words[s]=h,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var i,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)i=1;else{n&&(t=-t),e(t<=67108863,"Number is too big");var r=0|this.words[0];i=r===t?0:r<t?-1:1}return 0!==this.negative?0|-i:i},r.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},r.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,e=this.length-1;e>=0;e--){var n=0|this.words[e],r=0|t.words[e];if(n!==r){n<r?i=-1:n>r&&(i=1);break}}return i},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new b(t)},r.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},r.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},r.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},r.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},r.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},r.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},r.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var c={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new r(i,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=r._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,e=t;do{this.split(e,this.tmp),i=(e=(e=this.imulK(e)).iadd(this.tmp)).bitLength()}while(i>this.n);var n=i<this.n?-1:e.ucmp(this.p);return 0===n?(e.words[0]=0,e.length=1):n>0?e.isub(this.p):e.strip(),e},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,i){for(var e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var r=t.words[9];for(i.words[i.length++]=4194303&r,n=10;n<t.length;n++){var h=0|t.words[n];t.words[n-10]=(4194303&h)<<4|r>>>22,r=h}t.words[n-10]=r>>>=22,t.length-=0===r&&t.length>10?10:9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,e=0;e<t.length;e++){var n=0|t.words[e];t.words[e]=67108863&(i+=977*n),i=64*n+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(g,y),n(M,y),n(w,y),w.prototype.imulK=function(t){for(var i=0,e=0;e<t.length;e++){var n=19*(0|t.words[e])+i,r=67108863&n;n>>>=26,t.words[e]=r,i=n}return 0!==i&&(t.words[t.length++]=i),t},r._prime=function(t){if(c[t])return c[t];var i;if("k256"===t)i=new v;else if("p224"===t)i=new g;else if("p192"===t)i=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new w}return c[t]=i,i},b.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var e=t.add(i);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var e=t.iadd(i);return e.cmp(this.m)>=0&&e.isub(this.m),e},b.prototype.sub=function(t,i){this._verify2(t,i);var e=t.sub(i);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var e=t.isub(i);return e.cmpn(0)<0&&e.iadd(this.m),e},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var n=this.m.add(new r(1)).iushrn(2);return this.pow(t,n)}for(var h=this.m.subn(1),s=0;!h.isZero()&&0===h.andln(1);)s++,h.iushrn(1);e(!h.isZero());var o=new r(1).toRed(this),u=o.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new r(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,h),d=this.pow(t,h.addn(1).iushrn(1)),f=this.pow(t,h),p=s;0!==f.cmp(o);){for(var c=f,y=0;0!==c.cmp(o);y++)c=c.redSqr();e(y<p);var v=this.pow(m,new r(1).iushln(p-y-1));d=d.redMul(v),m=v.redSqr(),f=f.redMul(m),p=y}return d},b.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},b.prototype.pow=function(t,i){if(i.isZero())return new r(1);if(0===i.cmpn(1))return t.clone();var e=new Array(16);e[0]=new r(1).toRed(this),e[1]=t;for(var n=2;n<e.length;n++)e[n]=this.mul(e[n-1],t);var h=e[0],s=0,o=0,u=i.bitLength()%26;for(0===u&&(u=26),n=i.length-1;n>=0;n--){for(var a=i.words[n],l=u-1;l>=0;l--){var m=a>>l&1;h!==e[0]&&(h=this.sqr(h)),0!==m||0!==s?(s<<=1,s|=m,(4==++o||0===n&&0===l)&&(h=this.mul(h,e[s]),o=0,s=0)):o=0}u=26}return h},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},r.mont=function(t){return new _(t)},n(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=e.isub(n).iushrn(this.shift),h=r;return r.cmp(this.m)>=0?h=r.isub(this.m):r.cmpn(0)<0&&(h=r.iadd(this.m)),h._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new r(0)._forceRed(this);var e=t.mul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),h=e.isub(n).iushrn(this.shift),s=h;return h.cmp(this.m)>=0?s=h.isub(this.m):h.cmpn(0)<0&&(s=h.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,a)}(i={exports:{}}),i.exports}(),m=[{constant:!0,inputs:[{name:"",type:"address"}],name:"owners",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"},{name:"",type:"bytes32"},{name:"",type:"address"}],name:"delegates",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"nonce",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"changed",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"owner",type:"address"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDOwnerChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"delegateType",type:"bytes32"},{indexed:!1,name:"delegate",type:"address"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDDelegateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"name",type:"bytes32"},{indexed:!1,name:"value",type:"bytes"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDAttributeChanged",type:"event"},{constant:!0,inputs:[{name:"identity",type:"address"}],name:"identityOwner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"validDelegate",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"newOwner",type:"address"}],name:"changeOwner",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"newOwner",type:"address"}],name:"changeOwnerSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],d="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";function f(t){return h.Buffer.from(t.slice(2),"hex").toString("utf8").replace(/\0+$/,"")}function p(t){var i="0x"+h.Buffer.from(t).slice(0,32).toString("hex");return i+"0".repeat(66-i.length)}var c={Secp256k1SignatureAuthentication2018:p("sigAuth"),Secp256k1VerificationKey2018:p("veriKey")},y={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018"};function v(t,i,e){for(var n=new l(Math.floor((new Date).getTime()/1e3)),r=[{id:t+"#owner",type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:i}],s=[{type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#owner"}],o=0,u={},a={},m={},d=0,p=e;d<p.length;d+=1){var c=p[d],v=c.validTo,g=c._eventName+"-"+(c.delegateType||c.name)+"-"+(c.delegate||c.value);if(v&&v.gte(n)){if("DIDDelegateChanged"===c._eventName)switch(o++,f(c.delegateType)){case"sigAuth":u[g]={type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#delegate-"+o};case"veriKey":a[g]={id:t+"#delegate-"+o,type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:c.delegate}}else if("DIDAttributeChanged"===c._eventName){var M=f(c.name).match(/^did\/(pub|auth|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(M){var w=M[2],b=y[M[4]]||M[4],_=M[6];switch(M[1]){case"pub":var S={id:t+"#delegate-"+ ++o,type:""+w+b,owner:t};switch(_){case null:case void 0:case"hex":S.publicKeyHex=c.value.slice(2);break;case"base64":S.publicKeyBase64=h.Buffer.from(c.value.slice(2),"hex").toString("base64");break;case"base58":S.publicKeyBase58=h.Buffer.from(c.value.slice(2),"hex").toString("base58");break;case"pem":S.publicKeyPem=h.Buffer.from(c.value.slice(2),"hex").toString();break;default:S.value=c.value}a[g]=S;break;case"svc":m[g]={type:w,serviceEndpoint:h.Buffer.from(c.value.slice(2),"hex").toString()}}}}}else o>0&&("DIDDelegateChanged"===c._eventName||"DIDAttributeChanged"===c._eventName&&f(c.name).match(/^did\/pub\//))&&v.lt(n)&&o--,delete u[g],delete a[g],delete m[g]}var k={"@context":"https://w3id.org/did/v1",id:t,publicKey:r.concat(Object.values(a)),authentication:s.concat(Object.values(u))};return Object.values(m).length>0&&(k.service=Object.values(m)),k}module.exports={REGISTRY:d,bytes32toString:f,stringToBytes32:p,delegateTypes:c,attrTypes:y,wrapDidDocument:v,getResolver:function(t){void 0===t&&(t={});var h=function(t){return void 0===t&&(t={}),t.provider?t.provider:t.web3?t.web3.currentProvider:new i(t.rpcUrl||"https://mainnet.infura.io/ethr-did")}(t),a=new e(h),l=t.registry||d,f=new r(a)(m).at(l),p=n.logDecoder(m,!1);return{ethr:function(t,i){try{if(!i.id.match(/^0x[0-9a-fA-F]{40}$/))throw new Error("Not a valid ethr DID: "+t);return Promise.resolve(function(t){try{var i=[],e=t;return Promise.resolve(function(t){try{return Promise.resolve(f.changed(t)).then(function(t){if(t)return t[0]})}catch(t){return Promise.reject(t)}}(t)).then(function(n){function r(){function r(){return{owner:e,history:i}}var h=function(t,i,e){for(var n;;){var r=t();if(u(r)&&(r=r.v),!r)return h;if(r.then){n=0;break}var h=e();if(h&&h.then){if(!u(h)){n=1;break}h=h.s}if(i){var a=i();if(a&&a.then&&!u(a)){n=2;break}}}var l=new s,m=o.bind(null,l,2);return(0===n?r.then(f):1===n?h.then(d):a.then(p)).then(void 0,m),l;function d(n){h=n;do{if(i&&(a=i())&&a.then&&!u(a))return void a.then(p).then(void 0,m);if(!(r=t())||u(r)&&!r.v)return void o(l,1,h);if(r.then)return void r.then(f).then(void 0,m);u(h=e())&&(h=h.v)}while(!h||!h.then);h.then(d).then(void 0,m)}function f(t){t?(h=e())&&h.then?h.then(d).then(void 0,m):d(h):o(l,1,h)}function p(){(r=t())?r.then?r.then(f).then(void 0,m):f(r):o(l,1,h)}}(function(){return!!n},void 0,function(){var e=n;return Promise.resolve(a.getLogs({address:l,topics:[null,"0x000000000000000000000000"+t.slice(2)],fromBlock:n,toBlock:n})).then(function(t){var r=p(t);n=void 0;for(var h=0,s=r;h<s.length;h+=1){var o=s[h];i.unshift(o),o.previousChange.lt(e)&&(n=o.previousChange)}})});return h&&h.then?h.then(r):r()}var h=function(){if(n)return Promise.resolve(f.identityOwner(t)).then(function(t){e=t[0]})}();return h&&h.then?h.then(r):r()})}catch(t){return Promise.reject(t)}}(i.id)).then(function(i){return v(t,i.owner,i.history)})}catch(t){return Promise.reject(t)}}}}};
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var i=t(require("ethjs-provider-http")),e=t(require("ethjs-query")),n=t(require("ethjs-abi")),r=t(require("ethjs-contract")),h=require("buffer");const s=function(){function t(){}return t.prototype.then=function(i,e){const n=new t,r=this.s;if(r){const t=1&r?i:e;if(t){try{o(n,1,t(this.v))}catch(t){o(n,2,t)}return n}return this}return this.o=function(t){try{const r=t.v;1&t.s?o(n,1,i?i(r):r):e?o(n,1,e(r)):o(n,2,r)}catch(t){o(n,2,t)}},n},t}();function o(t,i,e){if(!t.s){if(e instanceof s){if(!e.s)return void(e.o=o.bind(null,t,i));1&i&&(i=e.s),e=e.v}if(e&&e.then)return void e.then(o.bind(null,t,i),o.bind(null,t,2));t.s=i,t.v=e;const n=t.o;n&&n(t)}}function a(t){return t instanceof s&&1&t.s}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l=function(t,i){return function(t){!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var e=function(){};e.prototype=i.prototype,t.prototype=new e,t.prototype.constructor=t}function r(t,i,e){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(e=i,i=10),this._init(t||0,i||10,e||"be"))}var h;"object"==typeof t?t.exports=r:i.BN=r,r.BN=r,r.wordSize=26;try{h=function(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}().Buffer}catch(t){}function s(t,i,e){for(var n=0,r=Math.min(t.length,e),h=i;h<r;h++){var s=t.charCodeAt(h)-48;n<<=4,n|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function o(t,i,e,n){for(var r=0,h=Math.min(t.length,e),s=i;s<h;s++){var o=t.charCodeAt(s)-48;r*=n,r+=o>=49?o-49+10:o>=17?o-17+10:o}return r}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,i){return t.cmp(i)>0?t:i},r.min=function(t,i){return t.cmp(i)<0?t:i},r.prototype._init=function(t,i,n){if("number"==typeof t)return this._initNumber(t,i,n);if("object"==typeof t)return this._initArray(t,i,n);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===i?this._parseHex(t,r):this._parseBase(t,i,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initNumber=function(t,i,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initArray=function(t,i,n){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var h,s,o=0;if("be"===n)for(r=t.length-1,h=0;r>=0;r-=3)this.words[h]|=(s=t[r]|t[r-1]<<8|t[r-2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);else if("le"===n)for(r=0,h=0;r<t.length;r+=3)this.words[h]|=(s=t[r]|t[r+1]<<8|t[r+2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);return this.strip()},r.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,r,h=0;for(e=t.length-6,n=0;e>=i;e-=6)r=s(t,e,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303,(h+=24)>=26&&(h-=26,n++);e+6!==i&&(r=s(t,i,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303),this.strip()},r.prototype._parseBase=function(t,i,e){this.words=[0],this.length=1;for(var n=0,r=1;r<=67108863;r*=i)n++;r=r/i|0;for(var h=t.length-e,s=h%--n,a=Math.min(h,h-s)+e,u=0,l=e;l<a;l+=n)u=o(t,l,l+n,i),this.imuln(r),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var m=1;for(u=o(t,l,t.length,i),l=0;l<s;l++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},r.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},r.prototype.clone=function(){var t=new r(null);return this.copy(t),t},r.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},r.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var a=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,e){e.negative=i.negative^t.negative;var n=t.length+i.length|0;e.length=n,n=n-1|0;var r=0|t.words[0],h=0|i.words[0],s=r*h,o=s/67108864|0;e.words[0]=67108863&s;for(var a=1;a<n;a++){for(var u=o>>>26,l=67108863&o,m=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=m;d++)u+=(s=(r=0|t.words[a-d|0])*(h=0|i.words[d])+l)/67108864|0,l=67108863&s;e.words[a]=0|l,o=0|u}return 0!==o?e.words[a]=0|o:e.length--,e.strip()}r.prototype.toString=function(t,i){var n;if(i=0|i||1,16===(t=t||10)||"hex"===t){n="";for(var r=0,h=0,s=0;s<this.length;s++){var o=this.words[s],m=(16777215&(o<<r|h)).toString(16);n=0!=(h=o>>>24-r&16777215)||s!==this.length-1?a[6-m.length]+m+n:m+n,(r+=2)>=26&&(r-=26,s--)}for(0!==h&&(n=h.toString(16)+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var d=u[t],f=l[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(t);n=(p=p.idivn(f)).isZero()?c+n:a[d-c.length]+c+n}for(this.isZero()&&(n="0"+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}e(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,i){return e(void 0!==h),this.toArrayLike(h,t,i)},r.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},r.prototype.toArrayLike=function(t,i,n){var r=this.byteLength(),h=n||Math.max(1,r);e(r<=h,"byte array longer than desired length"),e(h>0,"Requested array length <= 0"),this.strip();var s,o,a="le"===i,u=new t(h),l=this.clone();if(a){for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),u[o]=s;for(;o<h;o++)u[o]=0}else{for(o=0;o<h-r;o++)u[o]=0;for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),u[h-o-1]=s}return u},r.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var i=t,e=0;return i>=4096&&(e+=13,i>>>=13),i>=64&&(e+=7,i>>>=7),i>=8&&(e+=4,i>>>=4),i>=2&&(e+=2,i>>>=2),e+i},r.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,e=0;return 0==(8191&i)&&(e+=13,i>>>=13),0==(127&i)&&(e+=7,i>>>=7),0==(15&i)&&(e+=4,i>>>=4),0==(3&i)&&(e+=2,i>>>=2),0==(1&i)&&e++,e},r.prototype.bitLength=function(){var t=this._countBits(this.words[this.length-1]);return 26*(this.length-1)+t},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var e=this._zeroBits(this.words[i]);if(t+=e,26!==e)break}return t},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},r.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return 0!==this.negative},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this.strip()},r.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},r.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var e=0;e<i.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=i.length,this.strip()},r.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},r.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0;n<e.length;n++)this.words[n]=i.words[n]^e.words[n];if(this!==i)for(;n<i.length;n++)this.words[n]=i.words[n];return this.length=i.length,this.strip()},r.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},r.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),n=t%26;this._expand(i),n>0&&i--;for(var r=0;r<i;r++)this.words[r]=67108863&~this.words[r];return n>0&&(this.words[r]=~this.words[r]&67108863>>26-n),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var n=t/26|0,r=t%26;return this._expand(n+1),this.words[n]=i?this.words[n]|1<<r:this.words[n]&~(1<<r),this.strip()},r.prototype.iadd=function(t){var i,e,n;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0,h=0;h<n.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+(0|n.words[h])+r),r=i>>>26;for(;0!==r&&h<e.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+r),r=i>>>26;if(this.length=e.length,0!==r)this.words[this.length]=r,this.length++;else if(e!==this)for(;h<e.length;h++)this.words[h]=e.words[h];return this},r.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e,n,r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(e=this,n=t):(e=t,n=this);for(var h=0,s=0;s<n.length;s++)h=(i=(0|e.words[s])-(0|n.words[s])+h)>>26,this.words[s]=67108863&i;for(;0!==h&&s<e.length;s++)h=(i=(0|e.words[s])+h)>>26,this.words[s]=67108863&i;if(0===h&&s<e.length&&e!==this)for(;s<e.length;s++)this.words[s]=e.words[s];return this.length=Math.max(this.length,s),e!==this&&(this.negative=1),this.strip()},r.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,i,e){var n,r,h,s=t.words,o=i.words,a=e.words,u=0,l=0|s[0],m=8191&l,d=l>>>13,f=0|s[1],p=8191&f,c=f>>>13,y=0|s[2],v=8191&y,g=y>>>13,M=0|s[3],w=8191&M,b=M>>>13,_=0|s[4],k=8191&_,S=_>>>13,x=0|s[5],A=8191&x,R=x>>>13,B=0|s[6],q=8191&B,D=B>>>13,T=0|s[7],Z=8191&T,I=T>>>13,N=0|s[8],j=8191&N,O=N>>>13,K=0|s[9],L=8191&K,C=K>>>13,E=0|o[0],P=8191&E,z=E>>>13,V=0|o[1],U=8191&V,F=V>>>13,H=0|o[2],$=8191&H,G=H>>>13,J=0|o[3],Y=8191&J,Q=J>>>13,W=0|o[4],X=8191&W,tt=W>>>13,it=0|o[5],et=8191&it,nt=it>>>13,rt=0|o[6],ht=8191&rt,st=rt>>>13,ot=0|o[7],at=8191&ot,ut=ot>>>13,lt=0|o[8],mt=8191&lt,dt=lt>>>13,ft=0|o[9],pt=8191&ft,ct=ft>>>13;e.negative=t.negative^i.negative,e.length=19;var yt=(u+(n=Math.imul(m,P))|0)+((8191&(r=(r=Math.imul(m,z))+Math.imul(d,P)|0))<<13)|0;u=((h=Math.imul(d,z))+(r>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,P),r=(r=Math.imul(p,z))+Math.imul(c,P)|0,h=Math.imul(c,z);var vt=(u+(n=n+Math.imul(m,U)|0)|0)+((8191&(r=(r=r+Math.imul(m,F)|0)+Math.imul(d,U)|0))<<13)|0;u=((h=h+Math.imul(d,F)|0)+(r>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,P),r=(r=Math.imul(v,z))+Math.imul(g,P)|0,h=Math.imul(g,z),n=n+Math.imul(p,U)|0,r=(r=r+Math.imul(p,F)|0)+Math.imul(c,U)|0,h=h+Math.imul(c,F)|0;var gt=(u+(n=n+Math.imul(m,$)|0)|0)+((8191&(r=(r=r+Math.imul(m,G)|0)+Math.imul(d,$)|0))<<13)|0;u=((h=h+Math.imul(d,G)|0)+(r>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,P),r=(r=Math.imul(w,z))+Math.imul(b,P)|0,h=Math.imul(b,z),n=n+Math.imul(v,U)|0,r=(r=r+Math.imul(v,F)|0)+Math.imul(g,U)|0,h=h+Math.imul(g,F)|0,n=n+Math.imul(p,$)|0,r=(r=r+Math.imul(p,G)|0)+Math.imul(c,$)|0,h=h+Math.imul(c,G)|0;var Mt=(u+(n=n+Math.imul(m,Y)|0)|0)+((8191&(r=(r=r+Math.imul(m,Q)|0)+Math.imul(d,Y)|0))<<13)|0;u=((h=h+Math.imul(d,Q)|0)+(r>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,P),r=(r=Math.imul(k,z))+Math.imul(S,P)|0,h=Math.imul(S,z),n=n+Math.imul(w,U)|0,r=(r=r+Math.imul(w,F)|0)+Math.imul(b,U)|0,h=h+Math.imul(b,F)|0,n=n+Math.imul(v,$)|0,r=(r=r+Math.imul(v,G)|0)+Math.imul(g,$)|0,h=h+Math.imul(g,G)|0,n=n+Math.imul(p,Y)|0,r=(r=r+Math.imul(p,Q)|0)+Math.imul(c,Y)|0,h=h+Math.imul(c,Q)|0;var wt=(u+(n=n+Math.imul(m,X)|0)|0)+((8191&(r=(r=r+Math.imul(m,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((h=h+Math.imul(d,tt)|0)+(r>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(A,P),r=(r=Math.imul(A,z))+Math.imul(R,P)|0,h=Math.imul(R,z),n=n+Math.imul(k,U)|0,r=(r=r+Math.imul(k,F)|0)+Math.imul(S,U)|0,h=h+Math.imul(S,F)|0,n=n+Math.imul(w,$)|0,r=(r=r+Math.imul(w,G)|0)+Math.imul(b,$)|0,h=h+Math.imul(b,G)|0,n=n+Math.imul(v,Y)|0,r=(r=r+Math.imul(v,Q)|0)+Math.imul(g,Y)|0,h=h+Math.imul(g,Q)|0,n=n+Math.imul(p,X)|0,r=(r=r+Math.imul(p,tt)|0)+Math.imul(c,X)|0,h=h+Math.imul(c,tt)|0;var bt=(u+(n=n+Math.imul(m,et)|0)|0)+((8191&(r=(r=r+Math.imul(m,nt)|0)+Math.imul(d,et)|0))<<13)|0;u=((h=h+Math.imul(d,nt)|0)+(r>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(q,P),r=(r=Math.imul(q,z))+Math.imul(D,P)|0,h=Math.imul(D,z),n=n+Math.imul(A,U)|0,r=(r=r+Math.imul(A,F)|0)+Math.imul(R,U)|0,h=h+Math.imul(R,F)|0,n=n+Math.imul(k,$)|0,r=(r=r+Math.imul(k,G)|0)+Math.imul(S,$)|0,h=h+Math.imul(S,G)|0,n=n+Math.imul(w,Y)|0,r=(r=r+Math.imul(w,Q)|0)+Math.imul(b,Y)|0,h=h+Math.imul(b,Q)|0,n=n+Math.imul(v,X)|0,r=(r=r+Math.imul(v,tt)|0)+Math.imul(g,X)|0,h=h+Math.imul(g,tt)|0,n=n+Math.imul(p,et)|0,r=(r=r+Math.imul(p,nt)|0)+Math.imul(c,et)|0,h=h+Math.imul(c,nt)|0;var _t=(u+(n=n+Math.imul(m,ht)|0)|0)+((8191&(r=(r=r+Math.imul(m,st)|0)+Math.imul(d,ht)|0))<<13)|0;u=((h=h+Math.imul(d,st)|0)+(r>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(Z,P),r=(r=Math.imul(Z,z))+Math.imul(I,P)|0,h=Math.imul(I,z),n=n+Math.imul(q,U)|0,r=(r=r+Math.imul(q,F)|0)+Math.imul(D,U)|0,h=h+Math.imul(D,F)|0,n=n+Math.imul(A,$)|0,r=(r=r+Math.imul(A,G)|0)+Math.imul(R,$)|0,h=h+Math.imul(R,G)|0,n=n+Math.imul(k,Y)|0,r=(r=r+Math.imul(k,Q)|0)+Math.imul(S,Y)|0,h=h+Math.imul(S,Q)|0,n=n+Math.imul(w,X)|0,r=(r=r+Math.imul(w,tt)|0)+Math.imul(b,X)|0,h=h+Math.imul(b,tt)|0,n=n+Math.imul(v,et)|0,r=(r=r+Math.imul(v,nt)|0)+Math.imul(g,et)|0,h=h+Math.imul(g,nt)|0,n=n+Math.imul(p,ht)|0,r=(r=r+Math.imul(p,st)|0)+Math.imul(c,ht)|0,h=h+Math.imul(c,st)|0;var kt=(u+(n=n+Math.imul(m,at)|0)|0)+((8191&(r=(r=r+Math.imul(m,ut)|0)+Math.imul(d,at)|0))<<13)|0;u=((h=h+Math.imul(d,ut)|0)+(r>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(j,P),r=(r=Math.imul(j,z))+Math.imul(O,P)|0,h=Math.imul(O,z),n=n+Math.imul(Z,U)|0,r=(r=r+Math.imul(Z,F)|0)+Math.imul(I,U)|0,h=h+Math.imul(I,F)|0,n=n+Math.imul(q,$)|0,r=(r=r+Math.imul(q,G)|0)+Math.imul(D,$)|0,h=h+Math.imul(D,G)|0,n=n+Math.imul(A,Y)|0,r=(r=r+Math.imul(A,Q)|0)+Math.imul(R,Y)|0,h=h+Math.imul(R,Q)|0,n=n+Math.imul(k,X)|0,r=(r=r+Math.imul(k,tt)|0)+Math.imul(S,X)|0,h=h+Math.imul(S,tt)|0,n=n+Math.imul(w,et)|0,r=(r=r+Math.imul(w,nt)|0)+Math.imul(b,et)|0,h=h+Math.imul(b,nt)|0,n=n+Math.imul(v,ht)|0,r=(r=r+Math.imul(v,st)|0)+Math.imul(g,ht)|0,h=h+Math.imul(g,st)|0,n=n+Math.imul(p,at)|0,r=(r=r+Math.imul(p,ut)|0)+Math.imul(c,at)|0,h=h+Math.imul(c,ut)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(r=(r=r+Math.imul(m,dt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((h=h+Math.imul(d,dt)|0)+(r>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,P),r=(r=Math.imul(L,z))+Math.imul(C,P)|0,h=Math.imul(C,z),n=n+Math.imul(j,U)|0,r=(r=r+Math.imul(j,F)|0)+Math.imul(O,U)|0,h=h+Math.imul(O,F)|0,n=n+Math.imul(Z,$)|0,r=(r=r+Math.imul(Z,G)|0)+Math.imul(I,$)|0,h=h+Math.imul(I,G)|0,n=n+Math.imul(q,Y)|0,r=(r=r+Math.imul(q,Q)|0)+Math.imul(D,Y)|0,h=h+Math.imul(D,Q)|0,n=n+Math.imul(A,X)|0,r=(r=r+Math.imul(A,tt)|0)+Math.imul(R,X)|0,h=h+Math.imul(R,tt)|0,n=n+Math.imul(k,et)|0,r=(r=r+Math.imul(k,nt)|0)+Math.imul(S,et)|0,h=h+Math.imul(S,nt)|0,n=n+Math.imul(w,ht)|0,r=(r=r+Math.imul(w,st)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,st)|0,n=n+Math.imul(v,at)|0,r=(r=r+Math.imul(v,ut)|0)+Math.imul(g,at)|0,h=h+Math.imul(g,ut)|0,n=n+Math.imul(p,mt)|0,r=(r=r+Math.imul(p,dt)|0)+Math.imul(c,mt)|0,h=h+Math.imul(c,dt)|0;var xt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(r=(r=r+Math.imul(m,ct)|0)+Math.imul(d,pt)|0))<<13)|0;u=((h=h+Math.imul(d,ct)|0)+(r>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,U),r=(r=Math.imul(L,F))+Math.imul(C,U)|0,h=Math.imul(C,F),n=n+Math.imul(j,$)|0,r=(r=r+Math.imul(j,G)|0)+Math.imul(O,$)|0,h=h+Math.imul(O,G)|0,n=n+Math.imul(Z,Y)|0,r=(r=r+Math.imul(Z,Q)|0)+Math.imul(I,Y)|0,h=h+Math.imul(I,Q)|0,n=n+Math.imul(q,X)|0,r=(r=r+Math.imul(q,tt)|0)+Math.imul(D,X)|0,h=h+Math.imul(D,tt)|0,n=n+Math.imul(A,et)|0,r=(r=r+Math.imul(A,nt)|0)+Math.imul(R,et)|0,h=h+Math.imul(R,nt)|0,n=n+Math.imul(k,ht)|0,r=(r=r+Math.imul(k,st)|0)+Math.imul(S,ht)|0,h=h+Math.imul(S,st)|0,n=n+Math.imul(w,at)|0,r=(r=r+Math.imul(w,ut)|0)+Math.imul(b,at)|0,h=h+Math.imul(b,ut)|0,n=n+Math.imul(v,mt)|0,r=(r=r+Math.imul(v,dt)|0)+Math.imul(g,mt)|0,h=h+Math.imul(g,dt)|0;var At=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(r=(r=r+Math.imul(p,ct)|0)+Math.imul(c,pt)|0))<<13)|0;u=((h=h+Math.imul(c,ct)|0)+(r>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,$),r=(r=Math.imul(L,G))+Math.imul(C,$)|0,h=Math.imul(C,G),n=n+Math.imul(j,Y)|0,r=(r=r+Math.imul(j,Q)|0)+Math.imul(O,Y)|0,h=h+Math.imul(O,Q)|0,n=n+Math.imul(Z,X)|0,r=(r=r+Math.imul(Z,tt)|0)+Math.imul(I,X)|0,h=h+Math.imul(I,tt)|0,n=n+Math.imul(q,et)|0,r=(r=r+Math.imul(q,nt)|0)+Math.imul(D,et)|0,h=h+Math.imul(D,nt)|0,n=n+Math.imul(A,ht)|0,r=(r=r+Math.imul(A,st)|0)+Math.imul(R,ht)|0,h=h+Math.imul(R,st)|0,n=n+Math.imul(k,at)|0,r=(r=r+Math.imul(k,ut)|0)+Math.imul(S,at)|0,h=h+Math.imul(S,ut)|0,n=n+Math.imul(w,mt)|0,r=(r=r+Math.imul(w,dt)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,dt)|0;var Rt=(u+(n=n+Math.imul(v,pt)|0)|0)+((8191&(r=(r=r+Math.imul(v,ct)|0)+Math.imul(g,pt)|0))<<13)|0;u=((h=h+Math.imul(g,ct)|0)+(r>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,Y),r=(r=Math.imul(L,Q))+Math.imul(C,Y)|0,h=Math.imul(C,Q),n=n+Math.imul(j,X)|0,r=(r=r+Math.imul(j,tt)|0)+Math.imul(O,X)|0,h=h+Math.imul(O,tt)|0,n=n+Math.imul(Z,et)|0,r=(r=r+Math.imul(Z,nt)|0)+Math.imul(I,et)|0,h=h+Math.imul(I,nt)|0,n=n+Math.imul(q,ht)|0,r=(r=r+Math.imul(q,st)|0)+Math.imul(D,ht)|0,h=h+Math.imul(D,st)|0,n=n+Math.imul(A,at)|0,r=(r=r+Math.imul(A,ut)|0)+Math.imul(R,at)|0,h=h+Math.imul(R,ut)|0,n=n+Math.imul(k,mt)|0,r=(r=r+Math.imul(k,dt)|0)+Math.imul(S,mt)|0,h=h+Math.imul(S,dt)|0;var Bt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(r=(r=r+Math.imul(w,ct)|0)+Math.imul(b,pt)|0))<<13)|0;u=((h=h+Math.imul(b,ct)|0)+(r>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(L,X),r=(r=Math.imul(L,tt))+Math.imul(C,X)|0,h=Math.imul(C,tt),n=n+Math.imul(j,et)|0,r=(r=r+Math.imul(j,nt)|0)+Math.imul(O,et)|0,h=h+Math.imul(O,nt)|0,n=n+Math.imul(Z,ht)|0,r=(r=r+Math.imul(Z,st)|0)+Math.imul(I,ht)|0,h=h+Math.imul(I,st)|0,n=n+Math.imul(q,at)|0,r=(r=r+Math.imul(q,ut)|0)+Math.imul(D,at)|0,h=h+Math.imul(D,ut)|0,n=n+Math.imul(A,mt)|0,r=(r=r+Math.imul(A,dt)|0)+Math.imul(R,mt)|0,h=h+Math.imul(R,dt)|0;var qt=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(r=(r=r+Math.imul(k,ct)|0)+Math.imul(S,pt)|0))<<13)|0;u=((h=h+Math.imul(S,ct)|0)+(r>>>13)|0)+(qt>>>26)|0,qt&=67108863,n=Math.imul(L,et),r=(r=Math.imul(L,nt))+Math.imul(C,et)|0,h=Math.imul(C,nt),n=n+Math.imul(j,ht)|0,r=(r=r+Math.imul(j,st)|0)+Math.imul(O,ht)|0,h=h+Math.imul(O,st)|0,n=n+Math.imul(Z,at)|0,r=(r=r+Math.imul(Z,ut)|0)+Math.imul(I,at)|0,h=h+Math.imul(I,ut)|0,n=n+Math.imul(q,mt)|0,r=(r=r+Math.imul(q,dt)|0)+Math.imul(D,mt)|0,h=h+Math.imul(D,dt)|0;var Dt=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(r=(r=r+Math.imul(A,ct)|0)+Math.imul(R,pt)|0))<<13)|0;u=((h=h+Math.imul(R,ct)|0)+(r>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(L,ht),r=(r=Math.imul(L,st))+Math.imul(C,ht)|0,h=Math.imul(C,st),n=n+Math.imul(j,at)|0,r=(r=r+Math.imul(j,ut)|0)+Math.imul(O,at)|0,h=h+Math.imul(O,ut)|0,n=n+Math.imul(Z,mt)|0,r=(r=r+Math.imul(Z,dt)|0)+Math.imul(I,mt)|0,h=h+Math.imul(I,dt)|0;var Tt=(u+(n=n+Math.imul(q,pt)|0)|0)+((8191&(r=(r=r+Math.imul(q,ct)|0)+Math.imul(D,pt)|0))<<13)|0;u=((h=h+Math.imul(D,ct)|0)+(r>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,at),r=(r=Math.imul(L,ut))+Math.imul(C,at)|0,h=Math.imul(C,ut),n=n+Math.imul(j,mt)|0,r=(r=r+Math.imul(j,dt)|0)+Math.imul(O,mt)|0,h=h+Math.imul(O,dt)|0;var Zt=(u+(n=n+Math.imul(Z,pt)|0)|0)+((8191&(r=(r=r+Math.imul(Z,ct)|0)+Math.imul(I,pt)|0))<<13)|0;u=((h=h+Math.imul(I,ct)|0)+(r>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,n=Math.imul(L,mt),r=(r=Math.imul(L,dt))+Math.imul(C,mt)|0,h=Math.imul(C,dt);var It=(u+(n=n+Math.imul(j,pt)|0)|0)+((8191&(r=(r=r+Math.imul(j,ct)|0)+Math.imul(O,pt)|0))<<13)|0;u=((h=h+Math.imul(O,ct)|0)+(r>>>13)|0)+(It>>>26)|0,It&=67108863;var Nt=(u+(n=Math.imul(L,pt))|0)+((8191&(r=(r=Math.imul(L,ct))+Math.imul(C,pt)|0))<<13)|0;return u=((h=Math.imul(C,ct))+(r>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,a[0]=yt,a[1]=vt,a[2]=gt,a[3]=Mt,a[4]=wt,a[5]=bt,a[6]=_t,a[7]=kt,a[8]=St,a[9]=xt,a[10]=At,a[11]=Rt,a[12]=Bt,a[13]=qt,a[14]=Dt,a[15]=Tt,a[16]=Zt,a[17]=It,a[18]=Nt,0!==u&&(a[19]=u,e.length++),e};function f(t,i,e){return(new p).mulp(t,i,e)}function p(t,i){this.x=t,this.y=i}Math.imul||(d=m),r.prototype.mulTo=function(t,i){var e=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):e<63?m(this,t,i):e<1024?function(t,i,e){e.negative=i.negative^t.negative,e.length=t.length+i.length;for(var n=0,r=0,h=0;h<e.length-1;h++){var s=r;r=0;for(var o=67108863&n,a=Math.min(h,i.length-1),u=Math.max(0,h-t.length+1);u<=a;u++){var l=(0|t.words[h-u])*(0|i.words[u]),m=67108863&l;o=67108863&(m=m+o|0),r+=(s=(s=s+(l/67108864|0)|0)+(m>>>26)|0)>>>26,s&=67108863}e.words[h]=o,n=s,s=r}return 0!==n?e.words[h]=n:e.length--,e.strip()}(this,t,i):f(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),e=r.prototype._countBits(t)-1,n=0;n<t;n++)i[n]=this.revBin(n,e,t);return i},p.prototype.revBin=function(t,i,e){if(0===t||t===e-1)return t;for(var n=0,r=0;r<i;r++)n|=(1&t)<<i-r-1,t>>=1;return n},p.prototype.permute=function(t,i,e,n,r,h){for(var s=0;s<h;s++)n[s]=i[t[s]],r[s]=e[t[s]]},p.prototype.transform=function(t,i,e,n,r,h){this.permute(h,t,i,e,n,r);for(var s=1;s<r;s<<=1)for(var o=s<<1,a=Math.cos(2*Math.PI/o),u=Math.sin(2*Math.PI/o),l=0;l<r;l+=o)for(var m=a,d=u,f=0;f<s;f++){var p=e[l+f],c=n[l+f],y=e[l+f+s],v=n[l+f+s],g=m*y-d*v;v=m*v+d*y,e[l+f]=p+(y=g),n[l+f]=c+v,e[l+f+s]=p-y,n[l+f+s]=c-v,f!==o&&(g=a*m-u*d,d=a*d+u*m,m=g)}},p.prototype.guessLen13b=function(t,i){var e=1|Math.max(i,t),n=1&e,r=0;for(e=e/2|0;e;e>>>=1)r++;return 1<<r+1+n},p.prototype.conjugate=function(t,i,e){if(!(e<=1))for(var n=0;n<e/2;n++){var r=t[n];t[n]=t[e-n-1],t[e-n-1]=r,r=i[n],i[n]=-i[e-n-1],i[e-n-1]=-r}},p.prototype.normalize13b=function(t,i){for(var e=0,n=0;n<i/2;n++){var r=8192*Math.round(t[2*n+1]/i)+Math.round(t[2*n]/i)+e;t[n]=67108863&r,e=r<67108864?0:r/67108864|0}return t},p.prototype.convert13b=function(t,i,n,r){for(var h=0,s=0;s<i;s++)n[2*s]=8191&(h+=0|t[s]),n[2*s+1]=8191&(h>>>=13),h>>>=13;for(s=2*i;s<r;++s)n[s]=0;e(0===h),e(0==(-8192&h))},p.prototype.stub=function(t){for(var i=new Array(t),e=0;e<t;e++)i[e]=0;return i},p.prototype.mulp=function(t,i,e){var n=2*this.guessLen13b(t.length,i.length),r=this.makeRBT(n),h=this.stub(n),s=new Array(n),o=new Array(n),a=new Array(n),u=new Array(n),l=new Array(n),m=new Array(n),d=e.words;d.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(i.words,i.length,u,n),this.transform(s,h,o,a,n,r),this.transform(u,h,l,m,n,r);for(var f=0;f<n;f++){var p=o[f]*l[f]-a[f]*m[f];a[f]=o[f]*m[f]+a[f]*l[f],o[f]=p}return this.conjugate(o,a,n),this.transform(o,a,d,h,n,r),this.conjugate(d,h,n),this.normalize13b(d,n),e.negative=t.negative^i.negative,e.length=t.length+i.length,e.strip()},r.prototype.mul=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},r.prototype.mulf=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),f(this,t,i)},r.prototype.imul=function(t){return this.clone().mulTo(t,this)},r.prototype.imuln=function(t){e("number"==typeof t),e(t<67108864);for(var i=0,n=0;n<this.length;n++){var r=(0|this.words[n])*t,h=(67108863&r)+(67108863&i);i>>=26,i+=r/67108864|0,i+=h>>>26,this.words[n]=67108863&h}return 0!==i&&(this.words[n]=i,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),e=0;e<i.length;e++){var n=e%26;i[e]=(t.words[e/26|0]&1<<n)>>>n}return i}(t);if(0===i.length)return new r(1);for(var e=this,n=0;n<i.length&&0===i[n];n++,e=e.sqr());if(++n<i.length)for(var h=e.sqr();n<i.length;n++,h=h.sqr())0!==i[n]&&(e=e.mul(h));return e},r.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,n=t%26,r=(t-n)/26,h=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(i=0;i<this.length;i++){var o=this.words[i]&h;this.words[i]=(0|this.words[i])-o<<n|s,s=o>>>26-n}s&&(this.words[i]=s,this.length++)}if(0!==r){for(i=this.length-1;i>=0;i--)this.words[i+r]=this.words[i];for(i=0;i<r;i++)this.words[i]=0;this.length+=r}return this.strip()},r.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},r.prototype.iushrn=function(t,i,n){var r;e("number"==typeof t&&t>=0),r=i?(i-i%26)/26:0;var h=t%26,s=Math.min((t-h)/26,this.length),o=67108863^67108863>>>h<<h,a=n;if(r-=s,r=Math.max(0,r),a){for(var u=0;u<s;u++)a.words[u]=this.words[u];a.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=r);u--){var m=0|this.words[u];this.words[u]=l<<26-h|m>>>h,l=m&o}return a&&0!==l&&(a.words[a.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,i,n){return e(0===this.negative),this.iushrn(t,i,n)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return!(this.length<=n||!(this.words[n]&1<<i))},r.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return e(0===this.negative,"imaskn works only with positive numbers"),this.length<=n?this:(0!==i&&n++,this.length=Math.min(n,this.length),0!==i&&(this.words[this.length-1]&=67108863^67108863>>>i<<i),this.strip())},r.prototype.maskn=function(t){return this.clone().imaskn(t)},r.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},r.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},r.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},r.prototype.addn=function(t){return this.clone().iaddn(t)},r.prototype.subn=function(t){return this.clone().isubn(t)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(t,i,n){var r,h;this._expand(t.length+n);var s=0;for(r=0;r<t.length;r++){h=(0|this.words[r+n])+s;var o=(0|t.words[r])*i;s=((h-=67108863&o)>>26)-(o/67108864|0),this.words[r+n]=67108863&h}for(;r<this.length-n;r++)s=(h=(0|this.words[r+n])+s)>>26,this.words[r+n]=67108863&h;if(0===s)return this.strip();for(e(-1===s),s=0,r=0;r<this.length;r++)s=(h=-(0|this.words[r])+s)>>26,this.words[r]=67108863&h;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,i){var e,n=this.clone(),h=t,s=0|h.words[h.length-1];0!=(e=26-this._countBits(s))&&(h=h.ushln(e),n.iushln(e),s=0|h.words[h.length-1]);var o,a=n.length-h.length;if("mod"!==i){(o=new r(null)).length=a+1,o.words=new Array(o.length);for(var u=0;u<o.length;u++)o.words[u]=0}var l=n.clone()._ishlnsubmul(h,1,a);0===l.negative&&(n=l,o&&(o.words[a]=1));for(var m=a-1;m>=0;m--){var d=67108864*(0|n.words[h.length+m])+(0|n.words[h.length+m-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(h,d,m);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(h,1,m),n.isZero()||(n.negative^=1);o&&(o.words[m]=d)}return o&&o.strip(),n.strip(),"div"!==i&&0!==e&&n.iushrn(e),{div:o||null,mod:n}},r.prototype.divmod=function(t,i,n){return e(!t.isZero()),this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,i),"mod"!==i&&(h=o.div.neg()),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:h,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),i),"mod"!==i&&(h=o.div.neg()),{div:h,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),i),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,i);var h,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var e=0!==i.div.negative?i.mod.isub(t):i.mod,n=t.ushrn(1),r=t.andln(1),h=e.cmp(n);return h<0||1===r&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},r.prototype.modn=function(t){e(t<=67108863);for(var i=(1<<26)%t,n=0,r=this.length-1;r>=0;r--)n=(i*n+(0|this.words[r]))%t;return n},r.prototype.idivn=function(t){e(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var r=(0|this.words[n])+67108864*i;this.words[n]=r/t|0,i=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h=new r(1),s=new r(0),o=new r(0),a=new r(1),u=0;i.isEven()&&n.isEven();)i.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),m=i.clone();!i.isZero();){for(var d=0,f=1;0==(i.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(h.isOdd()||s.isOdd())&&(h.iadd(l),s.isub(m)),h.iushrn(1),s.iushrn(1);for(var p=0,c=1;0==(n.words[0]&c)&&p<26;++p,c<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(m)),o.iushrn(1),a.iushrn(1);i.cmp(n)>=0?(i.isub(n),h.isub(o),s.isub(a)):(n.isub(i),o.isub(h),a.isub(s))}return{a:o,b:a,gcd:n.iushln(u)}},r.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h,s=new r(1),o=new r(0),a=n.clone();i.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var m=0,d=1;0==(n.words[0]&d)&&m<26;++m,d<<=1);if(m>0)for(n.iushrn(m);m-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);i.cmp(n)>=0?(i.isub(n),s.isub(o)):(n.isub(i),o.isub(s))}return(h=0===i.cmpn(1)?s:o).cmpn(0)<0&&h.iadd(t),h},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),e=t.clone();i.negative=0,e.negative=0;for(var n=0;i.isEven()&&e.isEven();n++)i.iushrn(1),e.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;e.isEven();)e.iushrn(1);var r=i.cmp(e);if(r<0){var h=i;i=e,e=h}else if(0===r||0===e.cmpn(1))break;i.isub(e)}return e.iushln(n)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,n=(t-i)/26,r=1<<i;if(this.length<=n)return this._expand(n+1),this.words[n]|=r,this;for(var h=r,s=n;0!==h&&s<this.length;s++){var o=0|this.words[s];h=(o+=h)>>>26,this.words[s]=o&=67108863}return 0!==h&&(this.words[s]=h,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var i,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)i=1;else{n&&(t=-t),e(t<=67108863,"Number is too big");var r=0|this.words[0];i=r===t?0:r<t?-1:1}return 0!==this.negative?0|-i:i},r.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},r.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,e=this.length-1;e>=0;e--){var n=0|this.words[e],r=0|t.words[e];if(n!==r){n<r?i=-1:n>r&&(i=1);break}}return i},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new b(t)},r.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},r.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},r.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},r.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},r.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},r.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},r.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var c={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new r(i,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=r._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,e=t;do{this.split(e,this.tmp),i=(e=(e=this.imulK(e)).iadd(this.tmp)).bitLength()}while(i>this.n);var n=i<this.n?-1:e.ucmp(this.p);return 0===n?(e.words[0]=0,e.length=1):n>0?e.isub(this.p):e.strip(),e},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,i){for(var e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var r=t.words[9];for(i.words[i.length++]=4194303&r,n=10;n<t.length;n++){var h=0|t.words[n];t.words[n-10]=(4194303&h)<<4|r>>>22,r=h}t.words[n-10]=r>>>=22,t.length-=0===r&&t.length>10?10:9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,e=0;e<t.length;e++){var n=0|t.words[e];t.words[e]=67108863&(i+=977*n),i=64*n+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(g,y),n(M,y),n(w,y),w.prototype.imulK=function(t){for(var i=0,e=0;e<t.length;e++){var n=19*(0|t.words[e])+i,r=67108863&n;n>>>=26,t.words[e]=r,i=n}return 0!==i&&(t.words[t.length++]=i),t},r._prime=function(t){if(c[t])return c[t];var i;if("k256"===t)i=new v;else if("p224"===t)i=new g;else if("p192"===t)i=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new w}return c[t]=i,i},b.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var e=t.add(i);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var e=t.iadd(i);return e.cmp(this.m)>=0&&e.isub(this.m),e},b.prototype.sub=function(t,i){this._verify2(t,i);var e=t.sub(i);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var e=t.isub(i);return e.cmpn(0)<0&&e.iadd(this.m),e},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var n=this.m.add(new r(1)).iushrn(2);return this.pow(t,n)}for(var h=this.m.subn(1),s=0;!h.isZero()&&0===h.andln(1);)s++,h.iushrn(1);e(!h.isZero());var o=new r(1).toRed(this),a=o.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new r(2*l*l).toRed(this);0!==this.pow(l,u).cmp(a);)l.redIAdd(a);for(var m=this.pow(l,h),d=this.pow(t,h.addn(1).iushrn(1)),f=this.pow(t,h),p=s;0!==f.cmp(o);){for(var c=f,y=0;0!==c.cmp(o);y++)c=c.redSqr();e(y<p);var v=this.pow(m,new r(1).iushln(p-y-1));d=d.redMul(v),m=v.redSqr(),f=f.redMul(m),p=y}return d},b.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},b.prototype.pow=function(t,i){if(i.isZero())return new r(1);if(0===i.cmpn(1))return t.clone();var e=new Array(16);e[0]=new r(1).toRed(this),e[1]=t;for(var n=2;n<e.length;n++)e[n]=this.mul(e[n-1],t);var h=e[0],s=0,o=0,a=i.bitLength()%26;for(0===a&&(a=26),n=i.length-1;n>=0;n--){for(var u=i.words[n],l=a-1;l>=0;l--){var m=u>>l&1;h!==e[0]&&(h=this.sqr(h)),0!==m||0!==s?(s<<=1,s|=m,(4==++o||0===n&&0===l)&&(h=this.mul(h,e[s]),o=0,s=0)):o=0}a=26}return h},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},r.mont=function(t){return new _(t)},n(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=e.isub(n).iushrn(this.shift),h=r;return r.cmp(this.m)>=0?h=r.isub(this.m):r.cmpn(0)<0&&(h=r.iadd(this.m)),h._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new r(0)._forceRed(this);var e=t.mul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),h=e.isub(n).iushrn(this.shift),s=h;return h.cmp(this.m)>=0?s=h.isub(this.m):h.cmpn(0)<0&&(s=h.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,u)}(i={exports:{}}),i.exports}(),m=[{constant:!0,inputs:[{name:"",type:"address"}],name:"owners",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"},{name:"",type:"bytes32"},{name:"",type:"address"}],name:"delegates",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"nonce",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"changed",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"owner",type:"address"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDOwnerChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"delegateType",type:"bytes32"},{indexed:!1,name:"delegate",type:"address"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDDelegateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"name",type:"bytes32"},{indexed:!1,name:"value",type:"bytes"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDAttributeChanged",type:"event"},{constant:!0,inputs:[{name:"identity",type:"address"}],name:"identityOwner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"validDelegate",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"newOwner",type:"address"}],name:"changeOwner",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"newOwner",type:"address"}],name:"changeOwnerSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],d=[{name:"ropsten",rpcUrl:"https://ropsten.infura.io/ethr-did",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"rinkeby",rpcUrl:"https://rinkeby.infura.io/ethr-did",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"kovan",rpcUrl:"https://kovan.infura.io/ethr-did",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"rsk",rpcUrl:"https://did.rsk.co:4444",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"rsk:testnet",rpcUrl:"https://did.testnet.rsk.co:4444",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"}],f="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";function p(t){return h.Buffer.from(t.slice(2),"hex").toString("utf8").replace(/\0+$/,"")}function c(t){var i="0x"+h.Buffer.from(t).slice(0,32).toString("hex");return i+"0".repeat(66-i.length)}var y={Secp256k1SignatureAuthentication2018:c("sigAuth"),Secp256k1VerificationKey2018:c("veriKey")},v={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018"};function g(t,i,e){for(var n=new l(Math.floor((new Date).getTime()/1e3)),r=[{id:t+"#owner",type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:i}],s=[{type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#owner"}],o=0,a={},u={},m={},d=0,f=e;d<f.length;d+=1){var c=f[d],y=c.validTo,g=c._eventName+"-"+(c.delegateType||c.name)+"-"+(c.delegate||c.value);if(y&&y.gte(n)){if("DIDDelegateChanged"===c._eventName)switch(o++,p(c.delegateType)){case"sigAuth":a[g]={type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#delegate-"+o};case"veriKey":u[g]={id:t+"#delegate-"+o,type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:c.delegate}}else if("DIDAttributeChanged"===c._eventName){var M=p(c.name).match(/^did\/(pub|auth|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(M){var w=M[2],b=v[M[4]]||M[4],_=M[6];switch(M[1]){case"pub":var k={id:t+"#delegate-"+ ++o,type:""+w+b,owner:t};switch(_){case null:case void 0:case"hex":k.publicKeyHex=c.value.slice(2);break;case"base64":k.publicKeyBase64=h.Buffer.from(c.value.slice(2),"hex").toString("base64");break;case"base58":k.publicKeyBase58=h.Buffer.from(c.value.slice(2),"hex").toString("base58");break;case"pem":k.publicKeyPem=h.Buffer.from(c.value.slice(2),"hex").toString();break;default:k.value=c.value}u[g]=k;break;case"svc":m[g]={type:w,serviceEndpoint:h.Buffer.from(c.value.slice(2),"hex").toString()}}}}}else o>0&&("DIDDelegateChanged"===c._eventName||"DIDAttributeChanged"===c._eventName&&p(c.name).match(/^did\/pub\//))&&y.lt(n)&&o--,delete a[g],delete u[g],delete m[g]}var S={"@context":"https://w3id.org/did/v1",id:t,publicKey:r.concat(Object.values(u)),authentication:s.concat(Object.values(a))};return Object.values(m).length>0&&(S.service=Object.values(m)),S}function M(t){void 0===t&&(t={});var n=function(t){return void 0===t&&(t={}),t.provider?t.provider:t.web3?t.web3.currentProvider:new i(t.rpcUrl||"https://mainnet.infura.io/ethr-did")}(t),h=new e(n),s=t.registry||f;return{eth:h,registryAddress:s,didReg:new r(h)(m).at(s)}}function w(t){void 0===t&&(t=[]);for(var i={},e=0;e<t.length;e++){var n=t[e];i[n.name]=M(n)}return i}module.exports={REGISTRY:f,bytes32toString:p,stringToBytes32:c,delegateTypes:y,attrTypes:v,wrapDidDocument:g,getResolver:function(t){void 0===t&&(t={});var i=n.logDecoder(m,!1),e=Object.assign({},{mainnet:M(t)},w(d),w(t.networks));return{ethr:function(t,n){try{var r=n.id.match(/^(.*)?(0x[0-9a-fA-F]{40})$/);if(!r)throw new Error("Not a valid ethr DID: "+t);var h=r[2],u=r[1]?r[1].slice(0,-1):"mainnet";if(!e[u])throw new Error("No conf for networkId: "+u);return Promise.resolve(function(t,n){try{var r=[],h=t;return Promise.resolve(function(t,i){try{return Promise.resolve(e[i].didReg.changed(t)).then(function(t){if(t)return t[0]})}catch(t){return Promise.reject(t)}}(t,n)).then(function(u){function l(){function l(){return{owner:h,history:r}}var m=function(t,i,e){for(var n;;){var r=t();if(a(r)&&(r=r.v),!r)return h;if(r.then){n=0;break}var h=e();if(h&&h.then){if(!a(h)){n=1;break}h=h.s}if(i){var u=i();if(u&&u.then&&!a(u)){n=2;break}}}var l=new s,m=o.bind(null,l,2);return(0===n?r.then(f):1===n?h.then(d):u.then(p)).then(void 0,m),l;function d(n){h=n;do{if(i&&(u=i())&&u.then&&!a(u))return void u.then(p).then(void 0,m);if(!(r=t())||a(r)&&!r.v)return void o(l,1,h);if(r.then)return void r.then(f).then(void 0,m);a(h=e())&&(h=h.v)}while(!h||!h.then);h.then(d).then(void 0,m)}function f(t){t?(h=e())&&h.then?h.then(d).then(void 0,m):d(h):o(l,1,h)}function p(){(r=t())?r.then?r.then(f).then(void 0,m):f(r):o(l,1,h)}}(function(){return!!u},void 0,function(){var h=u;return Promise.resolve(e[n].eth.getLogs({address:e[n].registryAddress,topics:[null,"0x000000000000000000000000"+t.slice(2)],fromBlock:u,toBlock:u})).then(function(t){var e=i(t);u=void 0;for(var n=0,s=e;n<s.length;n+=1){var o=s[n];r.unshift(o),o.previousChange.lt(h)&&(u=o.previousChange)}})});return m&&m.then?m.then(l):l()}var m=function(){if(u)return Promise.resolve(e[n].didReg.identityOwner(t)).then(function(t){h=t[0]})}();return m&&m.then?m.then(l):l()})}catch(t){return Promise.reject(t)}}(h,u)).then(function(i){return g(t,i.owner,i.history)})}catch(t){return Promise.reject(t)}}}}};
//# sourceMappingURL=ethr-did-resolver.js.map

@@ -1,2 +0,2 @@

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("ethjs-provider-http"),require("ethjs-query"),require("ethjs-abi"),require("ethjs-contract"),require("buffer")):"function"==typeof define&&define.amd?define(["ethjs-provider-http","ethjs-query","ethjs-abi","ethjs-contract","buffer"],i):i(t.HttpProvider,t.Eth,t.abi,t.EthContract,t.buffer)}(this,function(t,i,e,n,r){t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;const h=function(){function t(){}return t.prototype.then=function(i,e){const n=new t,r=this.s;if(r){const t=1&r?i:e;if(t){try{s(n,1,t(this.v))}catch(t){s(n,2,t)}return n}return this}return this.o=function(t){try{const r=t.v;1&t.s?s(n,1,i?i(r):r):e?s(n,1,e(r)):s(n,2,r)}catch(t){s(n,2,t)}},n},t}();function s(t,i,e){if(!t.s){if(e instanceof h){if(!e.s)return void(e.o=s.bind(null,t,i));1&i&&(i=e.s),e=e.v}if(e&&e.then)return void e.then(s.bind(null,t,i),s.bind(null,t,2));t.s=i,t.v=e;const n=t.o;n&&n(t)}}function o(t){return t instanceof h&&1&t.s}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=function(t,i){return function(t){!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var e=function(){};e.prototype=i.prototype,t.prototype=new e,t.prototype.constructor=t}function r(t,i,e){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(e=i,i=10),this._init(t||0,i||10,e||"be"))}var h;"object"==typeof t?t.exports=r:i.BN=r,r.BN=r,r.wordSize=26;try{h=function(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}().Buffer}catch(t){}function s(t,i,e){for(var n=0,r=Math.min(t.length,e),h=i;h<r;h++){var s=t.charCodeAt(h)-48;n<<=4,n|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function o(t,i,e,n){for(var r=0,h=Math.min(t.length,e),s=i;s<h;s++){var o=t.charCodeAt(s)-48;r*=n,r+=o>=49?o-49+10:o>=17?o-17+10:o}return r}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,i){return t.cmp(i)>0?t:i},r.min=function(t,i){return t.cmp(i)<0?t:i},r.prototype._init=function(t,i,n){if("number"==typeof t)return this._initNumber(t,i,n);if("object"==typeof t)return this._initArray(t,i,n);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===i?this._parseHex(t,r):this._parseBase(t,i,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initNumber=function(t,i,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initArray=function(t,i,n){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var h,s,o=0;if("be"===n)for(r=t.length-1,h=0;r>=0;r-=3)this.words[h]|=(s=t[r]|t[r-1]<<8|t[r-2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);else if("le"===n)for(r=0,h=0;r<t.length;r+=3)this.words[h]|=(s=t[r]|t[r+1]<<8|t[r+2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);return this.strip()},r.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,r,h=0;for(e=t.length-6,n=0;e>=i;e-=6)r=s(t,e,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303,(h+=24)>=26&&(h-=26,n++);e+6!==i&&(r=s(t,i,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303),this.strip()},r.prototype._parseBase=function(t,i,e){this.words=[0],this.length=1;for(var n=0,r=1;r<=67108863;r*=i)n++;r=r/i|0;for(var h=t.length-e,s=h%--n,u=Math.min(h,h-s)+e,a=0,l=e;l<u;l+=n)a=o(t,l,l+n,i),this.imuln(r),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a);if(0!==s){var m=1;for(a=o(t,l,t.length,i),l=0;l<s;l++)m*=i;this.imuln(m),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a)}},r.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},r.prototype.clone=function(){var t=new r(null);return this.copy(t),t},r.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},r.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,e){e.negative=i.negative^t.negative;var n=t.length+i.length|0;e.length=n,n=n-1|0;var r=0|t.words[0],h=0|i.words[0],s=r*h,o=s/67108864|0;e.words[0]=67108863&s;for(var u=1;u<n;u++){for(var a=o>>>26,l=67108863&o,m=Math.min(u,i.length-1),d=Math.max(0,u-t.length+1);d<=m;d++)a+=(s=(r=0|t.words[u-d|0])*(h=0|i.words[d])+l)/67108864|0,l=67108863&s;e.words[u]=0|l,o=0|a}return 0!==o?e.words[u]=0|o:e.length--,e.strip()}r.prototype.toString=function(t,i){var n;if(i=0|i||1,16===(t=t||10)||"hex"===t){n="";for(var r=0,h=0,s=0;s<this.length;s++){var o=this.words[s],m=(16777215&(o<<r|h)).toString(16);n=0!=(h=o>>>24-r&16777215)||s!==this.length-1?u[6-m.length]+m+n:m+n,(r+=2)>=26&&(r-=26,s--)}for(0!==h&&(n=h.toString(16)+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var d=a[t],f=l[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(t);n=(p=p.idivn(f)).isZero()?c+n:u[d-c.length]+c+n}for(this.isZero()&&(n="0"+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}e(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,i){return e(void 0!==h),this.toArrayLike(h,t,i)},r.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},r.prototype.toArrayLike=function(t,i,n){var r=this.byteLength(),h=n||Math.max(1,r);e(r<=h,"byte array longer than desired length"),e(h>0,"Requested array length <= 0"),this.strip();var s,o,u="le"===i,a=new t(h),l=this.clone();if(u){for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),a[o]=s;for(;o<h;o++)a[o]=0}else{for(o=0;o<h-r;o++)a[o]=0;for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),a[h-o-1]=s}return a},r.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var i=t,e=0;return i>=4096&&(e+=13,i>>>=13),i>=64&&(e+=7,i>>>=7),i>=8&&(e+=4,i>>>=4),i>=2&&(e+=2,i>>>=2),e+i},r.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,e=0;return 0==(8191&i)&&(e+=13,i>>>=13),0==(127&i)&&(e+=7,i>>>=7),0==(15&i)&&(e+=4,i>>>=4),0==(3&i)&&(e+=2,i>>>=2),0==(1&i)&&e++,e},r.prototype.bitLength=function(){var t=this._countBits(this.words[this.length-1]);return 26*(this.length-1)+t},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var e=this._zeroBits(this.words[i]);if(t+=e,26!==e)break}return t},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},r.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return 0!==this.negative},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this.strip()},r.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},r.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var e=0;e<i.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=i.length,this.strip()},r.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},r.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0;n<e.length;n++)this.words[n]=i.words[n]^e.words[n];if(this!==i)for(;n<i.length;n++)this.words[n]=i.words[n];return this.length=i.length,this.strip()},r.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},r.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),n=t%26;this._expand(i),n>0&&i--;for(var r=0;r<i;r++)this.words[r]=67108863&~this.words[r];return n>0&&(this.words[r]=~this.words[r]&67108863>>26-n),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var n=t/26|0,r=t%26;return this._expand(n+1),this.words[n]=i?this.words[n]|1<<r:this.words[n]&~(1<<r),this.strip()},r.prototype.iadd=function(t){var i,e,n;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0,h=0;h<n.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+(0|n.words[h])+r),r=i>>>26;for(;0!==r&&h<e.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+r),r=i>>>26;if(this.length=e.length,0!==r)this.words[this.length]=r,this.length++;else if(e!==this)for(;h<e.length;h++)this.words[h]=e.words[h];return this},r.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e,n,r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(e=this,n=t):(e=t,n=this);for(var h=0,s=0;s<n.length;s++)h=(i=(0|e.words[s])-(0|n.words[s])+h)>>26,this.words[s]=67108863&i;for(;0!==h&&s<e.length;s++)h=(i=(0|e.words[s])+h)>>26,this.words[s]=67108863&i;if(0===h&&s<e.length&&e!==this)for(;s<e.length;s++)this.words[s]=e.words[s];return this.length=Math.max(this.length,s),e!==this&&(this.negative=1),this.strip()},r.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,i,e){var n,r,h,s=t.words,o=i.words,u=e.words,a=0,l=0|s[0],m=8191&l,d=l>>>13,f=0|s[1],p=8191&f,c=f>>>13,y=0|s[2],v=8191&y,g=y>>>13,M=0|s[3],w=8191&M,b=M>>>13,_=0|s[4],S=8191&_,k=_>>>13,x=0|s[5],A=8191&x,B=x>>>13,q=0|s[6],R=8191&q,D=q>>>13,T=0|s[7],Z=8191&T,I=T>>>13,N=0|s[8],j=8191&N,O=N>>>13,P=0|s[9],K=8191&P,L=P>>>13,C=0|o[0],E=8191&C,z=C>>>13,V=0|o[1],F=8191&V,H=V>>>13,$=0|o[2],U=8191&$,G=$>>>13,J=0|o[3],Y=8191&J,Q=J>>>13,W=0|o[4],X=8191&W,tt=W>>>13,it=0|o[5],et=8191&it,nt=it>>>13,rt=0|o[6],ht=8191&rt,st=rt>>>13,ot=0|o[7],ut=8191&ot,at=ot>>>13,lt=0|o[8],mt=8191&lt,dt=lt>>>13,ft=0|o[9],pt=8191&ft,ct=ft>>>13;e.negative=t.negative^i.negative,e.length=19;var yt=(a+(n=Math.imul(m,E))|0)+((8191&(r=(r=Math.imul(m,z))+Math.imul(d,E)|0))<<13)|0;a=((h=Math.imul(d,z))+(r>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,E),r=(r=Math.imul(p,z))+Math.imul(c,E)|0,h=Math.imul(c,z);var vt=(a+(n=n+Math.imul(m,F)|0)|0)+((8191&(r=(r=r+Math.imul(m,H)|0)+Math.imul(d,F)|0))<<13)|0;a=((h=h+Math.imul(d,H)|0)+(r>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,E),r=(r=Math.imul(v,z))+Math.imul(g,E)|0,h=Math.imul(g,z),n=n+Math.imul(p,F)|0,r=(r=r+Math.imul(p,H)|0)+Math.imul(c,F)|0,h=h+Math.imul(c,H)|0;var gt=(a+(n=n+Math.imul(m,U)|0)|0)+((8191&(r=(r=r+Math.imul(m,G)|0)+Math.imul(d,U)|0))<<13)|0;a=((h=h+Math.imul(d,G)|0)+(r>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,E),r=(r=Math.imul(w,z))+Math.imul(b,E)|0,h=Math.imul(b,z),n=n+Math.imul(v,F)|0,r=(r=r+Math.imul(v,H)|0)+Math.imul(g,F)|0,h=h+Math.imul(g,H)|0,n=n+Math.imul(p,U)|0,r=(r=r+Math.imul(p,G)|0)+Math.imul(c,U)|0,h=h+Math.imul(c,G)|0;var Mt=(a+(n=n+Math.imul(m,Y)|0)|0)+((8191&(r=(r=r+Math.imul(m,Q)|0)+Math.imul(d,Y)|0))<<13)|0;a=((h=h+Math.imul(d,Q)|0)+(r>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(S,E),r=(r=Math.imul(S,z))+Math.imul(k,E)|0,h=Math.imul(k,z),n=n+Math.imul(w,F)|0,r=(r=r+Math.imul(w,H)|0)+Math.imul(b,F)|0,h=h+Math.imul(b,H)|0,n=n+Math.imul(v,U)|0,r=(r=r+Math.imul(v,G)|0)+Math.imul(g,U)|0,h=h+Math.imul(g,G)|0,n=n+Math.imul(p,Y)|0,r=(r=r+Math.imul(p,Q)|0)+Math.imul(c,Y)|0,h=h+Math.imul(c,Q)|0;var wt=(a+(n=n+Math.imul(m,X)|0)|0)+((8191&(r=(r=r+Math.imul(m,tt)|0)+Math.imul(d,X)|0))<<13)|0;a=((h=h+Math.imul(d,tt)|0)+(r>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(A,E),r=(r=Math.imul(A,z))+Math.imul(B,E)|0,h=Math.imul(B,z),n=n+Math.imul(S,F)|0,r=(r=r+Math.imul(S,H)|0)+Math.imul(k,F)|0,h=h+Math.imul(k,H)|0,n=n+Math.imul(w,U)|0,r=(r=r+Math.imul(w,G)|0)+Math.imul(b,U)|0,h=h+Math.imul(b,G)|0,n=n+Math.imul(v,Y)|0,r=(r=r+Math.imul(v,Q)|0)+Math.imul(g,Y)|0,h=h+Math.imul(g,Q)|0,n=n+Math.imul(p,X)|0,r=(r=r+Math.imul(p,tt)|0)+Math.imul(c,X)|0,h=h+Math.imul(c,tt)|0;var bt=(a+(n=n+Math.imul(m,et)|0)|0)+((8191&(r=(r=r+Math.imul(m,nt)|0)+Math.imul(d,et)|0))<<13)|0;a=((h=h+Math.imul(d,nt)|0)+(r>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(R,E),r=(r=Math.imul(R,z))+Math.imul(D,E)|0,h=Math.imul(D,z),n=n+Math.imul(A,F)|0,r=(r=r+Math.imul(A,H)|0)+Math.imul(B,F)|0,h=h+Math.imul(B,H)|0,n=n+Math.imul(S,U)|0,r=(r=r+Math.imul(S,G)|0)+Math.imul(k,U)|0,h=h+Math.imul(k,G)|0,n=n+Math.imul(w,Y)|0,r=(r=r+Math.imul(w,Q)|0)+Math.imul(b,Y)|0,h=h+Math.imul(b,Q)|0,n=n+Math.imul(v,X)|0,r=(r=r+Math.imul(v,tt)|0)+Math.imul(g,X)|0,h=h+Math.imul(g,tt)|0,n=n+Math.imul(p,et)|0,r=(r=r+Math.imul(p,nt)|0)+Math.imul(c,et)|0,h=h+Math.imul(c,nt)|0;var _t=(a+(n=n+Math.imul(m,ht)|0)|0)+((8191&(r=(r=r+Math.imul(m,st)|0)+Math.imul(d,ht)|0))<<13)|0;a=((h=h+Math.imul(d,st)|0)+(r>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(Z,E),r=(r=Math.imul(Z,z))+Math.imul(I,E)|0,h=Math.imul(I,z),n=n+Math.imul(R,F)|0,r=(r=r+Math.imul(R,H)|0)+Math.imul(D,F)|0,h=h+Math.imul(D,H)|0,n=n+Math.imul(A,U)|0,r=(r=r+Math.imul(A,G)|0)+Math.imul(B,U)|0,h=h+Math.imul(B,G)|0,n=n+Math.imul(S,Y)|0,r=(r=r+Math.imul(S,Q)|0)+Math.imul(k,Y)|0,h=h+Math.imul(k,Q)|0,n=n+Math.imul(w,X)|0,r=(r=r+Math.imul(w,tt)|0)+Math.imul(b,X)|0,h=h+Math.imul(b,tt)|0,n=n+Math.imul(v,et)|0,r=(r=r+Math.imul(v,nt)|0)+Math.imul(g,et)|0,h=h+Math.imul(g,nt)|0,n=n+Math.imul(p,ht)|0,r=(r=r+Math.imul(p,st)|0)+Math.imul(c,ht)|0,h=h+Math.imul(c,st)|0;var St=(a+(n=n+Math.imul(m,ut)|0)|0)+((8191&(r=(r=r+Math.imul(m,at)|0)+Math.imul(d,ut)|0))<<13)|0;a=((h=h+Math.imul(d,at)|0)+(r>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(j,E),r=(r=Math.imul(j,z))+Math.imul(O,E)|0,h=Math.imul(O,z),n=n+Math.imul(Z,F)|0,r=(r=r+Math.imul(Z,H)|0)+Math.imul(I,F)|0,h=h+Math.imul(I,H)|0,n=n+Math.imul(R,U)|0,r=(r=r+Math.imul(R,G)|0)+Math.imul(D,U)|0,h=h+Math.imul(D,G)|0,n=n+Math.imul(A,Y)|0,r=(r=r+Math.imul(A,Q)|0)+Math.imul(B,Y)|0,h=h+Math.imul(B,Q)|0,n=n+Math.imul(S,X)|0,r=(r=r+Math.imul(S,tt)|0)+Math.imul(k,X)|0,h=h+Math.imul(k,tt)|0,n=n+Math.imul(w,et)|0,r=(r=r+Math.imul(w,nt)|0)+Math.imul(b,et)|0,h=h+Math.imul(b,nt)|0,n=n+Math.imul(v,ht)|0,r=(r=r+Math.imul(v,st)|0)+Math.imul(g,ht)|0,h=h+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,r=(r=r+Math.imul(p,at)|0)+Math.imul(c,ut)|0,h=h+Math.imul(c,at)|0;var kt=(a+(n=n+Math.imul(m,mt)|0)|0)+((8191&(r=(r=r+Math.imul(m,dt)|0)+Math.imul(d,mt)|0))<<13)|0;a=((h=h+Math.imul(d,dt)|0)+(r>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(K,E),r=(r=Math.imul(K,z))+Math.imul(L,E)|0,h=Math.imul(L,z),n=n+Math.imul(j,F)|0,r=(r=r+Math.imul(j,H)|0)+Math.imul(O,F)|0,h=h+Math.imul(O,H)|0,n=n+Math.imul(Z,U)|0,r=(r=r+Math.imul(Z,G)|0)+Math.imul(I,U)|0,h=h+Math.imul(I,G)|0,n=n+Math.imul(R,Y)|0,r=(r=r+Math.imul(R,Q)|0)+Math.imul(D,Y)|0,h=h+Math.imul(D,Q)|0,n=n+Math.imul(A,X)|0,r=(r=r+Math.imul(A,tt)|0)+Math.imul(B,X)|0,h=h+Math.imul(B,tt)|0,n=n+Math.imul(S,et)|0,r=(r=r+Math.imul(S,nt)|0)+Math.imul(k,et)|0,h=h+Math.imul(k,nt)|0,n=n+Math.imul(w,ht)|0,r=(r=r+Math.imul(w,st)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,st)|0,n=n+Math.imul(v,ut)|0,r=(r=r+Math.imul(v,at)|0)+Math.imul(g,ut)|0,h=h+Math.imul(g,at)|0,n=n+Math.imul(p,mt)|0,r=(r=r+Math.imul(p,dt)|0)+Math.imul(c,mt)|0,h=h+Math.imul(c,dt)|0;var xt=(a+(n=n+Math.imul(m,pt)|0)|0)+((8191&(r=(r=r+Math.imul(m,ct)|0)+Math.imul(d,pt)|0))<<13)|0;a=((h=h+Math.imul(d,ct)|0)+(r>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(K,F),r=(r=Math.imul(K,H))+Math.imul(L,F)|0,h=Math.imul(L,H),n=n+Math.imul(j,U)|0,r=(r=r+Math.imul(j,G)|0)+Math.imul(O,U)|0,h=h+Math.imul(O,G)|0,n=n+Math.imul(Z,Y)|0,r=(r=r+Math.imul(Z,Q)|0)+Math.imul(I,Y)|0,h=h+Math.imul(I,Q)|0,n=n+Math.imul(R,X)|0,r=(r=r+Math.imul(R,tt)|0)+Math.imul(D,X)|0,h=h+Math.imul(D,tt)|0,n=n+Math.imul(A,et)|0,r=(r=r+Math.imul(A,nt)|0)+Math.imul(B,et)|0,h=h+Math.imul(B,nt)|0,n=n+Math.imul(S,ht)|0,r=(r=r+Math.imul(S,st)|0)+Math.imul(k,ht)|0,h=h+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,r=(r=r+Math.imul(w,at)|0)+Math.imul(b,ut)|0,h=h+Math.imul(b,at)|0,n=n+Math.imul(v,mt)|0,r=(r=r+Math.imul(v,dt)|0)+Math.imul(g,mt)|0,h=h+Math.imul(g,dt)|0;var At=(a+(n=n+Math.imul(p,pt)|0)|0)+((8191&(r=(r=r+Math.imul(p,ct)|0)+Math.imul(c,pt)|0))<<13)|0;a=((h=h+Math.imul(c,ct)|0)+(r>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(K,U),r=(r=Math.imul(K,G))+Math.imul(L,U)|0,h=Math.imul(L,G),n=n+Math.imul(j,Y)|0,r=(r=r+Math.imul(j,Q)|0)+Math.imul(O,Y)|0,h=h+Math.imul(O,Q)|0,n=n+Math.imul(Z,X)|0,r=(r=r+Math.imul(Z,tt)|0)+Math.imul(I,X)|0,h=h+Math.imul(I,tt)|0,n=n+Math.imul(R,et)|0,r=(r=r+Math.imul(R,nt)|0)+Math.imul(D,et)|0,h=h+Math.imul(D,nt)|0,n=n+Math.imul(A,ht)|0,r=(r=r+Math.imul(A,st)|0)+Math.imul(B,ht)|0,h=h+Math.imul(B,st)|0,n=n+Math.imul(S,ut)|0,r=(r=r+Math.imul(S,at)|0)+Math.imul(k,ut)|0,h=h+Math.imul(k,at)|0,n=n+Math.imul(w,mt)|0,r=(r=r+Math.imul(w,dt)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,dt)|0;var Bt=(a+(n=n+Math.imul(v,pt)|0)|0)+((8191&(r=(r=r+Math.imul(v,ct)|0)+Math.imul(g,pt)|0))<<13)|0;a=((h=h+Math.imul(g,ct)|0)+(r>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(K,Y),r=(r=Math.imul(K,Q))+Math.imul(L,Y)|0,h=Math.imul(L,Q),n=n+Math.imul(j,X)|0,r=(r=r+Math.imul(j,tt)|0)+Math.imul(O,X)|0,h=h+Math.imul(O,tt)|0,n=n+Math.imul(Z,et)|0,r=(r=r+Math.imul(Z,nt)|0)+Math.imul(I,et)|0,h=h+Math.imul(I,nt)|0,n=n+Math.imul(R,ht)|0,r=(r=r+Math.imul(R,st)|0)+Math.imul(D,ht)|0,h=h+Math.imul(D,st)|0,n=n+Math.imul(A,ut)|0,r=(r=r+Math.imul(A,at)|0)+Math.imul(B,ut)|0,h=h+Math.imul(B,at)|0,n=n+Math.imul(S,mt)|0,r=(r=r+Math.imul(S,dt)|0)+Math.imul(k,mt)|0,h=h+Math.imul(k,dt)|0;var qt=(a+(n=n+Math.imul(w,pt)|0)|0)+((8191&(r=(r=r+Math.imul(w,ct)|0)+Math.imul(b,pt)|0))<<13)|0;a=((h=h+Math.imul(b,ct)|0)+(r>>>13)|0)+(qt>>>26)|0,qt&=67108863,n=Math.imul(K,X),r=(r=Math.imul(K,tt))+Math.imul(L,X)|0,h=Math.imul(L,tt),n=n+Math.imul(j,et)|0,r=(r=r+Math.imul(j,nt)|0)+Math.imul(O,et)|0,h=h+Math.imul(O,nt)|0,n=n+Math.imul(Z,ht)|0,r=(r=r+Math.imul(Z,st)|0)+Math.imul(I,ht)|0,h=h+Math.imul(I,st)|0,n=n+Math.imul(R,ut)|0,r=(r=r+Math.imul(R,at)|0)+Math.imul(D,ut)|0,h=h+Math.imul(D,at)|0,n=n+Math.imul(A,mt)|0,r=(r=r+Math.imul(A,dt)|0)+Math.imul(B,mt)|0,h=h+Math.imul(B,dt)|0;var Rt=(a+(n=n+Math.imul(S,pt)|0)|0)+((8191&(r=(r=r+Math.imul(S,ct)|0)+Math.imul(k,pt)|0))<<13)|0;a=((h=h+Math.imul(k,ct)|0)+(r>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(K,et),r=(r=Math.imul(K,nt))+Math.imul(L,et)|0,h=Math.imul(L,nt),n=n+Math.imul(j,ht)|0,r=(r=r+Math.imul(j,st)|0)+Math.imul(O,ht)|0,h=h+Math.imul(O,st)|0,n=n+Math.imul(Z,ut)|0,r=(r=r+Math.imul(Z,at)|0)+Math.imul(I,ut)|0,h=h+Math.imul(I,at)|0,n=n+Math.imul(R,mt)|0,r=(r=r+Math.imul(R,dt)|0)+Math.imul(D,mt)|0,h=h+Math.imul(D,dt)|0;var Dt=(a+(n=n+Math.imul(A,pt)|0)|0)+((8191&(r=(r=r+Math.imul(A,ct)|0)+Math.imul(B,pt)|0))<<13)|0;a=((h=h+Math.imul(B,ct)|0)+(r>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(K,ht),r=(r=Math.imul(K,st))+Math.imul(L,ht)|0,h=Math.imul(L,st),n=n+Math.imul(j,ut)|0,r=(r=r+Math.imul(j,at)|0)+Math.imul(O,ut)|0,h=h+Math.imul(O,at)|0,n=n+Math.imul(Z,mt)|0,r=(r=r+Math.imul(Z,dt)|0)+Math.imul(I,mt)|0,h=h+Math.imul(I,dt)|0;var Tt=(a+(n=n+Math.imul(R,pt)|0)|0)+((8191&(r=(r=r+Math.imul(R,ct)|0)+Math.imul(D,pt)|0))<<13)|0;a=((h=h+Math.imul(D,ct)|0)+(r>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(K,ut),r=(r=Math.imul(K,at))+Math.imul(L,ut)|0,h=Math.imul(L,at),n=n+Math.imul(j,mt)|0,r=(r=r+Math.imul(j,dt)|0)+Math.imul(O,mt)|0,h=h+Math.imul(O,dt)|0;var Zt=(a+(n=n+Math.imul(Z,pt)|0)|0)+((8191&(r=(r=r+Math.imul(Z,ct)|0)+Math.imul(I,pt)|0))<<13)|0;a=((h=h+Math.imul(I,ct)|0)+(r>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,n=Math.imul(K,mt),r=(r=Math.imul(K,dt))+Math.imul(L,mt)|0,h=Math.imul(L,dt);var It=(a+(n=n+Math.imul(j,pt)|0)|0)+((8191&(r=(r=r+Math.imul(j,ct)|0)+Math.imul(O,pt)|0))<<13)|0;a=((h=h+Math.imul(O,ct)|0)+(r>>>13)|0)+(It>>>26)|0,It&=67108863;var Nt=(a+(n=Math.imul(K,pt))|0)+((8191&(r=(r=Math.imul(K,ct))+Math.imul(L,pt)|0))<<13)|0;return a=((h=Math.imul(L,ct))+(r>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=Mt,u[4]=wt,u[5]=bt,u[6]=_t,u[7]=St,u[8]=kt,u[9]=xt,u[10]=At,u[11]=Bt,u[12]=qt,u[13]=Rt,u[14]=Dt,u[15]=Tt,u[16]=Zt,u[17]=It,u[18]=Nt,0!==a&&(u[19]=a,e.length++),e};function f(t,i,e){return(new p).mulp(t,i,e)}function p(t,i){this.x=t,this.y=i}Math.imul||(d=m),r.prototype.mulTo=function(t,i){var e=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):e<63?m(this,t,i):e<1024?function(t,i,e){e.negative=i.negative^t.negative,e.length=t.length+i.length;for(var n=0,r=0,h=0;h<e.length-1;h++){var s=r;r=0;for(var o=67108863&n,u=Math.min(h,i.length-1),a=Math.max(0,h-t.length+1);a<=u;a++){var l=(0|t.words[h-a])*(0|i.words[a]),m=67108863&l;o=67108863&(m=m+o|0),r+=(s=(s=s+(l/67108864|0)|0)+(m>>>26)|0)>>>26,s&=67108863}e.words[h]=o,n=s,s=r}return 0!==n?e.words[h]=n:e.length--,e.strip()}(this,t,i):f(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),e=r.prototype._countBits(t)-1,n=0;n<t;n++)i[n]=this.revBin(n,e,t);return i},p.prototype.revBin=function(t,i,e){if(0===t||t===e-1)return t;for(var n=0,r=0;r<i;r++)n|=(1&t)<<i-r-1,t>>=1;return n},p.prototype.permute=function(t,i,e,n,r,h){for(var s=0;s<h;s++)n[s]=i[t[s]],r[s]=e[t[s]]},p.prototype.transform=function(t,i,e,n,r,h){this.permute(h,t,i,e,n,r);for(var s=1;s<r;s<<=1)for(var o=s<<1,u=Math.cos(2*Math.PI/o),a=Math.sin(2*Math.PI/o),l=0;l<r;l+=o)for(var m=u,d=a,f=0;f<s;f++){var p=e[l+f],c=n[l+f],y=e[l+f+s],v=n[l+f+s],g=m*y-d*v;v=m*v+d*y,e[l+f]=p+(y=g),n[l+f]=c+v,e[l+f+s]=p-y,n[l+f+s]=c-v,f!==o&&(g=u*m-a*d,d=u*d+a*m,m=g)}},p.prototype.guessLen13b=function(t,i){var e=1|Math.max(i,t),n=1&e,r=0;for(e=e/2|0;e;e>>>=1)r++;return 1<<r+1+n},p.prototype.conjugate=function(t,i,e){if(!(e<=1))for(var n=0;n<e/2;n++){var r=t[n];t[n]=t[e-n-1],t[e-n-1]=r,r=i[n],i[n]=-i[e-n-1],i[e-n-1]=-r}},p.prototype.normalize13b=function(t,i){for(var e=0,n=0;n<i/2;n++){var r=8192*Math.round(t[2*n+1]/i)+Math.round(t[2*n]/i)+e;t[n]=67108863&r,e=r<67108864?0:r/67108864|0}return t},p.prototype.convert13b=function(t,i,n,r){for(var h=0,s=0;s<i;s++)n[2*s]=8191&(h+=0|t[s]),n[2*s+1]=8191&(h>>>=13),h>>>=13;for(s=2*i;s<r;++s)n[s]=0;e(0===h),e(0==(-8192&h))},p.prototype.stub=function(t){for(var i=new Array(t),e=0;e<t;e++)i[e]=0;return i},p.prototype.mulp=function(t,i,e){var n=2*this.guessLen13b(t.length,i.length),r=this.makeRBT(n),h=this.stub(n),s=new Array(n),o=new Array(n),u=new Array(n),a=new Array(n),l=new Array(n),m=new Array(n),d=e.words;d.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(i.words,i.length,a,n),this.transform(s,h,o,u,n,r),this.transform(a,h,l,m,n,r);for(var f=0;f<n;f++){var p=o[f]*l[f]-u[f]*m[f];u[f]=o[f]*m[f]+u[f]*l[f],o[f]=p}return this.conjugate(o,u,n),this.transform(o,u,d,h,n,r),this.conjugate(d,h,n),this.normalize13b(d,n),e.negative=t.negative^i.negative,e.length=t.length+i.length,e.strip()},r.prototype.mul=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},r.prototype.mulf=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),f(this,t,i)},r.prototype.imul=function(t){return this.clone().mulTo(t,this)},r.prototype.imuln=function(t){e("number"==typeof t),e(t<67108864);for(var i=0,n=0;n<this.length;n++){var r=(0|this.words[n])*t,h=(67108863&r)+(67108863&i);i>>=26,i+=r/67108864|0,i+=h>>>26,this.words[n]=67108863&h}return 0!==i&&(this.words[n]=i,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),e=0;e<i.length;e++){var n=e%26;i[e]=(t.words[e/26|0]&1<<n)>>>n}return i}(t);if(0===i.length)return new r(1);for(var e=this,n=0;n<i.length&&0===i[n];n++,e=e.sqr());if(++n<i.length)for(var h=e.sqr();n<i.length;n++,h=h.sqr())0!==i[n]&&(e=e.mul(h));return e},r.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,n=t%26,r=(t-n)/26,h=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(i=0;i<this.length;i++){var o=this.words[i]&h;this.words[i]=(0|this.words[i])-o<<n|s,s=o>>>26-n}s&&(this.words[i]=s,this.length++)}if(0!==r){for(i=this.length-1;i>=0;i--)this.words[i+r]=this.words[i];for(i=0;i<r;i++)this.words[i]=0;this.length+=r}return this.strip()},r.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},r.prototype.iushrn=function(t,i,n){var r;e("number"==typeof t&&t>=0),r=i?(i-i%26)/26:0;var h=t%26,s=Math.min((t-h)/26,this.length),o=67108863^67108863>>>h<<h,u=n;if(r-=s,r=Math.max(0,r),u){for(var a=0;a<s;a++)u.words[a]=this.words[a];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,a=0;a<this.length;a++)this.words[a]=this.words[a+s];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=r);a--){var m=0|this.words[a];this.words[a]=l<<26-h|m>>>h,l=m&o}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,i,n){return e(0===this.negative),this.iushrn(t,i,n)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return!(this.length<=n||!(this.words[n]&1<<i))},r.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return e(0===this.negative,"imaskn works only with positive numbers"),this.length<=n?this:(0!==i&&n++,this.length=Math.min(n,this.length),0!==i&&(this.words[this.length-1]&=67108863^67108863>>>i<<i),this.strip())},r.prototype.maskn=function(t){return this.clone().imaskn(t)},r.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},r.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},r.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},r.prototype.addn=function(t){return this.clone().iaddn(t)},r.prototype.subn=function(t){return this.clone().isubn(t)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(t,i,n){var r,h;this._expand(t.length+n);var s=0;for(r=0;r<t.length;r++){h=(0|this.words[r+n])+s;var o=(0|t.words[r])*i;s=((h-=67108863&o)>>26)-(o/67108864|0),this.words[r+n]=67108863&h}for(;r<this.length-n;r++)s=(h=(0|this.words[r+n])+s)>>26,this.words[r+n]=67108863&h;if(0===s)return this.strip();for(e(-1===s),s=0,r=0;r<this.length;r++)s=(h=-(0|this.words[r])+s)>>26,this.words[r]=67108863&h;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,i){var e,n=this.clone(),h=t,s=0|h.words[h.length-1];0!=(e=26-this._countBits(s))&&(h=h.ushln(e),n.iushln(e),s=0|h.words[h.length-1]);var o,u=n.length-h.length;if("mod"!==i){(o=new r(null)).length=u+1,o.words=new Array(o.length);for(var a=0;a<o.length;a++)o.words[a]=0}var l=n.clone()._ishlnsubmul(h,1,u);0===l.negative&&(n=l,o&&(o.words[u]=1));for(var m=u-1;m>=0;m--){var d=67108864*(0|n.words[h.length+m])+(0|n.words[h.length+m-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(h,d,m);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(h,1,m),n.isZero()||(n.negative^=1);o&&(o.words[m]=d)}return o&&o.strip(),n.strip(),"div"!==i&&0!==e&&n.iushrn(e),{div:o||null,mod:n}},r.prototype.divmod=function(t,i,n){return e(!t.isZero()),this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,i),"mod"!==i&&(h=o.div.neg()),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:h,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),i),"mod"!==i&&(h=o.div.neg()),{div:h,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),i),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,i);var h,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var e=0!==i.div.negative?i.mod.isub(t):i.mod,n=t.ushrn(1),r=t.andln(1),h=e.cmp(n);return h<0||1===r&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},r.prototype.modn=function(t){e(t<=67108863);for(var i=(1<<26)%t,n=0,r=this.length-1;r>=0;r--)n=(i*n+(0|this.words[r]))%t;return n},r.prototype.idivn=function(t){e(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var r=(0|this.words[n])+67108864*i;this.words[n]=r/t|0,i=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h=new r(1),s=new r(0),o=new r(0),u=new r(1),a=0;i.isEven()&&n.isEven();)i.iushrn(1),n.iushrn(1),++a;for(var l=n.clone(),m=i.clone();!i.isZero();){for(var d=0,f=1;0==(i.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(h.isOdd()||s.isOdd())&&(h.iadd(l),s.isub(m)),h.iushrn(1),s.iushrn(1);for(var p=0,c=1;0==(n.words[0]&c)&&p<26;++p,c<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(o.isOdd()||u.isOdd())&&(o.iadd(l),u.isub(m)),o.iushrn(1),u.iushrn(1);i.cmp(n)>=0?(i.isub(n),h.isub(o),s.isub(u)):(n.isub(i),o.isub(h),u.isub(s))}return{a:o,b:u,gcd:n.iushln(a)}},r.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h,s=new r(1),o=new r(0),u=n.clone();i.cmpn(1)>0&&n.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var m=0,d=1;0==(n.words[0]&d)&&m<26;++m,d<<=1);if(m>0)for(n.iushrn(m);m-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);i.cmp(n)>=0?(i.isub(n),s.isub(o)):(n.isub(i),o.isub(s))}return(h=0===i.cmpn(1)?s:o).cmpn(0)<0&&h.iadd(t),h},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),e=t.clone();i.negative=0,e.negative=0;for(var n=0;i.isEven()&&e.isEven();n++)i.iushrn(1),e.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;e.isEven();)e.iushrn(1);var r=i.cmp(e);if(r<0){var h=i;i=e,e=h}else if(0===r||0===e.cmpn(1))break;i.isub(e)}return e.iushln(n)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,n=(t-i)/26,r=1<<i;if(this.length<=n)return this._expand(n+1),this.words[n]|=r,this;for(var h=r,s=n;0!==h&&s<this.length;s++){var o=0|this.words[s];h=(o+=h)>>>26,this.words[s]=o&=67108863}return 0!==h&&(this.words[s]=h,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var i,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)i=1;else{n&&(t=-t),e(t<=67108863,"Number is too big");var r=0|this.words[0];i=r===t?0:r<t?-1:1}return 0!==this.negative?0|-i:i},r.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},r.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,e=this.length-1;e>=0;e--){var n=0|this.words[e],r=0|t.words[e];if(n!==r){n<r?i=-1:n>r&&(i=1);break}}return i},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new b(t)},r.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},r.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},r.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},r.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},r.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},r.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},r.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var c={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new r(i,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=r._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,e=t;do{this.split(e,this.tmp),i=(e=(e=this.imulK(e)).iadd(this.tmp)).bitLength()}while(i>this.n);var n=i<this.n?-1:e.ucmp(this.p);return 0===n?(e.words[0]=0,e.length=1):n>0?e.isub(this.p):e.strip(),e},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,i){for(var e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var r=t.words[9];for(i.words[i.length++]=4194303&r,n=10;n<t.length;n++){var h=0|t.words[n];t.words[n-10]=(4194303&h)<<4|r>>>22,r=h}t.words[n-10]=r>>>=22,t.length-=0===r&&t.length>10?10:9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,e=0;e<t.length;e++){var n=0|t.words[e];t.words[e]=67108863&(i+=977*n),i=64*n+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(g,y),n(M,y),n(w,y),w.prototype.imulK=function(t){for(var i=0,e=0;e<t.length;e++){var n=19*(0|t.words[e])+i,r=67108863&n;n>>>=26,t.words[e]=r,i=n}return 0!==i&&(t.words[t.length++]=i),t},r._prime=function(t){if(c[t])return c[t];var i;if("k256"===t)i=new v;else if("p224"===t)i=new g;else if("p192"===t)i=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new w}return c[t]=i,i},b.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var e=t.add(i);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var e=t.iadd(i);return e.cmp(this.m)>=0&&e.isub(this.m),e},b.prototype.sub=function(t,i){this._verify2(t,i);var e=t.sub(i);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var e=t.isub(i);return e.cmpn(0)<0&&e.iadd(this.m),e},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var n=this.m.add(new r(1)).iushrn(2);return this.pow(t,n)}for(var h=this.m.subn(1),s=0;!h.isZero()&&0===h.andln(1);)s++,h.iushrn(1);e(!h.isZero());var o=new r(1).toRed(this),u=o.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new r(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,h),d=this.pow(t,h.addn(1).iushrn(1)),f=this.pow(t,h),p=s;0!==f.cmp(o);){for(var c=f,y=0;0!==c.cmp(o);y++)c=c.redSqr();e(y<p);var v=this.pow(m,new r(1).iushln(p-y-1));d=d.redMul(v),m=v.redSqr(),f=f.redMul(m),p=y}return d},b.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},b.prototype.pow=function(t,i){if(i.isZero())return new r(1);if(0===i.cmpn(1))return t.clone();var e=new Array(16);e[0]=new r(1).toRed(this),e[1]=t;for(var n=2;n<e.length;n++)e[n]=this.mul(e[n-1],t);var h=e[0],s=0,o=0,u=i.bitLength()%26;for(0===u&&(u=26),n=i.length-1;n>=0;n--){for(var a=i.words[n],l=u-1;l>=0;l--){var m=a>>l&1;h!==e[0]&&(h=this.sqr(h)),0!==m||0!==s?(s<<=1,s|=m,(4==++o||0===n&&0===l)&&(h=this.mul(h,e[s]),o=0,s=0)):o=0}u=26}return h},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},r.mont=function(t){return new _(t)},n(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=e.isub(n).iushrn(this.shift),h=r;return r.cmp(this.m)>=0?h=r.isub(this.m):r.cmpn(0)<0&&(h=r.iadd(this.m)),h._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new r(0)._forceRed(this);var e=t.mul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),h=e.isub(n).iushrn(this.shift),s=h;return h.cmp(this.m)>=0?s=h.isub(this.m):h.cmpn(0)<0&&(s=h.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,u)}(i={exports:{}}),i.exports}(),l=[{constant:!0,inputs:[{name:"",type:"address"}],name:"owners",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"},{name:"",type:"bytes32"},{name:"",type:"address"}],name:"delegates",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"nonce",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"changed",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"owner",type:"address"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDOwnerChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"delegateType",type:"bytes32"},{indexed:!1,name:"delegate",type:"address"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDDelegateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"name",type:"bytes32"},{indexed:!1,name:"value",type:"bytes"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDAttributeChanged",type:"event"},{constant:!0,inputs:[{name:"identity",type:"address"}],name:"identityOwner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"validDelegate",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"newOwner",type:"address"}],name:"changeOwner",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"newOwner",type:"address"}],name:"changeOwnerSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],m="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";function d(t){return r.Buffer.from(t.slice(2),"hex").toString("utf8").replace(/\0+$/,"")}function f(t){var i="0x"+r.Buffer.from(t).slice(0,32).toString("hex");return i+"0".repeat(66-i.length)}var p={Secp256k1SignatureAuthentication2018:f("sigAuth"),Secp256k1VerificationKey2018:f("veriKey")},c={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018"};function y(t,i,e){for(var n=new a(Math.floor((new Date).getTime()/1e3)),h=[{id:t+"#owner",type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:i}],s=[{type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#owner"}],o=0,u={},l={},m={},f=0,p=e;f<p.length;f+=1){var y=p[f],v=y.validTo,g=y._eventName+"-"+(y.delegateType||y.name)+"-"+(y.delegate||y.value);if(v&&v.gte(n)){if("DIDDelegateChanged"===y._eventName)switch(o++,d(y.delegateType)){case"sigAuth":u[g]={type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#delegate-"+o};case"veriKey":l[g]={id:t+"#delegate-"+o,type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:y.delegate}}else if("DIDAttributeChanged"===y._eventName){var M=d(y.name).match(/^did\/(pub|auth|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(M){var w=M[2],b=c[M[4]]||M[4],_=M[6];switch(M[1]){case"pub":var S={id:t+"#delegate-"+ ++o,type:""+w+b,owner:t};switch(_){case null:case void 0:case"hex":S.publicKeyHex=y.value.slice(2);break;case"base64":S.publicKeyBase64=r.Buffer.from(y.value.slice(2),"hex").toString("base64");break;case"base58":S.publicKeyBase58=r.Buffer.from(y.value.slice(2),"hex").toString("base58");break;case"pem":S.publicKeyPem=r.Buffer.from(y.value.slice(2),"hex").toString();break;default:S.value=y.value}l[g]=S;break;case"svc":m[g]={type:w,serviceEndpoint:r.Buffer.from(y.value.slice(2),"hex").toString()}}}}}else o>0&&("DIDDelegateChanged"===y._eventName||"DIDAttributeChanged"===y._eventName&&d(y.name).match(/^did\/pub\//))&&v.lt(n)&&o--,delete u[g],delete l[g],delete m[g]}var k={"@context":"https://w3id.org/did/v1",id:t,publicKey:h.concat(Object.values(l)),authentication:s.concat(Object.values(u))};return Object.values(m).length>0&&(k.service=Object.values(m)),k}module.exports={REGISTRY:m,bytes32toString:d,stringToBytes32:f,delegateTypes:p,attrTypes:c,wrapDidDocument:y,getResolver:function(r){void 0===r&&(r={});var u=function(i){return void 0===i&&(i={}),i.provider?i.provider:i.web3?i.web3.currentProvider:new t(i.rpcUrl||"https://mainnet.infura.io/ethr-did")}(r),a=new i(u),d=r.registry||m,f=new n(a)(l).at(d),p=e.logDecoder(l,!1);return{ethr:function(t,i){try{if(!i.id.match(/^0x[0-9a-fA-F]{40}$/))throw new Error("Not a valid ethr DID: "+t);return Promise.resolve(function(t){try{var i=[],e=t;return Promise.resolve(function(t){try{return Promise.resolve(f.changed(t)).then(function(t){if(t)return t[0]})}catch(t){return Promise.reject(t)}}(t)).then(function(n){function r(){function r(){return{owner:e,history:i}}var u=function(t,i,e){for(var n;;){var r=t();if(o(r)&&(r=r.v),!r)return u;if(r.then){n=0;break}var u=e();if(u&&u.then){if(!o(u)){n=1;break}u=u.s}if(i){var a=i();if(a&&a.then&&!o(a)){n=2;break}}}var l=new h,m=s.bind(null,l,2);return(0===n?r.then(f):1===n?u.then(d):a.then(p)).then(void 0,m),l;function d(n){u=n;do{if(i&&(a=i())&&a.then&&!o(a))return void a.then(p).then(void 0,m);if(!(r=t())||o(r)&&!r.v)return void s(l,1,u);if(r.then)return void r.then(f).then(void 0,m);o(u=e())&&(u=u.v)}while(!u||!u.then);u.then(d).then(void 0,m)}function f(t){t?(u=e())&&u.then?u.then(d).then(void 0,m):d(u):s(l,1,u)}function p(){(r=t())?r.then?r.then(f).then(void 0,m):f(r):s(l,1,u)}}(function(){return!!n},void 0,function(){var e=n;return Promise.resolve(a.getLogs({address:d,topics:[null,"0x000000000000000000000000"+t.slice(2)],fromBlock:n,toBlock:n})).then(function(t){var r=p(t);n=void 0;for(var h=0,s=r;h<s.length;h+=1){var o=s[h];i.unshift(o),o.previousChange.lt(e)&&(n=o.previousChange)}})});return u&&u.then?u.then(r):r()}var u=function(){if(n)return Promise.resolve(f.identityOwner(t)).then(function(t){e=t[0]})}();return u&&u.then?u.then(r):r()})}catch(t){return Promise.reject(t)}}(i.id)).then(function(i){return y(t,i.owner,i.history)})}catch(t){return Promise.reject(t)}}}}}});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("ethjs-provider-http"),require("ethjs-query"),require("ethjs-abi"),require("ethjs-contract"),require("buffer")):"function"==typeof define&&define.amd?define(["ethjs-provider-http","ethjs-query","ethjs-abi","ethjs-contract","buffer"],i):i(t.HttpProvider,t.Eth,t.abi,t.EthContract,t.buffer)}(this,function(t,i,e,n,r){t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;const h=function(){function t(){}return t.prototype.then=function(i,e){const n=new t,r=this.s;if(r){const t=1&r?i:e;if(t){try{s(n,1,t(this.v))}catch(t){s(n,2,t)}return n}return this}return this.o=function(t){try{const r=t.v;1&t.s?s(n,1,i?i(r):r):e?s(n,1,e(r)):s(n,2,r)}catch(t){s(n,2,t)}},n},t}();function s(t,i,e){if(!t.s){if(e instanceof h){if(!e.s)return void(e.o=s.bind(null,t,i));1&i&&(i=e.s),e=e.v}if(e&&e.then)return void e.then(s.bind(null,t,i),s.bind(null,t,2));t.s=i,t.v=e;const n=t.o;n&&n(t)}}function o(t){return t instanceof h&&1&t.s}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u=function(t,i){return function(t){!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var e=function(){};e.prototype=i.prototype,t.prototype=new e,t.prototype.constructor=t}function r(t,i,e){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(e=i,i=10),this._init(t||0,i||10,e||"be"))}var h;"object"==typeof t?t.exports=r:i.BN=r,r.BN=r,r.wordSize=26;try{h=function(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}().Buffer}catch(t){}function s(t,i,e){for(var n=0,r=Math.min(t.length,e),h=i;h<r;h++){var s=t.charCodeAt(h)-48;n<<=4,n|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function o(t,i,e,n){for(var r=0,h=Math.min(t.length,e),s=i;s<h;s++){var o=t.charCodeAt(s)-48;r*=n,r+=o>=49?o-49+10:o>=17?o-17+10:o}return r}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,i){return t.cmp(i)>0?t:i},r.min=function(t,i){return t.cmp(i)<0?t:i},r.prototype._init=function(t,i,n){if("number"==typeof t)return this._initNumber(t,i,n);if("object"==typeof t)return this._initArray(t,i,n);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===i?this._parseHex(t,r):this._parseBase(t,i,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initNumber=function(t,i,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),i,n)},r.prototype._initArray=function(t,i,n){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var h,s,o=0;if("be"===n)for(r=t.length-1,h=0;r>=0;r-=3)this.words[h]|=(s=t[r]|t[r-1]<<8|t[r-2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);else if("le"===n)for(r=0,h=0;r<t.length;r+=3)this.words[h]|=(s=t[r]|t[r+1]<<8|t[r+2]<<16)<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);return this.strip()},r.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,r,h=0;for(e=t.length-6,n=0;e>=i;e-=6)r=s(t,e,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303,(h+=24)>=26&&(h-=26,n++);e+6!==i&&(r=s(t,i,e+6),this.words[n]|=r<<h&67108863,this.words[n+1]|=r>>>26-h&4194303),this.strip()},r.prototype._parseBase=function(t,i,e){this.words=[0],this.length=1;for(var n=0,r=1;r<=67108863;r*=i)n++;r=r/i|0;for(var h=t.length-e,s=h%--n,a=Math.min(h,h-s)+e,u=0,l=e;l<a;l+=n)u=o(t,l,l+n,i),this.imuln(r),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var m=1;for(u=o(t,l,t.length,i),l=0;l<s;l++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},r.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},r.prototype.clone=function(){var t=new r(null);return this.copy(t),t},r.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},r.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var a=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,e){e.negative=i.negative^t.negative;var n=t.length+i.length|0;e.length=n,n=n-1|0;var r=0|t.words[0],h=0|i.words[0],s=r*h,o=s/67108864|0;e.words[0]=67108863&s;for(var a=1;a<n;a++){for(var u=o>>>26,l=67108863&o,m=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=m;d++)u+=(s=(r=0|t.words[a-d|0])*(h=0|i.words[d])+l)/67108864|0,l=67108863&s;e.words[a]=0|l,o=0|u}return 0!==o?e.words[a]=0|o:e.length--,e.strip()}r.prototype.toString=function(t,i){var n;if(i=0|i||1,16===(t=t||10)||"hex"===t){n="";for(var r=0,h=0,s=0;s<this.length;s++){var o=this.words[s],m=(16777215&(o<<r|h)).toString(16);n=0!=(h=o>>>24-r&16777215)||s!==this.length-1?a[6-m.length]+m+n:m+n,(r+=2)>=26&&(r-=26,s--)}for(0!==h&&(n=h.toString(16)+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var d=u[t],f=l[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(t);n=(p=p.idivn(f)).isZero()?c+n:a[d-c.length]+c+n}for(this.isZero()&&(n="0"+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}e(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,i){return e(void 0!==h),this.toArrayLike(h,t,i)},r.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},r.prototype.toArrayLike=function(t,i,n){var r=this.byteLength(),h=n||Math.max(1,r);e(r<=h,"byte array longer than desired length"),e(h>0,"Requested array length <= 0"),this.strip();var s,o,a="le"===i,u=new t(h),l=this.clone();if(a){for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),u[o]=s;for(;o<h;o++)u[o]=0}else{for(o=0;o<h-r;o++)u[o]=0;for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),u[h-o-1]=s}return u},r.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var i=t,e=0;return i>=4096&&(e+=13,i>>>=13),i>=64&&(e+=7,i>>>=7),i>=8&&(e+=4,i>>>=4),i>=2&&(e+=2,i>>>=2),e+i},r.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,e=0;return 0==(8191&i)&&(e+=13,i>>>=13),0==(127&i)&&(e+=7,i>>>=7),0==(15&i)&&(e+=4,i>>>=4),0==(3&i)&&(e+=2,i>>>=2),0==(1&i)&&e++,e},r.prototype.bitLength=function(){var t=this._countBits(this.words[this.length-1]);return 26*(this.length-1)+t},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var e=this._zeroBits(this.words[i]);if(t+=e,26!==e)break}return t},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},r.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return 0!==this.negative},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this.strip()},r.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},r.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var e=0;e<i.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=i.length,this.strip()},r.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},r.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0;n<e.length;n++)this.words[n]=i.words[n]^e.words[n];if(this!==i)for(;n<i.length;n++)this.words[n]=i.words[n];return this.length=i.length,this.strip()},r.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},r.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),n=t%26;this._expand(i),n>0&&i--;for(var r=0;r<i;r++)this.words[r]=67108863&~this.words[r];return n>0&&(this.words[r]=~this.words[r]&67108863>>26-n),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var n=t/26|0,r=t%26;return this._expand(n+1),this.words[n]=i?this.words[n]|1<<r:this.words[n]&~(1<<r),this.strip()},r.prototype.iadd=function(t){var i,e,n;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0,h=0;h<n.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+(0|n.words[h])+r),r=i>>>26;for(;0!==r&&h<e.length;h++)this.words[h]=67108863&(i=(0|e.words[h])+r),r=i>>>26;if(this.length=e.length,0!==r)this.words[this.length]=r,this.length++;else if(e!==this)for(;h<e.length;h++)this.words[h]=e.words[h];return this},r.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e,n,r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(e=this,n=t):(e=t,n=this);for(var h=0,s=0;s<n.length;s++)h=(i=(0|e.words[s])-(0|n.words[s])+h)>>26,this.words[s]=67108863&i;for(;0!==h&&s<e.length;s++)h=(i=(0|e.words[s])+h)>>26,this.words[s]=67108863&i;if(0===h&&s<e.length&&e!==this)for(;s<e.length;s++)this.words[s]=e.words[s];return this.length=Math.max(this.length,s),e!==this&&(this.negative=1),this.strip()},r.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,i,e){var n,r,h,s=t.words,o=i.words,a=e.words,u=0,l=0|s[0],m=8191&l,d=l>>>13,f=0|s[1],p=8191&f,c=f>>>13,y=0|s[2],v=8191&y,g=y>>>13,M=0|s[3],w=8191&M,b=M>>>13,_=0|s[4],k=8191&_,S=_>>>13,x=0|s[5],A=8191&x,R=x>>>13,B=0|s[6],q=8191&B,D=B>>>13,T=0|s[7],Z=8191&T,I=T>>>13,N=0|s[8],j=8191&N,O=N>>>13,P=0|s[9],K=8191&P,E=P>>>13,L=0|o[0],C=8191&L,z=L>>>13,V=0|o[1],U=8191&V,F=V>>>13,H=0|o[2],$=8191&H,G=H>>>13,J=0|o[3],Y=8191&J,Q=J>>>13,W=0|o[4],X=8191&W,tt=W>>>13,it=0|o[5],et=8191&it,nt=it>>>13,rt=0|o[6],ht=8191&rt,st=rt>>>13,ot=0|o[7],at=8191&ot,ut=ot>>>13,lt=0|o[8],mt=8191&lt,dt=lt>>>13,ft=0|o[9],pt=8191&ft,ct=ft>>>13;e.negative=t.negative^i.negative,e.length=19;var yt=(u+(n=Math.imul(m,C))|0)+((8191&(r=(r=Math.imul(m,z))+Math.imul(d,C)|0))<<13)|0;u=((h=Math.imul(d,z))+(r>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,C),r=(r=Math.imul(p,z))+Math.imul(c,C)|0,h=Math.imul(c,z);var vt=(u+(n=n+Math.imul(m,U)|0)|0)+((8191&(r=(r=r+Math.imul(m,F)|0)+Math.imul(d,U)|0))<<13)|0;u=((h=h+Math.imul(d,F)|0)+(r>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,C),r=(r=Math.imul(v,z))+Math.imul(g,C)|0,h=Math.imul(g,z),n=n+Math.imul(p,U)|0,r=(r=r+Math.imul(p,F)|0)+Math.imul(c,U)|0,h=h+Math.imul(c,F)|0;var gt=(u+(n=n+Math.imul(m,$)|0)|0)+((8191&(r=(r=r+Math.imul(m,G)|0)+Math.imul(d,$)|0))<<13)|0;u=((h=h+Math.imul(d,G)|0)+(r>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,C),r=(r=Math.imul(w,z))+Math.imul(b,C)|0,h=Math.imul(b,z),n=n+Math.imul(v,U)|0,r=(r=r+Math.imul(v,F)|0)+Math.imul(g,U)|0,h=h+Math.imul(g,F)|0,n=n+Math.imul(p,$)|0,r=(r=r+Math.imul(p,G)|0)+Math.imul(c,$)|0,h=h+Math.imul(c,G)|0;var Mt=(u+(n=n+Math.imul(m,Y)|0)|0)+((8191&(r=(r=r+Math.imul(m,Q)|0)+Math.imul(d,Y)|0))<<13)|0;u=((h=h+Math.imul(d,Q)|0)+(r>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,C),r=(r=Math.imul(k,z))+Math.imul(S,C)|0,h=Math.imul(S,z),n=n+Math.imul(w,U)|0,r=(r=r+Math.imul(w,F)|0)+Math.imul(b,U)|0,h=h+Math.imul(b,F)|0,n=n+Math.imul(v,$)|0,r=(r=r+Math.imul(v,G)|0)+Math.imul(g,$)|0,h=h+Math.imul(g,G)|0,n=n+Math.imul(p,Y)|0,r=(r=r+Math.imul(p,Q)|0)+Math.imul(c,Y)|0,h=h+Math.imul(c,Q)|0;var wt=(u+(n=n+Math.imul(m,X)|0)|0)+((8191&(r=(r=r+Math.imul(m,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((h=h+Math.imul(d,tt)|0)+(r>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(A,C),r=(r=Math.imul(A,z))+Math.imul(R,C)|0,h=Math.imul(R,z),n=n+Math.imul(k,U)|0,r=(r=r+Math.imul(k,F)|0)+Math.imul(S,U)|0,h=h+Math.imul(S,F)|0,n=n+Math.imul(w,$)|0,r=(r=r+Math.imul(w,G)|0)+Math.imul(b,$)|0,h=h+Math.imul(b,G)|0,n=n+Math.imul(v,Y)|0,r=(r=r+Math.imul(v,Q)|0)+Math.imul(g,Y)|0,h=h+Math.imul(g,Q)|0,n=n+Math.imul(p,X)|0,r=(r=r+Math.imul(p,tt)|0)+Math.imul(c,X)|0,h=h+Math.imul(c,tt)|0;var bt=(u+(n=n+Math.imul(m,et)|0)|0)+((8191&(r=(r=r+Math.imul(m,nt)|0)+Math.imul(d,et)|0))<<13)|0;u=((h=h+Math.imul(d,nt)|0)+(r>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(q,C),r=(r=Math.imul(q,z))+Math.imul(D,C)|0,h=Math.imul(D,z),n=n+Math.imul(A,U)|0,r=(r=r+Math.imul(A,F)|0)+Math.imul(R,U)|0,h=h+Math.imul(R,F)|0,n=n+Math.imul(k,$)|0,r=(r=r+Math.imul(k,G)|0)+Math.imul(S,$)|0,h=h+Math.imul(S,G)|0,n=n+Math.imul(w,Y)|0,r=(r=r+Math.imul(w,Q)|0)+Math.imul(b,Y)|0,h=h+Math.imul(b,Q)|0,n=n+Math.imul(v,X)|0,r=(r=r+Math.imul(v,tt)|0)+Math.imul(g,X)|0,h=h+Math.imul(g,tt)|0,n=n+Math.imul(p,et)|0,r=(r=r+Math.imul(p,nt)|0)+Math.imul(c,et)|0,h=h+Math.imul(c,nt)|0;var _t=(u+(n=n+Math.imul(m,ht)|0)|0)+((8191&(r=(r=r+Math.imul(m,st)|0)+Math.imul(d,ht)|0))<<13)|0;u=((h=h+Math.imul(d,st)|0)+(r>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(Z,C),r=(r=Math.imul(Z,z))+Math.imul(I,C)|0,h=Math.imul(I,z),n=n+Math.imul(q,U)|0,r=(r=r+Math.imul(q,F)|0)+Math.imul(D,U)|0,h=h+Math.imul(D,F)|0,n=n+Math.imul(A,$)|0,r=(r=r+Math.imul(A,G)|0)+Math.imul(R,$)|0,h=h+Math.imul(R,G)|0,n=n+Math.imul(k,Y)|0,r=(r=r+Math.imul(k,Q)|0)+Math.imul(S,Y)|0,h=h+Math.imul(S,Q)|0,n=n+Math.imul(w,X)|0,r=(r=r+Math.imul(w,tt)|0)+Math.imul(b,X)|0,h=h+Math.imul(b,tt)|0,n=n+Math.imul(v,et)|0,r=(r=r+Math.imul(v,nt)|0)+Math.imul(g,et)|0,h=h+Math.imul(g,nt)|0,n=n+Math.imul(p,ht)|0,r=(r=r+Math.imul(p,st)|0)+Math.imul(c,ht)|0,h=h+Math.imul(c,st)|0;var kt=(u+(n=n+Math.imul(m,at)|0)|0)+((8191&(r=(r=r+Math.imul(m,ut)|0)+Math.imul(d,at)|0))<<13)|0;u=((h=h+Math.imul(d,ut)|0)+(r>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(j,C),r=(r=Math.imul(j,z))+Math.imul(O,C)|0,h=Math.imul(O,z),n=n+Math.imul(Z,U)|0,r=(r=r+Math.imul(Z,F)|0)+Math.imul(I,U)|0,h=h+Math.imul(I,F)|0,n=n+Math.imul(q,$)|0,r=(r=r+Math.imul(q,G)|0)+Math.imul(D,$)|0,h=h+Math.imul(D,G)|0,n=n+Math.imul(A,Y)|0,r=(r=r+Math.imul(A,Q)|0)+Math.imul(R,Y)|0,h=h+Math.imul(R,Q)|0,n=n+Math.imul(k,X)|0,r=(r=r+Math.imul(k,tt)|0)+Math.imul(S,X)|0,h=h+Math.imul(S,tt)|0,n=n+Math.imul(w,et)|0,r=(r=r+Math.imul(w,nt)|0)+Math.imul(b,et)|0,h=h+Math.imul(b,nt)|0,n=n+Math.imul(v,ht)|0,r=(r=r+Math.imul(v,st)|0)+Math.imul(g,ht)|0,h=h+Math.imul(g,st)|0,n=n+Math.imul(p,at)|0,r=(r=r+Math.imul(p,ut)|0)+Math.imul(c,at)|0,h=h+Math.imul(c,ut)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(r=(r=r+Math.imul(m,dt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((h=h+Math.imul(d,dt)|0)+(r>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(K,C),r=(r=Math.imul(K,z))+Math.imul(E,C)|0,h=Math.imul(E,z),n=n+Math.imul(j,U)|0,r=(r=r+Math.imul(j,F)|0)+Math.imul(O,U)|0,h=h+Math.imul(O,F)|0,n=n+Math.imul(Z,$)|0,r=(r=r+Math.imul(Z,G)|0)+Math.imul(I,$)|0,h=h+Math.imul(I,G)|0,n=n+Math.imul(q,Y)|0,r=(r=r+Math.imul(q,Q)|0)+Math.imul(D,Y)|0,h=h+Math.imul(D,Q)|0,n=n+Math.imul(A,X)|0,r=(r=r+Math.imul(A,tt)|0)+Math.imul(R,X)|0,h=h+Math.imul(R,tt)|0,n=n+Math.imul(k,et)|0,r=(r=r+Math.imul(k,nt)|0)+Math.imul(S,et)|0,h=h+Math.imul(S,nt)|0,n=n+Math.imul(w,ht)|0,r=(r=r+Math.imul(w,st)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,st)|0,n=n+Math.imul(v,at)|0,r=(r=r+Math.imul(v,ut)|0)+Math.imul(g,at)|0,h=h+Math.imul(g,ut)|0,n=n+Math.imul(p,mt)|0,r=(r=r+Math.imul(p,dt)|0)+Math.imul(c,mt)|0,h=h+Math.imul(c,dt)|0;var xt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(r=(r=r+Math.imul(m,ct)|0)+Math.imul(d,pt)|0))<<13)|0;u=((h=h+Math.imul(d,ct)|0)+(r>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(K,U),r=(r=Math.imul(K,F))+Math.imul(E,U)|0,h=Math.imul(E,F),n=n+Math.imul(j,$)|0,r=(r=r+Math.imul(j,G)|0)+Math.imul(O,$)|0,h=h+Math.imul(O,G)|0,n=n+Math.imul(Z,Y)|0,r=(r=r+Math.imul(Z,Q)|0)+Math.imul(I,Y)|0,h=h+Math.imul(I,Q)|0,n=n+Math.imul(q,X)|0,r=(r=r+Math.imul(q,tt)|0)+Math.imul(D,X)|0,h=h+Math.imul(D,tt)|0,n=n+Math.imul(A,et)|0,r=(r=r+Math.imul(A,nt)|0)+Math.imul(R,et)|0,h=h+Math.imul(R,nt)|0,n=n+Math.imul(k,ht)|0,r=(r=r+Math.imul(k,st)|0)+Math.imul(S,ht)|0,h=h+Math.imul(S,st)|0,n=n+Math.imul(w,at)|0,r=(r=r+Math.imul(w,ut)|0)+Math.imul(b,at)|0,h=h+Math.imul(b,ut)|0,n=n+Math.imul(v,mt)|0,r=(r=r+Math.imul(v,dt)|0)+Math.imul(g,mt)|0,h=h+Math.imul(g,dt)|0;var At=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(r=(r=r+Math.imul(p,ct)|0)+Math.imul(c,pt)|0))<<13)|0;u=((h=h+Math.imul(c,ct)|0)+(r>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(K,$),r=(r=Math.imul(K,G))+Math.imul(E,$)|0,h=Math.imul(E,G),n=n+Math.imul(j,Y)|0,r=(r=r+Math.imul(j,Q)|0)+Math.imul(O,Y)|0,h=h+Math.imul(O,Q)|0,n=n+Math.imul(Z,X)|0,r=(r=r+Math.imul(Z,tt)|0)+Math.imul(I,X)|0,h=h+Math.imul(I,tt)|0,n=n+Math.imul(q,et)|0,r=(r=r+Math.imul(q,nt)|0)+Math.imul(D,et)|0,h=h+Math.imul(D,nt)|0,n=n+Math.imul(A,ht)|0,r=(r=r+Math.imul(A,st)|0)+Math.imul(R,ht)|0,h=h+Math.imul(R,st)|0,n=n+Math.imul(k,at)|0,r=(r=r+Math.imul(k,ut)|0)+Math.imul(S,at)|0,h=h+Math.imul(S,ut)|0,n=n+Math.imul(w,mt)|0,r=(r=r+Math.imul(w,dt)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,dt)|0;var Rt=(u+(n=n+Math.imul(v,pt)|0)|0)+((8191&(r=(r=r+Math.imul(v,ct)|0)+Math.imul(g,pt)|0))<<13)|0;u=((h=h+Math.imul(g,ct)|0)+(r>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(K,Y),r=(r=Math.imul(K,Q))+Math.imul(E,Y)|0,h=Math.imul(E,Q),n=n+Math.imul(j,X)|0,r=(r=r+Math.imul(j,tt)|0)+Math.imul(O,X)|0,h=h+Math.imul(O,tt)|0,n=n+Math.imul(Z,et)|0,r=(r=r+Math.imul(Z,nt)|0)+Math.imul(I,et)|0,h=h+Math.imul(I,nt)|0,n=n+Math.imul(q,ht)|0,r=(r=r+Math.imul(q,st)|0)+Math.imul(D,ht)|0,h=h+Math.imul(D,st)|0,n=n+Math.imul(A,at)|0,r=(r=r+Math.imul(A,ut)|0)+Math.imul(R,at)|0,h=h+Math.imul(R,ut)|0,n=n+Math.imul(k,mt)|0,r=(r=r+Math.imul(k,dt)|0)+Math.imul(S,mt)|0,h=h+Math.imul(S,dt)|0;var Bt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(r=(r=r+Math.imul(w,ct)|0)+Math.imul(b,pt)|0))<<13)|0;u=((h=h+Math.imul(b,ct)|0)+(r>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(K,X),r=(r=Math.imul(K,tt))+Math.imul(E,X)|0,h=Math.imul(E,tt),n=n+Math.imul(j,et)|0,r=(r=r+Math.imul(j,nt)|0)+Math.imul(O,et)|0,h=h+Math.imul(O,nt)|0,n=n+Math.imul(Z,ht)|0,r=(r=r+Math.imul(Z,st)|0)+Math.imul(I,ht)|0,h=h+Math.imul(I,st)|0,n=n+Math.imul(q,at)|0,r=(r=r+Math.imul(q,ut)|0)+Math.imul(D,at)|0,h=h+Math.imul(D,ut)|0,n=n+Math.imul(A,mt)|0,r=(r=r+Math.imul(A,dt)|0)+Math.imul(R,mt)|0,h=h+Math.imul(R,dt)|0;var qt=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(r=(r=r+Math.imul(k,ct)|0)+Math.imul(S,pt)|0))<<13)|0;u=((h=h+Math.imul(S,ct)|0)+(r>>>13)|0)+(qt>>>26)|0,qt&=67108863,n=Math.imul(K,et),r=(r=Math.imul(K,nt))+Math.imul(E,et)|0,h=Math.imul(E,nt),n=n+Math.imul(j,ht)|0,r=(r=r+Math.imul(j,st)|0)+Math.imul(O,ht)|0,h=h+Math.imul(O,st)|0,n=n+Math.imul(Z,at)|0,r=(r=r+Math.imul(Z,ut)|0)+Math.imul(I,at)|0,h=h+Math.imul(I,ut)|0,n=n+Math.imul(q,mt)|0,r=(r=r+Math.imul(q,dt)|0)+Math.imul(D,mt)|0,h=h+Math.imul(D,dt)|0;var Dt=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(r=(r=r+Math.imul(A,ct)|0)+Math.imul(R,pt)|0))<<13)|0;u=((h=h+Math.imul(R,ct)|0)+(r>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(K,ht),r=(r=Math.imul(K,st))+Math.imul(E,ht)|0,h=Math.imul(E,st),n=n+Math.imul(j,at)|0,r=(r=r+Math.imul(j,ut)|0)+Math.imul(O,at)|0,h=h+Math.imul(O,ut)|0,n=n+Math.imul(Z,mt)|0,r=(r=r+Math.imul(Z,dt)|0)+Math.imul(I,mt)|0,h=h+Math.imul(I,dt)|0;var Tt=(u+(n=n+Math.imul(q,pt)|0)|0)+((8191&(r=(r=r+Math.imul(q,ct)|0)+Math.imul(D,pt)|0))<<13)|0;u=((h=h+Math.imul(D,ct)|0)+(r>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(K,at),r=(r=Math.imul(K,ut))+Math.imul(E,at)|0,h=Math.imul(E,ut),n=n+Math.imul(j,mt)|0,r=(r=r+Math.imul(j,dt)|0)+Math.imul(O,mt)|0,h=h+Math.imul(O,dt)|0;var Zt=(u+(n=n+Math.imul(Z,pt)|0)|0)+((8191&(r=(r=r+Math.imul(Z,ct)|0)+Math.imul(I,pt)|0))<<13)|0;u=((h=h+Math.imul(I,ct)|0)+(r>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,n=Math.imul(K,mt),r=(r=Math.imul(K,dt))+Math.imul(E,mt)|0,h=Math.imul(E,dt);var It=(u+(n=n+Math.imul(j,pt)|0)|0)+((8191&(r=(r=r+Math.imul(j,ct)|0)+Math.imul(O,pt)|0))<<13)|0;u=((h=h+Math.imul(O,ct)|0)+(r>>>13)|0)+(It>>>26)|0,It&=67108863;var Nt=(u+(n=Math.imul(K,pt))|0)+((8191&(r=(r=Math.imul(K,ct))+Math.imul(E,pt)|0))<<13)|0;return u=((h=Math.imul(E,ct))+(r>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,a[0]=yt,a[1]=vt,a[2]=gt,a[3]=Mt,a[4]=wt,a[5]=bt,a[6]=_t,a[7]=kt,a[8]=St,a[9]=xt,a[10]=At,a[11]=Rt,a[12]=Bt,a[13]=qt,a[14]=Dt,a[15]=Tt,a[16]=Zt,a[17]=It,a[18]=Nt,0!==u&&(a[19]=u,e.length++),e};function f(t,i,e){return(new p).mulp(t,i,e)}function p(t,i){this.x=t,this.y=i}Math.imul||(d=m),r.prototype.mulTo=function(t,i){var e=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):e<63?m(this,t,i):e<1024?function(t,i,e){e.negative=i.negative^t.negative,e.length=t.length+i.length;for(var n=0,r=0,h=0;h<e.length-1;h++){var s=r;r=0;for(var o=67108863&n,a=Math.min(h,i.length-1),u=Math.max(0,h-t.length+1);u<=a;u++){var l=(0|t.words[h-u])*(0|i.words[u]),m=67108863&l;o=67108863&(m=m+o|0),r+=(s=(s=s+(l/67108864|0)|0)+(m>>>26)|0)>>>26,s&=67108863}e.words[h]=o,n=s,s=r}return 0!==n?e.words[h]=n:e.length--,e.strip()}(this,t,i):f(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),e=r.prototype._countBits(t)-1,n=0;n<t;n++)i[n]=this.revBin(n,e,t);return i},p.prototype.revBin=function(t,i,e){if(0===t||t===e-1)return t;for(var n=0,r=0;r<i;r++)n|=(1&t)<<i-r-1,t>>=1;return n},p.prototype.permute=function(t,i,e,n,r,h){for(var s=0;s<h;s++)n[s]=i[t[s]],r[s]=e[t[s]]},p.prototype.transform=function(t,i,e,n,r,h){this.permute(h,t,i,e,n,r);for(var s=1;s<r;s<<=1)for(var o=s<<1,a=Math.cos(2*Math.PI/o),u=Math.sin(2*Math.PI/o),l=0;l<r;l+=o)for(var m=a,d=u,f=0;f<s;f++){var p=e[l+f],c=n[l+f],y=e[l+f+s],v=n[l+f+s],g=m*y-d*v;v=m*v+d*y,e[l+f]=p+(y=g),n[l+f]=c+v,e[l+f+s]=p-y,n[l+f+s]=c-v,f!==o&&(g=a*m-u*d,d=a*d+u*m,m=g)}},p.prototype.guessLen13b=function(t,i){var e=1|Math.max(i,t),n=1&e,r=0;for(e=e/2|0;e;e>>>=1)r++;return 1<<r+1+n},p.prototype.conjugate=function(t,i,e){if(!(e<=1))for(var n=0;n<e/2;n++){var r=t[n];t[n]=t[e-n-1],t[e-n-1]=r,r=i[n],i[n]=-i[e-n-1],i[e-n-1]=-r}},p.prototype.normalize13b=function(t,i){for(var e=0,n=0;n<i/2;n++){var r=8192*Math.round(t[2*n+1]/i)+Math.round(t[2*n]/i)+e;t[n]=67108863&r,e=r<67108864?0:r/67108864|0}return t},p.prototype.convert13b=function(t,i,n,r){for(var h=0,s=0;s<i;s++)n[2*s]=8191&(h+=0|t[s]),n[2*s+1]=8191&(h>>>=13),h>>>=13;for(s=2*i;s<r;++s)n[s]=0;e(0===h),e(0==(-8192&h))},p.prototype.stub=function(t){for(var i=new Array(t),e=0;e<t;e++)i[e]=0;return i},p.prototype.mulp=function(t,i,e){var n=2*this.guessLen13b(t.length,i.length),r=this.makeRBT(n),h=this.stub(n),s=new Array(n),o=new Array(n),a=new Array(n),u=new Array(n),l=new Array(n),m=new Array(n),d=e.words;d.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(i.words,i.length,u,n),this.transform(s,h,o,a,n,r),this.transform(u,h,l,m,n,r);for(var f=0;f<n;f++){var p=o[f]*l[f]-a[f]*m[f];a[f]=o[f]*m[f]+a[f]*l[f],o[f]=p}return this.conjugate(o,a,n),this.transform(o,a,d,h,n,r),this.conjugate(d,h,n),this.normalize13b(d,n),e.negative=t.negative^i.negative,e.length=t.length+i.length,e.strip()},r.prototype.mul=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},r.prototype.mulf=function(t){var i=new r(null);return i.words=new Array(this.length+t.length),f(this,t,i)},r.prototype.imul=function(t){return this.clone().mulTo(t,this)},r.prototype.imuln=function(t){e("number"==typeof t),e(t<67108864);for(var i=0,n=0;n<this.length;n++){var r=(0|this.words[n])*t,h=(67108863&r)+(67108863&i);i>>=26,i+=r/67108864|0,i+=h>>>26,this.words[n]=67108863&h}return 0!==i&&(this.words[n]=i,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),e=0;e<i.length;e++){var n=e%26;i[e]=(t.words[e/26|0]&1<<n)>>>n}return i}(t);if(0===i.length)return new r(1);for(var e=this,n=0;n<i.length&&0===i[n];n++,e=e.sqr());if(++n<i.length)for(var h=e.sqr();n<i.length;n++,h=h.sqr())0!==i[n]&&(e=e.mul(h));return e},r.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,n=t%26,r=(t-n)/26,h=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(i=0;i<this.length;i++){var o=this.words[i]&h;this.words[i]=(0|this.words[i])-o<<n|s,s=o>>>26-n}s&&(this.words[i]=s,this.length++)}if(0!==r){for(i=this.length-1;i>=0;i--)this.words[i+r]=this.words[i];for(i=0;i<r;i++)this.words[i]=0;this.length+=r}return this.strip()},r.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},r.prototype.iushrn=function(t,i,n){var r;e("number"==typeof t&&t>=0),r=i?(i-i%26)/26:0;var h=t%26,s=Math.min((t-h)/26,this.length),o=67108863^67108863>>>h<<h,a=n;if(r-=s,r=Math.max(0,r),a){for(var u=0;u<s;u++)a.words[u]=this.words[u];a.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=r);u--){var m=0|this.words[u];this.words[u]=l<<26-h|m>>>h,l=m&o}return a&&0!==l&&(a.words[a.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,i,n){return e(0===this.negative),this.iushrn(t,i,n)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return!(this.length<=n||!(this.words[n]&1<<i))},r.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26;return e(0===this.negative,"imaskn works only with positive numbers"),this.length<=n?this:(0!==i&&n++,this.length=Math.min(n,this.length),0!==i&&(this.words[this.length-1]&=67108863^67108863>>>i<<i),this.strip())},r.prototype.maskn=function(t){return this.clone().imaskn(t)},r.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},r.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},r.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},r.prototype.addn=function(t){return this.clone().iaddn(t)},r.prototype.subn=function(t){return this.clone().isubn(t)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(t,i,n){var r,h;this._expand(t.length+n);var s=0;for(r=0;r<t.length;r++){h=(0|this.words[r+n])+s;var o=(0|t.words[r])*i;s=((h-=67108863&o)>>26)-(o/67108864|0),this.words[r+n]=67108863&h}for(;r<this.length-n;r++)s=(h=(0|this.words[r+n])+s)>>26,this.words[r+n]=67108863&h;if(0===s)return this.strip();for(e(-1===s),s=0,r=0;r<this.length;r++)s=(h=-(0|this.words[r])+s)>>26,this.words[r]=67108863&h;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,i){var e,n=this.clone(),h=t,s=0|h.words[h.length-1];0!=(e=26-this._countBits(s))&&(h=h.ushln(e),n.iushln(e),s=0|h.words[h.length-1]);var o,a=n.length-h.length;if("mod"!==i){(o=new r(null)).length=a+1,o.words=new Array(o.length);for(var u=0;u<o.length;u++)o.words[u]=0}var l=n.clone()._ishlnsubmul(h,1,a);0===l.negative&&(n=l,o&&(o.words[a]=1));for(var m=a-1;m>=0;m--){var d=67108864*(0|n.words[h.length+m])+(0|n.words[h.length+m-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(h,d,m);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(h,1,m),n.isZero()||(n.negative^=1);o&&(o.words[m]=d)}return o&&o.strip(),n.strip(),"div"!==i&&0!==e&&n.iushrn(e),{div:o||null,mod:n}},r.prototype.divmod=function(t,i,n){return e(!t.isZero()),this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,i),"mod"!==i&&(h=o.div.neg()),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:h,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),i),"mod"!==i&&(h=o.div.neg()),{div:h,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),i),"div"!==i&&(s=o.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,i);var h,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var e=0!==i.div.negative?i.mod.isub(t):i.mod,n=t.ushrn(1),r=t.andln(1),h=e.cmp(n);return h<0||1===r&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},r.prototype.modn=function(t){e(t<=67108863);for(var i=(1<<26)%t,n=0,r=this.length-1;r>=0;r--)n=(i*n+(0|this.words[r]))%t;return n},r.prototype.idivn=function(t){e(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var r=(0|this.words[n])+67108864*i;this.words[n]=r/t|0,i=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h=new r(1),s=new r(0),o=new r(0),a=new r(1),u=0;i.isEven()&&n.isEven();)i.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),m=i.clone();!i.isZero();){for(var d=0,f=1;0==(i.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(h.isOdd()||s.isOdd())&&(h.iadd(l),s.isub(m)),h.iushrn(1),s.iushrn(1);for(var p=0,c=1;0==(n.words[0]&c)&&p<26;++p,c<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(m)),o.iushrn(1),a.iushrn(1);i.cmp(n)>=0?(i.isub(n),h.isub(o),s.isub(a)):(n.isub(i),o.isub(h),a.isub(s))}return{a:o,b:a,gcd:n.iushln(u)}},r.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h,s=new r(1),o=new r(0),a=n.clone();i.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var m=0,d=1;0==(n.words[0]&d)&&m<26;++m,d<<=1);if(m>0)for(n.iushrn(m);m-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);i.cmp(n)>=0?(i.isub(n),s.isub(o)):(n.isub(i),o.isub(s))}return(h=0===i.cmpn(1)?s:o).cmpn(0)<0&&h.iadd(t),h},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),e=t.clone();i.negative=0,e.negative=0;for(var n=0;i.isEven()&&e.isEven();n++)i.iushrn(1),e.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;e.isEven();)e.iushrn(1);var r=i.cmp(e);if(r<0){var h=i;i=e,e=h}else if(0===r||0===e.cmpn(1))break;i.isub(e)}return e.iushln(n)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,n=(t-i)/26,r=1<<i;if(this.length<=n)return this._expand(n+1),this.words[n]|=r,this;for(var h=r,s=n;0!==h&&s<this.length;s++){var o=0|this.words[s];h=(o+=h)>>>26,this.words[s]=o&=67108863}return 0!==h&&(this.words[s]=h,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var i,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)i=1;else{n&&(t=-t),e(t<=67108863,"Number is too big");var r=0|this.words[0];i=r===t?0:r<t?-1:1}return 0!==this.negative?0|-i:i},r.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},r.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,e=this.length-1;e>=0;e--){var n=0|this.words[e],r=0|t.words[e];if(n!==r){n<r?i=-1:n>r&&(i=1);break}}return i},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new b(t)},r.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},r.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},r.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},r.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},r.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},r.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},r.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var c={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new r(i,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=r._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,e=t;do{this.split(e,this.tmp),i=(e=(e=this.imulK(e)).iadd(this.tmp)).bitLength()}while(i>this.n);var n=i<this.n?-1:e.ucmp(this.p);return 0===n?(e.words[0]=0,e.length=1):n>0?e.isub(this.p):e.strip(),e},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,i){for(var e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var r=t.words[9];for(i.words[i.length++]=4194303&r,n=10;n<t.length;n++){var h=0|t.words[n];t.words[n-10]=(4194303&h)<<4|r>>>22,r=h}t.words[n-10]=r>>>=22,t.length-=0===r&&t.length>10?10:9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,e=0;e<t.length;e++){var n=0|t.words[e];t.words[e]=67108863&(i+=977*n),i=64*n+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(g,y),n(M,y),n(w,y),w.prototype.imulK=function(t){for(var i=0,e=0;e<t.length;e++){var n=19*(0|t.words[e])+i,r=67108863&n;n>>>=26,t.words[e]=r,i=n}return 0!==i&&(t.words[t.length++]=i),t},r._prime=function(t){if(c[t])return c[t];var i;if("k256"===t)i=new v;else if("p224"===t)i=new g;else if("p192"===t)i=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new w}return c[t]=i,i},b.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var e=t.add(i);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var e=t.iadd(i);return e.cmp(this.m)>=0&&e.isub(this.m),e},b.prototype.sub=function(t,i){this._verify2(t,i);var e=t.sub(i);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var e=t.isub(i);return e.cmpn(0)<0&&e.iadd(this.m),e},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var n=this.m.add(new r(1)).iushrn(2);return this.pow(t,n)}for(var h=this.m.subn(1),s=0;!h.isZero()&&0===h.andln(1);)s++,h.iushrn(1);e(!h.isZero());var o=new r(1).toRed(this),a=o.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new r(2*l*l).toRed(this);0!==this.pow(l,u).cmp(a);)l.redIAdd(a);for(var m=this.pow(l,h),d=this.pow(t,h.addn(1).iushrn(1)),f=this.pow(t,h),p=s;0!==f.cmp(o);){for(var c=f,y=0;0!==c.cmp(o);y++)c=c.redSqr();e(y<p);var v=this.pow(m,new r(1).iushln(p-y-1));d=d.redMul(v),m=v.redSqr(),f=f.redMul(m),p=y}return d},b.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},b.prototype.pow=function(t,i){if(i.isZero())return new r(1);if(0===i.cmpn(1))return t.clone();var e=new Array(16);e[0]=new r(1).toRed(this),e[1]=t;for(var n=2;n<e.length;n++)e[n]=this.mul(e[n-1],t);var h=e[0],s=0,o=0,a=i.bitLength()%26;for(0===a&&(a=26),n=i.length-1;n>=0;n--){for(var u=i.words[n],l=a-1;l>=0;l--){var m=u>>l&1;h!==e[0]&&(h=this.sqr(h)),0!==m||0!==s?(s<<=1,s|=m,(4==++o||0===n&&0===l)&&(h=this.mul(h,e[s]),o=0,s=0)):o=0}a=26}return h},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},r.mont=function(t){return new _(t)},n(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=e.isub(n).iushrn(this.shift),h=r;return r.cmp(this.m)>=0?h=r.isub(this.m):r.cmpn(0)<0&&(h=r.iadd(this.m)),h._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new r(0)._forceRed(this);var e=t.mul(i),n=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),h=e.isub(n).iushrn(this.shift),s=h;return h.cmp(this.m)>=0?s=h.isub(this.m):h.cmpn(0)<0&&(s=h.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,a)}(i={exports:{}}),i.exports}(),l=[{constant:!0,inputs:[{name:"",type:"address"}],name:"owners",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"},{name:"",type:"bytes32"},{name:"",type:"address"}],name:"delegates",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"nonce",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"changed",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"owner",type:"address"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDOwnerChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"delegateType",type:"bytes32"},{indexed:!1,name:"delegate",type:"address"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDDelegateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"identity",type:"address"},{indexed:!1,name:"name",type:"bytes32"},{indexed:!1,name:"value",type:"bytes"},{indexed:!1,name:"validTo",type:"uint256"},{indexed:!1,name:"previousChange",type:"uint256"}],name:"DIDAttributeChanged",type:"event"},{constant:!0,inputs:[{name:"identity",type:"address"}],name:"identityOwner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"validDelegate",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"newOwner",type:"address"}],name:"changeOwner",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"newOwner",type:"address"}],name:"changeOwnerSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"},{name:"validity",type:"uint256"}],name:"addDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegate",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"delegateType",type:"bytes32"},{name:"delegate",type:"address"}],name:"revokeDelegateSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"},{name:"validity",type:"uint256"}],name:"setAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttribute",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"identity",type:"address"},{name:"sigV",type:"uint8"},{name:"sigR",type:"bytes32"},{name:"sigS",type:"bytes32"},{name:"name",type:"bytes32"},{name:"value",type:"bytes"}],name:"revokeAttributeSigned",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],m=[{name:"ropsten",rpcUrl:"https://ropsten.infura.io/ethr-did",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"rinkeby",rpcUrl:"https://rinkeby.infura.io/ethr-did",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"kovan",rpcUrl:"https://kovan.infura.io/ethr-did",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"rsk",rpcUrl:"https://did.rsk.co:4444",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"},{name:"rsk:testnet",rpcUrl:"https://did.testnet.rsk.co:4444",registry:"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"}],d="0xdca7ef03e98e0dc2b855be647c39abe984fcf21b";function f(t){return r.Buffer.from(t.slice(2),"hex").toString("utf8").replace(/\0+$/,"")}function p(t){var i="0x"+r.Buffer.from(t).slice(0,32).toString("hex");return i+"0".repeat(66-i.length)}var c={Secp256k1SignatureAuthentication2018:p("sigAuth"),Secp256k1VerificationKey2018:p("veriKey")},y={sigAuth:"SignatureAuthentication2018",veriKey:"VerificationKey2018"};function v(t,i,e){for(var n=new u(Math.floor((new Date).getTime()/1e3)),h=[{id:t+"#owner",type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:i}],s=[{type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#owner"}],o=0,a={},l={},m={},d=0,p=e;d<p.length;d+=1){var c=p[d],v=c.validTo,g=c._eventName+"-"+(c.delegateType||c.name)+"-"+(c.delegate||c.value);if(v&&v.gte(n)){if("DIDDelegateChanged"===c._eventName)switch(o++,f(c.delegateType)){case"sigAuth":a[g]={type:"Secp256k1SignatureAuthentication2018",publicKey:t+"#delegate-"+o};case"veriKey":l[g]={id:t+"#delegate-"+o,type:"Secp256k1VerificationKey2018",owner:t,ethereumAddress:c.delegate}}else if("DIDAttributeChanged"===c._eventName){var M=f(c.name).match(/^did\/(pub|auth|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/);if(M){var w=M[2],b=y[M[4]]||M[4],_=M[6];switch(M[1]){case"pub":var k={id:t+"#delegate-"+ ++o,type:""+w+b,owner:t};switch(_){case null:case void 0:case"hex":k.publicKeyHex=c.value.slice(2);break;case"base64":k.publicKeyBase64=r.Buffer.from(c.value.slice(2),"hex").toString("base64");break;case"base58":k.publicKeyBase58=r.Buffer.from(c.value.slice(2),"hex").toString("base58");break;case"pem":k.publicKeyPem=r.Buffer.from(c.value.slice(2),"hex").toString();break;default:k.value=c.value}l[g]=k;break;case"svc":m[g]={type:w,serviceEndpoint:r.Buffer.from(c.value.slice(2),"hex").toString()}}}}}else o>0&&("DIDDelegateChanged"===c._eventName||"DIDAttributeChanged"===c._eventName&&f(c.name).match(/^did\/pub\//))&&v.lt(n)&&o--,delete a[g],delete l[g],delete m[g]}var S={"@context":"https://w3id.org/did/v1",id:t,publicKey:h.concat(Object.values(l)),authentication:s.concat(Object.values(a))};return Object.values(m).length>0&&(S.service=Object.values(m)),S}function g(e){void 0===e&&(e={});var r=function(i){return void 0===i&&(i={}),i.provider?i.provider:i.web3?i.web3.currentProvider:new t(i.rpcUrl||"https://mainnet.infura.io/ethr-did")}(e),h=new i(r),s=e.registry||d;return{eth:h,registryAddress:s,didReg:new n(h)(l).at(s)}}function M(t){void 0===t&&(t=[]);for(var i={},e=0;e<t.length;e++){var n=t[e];i[n.name]=g(n)}return i}module.exports={REGISTRY:d,bytes32toString:f,stringToBytes32:p,delegateTypes:c,attrTypes:y,wrapDidDocument:v,getResolver:function(t){void 0===t&&(t={});var i=e.logDecoder(l,!1),n=Object.assign({},{mainnet:g(t)},M(m),M(t.networks));return{ethr:function(t,e){try{var r=e.id.match(/^(.*)?(0x[0-9a-fA-F]{40})$/);if(!r)throw new Error("Not a valid ethr DID: "+t);var a=r[2],u=r[1]?r[1].slice(0,-1):"mainnet";if(!n[u])throw new Error("No conf for networkId: "+u);return Promise.resolve(function(t,e){try{var r=[],a=t;return Promise.resolve(function(t,i){try{return Promise.resolve(n[i].didReg.changed(t)).then(function(t){if(t)return t[0]})}catch(t){return Promise.reject(t)}}(t,e)).then(function(u){function l(){function l(){return{owner:a,history:r}}var m=function(t,i,e){for(var n;;){var r=t();if(o(r)&&(r=r.v),!r)return a;if(r.then){n=0;break}var a=e();if(a&&a.then){if(!o(a)){n=1;break}a=a.s}if(i){var u=i();if(u&&u.then&&!o(u)){n=2;break}}}var l=new h,m=s.bind(null,l,2);return(0===n?r.then(f):1===n?a.then(d):u.then(p)).then(void 0,m),l;function d(n){a=n;do{if(i&&(u=i())&&u.then&&!o(u))return void u.then(p).then(void 0,m);if(!(r=t())||o(r)&&!r.v)return void s(l,1,a);if(r.then)return void r.then(f).then(void 0,m);o(a=e())&&(a=a.v)}while(!a||!a.then);a.then(d).then(void 0,m)}function f(t){t?(a=e())&&a.then?a.then(d).then(void 0,m):d(a):s(l,1,a)}function p(){(r=t())?r.then?r.then(f).then(void 0,m):f(r):s(l,1,a)}}(function(){return!!u},void 0,function(){var h=u;return Promise.resolve(n[e].eth.getLogs({address:n[e].registryAddress,topics:[null,"0x000000000000000000000000"+t.slice(2)],fromBlock:u,toBlock:u})).then(function(t){var e=i(t);u=void 0;for(var n=0,s=e;n<s.length;n+=1){var o=s[n];r.unshift(o),o.previousChange.lt(h)&&(u=o.previousChange)}})});return m&&m.then?m.then(l):l()}var m=function(){if(u)return Promise.resolve(n[e].didReg.identityOwner(t)).then(function(t){a=t[0]})}();return m&&m.then?m.then(l):l()})}catch(t){return Promise.reject(t)}}(a,u)).then(function(i){return v(t,i.owner,i.history)})}catch(t){return Promise.reject(t)}}}}}});
//# sourceMappingURL=ethr-did-resolver.umd.js.map
{
"name": "ethr-did-resolver",
"version": "1.0.1",
"version": "1.0.2",
"description": "Resolve DID documents around ethereum addresses",

@@ -24,4 +24,5 @@ "main": "dist/ethr-did-resolver.js",

"scripts": {
"build": "./node_modules/.bin/microbundle",
"test": "./node_modules/.bin/jest"
"build": "microbundle",
"test": "jest",
"prepublishOnly": "npm test && npm run build"
},

@@ -28,0 +29,0 @@ "jest": {

@@ -31,3 +31,3 @@ ---

The minimal DID document for a an ethereum address `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with no transactions to the registry looks like this:
The minimal DID document for a an ethereum address `0xb9c5714089478a327f09197987f16f9e5d936e8a` with no transactions to the registry looks like this:

@@ -34,0 +34,0 @@ ```js

@@ -8,2 +8,3 @@ import HttpProvider from 'ethjs-provider-http'

import { Buffer } from 'buffer'
import networksJson from './networks.json'
const REGISTRY = '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b'

@@ -179,3 +180,3 @@

function getResolver (conf = {}) {
function configureNetwork (conf = {}) {
const provider = configureProvider(conf)

@@ -186,6 +187,26 @@ const eth = new Eth(provider)

const didReg = DidReg.at(registryAddress)
return { eth, registryAddress, didReg }
}
function configureNetworks (networksConf = []) {
const networks = {}
for (let i = 0; i < networksConf.length; i++) {
const net = networksConf[i]
networks[net.name] = configureNetwork(net)
}
return networks
}
function getResolver (conf = {}) {
const logDecoder = abi.logDecoder(DidRegistryContract, false)
const lastChanged = async identity => {
const result = await didReg.changed(identity)
const networks = {
mainnet: configureNetwork(conf),
...configureNetworks(networksJson),
...configureNetworks(conf.networks)
}
const lastChanged = async (identity, networkId) => {
const result = await networks[networkId].didReg.changed(identity)
if (result) {

@@ -195,8 +216,8 @@ return result['0']

}
async function changeLog (identity) {
async function changeLog (identity, networkId) {
const history = []
let owner = identity
let previousChange = await lastChanged(identity)
let previousChange = await lastChanged(identity, networkId)
if (previousChange) {
const ownerRecord = await didReg.identityOwner(identity)
const ownerRecord = await networks[networkId].didReg.identityOwner(identity)
owner = ownerRecord['0']

@@ -206,4 +227,4 @@ }

const blockNumber = previousChange
const logs = await eth.getLogs({
address: registryAddress,
const logs = await networks[networkId].eth.getLogs({
address: networks[networkId].registryAddress,
topics: [null, `0x000000000000000000000000${identity.slice(2)}`],

@@ -225,8 +246,14 @@ fromBlock: previousChange,

async function resolve (did, parsed) {
if (!parsed.id.match(/^0x[0-9a-fA-F]{40}$/)) throw new Error(`Not a valid ethr DID: ${did}`)
const { owner, history } = await changeLog(parsed.id)
const fullId = parsed.id.match(/^(.*)?(0x[0-9a-fA-F]{40})$/)
if (!fullId) throw new Error(`Not a valid ethr DID: ${did}`)
const id = fullId[2]
const networkId = (!fullId[1]) ? 'mainnet' : fullId[1].slice(0, -1)
if (!networks[networkId]) throw new Error(`No conf for networkId: ${networkId}`)
const { owner, history } = await changeLog(id, networkId)
return wrapDidDocument(did, owner, history)
}
return { 'ethr': resolve }
return { ethr: resolve }
}

@@ -233,0 +260,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc