@mikeargento/bitgraph-player 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/fuse-check.test.d.ts +2 -0
- package/dist/__tests__/fuse-check.test.d.ts.map +1 -0
- package/dist/__tests__/fuse-check.test.js +152 -0
- package/dist/__tests__/fuse-check.test.js.map +1 -0
- package/dist/check.d.ts +53 -2
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +182 -6
- package/dist/check.js.map +1 -1
- package/dist/cli.js +0 -0
- package/dist/verdict.d.ts +1 -1
- package/dist/verdict.js +1 -1
- package/dist-web/verify.html +5 -5
- package/package.json +4 -4
- package/src/__tests__/fuse-check.test.ts +168 -0
- package/src/check.ts +232 -7
- package/src/verdict.ts +1 -1
package/dist-web/verify.html
CHANGED
|
@@ -136,7 +136,7 @@ h1.bg-page-title { font-size: clamp(26px, 6vw, 40px); font-weight: 600; letter-s
|
|
|
136
136
|
</div>
|
|
137
137
|
</main>
|
|
138
138
|
<script>
|
|
139
|
-
"use strict";(()=>{var Ba=Object.create;var Ir=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var Aa=Object.getOwnPropertyNames;var ka=Object.getPrototypeOf,Ia=Object.prototype.hasOwnProperty;var Ha=(t,e)=>()=>(t&&(e=t(t=0)),e);var Un=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Sa=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Aa(e))!Ia.call(t,r)&&r!==n&&Ir(t,r,{get:()=>e[r],enumerable:!(o=va(e,r))||o.enumerable});return t};var Ca=(t,e,n)=>(n=t!=null?Ba(ka(t)):{},Sa(e||!t||!t.__esModule?Ir(n,"default",{value:t,enumerable:!0}):n,t));var Cr=Un(Gt=>{"use strict";b();Gt.byteLength=$a;Gt.toByteArray=Pa;Gt.fromByteArray=Ma;var xe=[],pe=[],Ta=typeof Uint8Array<"u"?Uint8Array:Array,Fn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(et=0,Hr=Fn.length;et<Hr;++et)xe[et]=Fn[et],pe[Fn.charCodeAt(et)]=et;var et,Hr;pe[45]=62;pe[95]=63;function Sr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var o=n===e?0:4-n%4;return[n,o]}function $a(t){var e=Sr(t),n=e[0],o=e[1];return(n+o)*3/4-o}function Ra(t,e,n){return(e+n)*3/4-n}function Pa(t){var e,n=Sr(t),o=n[0],r=n[1],i=new Ta(Ra(t,o,r)),s=0,a=r>0?o-4:o,c;for(c=0;c<a;c+=4)e=pe[t.charCodeAt(c)]<<18|pe[t.charCodeAt(c+1)]<<12|pe[t.charCodeAt(c+2)]<<6|pe[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return r===2&&(e=pe[t.charCodeAt(c)]<<2|pe[t.charCodeAt(c+1)]>>4,i[s++]=e&255),r===1&&(e=pe[t.charCodeAt(c)]<<10|pe[t.charCodeAt(c+1)]<<4|pe[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function Da(t){return xe[t>>18&63]+xe[t>>12&63]+xe[t>>6&63]+xe[t&63]}function La(t,e,n){for(var o,r=[],i=e;i<n;i+=3)o=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),r.push(Da(o));return r.join("")}function Ma(t){for(var e,n=t.length,o=n%3,r=[],i=16383,s=0,a=n-o;s<a;s+=i)r.push(La(t,s,s+i>a?a:s+i));return o===1?(e=t[n-1],r.push(xe[e>>2]+xe[e<<4&63]+"==")):o===2&&(e=(t[n-2]<<8)+t[n-1],r.push(xe[e>>10]+xe[e>>4&63]+xe[e<<2&63]+"=")),r.join("")}});var Tr=Un(_n=>{b();_n.read=function(t,e,n,o,r){var i,s,a=r*8-o-1,c=(1<<a)-1,f=c>>1,d=-7,u=n?r-1:0,h=n?-1:1,l=t[e+u];for(u+=h,i=l&(1<<-d)-1,l>>=-d,d+=a;d>0;i=i*256+t[e+u],u+=h,d-=8);for(s=i&(1<<-d)-1,i>>=-d,d+=o;d>0;s=s*256+t[e+u],u+=h,d-=8);if(i===0)i=1-f;else{if(i===c)return s?NaN:(l?-1:1)*(1/0);s=s+Math.pow(2,o),i=i-f}return(l?-1:1)*s*Math.pow(2,i-o)};_n.write=function(t,e,n,o,r,i){var s,a,c,f=i*8-r-1,d=(1<<f)-1,u=d>>1,h=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,l=o?0:i-1,p=o?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=d):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*c-1)*Math.pow(2,r),s=s+u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[n+l]=a&255,l+=p,a/=256,r-=8);for(s=s<<r|a,f+=r;f>0;t[n+l]=s&255,l+=p,s/=256,f-=8);t[n+l-p]|=m*128}});var Gr=Un(lt=>{"use strict";b();var Kn=Cr(),ut=Tr(),$r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;lt.Buffer=g;lt.SlowBuffer=Ka;lt.INSPECT_MAX_BYTES=50;var Wt=2147483647;lt.kMaxLength=Wt;g.TYPED_ARRAY_SUPPORT=Na();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Na(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Te(t){if(t>Wt)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,g.prototype),e}function g(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return qn(t)}return Lr(t,e,n)}g.poolSize=8192;function Lr(t,e,n){if(typeof t=="string")return Ua(t,e);if(ArrayBuffer.isView(t))return Fa(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Ee(t,ArrayBuffer)||t&&Ee(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ee(t,SharedArrayBuffer)||t&&Ee(t.buffer,SharedArrayBuffer)))return Vn(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=t.valueOf&&t.valueOf();if(o!=null&&o!==t)return g.from(o,e,n);let r=_a(t);if(r)return r;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return g.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}g.from=function(t,e,n){return Lr(t,e,n)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function Mr(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Oa(t,e,n){return Mr(t),t<=0?Te(t):e!==void 0?typeof n=="string"?Te(t).fill(e,n):Te(t).fill(e):Te(t)}g.alloc=function(t,e,n){return Oa(t,e,n)};function qn(t){return Mr(t),Te(t<0?0:Gn(t)|0)}g.allocUnsafe=function(t){return qn(t)};g.allocUnsafeSlow=function(t){return qn(t)};function Ua(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=Nr(t,e)|0,o=Te(n),r=o.write(t,e);return r!==n&&(o=o.slice(0,r)),o}function jn(t){let e=t.length<0?0:Gn(t.length)|0,n=Te(e);for(let o=0;o<e;o+=1)n[o]=t[o]&255;return n}function Fa(t){if(Ee(t,Uint8Array)){let e=new Uint8Array(t);return Vn(e.buffer,e.byteOffset,e.byteLength)}return jn(t)}function Vn(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let o;return e===void 0&&n===void 0?o=new Uint8Array(t):n===void 0?o=new Uint8Array(t,e):o=new Uint8Array(t,e,n),Object.setPrototypeOf(o,g.prototype),o}function _a(t){if(g.isBuffer(t)){let e=Gn(t.length)|0,n=Te(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||Zn(t.length)?Te(0):jn(t);if(t.type==="Buffer"&&Array.isArray(t.data))return jn(t.data)}function Gn(t){if(t>=Wt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Wt.toString(16)+" bytes");return t|0}function Ka(t){return+t!=t&&(t=0),g.alloc(+t)}g.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==g.prototype};g.compare=function(e,n){if(Ee(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),Ee(n,Uint8Array)&&(n=g.from(n,n.offset,n.byteLength)),!g.isBuffer(e)||!g.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;let o=e.length,r=n.length;for(let i=0,s=Math.min(o,r);i<s;++i)if(e[i]!==n[i]){o=e[i],r=n[i];break}return o<r?-1:r<o?1:0};g.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return g.alloc(0);let o;if(n===void 0)for(n=0,o=0;o<e.length;++o)n+=e[o].length;let r=g.allocUnsafe(n),i=0;for(o=0;o<e.length;++o){let s=e[o];if(Ee(s,Uint8Array))i+s.length>r.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(r,i)):Uint8Array.prototype.set.call(r,s,i);else if(g.isBuffer(s))s.copy(r,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return r};function Nr(t,e){if(g.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ee(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let n=t.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return zn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return qr(t).length;default:if(r)return o?-1:zn(t).length;e=(""+e).toLowerCase(),r=!0}}g.byteLength=Nr;function ja(t,e,n){let o=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Qa(this,e,n);case"utf8":case"utf-8":return Ur(this,e,n);case"ascii":return Xa(this,e,n);case"latin1":case"binary":return Ja(this,e,n);case"base64":return Za(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ec(this,e,n);default:if(o)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}g.prototype._isBuffer=!0;function tt(t,e,n){let o=t[e];t[e]=t[n],t[n]=o}g.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<e;n+=2)tt(this,n,n+1);return this};g.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<e;n+=4)tt(this,n,n+3),tt(this,n+1,n+2);return this};g.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<e;n+=8)tt(this,n,n+7),tt(this,n+1,n+6),tt(this,n+2,n+5),tt(this,n+3,n+4);return this};g.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ur(this,0,e):ja.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(e){if(!g.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:g.compare(this,e)===0};g.prototype.inspect=function(){let e="",n=lt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};$r&&(g.prototype[$r]=g.prototype.inspect);g.prototype.compare=function(e,n,o,r,i){if(Ee(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(n===void 0&&(n=0),o===void 0&&(o=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),n<0||o>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&n>=o)return 0;if(r>=i)return-1;if(n>=o)return 1;if(n>>>=0,o>>>=0,r>>>=0,i>>>=0,this===e)return 0;let s=i-r,a=o-n,c=Math.min(s,a),f=this.slice(r,i),d=e.slice(n,o);for(let u=0;u<c;++u)if(f[u]!==d[u]){s=f[u],a=d[u];break}return s<a?-1:a<s?1:0};function Or(t,e,n,o,r){if(t.length===0)return-1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Zn(n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0)if(r)n=0;else return-1;if(typeof e=="string"&&(e=g.from(e,o)),g.isBuffer(e))return e.length===0?-1:Rr(t,e,n,o,r);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):Rr(t,[e],n,o,r);throw new TypeError("val must be string, number or Buffer")}function Rr(t,e,n,o,r){let i=1,s=t.length,a=e.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,n/=2}function c(d,u){return i===1?d[u]:d.readUInt16BE(u*i)}let f;if(r){let d=-1;for(f=n;f<s;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*i}else d!==-1&&(f-=f-d),d=-1}else for(n+a>s&&(n=s-a),f=n;f>=0;f--){let d=!0;for(let u=0;u<a;u++)if(c(t,f+u)!==c(e,u)){d=!1;break}if(d)return f}return-1}g.prototype.includes=function(e,n,o){return this.indexOf(e,n,o)!==-1};g.prototype.indexOf=function(e,n,o){return Or(this,e,n,o,!0)};g.prototype.lastIndexOf=function(e,n,o){return Or(this,e,n,o,!1)};function Va(t,e,n,o){n=Number(n)||0;let r=t.length-n;o?(o=Number(o),o>r&&(o=r)):o=r;let i=e.length;o>i/2&&(o=i/2);let s;for(s=0;s<o;++s){let a=parseInt(e.substr(s*2,2),16);if(Zn(a))return s;t[n+s]=a}return s}function za(t,e,n,o){return Zt(zn(e,t.length-n),t,n,o)}function qa(t,e,n,o){return Zt(rc(e),t,n,o)}function Ga(t,e,n,o){return Zt(qr(e),t,n,o)}function Wa(t,e,n,o){return Zt(ic(e,t.length-n),t,n,o)}g.prototype.write=function(e,n,o,r){if(n===void 0)r="utf8",o=this.length,n=0;else if(o===void 0&&typeof n=="string")r=n,o=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(o)?(o=o>>>0,r===void 0&&(r="utf8")):(r=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-n;if((o===void 0||o>i)&&(o=i),e.length>0&&(o<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let s=!1;for(;;)switch(r){case"hex":return Va(this,e,n,o);case"utf8":case"utf-8":return za(this,e,n,o);case"ascii":case"latin1":case"binary":return qa(this,e,n,o);case"base64":return Ga(this,e,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wa(this,e,n,o);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Za(t,e,n){return e===0&&n===t.length?Kn.fromByteArray(t):Kn.fromByteArray(t.slice(e,n))}function Ur(t,e,n){n=Math.min(t.length,n);let o=[],r=e;for(;r<n;){let i=t[r],s=null,a=i>239?4:i>223?3:i>191?2:1;if(r+a<=n){let c,f,d,u;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[r+1],(c&192)===128&&(u=(i&31)<<6|c&63,u>127&&(s=u));break;case 3:c=t[r+1],f=t[r+2],(c&192)===128&&(f&192)===128&&(u=(i&15)<<12|(c&63)<<6|f&63,u>2047&&(u<55296||u>57343)&&(s=u));break;case 4:c=t[r+1],f=t[r+2],d=t[r+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(u=(i&15)<<18|(c&63)<<12|(f&63)<<6|d&63,u>65535&&u<1114112&&(s=u))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,o.push(s>>>10&1023|55296),s=56320|s&1023),o.push(s),r+=a}return Ya(o)}var Pr=4096;function Ya(t){let e=t.length;if(e<=Pr)return String.fromCharCode.apply(String,t);let n="",o=0;for(;o<e;)n+=String.fromCharCode.apply(String,t.slice(o,o+=Pr));return n}function Xa(t,e,n){let o="";n=Math.min(t.length,n);for(let r=e;r<n;++r)o+=String.fromCharCode(t[r]&127);return o}function Ja(t,e,n){let o="";n=Math.min(t.length,n);for(let r=e;r<n;++r)o+=String.fromCharCode(t[r]);return o}function Qa(t,e,n){let o=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>o)&&(n=o);let r="";for(let i=e;i<n;++i)r+=sc[t[i]];return r}function ec(t,e,n){let o=t.slice(e,n),r="";for(let i=0;i<o.length-1;i+=2)r+=String.fromCharCode(o[i]+o[i+1]*256);return r}g.prototype.slice=function(e,n){let o=this.length;e=~~e,n=n===void 0?o:~~n,e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),n<0?(n+=o,n<0&&(n=0)):n>o&&(n=o),n<e&&(n=e);let r=this.subarray(e,n);return Object.setPrototypeOf(r,g.prototype),r};function J(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=this[e],i=1,s=0;for(;++s<n&&(i*=256);)r+=this[e+s]*i;return r};g.prototype.readUintBE=g.prototype.readUIntBE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=this[e+--n],i=1;for(;n>0&&(i*=256);)r+=this[e+--n]*i;return r};g.prototype.readUint8=g.prototype.readUInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]|this[e+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]<<8|this[e+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};g.prototype.readBigUInt64LE=Ke(function(e){e=e>>>0,ht(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Ct(e,this.length-8);let r=n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+o*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))});g.prototype.readBigUInt64BE=Ke(function(e){e=e>>>0,ht(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Ct(e,this.length-8);let r=n*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o;return(BigInt(r)<<BigInt(32))+BigInt(i)});g.prototype.readIntLE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=this[e],i=1,s=0;for(;++s<n&&(i*=256);)r+=this[e+s]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*n)),r};g.prototype.readIntBE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=n,i=1,s=this[e+--r];for(;r>0&&(i*=256);)s+=this[e+--r]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s};g.prototype.readInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};g.prototype.readInt16LE=function(e,n){e=e>>>0,n||J(e,2,this.length);let o=this[e]|this[e+1]<<8;return o&32768?o|4294901760:o};g.prototype.readInt16BE=function(e,n){e=e>>>0,n||J(e,2,this.length);let o=this[e+1]|this[e]<<8;return o&32768?o|4294901760:o};g.prototype.readInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};g.prototype.readInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};g.prototype.readBigInt64LE=Ke(function(e){e=e>>>0,ht(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Ct(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(o<<24);return(BigInt(r)<<BigInt(32))+BigInt(n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});g.prototype.readBigInt64BE=Ke(function(e){e=e>>>0,ht(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Ct(e,this.length-8);let r=(n<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o)});g.prototype.readFloatLE=function(e,n){return e=e>>>0,n||J(e,4,this.length),ut.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,n){return e=e>>>0,n||J(e,4,this.length),ut.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||J(e,8,this.length),ut.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||J(e,8,this.length),ut.read(this,e,!1,52,8)};function ae(t,e,n,o,r,i){if(!g.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<i)throw new RangeError('"value" argument is out of bounds');if(n+o>t.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(e,n,o,r){if(e=+e,n=n>>>0,o=o>>>0,!r){let a=Math.pow(2,8*o)-1;ae(this,e,n,o,a,0)}let i=1,s=0;for(this[n]=e&255;++s<o&&(i*=256);)this[n+s]=e/i&255;return n+o};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(e,n,o,r){if(e=+e,n=n>>>0,o=o>>>0,!r){let a=Math.pow(2,8*o)-1;ae(this,e,n,o,a,0)}let i=o-1,s=1;for(this[n+i]=e&255;--i>=0&&(s*=256);)this[n+i]=e/s&255;return n+o};g.prototype.writeUint8=g.prototype.writeUInt8=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,1,255,0),this[n]=e&255,n+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=e&255,n+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};function Fr(t,e,n,o,r){zr(e,o,r,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,n}function _r(t,e,n,o,r){zr(e,o,r,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i=i>>8,t[n+6]=i,i=i>>8,t[n+5]=i,i=i>>8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s=s>>8,t[n+2]=s,s=s>>8,t[n+1]=s,s=s>>8,t[n]=s,n+8}g.prototype.writeBigUInt64LE=Ke(function(e,n=0){return Fr(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=Ke(function(e,n=0){return _r(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(e,n,o,r){if(e=+e,n=n>>>0,!r){let c=Math.pow(2,8*o-1);ae(this,e,n,o,c-1,-c)}let i=0,s=1,a=0;for(this[n]=e&255;++i<o&&(s*=256);)e<0&&a===0&&this[n+i-1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+o};g.prototype.writeIntBE=function(e,n,o,r){if(e=+e,n=n>>>0,!r){let c=Math.pow(2,8*o-1);ae(this,e,n,o,c-1,-c)}let i=o-1,s=1,a=0;for(this[n+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[n+i+1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+o};g.prototype.writeInt8=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};g.prototype.writeInt16LE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeInt16BE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeInt32LE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,4,2147483647,-2147483648),this[n]=e&255,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4};g.prototype.writeInt32BE=function(e,n,o){return e=+e,n=n>>>0,o||ae(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};g.prototype.writeBigInt64LE=Ke(function(e,n=0){return Fr(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=Ke(function(e,n=0){return _r(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Kr(t,e,n,o,r,i){if(n+o>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function jr(t,e,n,o,r){return e=+e,n=n>>>0,r||Kr(t,e,n,4,34028234663852886e22,-34028234663852886e22),ut.write(t,e,n,o,23,4),n+4}g.prototype.writeFloatLE=function(e,n,o){return jr(this,e,n,!0,o)};g.prototype.writeFloatBE=function(e,n,o){return jr(this,e,n,!1,o)};function Vr(t,e,n,o,r){return e=+e,n=n>>>0,r||Kr(t,e,n,8,17976931348623157e292,-17976931348623157e292),ut.write(t,e,n,o,52,8),n+8}g.prototype.writeDoubleLE=function(e,n,o){return Vr(this,e,n,!0,o)};g.prototype.writeDoubleBE=function(e,n,o){return Vr(this,e,n,!1,o)};g.prototype.copy=function(e,n,o,r){if(!g.isBuffer(e))throw new TypeError("argument should be a Buffer");if(o||(o=0),!r&&r!==0&&(r=this.length),n>=e.length&&(n=e.length),n||(n=0),r>0&&r<o&&(r=o),r===o||e.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-n<r-o&&(r=e.length-n+o);let i=r-o;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,o,r):Uint8Array.prototype.set.call(e,this.subarray(o,r),n),i};g.prototype.fill=function(e,n,o,r){if(typeof e=="string"){if(typeof n=="string"?(r=n,n=0,o=this.length):typeof o=="string"&&(r=o,o=this.length),r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!g.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(e.length===1){let s=e.charCodeAt(0);(r==="utf8"&&s<128||r==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(n<0||this.length<n||this.length<o)throw new RangeError("Out of range index");if(o<=n)return this;n=n>>>0,o=o===void 0?this.length:o>>>0,e||(e=0);let i;if(typeof e=="number")for(i=n;i<o;++i)this[i]=e;else{let s=g.isBuffer(e)?e:g.from(e,r),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<o-n;++i)this[i+n]=s[i%a]}return this};var dt={};function Wn(t,e,n){dt[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(r){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:r,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Wn("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Wn("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Wn("ERR_OUT_OF_RANGE",function(t,e,n){let o=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=Dr(String(n)):typeof n=="bigint"&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=Dr(r)),r+="n"),o+=` It must be ${e}. Received ${r}`,o},RangeError);function Dr(t){let e="",n=t.length,o=t[0]==="-"?1:0;for(;n>=o+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function tc(t,e,n){ht(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&Ct(e,t.length-(n+1))}function zr(t,e,n,o,r,i){if(t>n||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${n}${s}`,new dt.ERR_OUT_OF_RANGE("value",a,t)}tc(o,r,i)}function ht(t,e){if(typeof t!="number")throw new dt.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ct(t,e,n){throw Math.floor(t)!==t?(ht(t,n),new dt.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new dt.ERR_BUFFER_OUT_OF_BOUNDS:new dt.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var nc=/[^+/0-9A-Za-z-_]/g;function oc(t){if(t=t.split("=")[0],t=t.trim().replace(nc,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function zn(t,e){e=e||1/0;let n,o=t.length,r=null,i=[];for(let s=0;s<o;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===o){(e-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),r=n;continue}n=(r-55296<<10|n-56320)+65536}else r&&(e-=3)>-1&&i.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function rc(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function ic(t,e){let n,o,r,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),o=n>>8,r=n%256,i.push(r),i.push(o);return i}function qr(t){return Kn.toByteArray(oc(t))}function Zt(t,e,n,o){let r;for(r=0;r<o&&!(r+n>=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function Ee(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Zn(t){return t!==t}var sc=(function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let o=n*16;for(let r=0;r<16;++r)e[o+r]=t[n]+t[r]}return e})();function Ke(t){return typeof BigInt>"u"?ac:t}function ac(){throw new Error("BigInt not supported")}});var B,b=Ha(()=>{"use strict";B=Ca(Gr(),1);globalThis.Buffer=B.Buffer});b();b();var cc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ne,n:Yt,Gx:Wr,Gy:Zr,a:Yn,d:Xn}=cc,fc=8n,Tt=32,Jn=64,me=(t="")=>{throw new Error(t)},dc=t=>typeof t=="bigint",ti=t=>typeof t=="string",uc=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",mt=(t,e)=>!uc(t)||typeof e=="number"&&e>0&&t.length!==e?me("Uint8Array expected"):t,en=t=>new Uint8Array(t),no=t=>Uint8Array.from(t),ni=(t,e)=>t.toString(16).padStart(e,"0"),oo=t=>Array.from(mt(t)).map(e=>ni(e,2)).join(""),$e={_0:48,_9:57,A:65,F:70,a:97,f:102},Yr=t=>{if(t>=$e._0&&t<=$e._9)return t-$e._0;if(t>=$e.A&&t<=$e.F)return t-($e.A-10);if(t>=$e.a&&t<=$e.f)return t-($e.a-10)},ro=t=>{let e="hex invalid";if(!ti(t))return me(e);let n=t.length,o=n/2;if(n%2)return me(e);let r=en(o);for(let i=0,s=0;i<o;i++,s+=2){let a=Yr(t.charCodeAt(s)),c=Yr(t.charCodeAt(s+1));if(a===void 0||c===void 0)return me(e);r[i]=a*16+c}return r},Xt=(t,e)=>mt(ti(t)?ro(t):no(mt(t)),e),oi=()=>globalThis?.crypto,hc=()=>oi()?.subtle??me("crypto.subtle must be defined"),Qn=(...t)=>{let e=en(t.reduce((o,r)=>o+mt(r).length,0)),n=0;return t.forEach(o=>{e.set(o,n),n+=o.length}),e},lc=(t=Tt)=>oi().getRandomValues(en(t)),Jt=BigInt,nt=(t,e,n,o="bad number: out of range")=>dc(t)&&e<=t&&t<n?t:me(o),k=(t,e=ne)=>{let n=t%e;return n>=0n?n:e+n},pc=t=>k(t,Yt),ri=(t,e)=>{(t===0n||e<=0n)&&me("no inverse n="+t+" mod="+e);let n=k(t,e),o=e,r=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=o/n,f=o%n,d=r-s*c,u=i-a*c;o=n,n=f,r=s,i=a,s=d,a=u}return o===1n?k(r,e):me("no inverse")};var Xr=t=>t instanceof Re?t:me("Point expected"),eo=2n**256n,Re=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,o,r){let i=eo;this.ex=nt(e,0n,i),this.ey=nt(n,0n,i),this.ez=nt(o,1n,i),this.et=nt(r,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,k(e.x*e.y))}static fromBytes(e,n=!1){let o=Xn,r=no(mt(e,Tt)),i=e[31];r[31]=i&-129;let s=io(r);nt(s,0n,n?eo:ne);let c=k(s*s),f=k(c-1n),d=k(o*c+1n),{isValid:u,value:h}=bc(f,d);u||me("bad point: y not sqrt");let l=(h&1n)===1n,p=(i&128)!==0;return!n&&h===0n&&p&&me("bad point: x==0, isLastByteOdd"),p!==l&&(h=k(-h)),new t(h,s,1n,k(h*s))}assertValidity(){let e=Yn,n=Xn,o=this;if(o.is0())throw new Error("bad point: ZERO");let{ex:r,ey:i,ez:s,et:a}=o,c=k(r*r),f=k(i*i),d=k(s*s),u=k(d*d),h=k(c*e),l=k(d*k(h+f)),p=k(u+k(n*k(c*f)));if(l!==p)throw new Error("bad point: equation left != right (1)");let m=k(r*i),x=k(s*a);if(m!==x)throw new Error("bad point: equation left != right (2)");return this}equals(e){let{ex:n,ey:o,ez:r}=this,{ex:i,ey:s,ez:a}=Xr(e),c=k(n*a),f=k(i*r),d=k(o*a),u=k(s*r);return c===f&&d===u}is0(){return this.equals(pt)}negate(){return new t(k(-this.ex),this.ey,this.ez,k(-this.et))}double(){let{ex:e,ey:n,ez:o}=this,r=Yn,i=k(e*e),s=k(n*n),a=k(2n*k(o*o)),c=k(r*i),f=e+n,d=k(k(f*f)-i-s),u=c+s,h=u-a,l=c-s,p=k(d*h),m=k(u*l),x=k(d*l),y=k(h*u);return new t(p,m,y,x)}add(e){let{ex:n,ey:o,ez:r,et:i}=this,{ex:s,ey:a,ez:c,et:f}=Xr(e),d=Yn,u=Xn,h=k(n*s),l=k(o*a),p=k(i*u*f),m=k(r*c),x=k((n+o)*(s+a)-h-l),y=k(m-p),T=k(m+p),C=k(l-d*h),_=k(x*y),G=k(T*C),$=k(x*C),O=k(y*T);return new t(_,G,O,$)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return pt;if(nt(e,1n,Yt),e===1n)return this;if(this.equals(gt))return Ac(e).p;let o=pt,r=gt;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?o=o.add(i):n&&(r=r.add(i));return o}toAffine(){let{ex:e,ey:n,ez:o}=this;if(this.equals(pt))return{x:0n,y:1n};let r=ri(o,ne);return k(o*r)!==1n&&me("invalid inverse"),{x:k(e*r),y:k(n*r)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),o=mc(n);return o[31]|=e&1n?128:0,o}toHex(){return oo(this.toBytes())}clearCofactor(){return this.multiply(Jt(fc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(Yt/2n,!1).double();return Yt%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(Xt(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},gt=new Re(Wr,Zr,1n,k(Wr*Zr)),pt=new Re(0n,1n,1n,0n);Re.BASE=gt;Re.ZERO=pt;var mc=t=>ro(ni(nt(t,0n,eo),Jn)).reverse(),io=t=>Jt("0x"+oo(no(mt(t)).reverse())),Be=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=ne;return n},gc=t=>{let n=t*t%ne*t%ne,o=Be(n,2n)*n%ne,r=Be(o,1n)*t%ne,i=Be(r,5n)*r%ne,s=Be(i,10n)*i%ne,a=Be(s,20n)*s%ne,c=Be(a,40n)*a%ne,f=Be(c,80n)*c%ne,d=Be(f,80n)*c%ne,u=Be(d,10n)*i%ne;return{pow_p_5_8:Be(u,2n)*t%ne,b2:n}},Jr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,bc=(t,e)=>{let n=k(e*e*e),o=k(n*n*e),r=gc(t*o).pow_p_5_8,i=k(t*n*r),s=k(e*i*i),a=i,c=k(i*Jr),f=s===t,d=s===k(-t),u=s===k(-t*Jr);return f&&(i=a),(d||u)&&(i=c),(k(i)&1n)===1n&&(i=k(-i)),{isValid:f||d,value:i}},yc=t=>pc(io(t)),wc=(...t)=>tn.sha512Async(...t);var xc=t=>wc(t.hashable).then(t.finish);var ii={zip215:!0},Ec=(t,e,n,o=ii)=>{t=Xt(t,Jn),e=Xt(e),n=Xt(n,Tt);let{zip215:r}=o,i,s,a,c,f=Uint8Array.of();try{i=Re.fromHex(n,r),s=Re.fromHex(t.slice(0,Tt),r),a=io(t.slice(Tt,Jn)),c=gt.multiply(a,!1),f=Qn(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:u=>{if(c==null||!r&&i.isSmallOrder())return!1;let h=yc(u);return s.add(i.multiply(h,!1)).add(c.negate()).clearCofactor().is0()}}},so=async(t,e,n,o=ii)=>xc(Ec(t,e,n,o));var tn={sha512Async:async(...t)=>{let e=hc(),n=Qn(...t);return en(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:oo,hexToBytes:ro,concatBytes:Qn,mod:k,invert:ri,randomBytes:lc};var Qt=8,Bc=256,si=Math.ceil(Bc/Qt)+1,to=2**(Qt-1),vc=()=>{let t=[],e=gt,n=e;for(let o=0;o<si;o++){n=e,t.push(n);for(let r=1;r<to;r++)n=n.add(e),t.push(n);e=n.double()}return t},Qr,ei=(t,e)=>{let n=e.negate();return t?n:e},Ac=t=>{let e=Qr||(Qr=vc()),n=pt,o=gt,r=2**Qt,i=r,s=Jt(r-1),a=Jt(Qt);for(let c=0;c<si;c++){let f=Number(t&s);t>>=a,f>to&&(f-=i,t+=1n);let d=c*to,u=d,h=d+Math.abs(f)-1,l=c%2!==0,p=f<0;f===0?o=o.add(ei(l,e[u])):n=n.add(ei(p,e[h]))}return{p:n,f:o}};b();b();b();function Ic(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ao(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ot(t,...e){if(!Ic(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function yt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function nn(t,e){ot(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function ai(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function ve(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function on(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ge(t,e){return t<<32-e|t>>>e}var Hc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Sc(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Cc(t){for(let e=0;e<t.length;e++)t[e]=Sc(t[e]);return t}var co=Hc?t=>t:Cc;function Tc(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function $t(t){return typeof t=="string"&&(t=Tc(t)),ot(t),t}var bt=class{};function Rt(t){let e=o=>t().update($t(o)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function $c(t,e,n,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,o);let r=BigInt(32),i=BigInt(4294967295),s=Number(n>>r&i),a=Number(n&i),c=o?4:0,f=o?0:4;t.setUint32(e+c,s,o),t.setUint32(e+f,a,o)}function ci(t,e,n){return t&e^~t&n}function fi(t,e,n){return t&e^t&n^e&n}var Pt=class extends bt{constructor(e,n,o,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(e),this.view=on(this.buffer)}update(e){yt(this),e=$t(e),ot(e);let{view:n,buffer:o,blockLen:r}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(r-this.pos,i-s);if(a===r){let c=on(e);for(;r<=i-s;s+=r)this.process(c,s);continue}o.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){yt(this),nn(e,this),this.finished=!0;let{buffer:n,view:o,blockLen:r,isLE:i}=this,{pos:s}=this;n[s++]=128,ve(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(o,0),s=0);for(let u=s;u<r;u++)n[u]=0;$c(o,r-8,BigInt(this.length*8),i),this.process(o,0);let a=on(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,d[u],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let o=e.slice(0,n);return this.destroy(),o}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:o,length:r,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=r,e.pos=a,r%n&&e.buffer.set(o),e}clone(){return this._cloneInto()}},Pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);b();var rn=BigInt(4294967295),di=BigInt(32);function Rc(t,e=!1){return e?{h:Number(t&rn),l:Number(t>>di&rn)}:{h:Number(t>>di&rn)|0,l:Number(t&rn)|0}}function sn(t,e=!1){let n=t.length,o=new Uint32Array(n),r=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=Rc(t[i],e);[o[i],r[i]]=[s,a]}return[o,r]}var fo=(t,e,n)=>t>>>n,uo=(t,e,n)=>t<<32-n|e>>>n,rt=(t,e,n)=>t>>>n|e<<32-n,it=(t,e,n)=>t<<32-n|e>>>n,Dt=(t,e,n)=>t<<64-n|e>>>n-32,Lt=(t,e,n)=>t>>>n-32|e<<64-n;var ui=(t,e,n)=>t<<n|e>>>32-n,hi=(t,e,n)=>e<<n|t>>>32-n,li=(t,e,n)=>e<<n-32|t>>>64-n,pi=(t,e,n)=>t<<n-32|e>>>64-n;function Ae(t,e,n,o){let r=(e>>>0)+(o>>>0);return{h:t+n+(r/2**32|0)|0,l:r|0}}var mi=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),gi=(t,e,n,o)=>e+n+o+(t/2**32|0)|0,bi=(t,e,n,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),yi=(t,e,n,o,r)=>e+n+o+r+(t/2**32|0)|0,wi=(t,e,n,o,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0)+(r>>>0),xi=(t,e,n,o,r,i)=>e+n+o+r+i+(t/2**32|0)|0;var Dc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),je=new Uint32Array(64),an=class extends Pt{constructor(e=32){super(64,e,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){let{A:e,B:n,C:o,D:r,E:i,F:s,G:a,H:c}=this;return[e,n,o,r,i,s,a,c]}set(e,n,o,r,i,s,a,c){this.A=e|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)je[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){let h=je[u-15],l=je[u-2],p=ge(h,7)^ge(h,18)^h>>>3,m=ge(l,17)^ge(l,19)^l>>>10;je[u]=m+je[u-7]+p+je[u-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:f,H:d}=this;for(let u=0;u<64;u++){let h=ge(a,6)^ge(a,11)^ge(a,25),l=d+h+ci(a,c,f)+Dc[u]+je[u]|0,m=(ge(o,2)^ge(o,13)^ge(o,22))+fi(o,r,i)|0;d=f,f=c,c=a,a=s+l|0,s=i,i=r,r=o,o=l+m|0}o=o+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(o,r,i,s,a,c,f,d)}roundClean(){ve(je)}destroy(){this.set(0,0,0,0,0,0,0,0),ve(this.buffer)}};var Ei=sn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Lc=Ei[0],Mc=Ei[1],Ve=new Uint32Array(80),ze=new Uint32Array(80),ho=class extends Pt{constructor(e=64){super(128,e,16,!1),this.Ah=Q[0]|0,this.Al=Q[1]|0,this.Bh=Q[2]|0,this.Bl=Q[3]|0,this.Ch=Q[4]|0,this.Cl=Q[5]|0,this.Dh=Q[6]|0,this.Dl=Q[7]|0,this.Eh=Q[8]|0,this.El=Q[9]|0,this.Fh=Q[10]|0,this.Fl=Q[11]|0,this.Gh=Q[12]|0,this.Gl=Q[13]|0,this.Hh=Q[14]|0,this.Hl=Q[15]|0}get(){let{Ah:e,Al:n,Bh:o,Bl:r,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:d,Fh:u,Fl:h,Gh:l,Gl:p,Hh:m,Hl:x}=this;return[e,n,o,r,i,s,a,c,f,d,u,h,l,p,m,x]}set(e,n,o,r,i,s,a,c,f,d,u,h,l,p,m,x){this.Ah=e|0,this.Al=n|0,this.Bh=o|0,this.Bl=r|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=u|0,this.Fl=h|0,this.Gh=l|0,this.Gl=p|0,this.Hh=m|0,this.Hl=x|0}process(e,n){for(let C=0;C<16;C++,n+=4)Ve[C]=e.getUint32(n),ze[C]=e.getUint32(n+=4);for(let C=16;C<80;C++){let _=Ve[C-15]|0,G=ze[C-15]|0,$=rt(_,G,1)^rt(_,G,8)^fo(_,G,7),O=it(_,G,1)^it(_,G,8)^uo(_,G,7),U=Ve[C-2]|0,Z=ze[C-2]|0,V=rt(U,Z,19)^Dt(U,Z,61)^fo(U,Z,6),le=it(U,Z,19)^Lt(U,Z,61)^uo(U,Z,6),L=bi(O,le,ze[C-7],ze[C-16]),ie=yi(L,$,V,Ve[C-7],Ve[C-16]);Ve[C]=ie|0,ze[C]=L|0}let{Ah:o,Al:r,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:d,Eh:u,El:h,Fh:l,Fl:p,Gh:m,Gl:x,Hh:y,Hl:T}=this;for(let C=0;C<80;C++){let _=rt(u,h,14)^rt(u,h,18)^Dt(u,h,41),G=it(u,h,14)^it(u,h,18)^Lt(u,h,41),$=u&l^~u&m,O=h&p^~h&x,U=wi(T,G,O,Mc[C],ze[C]),Z=xi(U,y,_,$,Lc[C],Ve[C]),V=U|0,le=rt(o,r,28)^Dt(o,r,34)^Dt(o,r,39),L=it(o,r,28)^Lt(o,r,34)^Lt(o,r,39),ie=o&i^o&a^i&a,oe=r&s^r&c^s&c;y=m|0,T=x|0,m=l|0,x=p|0,l=u|0,p=h|0,{h:u,l:h}=Ae(f|0,d|0,Z|0,V|0),f=a|0,d=c|0,a=i|0,c=s|0,i=o|0,s=r|0;let N=mi(V,L,oe);o=gi(N,Z,le,ie),r=N|0}({h:o,l:r}=Ae(this.Ah|0,this.Al|0,o|0,r|0)),{h:i,l:s}=Ae(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Ae(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=Ae(this.Dh|0,this.Dl|0,f|0,d|0),{h:u,l:h}=Ae(this.Eh|0,this.El|0,u|0,h|0),{h:l,l:p}=Ae(this.Fh|0,this.Fl|0,l|0,p|0),{h:m,l:x}=Ae(this.Gh|0,this.Gl|0,m|0,x|0),{h:y,l:T}=Ae(this.Hh|0,this.Hl|0,y|0,T|0),this.set(o,r,i,s,a,c,f,d,u,h,l,p,m,x,y,T)}roundClean(){ve(Ve,ze)}destroy(){ve(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Bi=Rt(()=>new an);var cn=Rt(()=>new ho);b();b();b();function ce(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var vi=ce("fs.createReadStream"),ch=ce("fs.readFileSync"),fh=ce("fs.existsSync"),dh=ce("fs.writeFileSync"),Nc=ce("fs.open"),Oc=ce("fs.readdir"),Ai=ce("fs.readFile"),Uc=ce("fs.stat"),uh=ce("fs.mkdir"),hh=ce("fs.writeFile"),ki=ce("path.join"),lh=ce("path.basename"),Ii=ce("zlib.createGunzip"),Fc=ce("zlib.gzipSync");b();var q=Bi;b();b();b();b();b();b();b();var _c=t=>t/2**32|0,Kc=t=>t>>>0;function Hi(t,e,n,o){let r=_c(n),i=Kc(n);t.setUint32(e,o?i:r,o),t.setUint32(e+4,o?r:i,o)}b();function fn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var lo=t=>t?`"${t}" `:"";function De(t,e=""){if(typeof t!="number")throw new TypeError(lo(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(lo(e)+"expected integer >= 0, got "+t);return t}function ke(t,e,n=""){if(fn(t)&&(e===void 0||t.length===e))return t;e!==void 0&&De(e,"length");let o=fn(t),r=e!==void 0?` of length ${e}`:"",i=o?`length=${t.length}`:`type=${typeof t}`,s=lo(n)+"expected Uint8Array"+r+", got "+i;throw o?new RangeError(s):new TypeError(s)}function dn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(De(t.outputLen),De(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Si=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function wt(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function un(t,e){ke(t,void 0,"output");let n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function Mt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function hn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function be(t,e){return t<<32-e|t>>>e}var Ti=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",jc=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ln(t){if(ke(t),Ti)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=jc[t[n]];return e}function Ci(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function po(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Ti)try{return Uint8Array.fromHex(t)}catch(r){throw r instanceof SyntaxError?new RangeError(r.message):r}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let o=new Uint8Array(n);for(let r=0,i=0;r<n;r++,i+=2){let s=Ci(t.charCodeAt(i)),a=Ci(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[r]=s*16+a}return o}function $i(...t){let e=0;for(let o=0;o<t.length;o++){let r=t[o];ke(r),e+=r.length}let n=new Uint8Array(e);for(let o=0,r=0;o<t.length;o++){let i=t[o];n.set(i,r),r+=i.length}return n}function Vc(t,e,n="opts"){return Si(t,"defaults"),e!==void 0&&Si(e,n),Object.assign(t,e)}function Ri(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=Vc({},e,"info");let n=(r,i)=>t(i).update(r).digest(),o=t(void 0);return n.outputLen=o.outputLen,n.blockLen=o.blockLen,n.canXOF=o.canXOF,n.create=r=>t(r),Object.assign(n,e),Object.freeze(n)}function Pi(t=32){De(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var Di=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Li(t,e,n){return t&e^~t&n}function Mi(t,e,n){return t&e^t&n^e&n}var pn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,o,r){this.blockLen=e,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(e),this.view=hn(this.buffer)}update(e){wt(this),ke(e);let{view:n,buffer:o,blockLen:r}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(r-this.pos,i-a);if(c===r){let f=hn(e);for(;r<=i-a;a+=r)this.process(f,a);s=!0;continue}o.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===r&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){wt(this),un(e,this),this.finished=!0;let{buffer:n,view:o,blockLen:r,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>r-s&&(this.process(o,0),n.fill(0)),Hi(o,r-8,this.length*8,i),this.process(o,0),this.roundClean();let a=e===n?o:hn(e),c=this.outputLen,f=c/4,d=this.get();if(c%4||f>d.length)throw new Error("invalid outputLen");for(let u=0;u<f;u++)a.setUint32(4*u,d[u],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let o=e.slice(0,n);return this.destroy(),o}_cloneIntoMeta(e){let{buffer:n,length:o,finished:r,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=r,e.length=o,e.pos=s,s&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Ni=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var zc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),qe=new Uint32Array(64),mo=class extends pn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,n){super(64,e,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:e,B:n,C:o,D:r,E:i,F:s,G:a,H:c}=this;return[e,n,o,r,i,s,a,c]}set(e,n,o,r,i,s,a,c){this.A=e|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let u=0;u<16;u++,n+=4)qe[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){let h=qe[u-15],l=qe[u-2],p=be(h,7)^be(h,18)^h>>>3,m=be(l,17)^be(l,19)^l>>>10;qe[u]=m+qe[u-7]+p+qe[u-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:f,H:d}=this;for(let u=0;u<64;u++){let h=be(a,6)^be(a,11)^be(a,25),l=d+h+Li(a,c,f)+zc[u]+qe[u]|0,m=(be(o,2)^be(o,13)^be(o,22))+Mi(o,r,i)|0;d=f,f=c,c=a,a=s+l|0,s=i,i=r,r=o,o=l+m|0}o=o+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(o,r,i,s,a,c,f,d)}roundClean(){Mt(qe)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Mt(this.buffer)}},go=class extends mo{constructor(){super(32,Ni)}};var Oi=Ri(()=>new go,Di(1));b();function gn(t,e,n=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let o=0;o<t.length;o++)n(t[o],`${e}[${o}]`);return t}var X=(t,e,n)=>ke(t,e,n),bo=De;function Fi(t,e=""){if(typeof t!="string"){let n=e&&`"${e}" `;throw new TypeError(n+"expected string, got type="+typeof t)}return t}function Ge(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function st(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var yo=ln,Le=(...t)=>$i(...t),bn=t=>po(t),xt=fn,yn=t=>Pi(t),mn=BigInt(0),Ui=BigInt(1),qc=t=>t?`"${t}" `:"";function Ie(t,e=""){if(typeof t!="boolean")throw new TypeError(qc(e)+"expected boolean, got type="+typeof t);return t}function wn(t){if(typeof t=="bigint"){if(!We(t))throw new RangeError("positive bigint expected, got "+t)}else bo(t);return t}function Et(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(n+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let n=e&&`"${e}" `;throw new RangeError(n+"expected safe integer, got "+t)}}function Nt(t){let e=wn(t).toString(16);return e.length&1?"0"+e:e}function _i(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?mn:BigInt("0x"+t)}function He(t){return _i(ln(t))}function wo(t){return _i(ln(Gc(ke(t)).reverse()))}function xn(t,e){if(De(e),e===0)throw new Error("zero output length is invalid");t=wn(t);let n=e*2,o=t.toString(16);if(o.length>n)throw new RangeError("number is too large");return po(o.padStart(n,"0"))}function xo(t,e){return xn(t,e).reverse()}function Gc(t){return Uint8Array.from(X(t))}function We(t){return typeof t=="bigint"&&mn<=t}function Eo(t,e,n){return We(t)&&We(e)&&We(n)&&e<=t&&t<n}function Bo(t,e,n,o){if(!Eo(e,n,o))throw new RangeError("expected valid "+t+": "+n+" <= n < "+o+", got "+e)}function Bt(t){if(t<mn)throw new Error("expected non-negative bigint, got "+t);return t===mn?0:t.toString(2).length}var Ot=t=>(Et(t,"n"),(Ui<<BigInt(t))-Ui);function Ki(t,e,n){if(De(t,"hashLen"),De(e,"qByteLen"),typeof n!="function")throw new TypeError("hmacFn must be a function");let o=x=>new Uint8Array(x),r=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=o(t),f=o(t),d=0,u=()=>{c.fill(1),f.fill(0),d=0},h=(...x)=>n(f,Le(c,...x)),l=(x=r)=>{f=h(i,x),c=h(),x.length!==0&&(f=h(s,x),c=h())},p=()=>{if(d++>=a)throw new Error("drbg: tried max amount of iterations");let x=0,y=[];for(;x<e;){c=h();let T=c.slice();y.push(T),x+=c.length}return Le(...y)};return(x,y)=>{u(),l(x);let T;for(;(T=y(p()))===void 0;)l();return u(),T}}function Ze(t,e={},n={},o="object"){Ge(t,o),Ge(e,"fields"),Ge(n,"optFields");function r(s,a,c){let f=o==="object"?`param "${String(s)}"`:`"${o}.${String(s)}"`,d=t[s];if(!Object.hasOwn(t,s)&&(c?d!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&d===void 0)return;let u=typeof d;if(u!==a||d===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${u}`)}let i=(s,a)=>Object.entries(s).forEach(([c,f])=>r(c,f,a));i(e,!1),i(n,!0)}b();b();var ee=BigInt(0),j=BigInt(1),Ye=BigInt(2),qi=BigInt(3),vo=BigInt(4),Gi=BigInt(5),Wc=BigInt(7),Wi=BigInt(8),Zc=BigInt(9),Yc=BigInt(15),Zi=BigInt(16),Xc=BigInt("0x10000000000000000");function ue(t,e){if(e<=ee)throw new Error("mod: expected positive modulus, got "+e);let n=t%e;return n>=ee?n:e+n}function Yi(t,e,n){if(n<=j)throw new Error("pow: expected modulus > 1, got "+n);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<ee)throw new Error("invalid exponent, negatives unsupported");if(e===ee)return j;if(e===j)return t;let o=t%n;if(o<ee&&(o+=n),e<Xc){let a=j;for(;e>ee;)e&j&&(a=a*o%n),o=o*o%n,e>>=j;return a}let r=[];for(;e>ee;)r.push(Number(e&Yc)),e>>=vo;let i=new Array(16);i[0]=j,i[1]=o;for(let a=2;a<16;a++)i[a]=i[a-1]*o%n;let s=i[r[r.length-1]];for(let a=r.length-2;a>=0;a--){s=s*s%n,s=s*s%n,s=s*s%n,s=s*s%n;let c=r[a];c!==0&&(s=s*i[c]%n)}return s}function ji(t,e){if(t===ee)throw new Error("invert: expected non-zero number");if(e<=j)throw new Error("invert: expected modulus > 1, got "+e);let n=ue(t,e),o=e,r=ee,i=j;for(;n!==ee;){let a=o/n,c=o-n*a,f=r-i*a;o=n,n=c,r=i,i=f}if(o!==j)throw new Error("invert: does not exist");return ue(r,e)}function Xi(t,e){if(e<=j)throw new Error("invertCt: expected prime modulus > 1, got "+e);let n=ue(t,e);if(n===ee)throw new Error("invertCt: expected non-zero number");let o=Yi(n,e-Ye,e);if(ue(n*o,e)!==j)throw new Error("invertCt: does not exist");return o}function Ao(t,e,n){let o=t;if(!o.eql(o.sqr(e),n))throw new Error("Cannot find square root")}function ko(t,e){if((t&j)===ee)throw new Error(e+": expected odd modulus, got "+t)}function Ji(t,e){let n=t,o=(n.ORDER+j)/vo,r=n.pow(e,o);return Ao(n,r,e),r}function Jc(t,e){let n=t,o=(n.ORDER-Gi)/Wi,r=n.mul(e,Ye),i=n.pow(r,o),s=n.mul(e,i),a=n.mul(n.mul(s,Ye),i),c=n.mul(s,n.sub(a,n.ONE));return Ao(n,c,e),c}function Qc(t){let e=Bn(t),n=Qi(t),o=n(e,e.neg(e.ONE)),r=n(e,o),i=n(e,e.neg(o)),s=(t+Wc)/Zi;return((a,c)=>{let f=a,d=f.pow(c,s),u=f.mul(d,o),h=f.mul(d,r),l=f.mul(d,i),p=f.eql(f.sqr(u),c),m=f.eql(f.sqr(h),c);d=f.cmov(d,u,p),u=f.cmov(l,h,m);let x=f.eql(f.sqr(u),c),y=f.cmov(d,u,x);return Ao(f,y,c),y})}function Qi(t){if(t<qi)throw new Error("sqrt is not defined for small field");ko(t,"tonelliShanks");let e=t-j,n=0;for(;e%Ye===ee;)e/=Ye,n++;let o=Ye,r=Bn(t);for(;Vi(r,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Ji;let i=r.pow(o,e),s=(e+j)/Ye;return function(c,f){let d=c;if(d.is0(f))return f;if(Vi(d,f)!==1)throw new Error("Cannot find square root");let u=n,h=d.mul(d.ONE,i),l=d.pow(f,e),p=d.pow(f,s);for(;!d.eql(l,d.ONE);){if(d.is0(l))throw new Error("Cannot find square root: probably non-prime P");let m=1,x=d.sqr(l);for(;!d.eql(x,d.ONE);)if(m++,x=d.sqr(x),m===u)throw new Error("Cannot find square root");let y=j<<BigInt(u-m-1),T=d.pow(h,y);u=m,h=d.sqr(T),l=d.mul(l,h),p=d.mul(p,T)}return p}}function ef(t){return ko(t,"Fp.sqrt"),t%vo===qi?Ji:t%Wi===Gi?Jc:t%Zi===Zc?Qc(t):Qi(t)}var tf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vt(t){if(Ge(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);Et(t.BYTES,"BYTES"),Et(t.BITS,"BITS");for(let e of tf)st(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=j)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Io(t,e,n=!1){vt(t),gn(e,"nums"),Ie(n,"passZero");let o=t,r=new Array(e.length).fill(n?o.ZERO:void 0),i=e.reduce((a,c,f)=>o.is0(c)?a:(r[f]=a,o.mul(a,c)),o.ONE),s=o.inv(i);return e.reduceRight((a,c,f)=>o.is0(c)?a:(r[f]=o.mul(a,r[f]),o.mul(a,c)),s),r}function Vi(t,e){vt(t);let n=t;ko(n.ORDER,"FpLegendre");let o=(n.ORDER-j)/Ye,r=n.pow(e,o),i=n.eql(r,n.ONE),s=n.eql(r,n.ZERO),a=n.eql(r,n.neg(n.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function nf(t,e){if(e!==void 0&&bo(e),t<=ee)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let n=Bt(t);if(e!==void 0&&e<n)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${n})`);let o=e!==void 0?e:n,r=Math.ceil(o/8);return{nBitLength:o,nByteLength:r}}var zi=new WeakMap,En=class{ORDER;BITS;BYTES;isLE;ZERO=ee;ONE=j;_lengths;_mod;constructor(e,n={}){if(e<=j)throw new Error("invalid field: expected ORDER > 1, got "+e);let o;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(o=n.BITS),typeof n.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:n.sqrt,enumerable:!0}),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=Object.freeze(n.allowedLengths.slice())),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));let{nBitLength:r,nByteLength:i}=nf(e,o);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return ue(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ee<=e&&e<this.ORDER}is0(e){return e===ee}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&j)===j}neg(e){return ue(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return ue(e*e,this.ORDER)}add(e,n){return ue(e+n,this.ORDER)}sub(e,n){return ue(e-n,this.ORDER)}mul(e,n){return ue(e*n,this.ORDER)}pow(e,n){return Yi(e,n,this.ORDER)}div(e,n){return ue(e*ji(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return ji(e,this.ORDER)}sqrt(e){let n=zi.get(this);return n||zi.set(this,n=ef(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?xo(e,this.BYTES):xn(e,this.BYTES)}fromBytes(e,n=!1){X(e);let{_lengths:o,BYTES:r,isLE:i,ORDER:s,_mod:a}=this;if(o){if(e.length<1||!o.includes(e.length)||e.length>r)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let f=new Uint8Array(r);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=i?wo(e):He(e);if(a&&(c=ue(c,s)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Io(this,e,!0)}cmov(e,n,o){return Ie(o,"condition"),o?n:e}};function Bn(t,e={}){return Object.freeze(En.prototype),new En(t,e)}function es(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=j)throw new Error("field order must be greater than 1");let e=Bt(t-j);return Math.ceil(e/8)}function vn(t){let e=es(t);return e+Math.ceil(e/2)}function Ho(t,e,n=!1){X(t);let o=t.length,r=es(e),i=Math.max(vn(e),16);if(o<i||o>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+o);let s=n?wo(t):He(t),a=ue(s,e-j)+j;return n?xo(a,r):xn(a,r)}var To=BigInt(0),Ut=BigInt(1),of=BigInt(4),So=16,ts=128,rf=5,ns=2**31;function At(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);st(e.fromAffine,"Point.fromAffine"),st(e.fromBytes,"Point.fromBytes"),st(e.fromHex,"Point.fromHex"),Ge(e.BASE,"Point.BASE"),Ge(e.ZERO,"Point.ZERO"),vt(e.Fp),vt(e.Fn)}function rs(t,e){At(t),is(e,t);let n=Io(t.Fp,e.map(o=>o.Z));return e.map((o,r)=>t.fromAffine(o.toAffine(n[r])))}function sf(t,e,n=1){if(!Number.isSafeInteger(t)||t<n||t>e)throw new Error("invalid window size, expected ["+n+".."+e+"], got W="+t)}function af(t,e){let n=t*(4*e+128);if(n>ns)throw new Error("invalid window size: table would need ~"+Math.ceil(n/2**20)+" MiB, max "+ns/2**20+" MiB")}function $o(t,e){if(t!==void 0){st(t,"randomBytes");try{let n=t(e);if(!xt(n)||n.length!==e)return}catch{return}return t}}function is(t,e){gn(t,"points"),t.forEach((n,o)=>{if(!(n instanceof e))throw new Error("invalid point at index "+o)})}function cf(t,e,n){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((o,r)=>{if(!(n===void 0?e.isValid(o):We(o)&&o<n))throw new Error("invalid scalar at index "+r)})}var ss=new WeakMap;function Co(t){return ss.get(t)||1}function ff(t,e){let n=t.double(),o=[t];for(let r=1;r<e;r++)o.push(o[r-1].add(n));return o}function df(t,e){let n=2**e,o=n/2,r=BigInt(n-1),i=[];for(;t>To;){let s=0;t&Ut&&(s=Number(t&r),s>=o&&(s-=n),t-=BigInt(s)),i.push(s),t>>=Ut}return i}function uf(t,e,n){let o=2**e,r=o/2,i=BigInt(o-1),s=BigInt(e),a=[];for(let c=0;c<n;c++){let f=Number(t&i);t>>=s,f>r&&(f-=o,t+=Ut),a.push(f)}if(t!==To)throw new Error("invalid wnaf");return a}function hf(t,e,n){let o=0;for(let i of n)o=Math.max(o,i.length);let r=t;for(let i=o-1;i>=0;i--){i!==o-1&&(r=r.double());for(let s=0;s<n.length;s++){let a=n[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];r=r.add(a<0?c.negate():c)}}}return r}var An=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){At(e),this.randomBytes=$o(n,So),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,n,o){let r=Math.ceil(o/n)+1,i=2**(n-1),s=[],a=e;for(let c=0;c<r;c++){let f=a;for(let d=0;d<i;d++)s.push(f),f=f.add(a);a=s[s.length-1].double()}return{W:n,bits:o,windows:r,comp:s}}wnafCachedCT(e,n){let{W:o,windows:r,comp:i}=e,s=2**(o-1),a=uf(n,o,r),c=this.ZERO,f=this.BASE;for(let d=0;d<r;d++){let u=a[d],h=d*s,l=Math.abs(u)-1,p=i[h];for(let x=1;x<s;x++)p=x===l?i[h+x]:p;let m=p.negate();u===0?f=f.add(i[h]):c=c.add(u<0?m:p)}return{p:c,f}}getWnafPrecomputes(e,n,o,r){let i=this.wnafPrecomputes.get(n),s=i?.find(a=>a.W===e&&a.bits===o);return s||(s=this.buildWnafTable(n,e,o),typeof r=="function"&&(s={...s,comp:r(s.comp)}),i||(i=[],this.wnafPrecomputes.set(n,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,n){if(this.assertPoint(e),!Eo(n,Ut,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,o,r){let i=Co(e);return i===1?this.fixedWindowCT(e,n,o):this.wnafCachedCT(this.getWnafPrecomputes(i,e,o,r),n)}mulCT(e,n,o){return this.validateMulInput(e,n),this.runCT(e,n,this.bits,o)}mulCTBlinded(e,n,o){if(this.validateMulInput(e,n),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let r=this.Point.Fn.BITS+ts,i=this.randomBytes(So);if(!xt(i)||i.length!==So)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=n+He(i)*this.Point.Fn.ORDER;return this.runCT(e,s,r,o)}fixedWindowCT(e,n,o){let r=rf,i=1<<r,s=Ot(r),a=new Array(i);a[0]=this.ZERO;for(let d=1;d<i;d++)a[d]=a[d-1].add(e);let c=Math.ceil(o/r),f=this.ZERO;for(let d=c-1;d>=0;d--){if(d!==c-1)for(let l=0;l<r;l++)f=f.double();let u=Number(n>>BigInt(d*r)&s),h=a[0];for(let l=1;l<i;l++)h=l===u?a[l]:h;f=f.add(h)}return{p:f,f}}shouldBlind(e,n){return this.randomBytes===void 0?!1:n===Ut?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,n,o,r){return this.shouldBlind(e,o)?this.mulCTBlinded(e,n,r):this.mulCT(e,n,r)}mulUnsafe(e,n,o){if(this.assertPoint(e),!We(n))throw new Error("invalid scalar");let r=Co(e);if(r===1||n>=this.Point.Fn.ORDER)return kn(this.Point,[e],[n],!0);let i=this.getWnafPrecomputes(r,e,this.bits,o);return this.wnafCachedCT(i,n).p}setWindowSize(e,n){this.assertPoint(e),sf(n,this.bits);let o=Math.ceil((this.bits+ts)/n)+1;af(o*2**(n-1),this.Point.Fp.BYTES),ss.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Co(e)!==1}};function kn(t,e,n,o=!1){if(At(t),is(e,t),Ie(o,"allowOversized"),cf(n,t.Fn,o?t.Fn.ORDER**of:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let r=e.map(s=>ff(s,4)),i=n.map(s=>df(s,4));return hf(t.ZERO,r,i)}function os(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return vt(e),e}else return Bn(t,{isLE:n})}function as(t,e,n={},o){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(o===void 0&&(o=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);Ze(n);for(let c of["p","n","h"]){let f=e[c];if(!(We(f)&&f!==To))throw new Error(`CURVE.${c} must be positive bigint`)}let r=os(e.p,n.Fp,o),i=os(e.n,n.Fn,o),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!r.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:r,Fn:i}}function cs(t,e){return function(o){let r=t(o);return{secretKey:r,publicKey:e(r)}}}b();b();var In=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(dn(e),ke(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,r=new Uint8Array(o);r.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<r.length;i++)r[i]^=54;this.iHash.update(r),this.oHash=e.create();for(let i=0;i<r.length;i++)r[i]^=106;this.oHash.update(r),Mt(r)}update(e){return wt(this),this.iHash.update(e),this}digestInto(e){wt(this),un(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:n,iHash:o,finished:r,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=n._cloneInto(e.oHash),e.iHash=o._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},fs=(()=>{let t=((e,n,o)=>new In(e,n).update(o).digest());return t.create=(e,n)=>new In(e,n),t})();b();var lf=BigInt(0),Ro=class extends Error{constructor(e=""){super(e)}},Me={Err:Ro,_tlv:{encode:(t,e)=>{let{Err:n}=Me;if(Et(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(Fi(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let o=e.length/2,r=Nt(o);if(r.length/2&128)throw new n("tlv.encode: long form length too big");let i=o>127?Nt(r.length/2|128):"";return Nt(t)+i+r+e},decode(t,e){let{Err:n}=Me;e=X(e,void 0,"DER data");let o=0;if(t<0||t>255)throw new n("tlv.decode: wrong tag");if(e.length<2||e[o++]!==t)throw new n("tlv.decode: wrong tlv");let r=e[o++],i=!!(r&128),s=0;if(!i)s=r;else{let c=r&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");let f=e.subarray(o,o+c);if(f.length!==c)throw new n("tlv.decode: length bytes not complete");if(f[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(let d of f)s=s<<8|d;if(o+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}let a=e.subarray(o,o+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(o+s)}}},_int:{encode(t){let{Err:e}=Me;if(wn(t),t<lf)throw new e("integer: negative integers are not allowed");let n=Nt(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){let{Err:e}=Me;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return He(t)}},toSig(t){let{Err:e,_int:n,_tlv:o}=Me,r=X(t,void 0,"signature"),{v:i,l:s}=o.decode(48,r);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:f,l:d}=o.decode(2,c);if(d.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(f)}},hexFromSig(t){let{_tlv:e,_int:n}=Me;Ze(t,{r:"bigint",s:"bigint"},{},"sig");let o=e.encode(2,n.encode(t.r)),r=e.encode(2,n.encode(t.s)),i=o+r;return e.encode(48,i)}},Po=(Object.freeze(Me._tlv),Object.freeze(Me._int),Object.freeze(Me));var ds=(t,e)=>(t+(t>=0?e:-e)/us)/e;function pf(t,e,n){Bo("scalar",t,Ne,n);let[[o,r],[i,s]]=e,a=ds(s*t,n),c=ds(-r*t,n),f=t-a*o-c*i,d=-a*r-c*s,u=f<Ne,h=d<Ne;u&&(f=-f),h&&(d=-d);let l=Ot(Math.ceil(Bt(n)/2))+at;if(f<Ne||f>=l||d<Ne||d>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:u,k1:f,k2neg:h,k2:d}}function Mo(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Do(t,e){Ze(t);let n={};for(let o of Object.keys(e))n[o]=t[o]===void 0?e[o]:t[o];return Ie(n.lowS,"lowS"),Ie(n.prehash,"prehash"),n.format!==void 0&&Mo(n.format),n}var Ne=BigInt(0),at=BigInt(1),us=BigInt(2),Lo=BigInt(3),mf=BigInt(4);function hs(t,e={}){let n=as("weierstrass",t,e),o=n.Fp,r=n.Fn,i=n.CURVE,{h:s,n:a}=i;Ze(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=e,d=e.randomBytes===void 0?yn:e.randomBytes;if(c&&(!o.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=ps(o,r);function h(){if(!o.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(N,E,v){if(f&&E.is0())return Uint8Array.of(0);let{x:H,y:D}=E.toAffine(),A=o.toBytes(H);if(Ie(v,"isCompressed"),v){h();let w=!o.isOdd(D);return Le(ls(w),A)}else return Le(Uint8Array.of(4),A,o.toBytes(D))}function p(N){X(N,void 0,"Point");let{publicKey:E,publicKeyUncompressed:v}=u,H=N.length,D=N[0],A=N.subarray(1);if(f&&H===1&&D===0)return{x:o.ZERO,y:o.ZERO};if(H===E&&(D===2||D===3)){let w=o.fromBytes(A);if(!o.isValid(w))throw new Error("bad point: is not on curve, wrong x");let I=C(w),S;try{S=o.sqrt(I)}catch(K){let F=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+F)}h();let M=o.isOdd(S);return(D&1)===1!==M&&(S=o.neg(S)),{x:w,y:S}}else if(H===v&&D===4){let w=o.BYTES,I=o.fromBytes(A.subarray(0,w)),S=o.fromBytes(A.subarray(w,w*2));if(!_(I,S))throw new Error("bad point: is not on curve");return{x:I,y:S}}else throw new Error(`bad point: got length ${H}, expected compressed=${E} or uncompressed=${v}`)}let m=e.toBytes===void 0?l:e.toBytes,x=e.fromBytes===void 0?p:e.fromBytes,y=o.mul(i.b,Lo),T=o.is0(i.a)?N=>o.ZERO:N=>o.mul(i.a,N);function C(N){let E=o.sqr(N),v=o.mul(E,N);return o.add(o.add(v,o.mul(N,i.a)),i.b)}function _(N,E){let v=o.sqr(E),H=C(N);return o.eql(v,H)}if(!_(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let G=o.mul(o.pow(i.a,Lo),mf),$=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(G,$)))throw new Error("bad curve params: a or b");function O(N,E,v=!1){if(!o.isValid(E)||v&&o.is0(E))throw new Error(`bad point coordinate ${N}`);return E}function U(N){if(!(N instanceof L))throw new Error("Weierstrass Point expected")}function Z(N){if(!c||!c.basises)throw new Error("no endo");return pf(N,c.basises,r.ORDER)}function V(N,E,v,H){if(!r.isValid(H))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:D,k1:A,k2neg:w,k2:I}=Z(H),S=new L(o.mul(v.X,c.beta),v.Y,v.Z);N.push(D?v.negate():v,w?S.negate():S),E.push(A,I)}else N.push(v),E.push(H)}let le=new WeakSet;class L{static BASE=new L(i.Gx,i.Gy,o.ONE);static ZERO=new L(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=r;X;Y;Z;constructor(E,v,H){this.X=O("x",E),this.Y=O("y",v,!0),this.Z=O("z",H),Object.freeze(this)}static CURVE(){return i}static fromAffine(E){let{x:v,y:H}=E||{};if(!E||!o.isValid(v)||!o.isValid(H))throw new Error("invalid affine point");if(E instanceof L)throw new Error("projective point not allowed");return o.is0(v)&&o.is0(H)?L.ZERO:new L(v,H,o.ONE)}static fromBytes(E){let v=L.fromAffine(x(X(E,void 0,"point")));return v.assertValidity(),v}static fromHex(E){return L.fromBytes(bn(E))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=6,v=!0){return oe.setWindowSize(this,E),v||this.multiply(Lo),this}assertValidity(){let E=this;if(E.is0()){if(e.allowInfinityPoint&&o.is0(E.X)&&o.eql(E.Y,o.ONE)&&o.is0(E.Z))return;throw new Error("bad point: ZERO")}if(le.has(E))return;let{x:v,y:H}=E.toAffine();if(!o.isValid(v)||!o.isValid(H))throw new Error("bad point: x or y not field elements");if(!_(v,H))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");le.add(E)}hasEvenY(){let{y:E}=this.toAffine();if(!o.isOdd)throw new Error("Field doesn't support isOdd");return!o.isOdd(E)}equals(E){U(E);let{X:v,Y:H,Z:D}=this,{X:A,Y:w,Z:I}=E,S=o.eql(o.mul(v,I),o.mul(A,D)),M=o.eql(o.mul(H,I),o.mul(w,D));return S&&M}negate(){return new L(this.X,o.neg(this.Y),this.Z)}double(){let{X:E,Y:v,Z:H}=this,D=o.ZERO,A=o.ZERO,w=o.ZERO,I=o.mul(E,E),S=o.mul(v,v),M=o.mul(H,H),R=o.mul(E,v);return R=o.add(R,R),w=o.mul(E,H),w=o.add(w,w),D=T(w),A=o.mul(y,M),A=o.add(D,A),D=o.sub(S,A),A=o.add(S,A),A=o.mul(D,A),D=o.mul(R,D),w=o.mul(y,w),M=T(M),R=o.sub(I,M),R=T(R),R=o.add(R,w),w=o.add(I,I),I=o.add(w,I),I=o.add(I,M),I=o.mul(I,R),A=o.add(A,I),M=o.mul(v,H),M=o.add(M,M),I=o.mul(M,R),D=o.sub(D,I),w=o.mul(M,S),w=o.add(w,w),w=o.add(w,w),new L(D,A,w)}add(E){U(E);let{X:v,Y:H,Z:D}=this,{X:A,Y:w,Z:I}=E,S=o.ZERO,M=o.ZERO,R=o.ZERO,K=o.mul(v,A),F=o.mul(H,w),W=o.mul(D,I),se=o.add(v,H),z=o.add(A,w);se=o.mul(se,z),z=o.add(K,F),se=o.sub(se,z),z=o.add(v,D);let te=o.add(A,I);return z=o.mul(z,te),te=o.add(K,W),z=o.sub(z,te),te=o.add(H,D),S=o.add(w,I),te=o.mul(te,S),S=o.add(F,W),te=o.sub(te,S),R=T(z),S=o.mul(y,W),R=o.add(S,R),S=o.sub(F,R),R=o.add(F,R),M=o.mul(S,R),F=o.add(K,K),F=o.add(F,K),W=T(W),z=o.mul(y,z),F=o.add(F,W),W=o.sub(K,W),W=T(W),z=o.add(z,W),K=o.mul(F,z),M=o.add(M,K),K=o.mul(te,z),S=o.mul(se,S),S=o.sub(S,K),K=o.mul(se,F),R=o.mul(te,R),R=o.add(R,K),new L(S,M,R)}subtract(E){return U(E),this.add(E.negate())}is0(){return this.equals(L.ZERO)}multiply(E){if(!r.isValidNot0(E))throw new RangeError("invalid scalar: out of range");let{p:v,f:H}=oe.mulSecret(this,E,s,ie);return ie([v,H])[0]}multiplyUnsafe(E){let v=this,H=E;if(!r.isValid(H))throw new RangeError("invalid scalar: out of range");if(H===Ne||v.is0())return L.ZERO;if(H===at)return v;if(oe.hasWindowSize(this))return oe.mulUnsafe(v,H,ie);let D=[],A=[];return V(D,A,v,H),kn(L,D,A)}mulAddUnsafe(E,v,H){U(v);let D=[],A=[];return V(D,A,this,E),V(D,A,v,H),kn(L,D,A)}toAffine(E){let v=this,H=E;if(H!=null&&!o.isValid(H))throw new RangeError('"invertedZ" expected valid field element');let{X:D,Y:A,Z:w}=v;if(o.eql(w,o.ONE))return{x:D,y:A};let I=v.is0();H==null&&(H=I?o.ONE:o.inv(w));let S=o.mul(D,H),M=o.mul(A,H),R=o.mul(w,H);if(I)return{x:o.ZERO,y:o.ZERO};if(!o.eql(R,o.ONE))throw new Error("invZ was invalid");return{x:S,y:M}}isTorsionFree(){let{isTorsionFree:E}=e;return s===at?!0:E?E(L,this):oe.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:E}=e;return s===at?this:E?E(L,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===at?this.is0():this.clearCofactor().is0()}toBytes(E=!0){return Ie(E,"isCompressed"),this.assertValidity(),m(L,this,E)}toHex(E=!0){return yo(this.toBytes(E))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ie=N=>rs(L,N),oe=new An(L,d);return oe.bits>=6&&L.BASE.precompute(6),Object.freeze(L.prototype),Object.freeze(L),L}function ls(t){return Uint8Array.of(t?2:3)}function ps(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function gf(t,e={}){At(t);let{Fn:n}=t,o=e.randomBytes===void 0?yn:e.randomBytes,r=Object.assign(ps(t.Fp,n),{seed:Math.max(vn(n.ORDER),16)});function i(l){try{let p=n.fromBytes(l);return n.isValidNot0(p)}catch{return!1}}function s(l,p){let{publicKey:m,publicKeyUncompressed:x}=r;try{let y=l.length;return p===!0&&y!==m||p===!1&&y!==x?!1:!!t.fromBytes(l)}catch{return!1}}function a(l){return l=l===void 0?o(r.seed):l,Ho(X(l,r.seed,"seed"),n.ORDER)}function c(l,p=!0){return t.BASE.multiply(n.fromBytes(l)).toBytes(p)}function f(l){let{secretKey:p,publicKey:m,publicKeyUncompressed:x}=r,y=n._lengths;if(!xt(l))return;let T=X(l,void 0,"key").length,C=T===m||T===x,_=T===p||!!y?.includes(T);if(!(C&&_))return C}function d(l,p,m=!0){if(f(l)===!0)throw new Error("first arg must be private key");if(f(p)===!1)throw new Error("second arg must be public key");let x=n.fromBytes(l);return t.fromBytes(p).multiply(x).toBytes(m)}let u={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=cs(a,c);return Object.freeze(u),Object.freeze(r),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:h,Point:t,utils:u,lengths:r})}function ms(t,e,n={}){At(t);let o=e;dn(o),Ze(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let r=Object.assign({},n),i=r.randomBytes===void 0?yn:r.randomBytes,s=r.hmac===void 0?(A,w)=>fs(o,A,w):r.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:d}=c,u=vn(f),h=$o(i,u),{keygen:l,getPublicKey:p,getSharedSecret:m,utils:x,lengths:y}=gf(t,r),T={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},C=f*us+at<a.ORDER;function _(A){let w=f>>at;return A>w}function G(A,w){if(!c.isValidNot0(w))throw new Error(`invalid signature ${A}: out of range 1..Point.Fn.ORDER`);return w}function $(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function O(A,w,I){return $(),(A===I?0:2)|Number(a.isOdd(w))}function U(){if(C)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function Z(A,w){Mo(w);let I=y.signature,S=w==="compact"?I:w==="recovered"?I+1:void 0;return X(A,S)}class V{r;s;recovery;constructor(w,I,S){if(this.r=G("r",w),this.s=G("s",I),S!=null){if(U(),![0,1,2,3].includes(S))throw new Error("invalid recovery id");this.recovery=S}Object.freeze(this)}static fromBytes(w,I=T.format){Z(w,I);let S;if(I==="der"){let{r:F,s:W}=Po.toSig(X(w));return new V(F,W)}I==="recovered"&&(S=w[0],I="compact",w=w.subarray(1));let M=y.signature/2,R=w.subarray(0,M),K=w.subarray(M,M*2);return new V(c.fromBytes(R),c.fromBytes(K),S)}static fromHex(w,I){return this.fromBytes(bn(w),I)}assertRecovery(){let{recovery:w}=this;if(w==null)throw new Error("invalid recovery id: must be present");return w}addRecoveryBit(w){return new V(this.r,this.s,w)}recoverPublicKey(w){let{r:I,s:S}=this,M=this.assertRecovery(),R=M===2||M===3?I+f:I;if(!a.isValid(R))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=a.toBytes(R),F=t.fromBytes(Le(ls((M&1)===0),K)),W=c.inv(R),se=L(X(w,void 0,"msgHash")),z=c.create(-se*W),te=c.create(S*W),ye=t.BASE.mulAddUnsafe(z,F,te);if(ye.is0())throw new Error("invalid recovery: point at infinify");return ye.assertValidity(),ye}hasHighS(){return _(this.s)}toBytes(w=T.format){if(Mo(w),w==="der")return bn(Po.hexFromSig(this));let{r:I,s:S}=this,M=c.toBytes(I),R=c.toBytes(S);return w==="recovered"?(U(),Le(Uint8Array.of(this.assertRecovery()),M,R)):Le(M,R)}toHex(w){return yo(this.toBytes(w))}}Object.freeze(V.prototype),Object.freeze(V);let le=r.bits2int===void 0?function(w){if(w.length>8192)throw new Error("input is too large");let I=He(w),S=w.length*8-d;return S>0?I>>BigInt(S):I}:r.bits2int,L=r.bits2int_modN===void 0?function(w){return c.create(le(w))}:r.bits2int_modN,ie=Ot(d);function oe(A){return Bo("num < 2^"+d,A,Ne,ie),c.toBytes(A)}function N(A,w){return X(A,void 0,"message"),w?X(o(A),void 0,"prehashed message"):A}function E(A,w,I){let{lowS:S,prehash:M,extraEntropy:R}=Do(I,T);A=N(A,M);let K=L(A),F=c.fromBytes(w);if(!c.isValidNot0(F))throw new Error("invalid private key");let W=[oe(F),oe(K)];if(R!=null&&R!==!1){let ye=R===!0?i(y.secretKey):R;W.push(X(ye,void 0,"extraEntropy"))}let se=Le(...W),z=K;function te(ye){let ft=le(ye);if(!c.isValidNot0(ft))return;let Ht=t.BASE.multiply(ft).toAffine(),_e=c.create(Ht.x);if(_e===Ne)return;let we;if(h!==void 0){let St=He(Ho(h(u),f)),wa=c.inv(c.mul(St,ft)),xa=c.mul(St,z),Ea=c.mul(St,F);we=c.create(wa*c.create(xa+Ea*_e))}else{let St=Xi(ft,f);we=c.create(St*c.create(z+_e*F))}if(we===Ne)return;let On=O(Ht.x,Ht.y,_e),kr=we;return S&&_(we)&&(kr=c.neg(we),On^=1),new V(_e,kr,C?void 0:On)}return{seed:se,k2sig:te}}function v(A,w,I={}){let{seed:S,k2sig:M}=E(A,w,I);return Ki(o.outputLen,c.BYTES,s)(S,M).toBytes(I.format)}function H(A,w,I,S={}){let{lowS:M,prehash:R,format:K}=Do(S,T);if(I=X(I,void 0,"publicKey"),w=N(w,R),!xt(A)){let F=A instanceof V?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+F)}Z(A,K);try{let F=V.fromBytes(A,K),W=t.fromBytes(I);if(M&&F.hasHighS())return!1;let{r:se,s:z}=F,te=L(w),ye=c.inv(z),ft=c.create(te*ye),Ht=c.create(se*ye),_e=t.BASE.mulAddUnsafe(ft,W,Ht);if(_e.is0())return!1;let we=_e.toAffine();return!(c.create(we.x)!==se||K==="recovered"&&F.recovery!==O(we.x,we.y,se))}catch{return!1}}function D(A,w,I={}){let{prehash:S}=Do(I,T);return w=N(w,S),V.fromBytes(A,"recovered").recoverPublicKey(w).toBytes()}return Object.freeze({keygen:l,getPublicKey:p,getSharedSecret:m,utils:x,lengths:y,Point:t,sign:v,verify:H,recoverPublicKey:D,Signature:V,hash:o})}var bf={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var yf=hs(bf),gs=ms(yf,Oi);var Oo=globalThis.crypto,No=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=q.create();else if(n==="sha512")this.hasher=cn.create();else throw new Error(`createHash: unsupported algorithm ${e} in the browser verifier`)}update(e){return this.hasher.update(typeof e=="string"?new TextEncoder().encode(e):e),this}digest(e){let n=this.hasher.digest(),o=B.Buffer.from(n);return e===void 0?o:o.toString(e)}};function Hn(t){return new No(t)}function Uo(t){let e=[];return{update(n){return e.push(n),this},verify(n,o){try{let r=n instanceof Uint8Array?n:n.key,i=r.subarray(r.length-65);if(i.length!==65||i[0]!==4)return!1;let s=0;for(let f of e)s+=f.length;let a=new Uint8Array(s),c=0;for(let f of e)a.set(f,c),c+=f.length;return gs.verify(o,q(a),i,{format:"der",prehash:!1,lowS:!1})}catch{return!1}}}}b();function Xe(t){let e=bs(t);return new TextEncoder().encode(e)}function bs(t){return JSON.stringify(Fo(t))}function Fo(t){if(t===null||typeof t!="object"){if(typeof t>"u")throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");if(typeof t=="function"||typeof t=="symbol")throw new TypeError(`bitgraph-core/canonical: ${typeof t} values are not serializable to canonical JSON`);if(typeof t=="bigint")throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; convert to string (decimal) before canonicalizing");return t}if(Array.isArray(t))return t.map(Fo);let e={};for(let n of Object.keys(t).sort()){let o=t[n];typeof o>"u"||(e[n]=Fo(o))}return e}function Sn(t,e){if(t.length!==e.length)return!1;let n=0;for(let o=0;o<t.length;o++)n|=t[o]^e[o];return n===0}async function Ko(t){let{proof:e,bytes:n,trustAnchors:o}=t,r=await ys(e,n,o);return r===null?{valid:!0}:Hf(r)}async function _t(t){let{proof:e,trustAnchors:n}=t,o=await ys(e,void 0,n);return o===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:o}}async function ys(t,e,n){let o=xf(t);if(o!==null)return o;let r=e===void 0?void 0:q(e),i;try{i=kt(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(r!==void 0&&!Sn(r,i))return"artifact digest mismatch: the provided bytes do not match the committed digest";let s;try{s=kt(t.signer.publicKeyB64)}catch{return"signer.publicKeyB64 is not valid base64"}if(s.length!==32)return`signer.publicKeyB64 decodes to ${s.length} bytes; expected 32 (Ed25519)`;let a={version:t.version,artifact:t.artifact,commit:t.commit,publicKeyB64:t.signer.publicKeyB64,enforcement:t.environment.enforcement,measurement:t.environment.measurement};t.environment.attestation!==void 0&&(a.attestationFormat=t.environment.attestation.format),t.agency!==void 0&&(a.actor=t.agency.actor),t.policy!==void 0&&(a.policy=t.policy),t.attribution!==void 0&&(a.attribution=t.attribution);let c=Xe(a),f;try{f=kt(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(f.length!==64)return`signer.signatureB64 decodes to ${f.length} bytes; expected 64 (Ed25519)`;let d;try{d=await so(f,c,s)}catch(u){return`signature verification error: ${u instanceof Error?u.message:String(u)}`}if(!d)return"signature verification failed: signature does not match";if(t.agency!==void 0){let u=vf(t);if(u!==null)return u}if(t.slotAllocation!==void 0){let u=await Af(t);if(u!==null)return u}if(t.commit.epochLink!==void 0){let u=If(t);if(u!==null)return u}if(n!==void 0){let u=Ef(t,n);if(u!==null)return u}return null}var wf=new Set(["stub","hw-key","measured-tee"]);function xf(t){if(t===null||typeof t!="object")return"proof must be an object";let e=t;if(e.version!=="bitgraph/1")return`unsupported proof version: ${String(e.version)}`;if(!Ft(e.artifact))return"proof.artifact is missing or not an object";let n=e.artifact;if(n.hashAlg!=="sha256")return`unsupported hashAlg: ${String(n.hashAlg)}`;if(typeof n.digestB64!="string"||n.digestB64.length===0)return"proof.artifact.digestB64 must be a non-empty string";if(!Ft(e.commit))return"proof.commit is missing or not an object";let o=e.commit;if(typeof o.nonceB64!="string"||o.nonceB64.length===0)return"proof.commit.nonceB64 must be a non-empty string";if(o.counter!==void 0&&typeof o.counter!="string")return"proof.commit.counter must be a string when present";if(o.time!==void 0&&(typeof o.time!="number"||!Number.isFinite(o.time)||o.time<0))return"proof.commit.time must be a non-negative finite number when present";if(o.prevB64!==void 0&&typeof o.prevB64!="string")return"proof.commit.prevB64 must be a string when present";if(o.epochId!==void 0&&typeof o.epochId!="string")return"proof.commit.epochId must be a string when present";if(!Ft(e.signer))return"proof.signer is missing or not an object";let r=e.signer;if(typeof r.publicKeyB64!="string"||r.publicKeyB64.length===0)return"proof.signer.publicKeyB64 must be a non-empty string";if(typeof r.signatureB64!="string"||r.signatureB64.length===0)return"proof.signer.signatureB64 must be a non-empty string";if(!Ft(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!wf.has(i.enforcement))return"proof.environment.enforcement must be one of: stub, hw-key, measured-tee";if(typeof i.measurement!="string"||i.measurement.length===0)return"proof.environment.measurement must be a non-empty string";if(i.attestation!==void 0){if(!Ft(i.attestation))return"proof.environment.attestation must be an object when present";let s=i.attestation;if(typeof s.format!="string"||s.format.length===0)return"proof.environment.attestation.format must be a non-empty string";if(typeof s.reportB64!="string"||s.reportB64.length===0)return"proof.environment.attestation.reportB64 must be a non-empty string"}return null}function Ef(t,e){if(e.requireEnforcement!==void 0&&t.environment.enforcement!==e.requireEnforcement)return`enforcement tier "${t.environment.enforcement}" does not meet required tier "${e.requireEnforcement}"`;if(e.allowedMeasurements!==void 0&&e.allowedMeasurements.length>0&&!e.allowedMeasurements.includes(t.environment.measurement))return`measurement "${t.environment.measurement}" is not in the allowed set`;if(e.allowedPublicKeys!==void 0&&e.allowedPublicKeys.length>0&&!e.allowedPublicKeys.includes(t.signer.publicKeyB64))return"proof public key is not in the allowed set";if(e.requireAttestation===!0&&t.environment.attestation===void 0)return"policy requires attestation but proof has none";if(e.requireAttestationFormat!==void 0&&e.requireAttestationFormat.length>0){if(t.environment.attestation===void 0)return"policy requires attestation format but proof has no attestation";if(!e.requireAttestationFormat.includes(t.environment.attestation.format))return`attestation format "${t.environment.attestation.format}" is not in the required set`}if(e.minCounter!==void 0||e.maxCounter!==void 0){if(t.commit.counter===void 0)return"policy requires a counter but proof has none";let n;try{n=BigInt(t.commit.counter)}catch{return"could not parse proof counter value as integer"}if(e.minCounter!==void 0){let o;try{o=BigInt(e.minCounter)}catch{return"could not parse policy minCounter as integer"}if(n<o)return`counter ${t.commit.counter} is below minimum ${e.minCounter}`}if(e.maxCounter!==void 0){let o;try{o=BigInt(e.maxCounter)}catch{return"could not parse policy maxCounter as integer"}if(n>o)return`counter ${t.commit.counter} is above maximum ${e.maxCounter}`}}if(e.minTime!==void 0||e.maxTime!==void 0){if(t.commit.time===void 0)return"policy requires a time field but proof has none";if(e.minTime!==void 0&&t.commit.time<e.minTime)return`commit time ${t.commit.time} is before minimum ${e.minTime}`;if(e.maxTime!==void 0&&t.commit.time>e.maxTime)return`commit time ${t.commit.time} is after maximum ${e.maxTime}`}if(e.requireEpochId===!0&&(t.commit.epochId===void 0||t.commit.epochId.length===0))return"policy requires epochId but proof has none";if(e.requireActor===!0&&t.agency===void 0)return"policy requires actor (agency) but proof has none";if(e.allowedActorKeyIds!==void 0&&e.allowedActorKeyIds.length>0){if(t.agency===void 0)return"policy requires allowed actor key ID but proof has no agency";if(!e.allowedActorKeyIds.includes(t.agency.actor.keyId))return"actor key ID is not in the allowed set"}if(e.allowedActorProviders!==void 0&&e.allowedActorProviders.length>0){if(t.agency===void 0)return"policy requires allowed actor provider but proof has no agency";if(!e.allowedActorProviders.includes(t.agency.actor.provider))return`actor provider "${t.agency.actor.provider}" is not in the allowed set`}if(e.allowedOrigins!==void 0&&e.allowedOrigins.length>0){if(t.agency===void 0)return"policy requires an allowed origin but proof has no agency";let n=t.agency.authorization;if(!("format"in n)||n.format!=="webauthn")return"policy requires an allowed WebAuthn origin but the authorization is not WebAuthn";let o;try{o=JSON.parse(n.clientDataJSON).origin}catch{o=void 0}if(typeof o!="string"||!e.allowedOrigins.includes(o))return`WebAuthn origin "${o??"(none)"}" is not in the allowed set`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function Bf(t,e){if(typeof t!="string"||t.length===0)return"agency: clientDataJSON missing origin field";let n;try{n=new URL(t).hostname.toLowerCase()}catch{return"agency: clientDataJSON origin is not a valid origin"}if(!n)return"agency: clientDataJSON origin has no host";let o=e.subarray(0,32).toString("hex"),r=n.split("."),i=[];for(let a=0;a<r.length;a++){let c=r.slice(a).join(".");if(a>0&&r.length-a<2)break;i.push(c)}return i.some(a=>Hn("sha256").update(a,"utf8").digest("hex")===o)?null:"agency: authenticatorData rpIdHash does not match the origin's domain"}function vf(t){let e=t.agency,{actor:n,authorization:o}=e,r="format"in o&&o.format==="webauthn";if(typeof n.keyId!="string"||n.keyId.length===0)return"agency.actor.keyId must be a non-empty string";if(typeof n.publicKeyB64!="string"||n.publicKeyB64.length===0)return"agency.actor.publicKeyB64 must be a non-empty string";if(n.algorithm!=="ES256")return`agency.actor.algorithm must be "ES256", got "${String(n.algorithm)}"`;if(typeof n.provider!="string"||n.provider.length===0)return"agency.actor.provider must be a non-empty string";if(o.purpose!=="bitgraph/commit-authorize/v1")return`agency.authorization.purpose must be "bitgraph/commit-authorize/v1", got "${String(o.purpose)}"`;if(typeof o.signatureB64!="string"||o.signatureB64.length===0)return"agency.authorization.signatureB64 must be a non-empty string";let i;try{i=B.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(Hn("sha256").update(i).digest("hex")!==n.keyId)return"agency: actor.keyId does not match SHA-256 of public key";if(o.actorKeyId!==n.keyId)return"agency: authorization.actorKeyId does not match actor.keyId";if(o.artifactHash!==t.artifact.digestB64){let c=e.batchContext;if(!c||!Array.isArray(c.batchDigests)||!c.batchDigests.includes(t.artifact.digestB64)||c.batchDigests[0]!==o.artifactHash)return"agency: authorization.artifactHash does not match proof.artifact.digestB64"}let a;try{a=B.Buffer.from(o.signatureB64,"base64")}catch{return"agency.authorization.signatureB64 is not valid base64"}try{if(r){let c=o;if(typeof c.clientDataJSON!="string"||!c.clientDataJSON)return"agency: WebAuthn authorization missing clientDataJSON";if(typeof c.authenticatorDataB64!="string"||!c.authenticatorDataB64)return"agency: WebAuthn authorization missing authenticatorDataB64";let f;try{f=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(f.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${f.type}"`;if(!f.challenge)return"agency: clientDataJSON missing challenge field";let d=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;d.length%4;)d+="=";if(d!==o.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let u=B.Buffer.from(c.authenticatorDataB64,"base64");if(u.length<37)return"agency: authenticatorData too short";let h=u[32];if(!(h&1))return"agency: authenticatorData UP flag not set";if(!(h&4))return"agency: authenticatorData UV flag not set";let l=Bf(f.origin,u);if(l!==null)return l;let p=Hn("sha256").update(B.Buffer.from(c.clientDataJSON,"utf8")).digest(),m=B.Buffer.concat([u,p]),x=Uo("SHA256");if(x.update(m),!x.verify({key:i,format:"der",type:"spki"},a))return"agency: WebAuthn P-256 signature verification failed"}else{let c={purpose:o.purpose,actorKeyId:o.actorKeyId,artifactHash:o.artifactHash,challenge:o.challenge,timestamp:o.timestamp};"protocolVersion"in o&&o.protocolVersion!==void 0&&(c.protocolVersion=o.protocolVersion);let f=B.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),d=Uo("SHA256");if(d.update(f),!d.verify({key:i,format:"der",type:"spki"},a))return"agency: P-256 signature verification failed"}}catch(c){return`agency: P-256 signature verification error: ${c instanceof Error?c.message:String(c)}`}return null}async function Af(t){let e=t.slotAllocation;if(e.version!=="bitgraph/slot/1")return`slotAllocation.version must be "bitgraph/slot/1", got "${String(e.version)}"`;if(typeof e.nonceB64!="string"||e.nonceB64.length===0)return"slotAllocation.nonceB64 must be a non-empty string";if(typeof e.counter!="string"||e.counter.length===0)return"slotAllocation.counter must be a non-empty string";if(e.time!==void 0&&(typeof e.time!="number"||!Number.isFinite(e.time)||e.time<0))return"slotAllocation.time must be a non-negative finite number when present";if(typeof e.epochId!="string"||e.epochId.length===0)return"slotAllocation.epochId must be a non-empty string";if(typeof e.publicKeyB64!="string"||e.publicKeyB64.length===0)return"slotAllocation.publicKeyB64 must be a non-empty string";if(typeof e.signatureB64!="string"||e.signatureB64.length===0)return"slotAllocation.signatureB64 must be a non-empty string";let n={version:e.version,nonceB64:e.nonceB64,counter:e.counter,...e.time!==void 0?{time:e.time}:{},epochId:e.epochId,publicKeyB64:e.publicKeyB64,...e.chainId?{chainId:e.chainId}:{}},o=Xe(n),r,i;try{r=kt(e.signatureB64),i=kt(e.publicKeyB64)}catch{return"slotAllocation contains invalid base64"}if(r.length!==64)return`slotAllocation.signatureB64 decodes to ${r.length} bytes; expected 64 (Ed25519)`;if(i.length!==32)return`slotAllocation.publicKeyB64 decodes to ${i.length} bytes; expected 32 (Ed25519)`;let s;try{s=await so(r,o,i)}catch(u){return`slotAllocation signature verification error: ${u instanceof Error?u.message:String(u)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let u of c)if(a.has(u))return`slotAllocation body contains forbidden field '${u}' \u2014 causal independence violated`;if(typeof t.commit.slotHashB64!="string"||t.commit.slotHashB64.length===0)return"commit.slotHashB64 must be present when slotAllocation is present";let f=q(o),d;try{d=kt(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!Sn(f,d))return"commit.slotHashB64 does not match SHA-256 of canonical slot body \u2014 slot binding broken";if(e.nonceB64!==t.commit.nonceB64)return"slotAllocation.nonceB64 does not match commit.nonceB64";if(typeof t.commit.slotCounter!="string"||t.commit.slotCounter.length===0)return"commit.slotCounter must be present when slotAllocation is present";if(t.commit.slotCounter!==e.counter)return"commit.slotCounter does not match slotAllocation.counter";if(t.commit.counter===void 0)return"commit.counter must be present for slot ordering verification";try{let u=BigInt(e.counter),h=BigInt(t.commit.counter);if(u>=h)return`slotAllocation.counter (${e.counter}) must be less than commit.counter (${t.commit.counter})`}catch{return"could not parse slot or commit counter as integer"}return e.publicKeyB64!==t.signer.publicKeyB64?"slotAllocation.publicKeyB64 does not match signer.publicKeyB64 \u2014 different enclave":t.commit.epochId!==void 0&&e.epochId!==t.commit.epochId?"slotAllocation.epochId does not match commit.epochId \u2014 different lifecycle":null}var _o=new Map;function kf(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=q(new TextEncoder().encode(e));return B.Buffer.from(n).toString("base64")}function If(t){let e=t.commit.epochLink;if(typeof e.prevEpochId!="string"||e.prevEpochId.length===0)return"epochLink.prevEpochId must be a non-empty string";if(typeof e.prevPublicKeyB64!="string"||e.prevPublicKeyB64.length===0)return"epochLink.prevPublicKeyB64 must be a non-empty string";if(typeof e.prevCounter!="string"||e.prevCounter.length===0)return"epochLink.prevCounter must be a non-empty string";if(typeof e.prevProofHashB64!="string"||e.prevProofHashB64.length===0)return"epochLink.prevProofHashB64 must be a non-empty string";if(typeof e.toEpochId!="string"||e.toEpochId.length===0)return"epochLink.toEpochId must be a non-empty string";if(typeof e.toPublicKeyB64!="string"||e.toPublicKeyB64.length===0)return"epochLink.toPublicKeyB64 must be a non-empty string";try{BigInt(e.prevCounter)}catch{return"epochLink.prevCounter is not a valid decimal string"}if(t.commit.epochId!==void 0&&e.toEpochId!==t.commit.epochId)return`epochLink.toEpochId "${e.toEpochId}" does not match proof commit.epochId "${t.commit.epochId}" \u2014 successor binding broken`;if(e.toPublicKeyB64!==t.signer.publicKeyB64)return"epochLink.toPublicKeyB64 does not match proof signer.publicKeyB64 \u2014 successor binding broken";if(e.prevEpochId===e.toEpochId)return"epochLink.prevEpochId equals toEpochId \u2014 epoch link must cross epoch boundary";if(e.prevPublicKeyB64===e.toPublicKeyB64)return"epochLink.prevPublicKeyB64 equals toPublicKeyB64 \u2014 epochs must have different keys";let n=kf(e),o=_o.get(n);if(o!==void 0){if(o!==e.toEpochId)return`FORK DETECTED: predecessor (epoch=${e.prevEpochId.slice(0,12)}..., counter=${e.prevCounter}) already consumed by epoch ${o.slice(0,12)}..., but this proof claims consumption by epoch ${e.toEpochId.slice(0,12)}... \u2014 single-successor invariant violated`}else _o.set(n,e.toEpochId);return null}function It(){_o.clear()}function Hf(t){return{valid:!1,reason:t}}function Ft(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function kt(t){let e=B.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}b();function Cn(t){let e=t,n=e.signer,o=e.environment,r={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:o?.enforcement,measurement:o?.measurement};e.attribution&&(r.attribution=e.attribution),o?.attestation&&(r.attestationFormat=o.attestation.format);let i=Xe(r),s=q(i);return Vo(s)}var ws=["proofHash","ethereum"];function jo(t){let e=t,n=e;if(ws.some(r=>Object.prototype.hasOwnProperty.call(e,r))){n={};for(let r of Object.keys(e))ws.includes(r)||(n[r]=e[r])}let o=Xe(n);return Vo(q(o))}function Vo(t){if(typeof B.Buffer<"u")return B.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function xs(t){let e=t,n=e.signer,o=e.environment,r={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:o?.enforcement,measurement:o?.measurement};o?.attestation!==void 0&&(r.attestationFormat=o.attestation.format);let i=e.agency;return i!==void 0&&(r.actor=i.actor),e.policy!==void 0&&(r.policy=e.policy),e.attribution!==void 0&&(r.attribution=e.attribution),r}function zo(t){return Vo(q(Xe(xs(t))))}b();async function*Bs(t,e){let n=new Go(t,e?.maxTotalBytes),o=e?.maxEntryCount??Number.POSITIVE_INFINITY,r=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(d,u)=>{if(d>r)throw new Error(`tar: ${u} metadata entry of ${d} bytes exceeds the ${r}-byte cap`)};for(;;){let d=await n.readExact(512);if(d===null||$f(d))return;if(++c>o)throw new Error(`tar: archive exceeds the maximum of ${o} entries`);let u=Cf(d),h=u.typeflag;if(h==="x"||h==="g"){f(u.size,"PAX");let C=await Es(n,u.size);await n.skip(Tn(u.size));let _=Rf(C);h==="x"?i=_:s=Pf(s,_);continue}if(h==="L"){f(u.size,"GNU long-name");let C=await Es(n,u.size);await n.skip(Tn(u.size)),a=ct(Df(C));continue}if(h==="K"){await n.skip(u.size+Tn(u.size));continue}let l=u.name;s!==null&&s.has("path")&&(l=s.get("path")),a!==null&&(l=a),i!==null&&i.has("path")&&(l=i.get("path"));let p=u.size,m=i?.get("size")??s?.get("size");if(m!==void 0){let C=Number(m);if(!Number.isSafeInteger(C)||C<0)throw new Error("tar: invalid PAX size value");p=C}i=null,a=null;let x=h==="0"||h==="\0",y={remaining:p},T=Sf(n,y);yield{path:l,size:p,kind:x?"file":"other",typeflag:h,body:T},y.remaining>0&&(await n.skip(y.remaining),y.remaining=0),await n.skip(Tn(p))}}async function*Sf(t,e){for(;e.remaining>0;){let n=await t.readSome(e.remaining);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");e.remaining-=n.length,yield n}}async function Es(t,e){if(e===0)return new Uint8Array(0);let n=await t.readExact(e);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream)");return n}function Cf(t){Tf(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),o=ct(qo(t,0,100));if(ct(qo(t,257,6))==="ustar"){let s=ct(qo(t,345,155));s.length>0&&(o=`${s}/${o}`)}let i=vs(t.subarray(124,136));return{name:o,size:i,typeflag:n}}function qo(t,e,n){let o=t.subarray(e,e+n),r=o.indexOf(0);return r===-1&&(r=o.length),o.subarray(0,r)}function vs(t){if(t.length>0&&(t[0]&128)!==0){let o=0n;for(let r=0;r<t.length;r++){let i=r===0?t[0]&127:t[r];o=o<<8n|BigInt(i)}if(o>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("tar: numeric field exceeds the supported range");return Number(o)}let e=ct(t).trim().replace(/\0+$/,"").trim();if(e.length===0)return 0;let n=Number.parseInt(e,8);if(!Number.isSafeInteger(n)||n<0)throw new Error(`tar: invalid octal numeric field: "${e}"`);return n}function Tf(t){let e=vs(t.subarray(148,156)),n=0;for(let o=0;o<512;o++)n+=o>=148&&o<156?32:t[o];if(n!==e)throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)")}function $f(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function Rf(t){let e=new Map,n=0;for(;n<t.length;){let o=n;for(;o<t.length&&t[o]!==32;)o++;if(o>=t.length)throw new Error("tar: malformed PAX record (no length delimiter)");let r=Number(ct(t.subarray(n,o)));if(!Number.isInteger(r)||r<=0||n+r>t.length)throw new Error("tar: malformed PAX record (bad length)");let i=t.subarray(o+1,n+r);if(i.length===0||i[i.length-1]!==10)throw new Error("tar: malformed PAX record (missing newline)");let s=ct(i.subarray(0,i.length-1)),a=s.indexOf("=");if(a===-1)throw new Error("tar: malformed PAX record (missing '=')");e.set(s.slice(0,a),s.slice(a+1)),n+=r}return e}function Pf(t,e){let n=new Map(t??[]);for(let[o,r]of e)n.set(o,r);return n}function ct(t){return new TextDecoder("utf-8").decode(t)}function Df(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var Go=class{iter;chunks=[];head=0;available=0;ended=!1;totalPulled=0;maxTotalBytes;constructor(e,n){this.iter=e[Symbol.asyncIterator](),this.maxTotalBytes=n??Number.POSITIVE_INFINITY}async fill(){if(this.ended)return!1;let e=await this.iter.next();if(e.done===!0)return this.ended=!0,!1;let n=e.value;if(n.length>0){if(this.totalPulled+=n.length,this.totalPulled>this.maxTotalBytes)throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);this.chunks.push(n),this.available+=n.length}return!0}async readExact(e){for(;this.available<e;)if(!await this.fill()){if(this.available===0)return null;throw new Error("tar: truncated archive (unexpected end of stream)")}return this.take(e)}async readSome(e){for(;this.available===0;)if(!await this.fill())return null;let n=this.chunks[0],o=Math.min(e,n.length-this.head),r=n.subarray(this.head,this.head+o);return this.advance(o,n),r}async skip(e){let n=e;for(;n>0;){let o=await this.readSome(n);if(o===null)throw new Error("tar: truncated archive (unexpected end of stream)");n-=o.length}}take(e){let n=new Uint8Array(e),o=0;for(;o<e;){let r=this.chunks[0],i=Math.min(e-o,r.length-this.head);n.set(r.subarray(this.head,this.head+i),o),o+=i,this.advance(i,r)}return n}advance(e,n){this.head+=e,this.available-=e,this.head===n.length&&(this.chunks.shift(),this.head=0)}};function Tn(t){return(512-t%512)%512}b();var Nl=new Uint8Array([0]);function As(t){let e=Array.from(t,o=>({pathBytes:Lf(o.path),entryDigest:o.entryDigest}));e.sort((o,r)=>Mf(o.pathBytes,r.pathBytes));let n=q.create();for(let o of e)n.update(o.entryDigest);return B.Buffer.from(n.digest()).toString("base64")}function Lf(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Mf(t,e){let n=Math.min(t.length,e.length);for(let o=0;o<n;o++){let r=t[o]-e[o];if(r!==0)return r}return t.length-e.length}var ks=8*1024*1024,Cs={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},Is=new Uint8Array([0]),Hs="manifest.json",Wo="bitgraph-bundle/1",Nf="bitgraph-anchor-witness/1";var Ts=new WeakMap;async function Zo(t,e){let n=[],o=0,r=0,i=[],s=new Map,a=Array.from(t).sort((f,d)=>f.path<d.path?-1:f.path>d.path?1:0);for(let f of a){r++;let d=Rs(f.path);if(d.unsafe){o++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${d.reason}`});continue}let u=await _f(d.path,void 0,void 0,$s(f.open()));i.push(Kf(d.path,u)),s.set(d.path,f)}let c=Uf({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:r,skippedUnsafePaths:o});return Ts.set(c,s),c}async function*$s(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function Of(t){let e=[],n=0;for await(let o of $s(t.open()))e.push(o),n+=o.length;return Yo(e,n)}function Uf(t){let{bundlePath:e,container:n,scanned:o,strippedRootPrefix:r,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let $ of o){let O=$.rawPath,U=$.entryDigestFull;r!==void 0&&(O=$.rawPath.slice(r.length+1),U=$.entryDigestStripped),c.has(O)&&i.push({code:"duplicate-path",path:O,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(O,{path:O,sha256Hex:$.sha256Hex,byteLength:$.byteLength,entryDigest:U,...$.json!==void 0?{json:$.json}:{}})}let f=Array.from(c.values()),d=As(f.filter($=>$.path!==Hs).map($=>({path:$.path,entryDigest:$.entryDigest}))),u=[],h=new Map,l=[],p=[],m=new Map,x,y=0,T=0,C=0;for(let $ of f){if($.path===Hs){x=Wf($,d,i);continue}let O=$.json;if(O!==void 0&&Vf(O)){let U=O.version;if(U==="bitgraph/1"){y++;let Z=zf($,O,h,u,i);Z==="exact-duplicate"&&T++,Z==="semantic-duplicate"&&C++;continue}l.push({code:"unsupported-version",path:$.path,version:U,fileSha256Hex:$.sha256Hex}),i.push({code:"unsupported-version",path:$.path,message:`proof-shaped file rejected: version "${U}" is not "bitgraph/1"`,details:{version:U}}),Ss($,m);continue}if(O!==void 0&&O.version===Nf){p.push({path:$.path,fileSha256Hex:$.sha256Hex,witness:O});continue}Ss($,m)}for(let $ of u){let O=Gf($.proof.artifact);if(O===null)continue;let U=m.get(O);U!==void 0&&U.matchedProofHashes.push($.proofHash)}let _=Array.from(m.values()),G={observed:u.length,proofFiles:y,exactDuplicates:T,semanticDuplicates:C,unsupportedVersion:l.length,artifacts:_.length,witnesses:p.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...r!==void 0?{strippedRootPrefix:r}:{},entriesScanned:s,proofs:u,unsupportedVersions:l,artifacts:_,witnesses:p,...x!==void 0?{manifest:x}:{},computedContentsHashB64:d,findings:i,counts:G}}async function*Kt(t){let e=t.artifacts.filter(s=>s.matchedProofHashes.length>0);if(e.length===0)return;if(t.container==="memory"){let s=Ts.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let f=s.get(c);if(f===void 0)continue;let d;try{d=await Of(f)}catch{continue}if($n(q(d))===a.sha256Hex){yield{sha256Hex:a.sha256Hex,path:c,bytes:d};break}}return}if(t.container==="directory"){for(let s of e)for(let a of s.paths){let c;try{c=new Uint8Array(await Ai(ki(t.bundlePath,...a.split("/"))))}catch{continue}if($n(q(c))===s.sha256Hex){yield{sha256Hex:s.sha256Hex,path:a,bytes:c};break}}return}let n=new Map;for(let s of e)for(let a of s.paths)n.set(a,s);let o=new Set,{stream:r,close:i}=Ff(t.bundlePath,t.container);try{for await(let s of Bs(r,Cs)){if(o.size===e.length)break;if(s.kind!=="file")continue;let a=Rs(s.path);if(a.unsafe)continue;let c=a.path;if(t.strippedRootPrefix!==void 0){if(!c.startsWith(`${t.strippedRootPrefix}/`))continue;c=c.slice(t.strippedRootPrefix.length+1)}let f=n.get(c);if(f===void 0||o.has(f.sha256Hex))continue;let d=[],u=0;for await(let l of s.body)d.push(l.slice()),u+=l.length;let h=Yo(d,u);$n(q(h))===f.sha256Hex&&(o.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:h})}}finally{i()}}function Ff(t,e){let n=vi(t);if(e==="tar-gz"){let o=Ii();return n.pipe(o),n.on("error",r=>o.destroy(r)),{stream:o,close:()=>{o.destroy(),n.destroy()}}}return{stream:n,close:()=>n.destroy()}}async function _f(t,e,n,o){let r=new TextEncoder,i=q.create(),s=q.create();s.update(r.encode(t)),s.update(Is);let a=e===void 0?void 0:q.create();a!==void 0&&(a.update(r.encode(e)),a.update(Is));let c=n===void 0||n<=ks,f=[],d=0;for await(let u of o)i.update(u),s.update(u),a?.update(u),d+=u.length,c&&(d>ks?(f.length=0,c=!1):f.push(u.slice()));return{sha256Hex:$n(i.digest()),byteLength:d,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:Yo(f,d)}:{}}}function Kf(t,e){let n=e.buffered===void 0?void 0:jf(e.buffered);return{rawPath:t,sha256Hex:e.sha256Hex,byteLength:e.byteLength,entryDigestFull:e.entryDigestFull,...e.entryDigestStripped!==void 0?{entryDigestStripped:e.entryDigestStripped}:{},...n!==void 0?{json:n}:{}}}function jf(t){let e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let n;try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}let o;try{o=JSON.parse(n)}catch{return}if(!(o===null||typeof o!="object"||Array.isArray(o)))return o}function Rs(t){if(t.includes("\0"))return{path:t,unsafe:!0,reason:"path contains a NUL byte"};let e=t.startsWith("/"),n=t.split("/").filter(r=>r!==""&&r!=="."),o=n.join("/");return e?{path:o,unsafe:!0,reason:"absolute path"}:n.some(r=>r==="..")?{path:o,unsafe:!0,reason:"path escapes the bundle root"}:o===""?{path:o,unsafe:!0,reason:"empty path"}:{path:o,unsafe:!1}}function fe(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Vf(t){return fe(t)?typeof t.version=="string"&&fe(t.artifact)&&fe(t.commit)&&fe(t.signer):!1}function zf(t,e,n,o,r){let i=Cn(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=qf(e,i);a==="mismatch"&&r.push({code:"proofhash-mismatch",path:t.path,message:"embedded proofHash does not match the computed canonical proof hash",details:{embedded:e.proofHash,computed:i}});let c=n.get(i);if(c!==void 0){let x=c.sources.some(y=>y.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),r.push({code:x?"exact-duplicate":"semantic-duplicate",path:t.path,message:x?"byte-identical copy of an already observed proof":"different byte encoding of an already observed proof (same canonical identity)",details:{proofHash:i,firstObservedAt:c.sources[0].path}}),x?"exact-duplicate":"semantic-duplicate"}let f=fe(e.commit)?e.commit:{},d=fe(e.signer)?e.signer:{},u=fe(e.environment)?e.environment:{},h=he(f.counter),l=he(f.epochId),p=he(f.chainId),m={proofHash:i,chainHash:jo(e),proof:e,sources:[s],version:"bitgraph/1",...h!==void 0?{counter:h}:{},...he(f.slotCounter)!==void 0?{slotCounter:he(f.slotCounter)}:{},...he(f.prevB64)!==void 0?{prevB64:he(f.prevB64)}:{},...l!==void 0?{epochId:l}:{},chainId:p!==void 0&&p.length>0?p:"global",...he(d.publicKeyB64)!==void 0?{publicKeyB64:he(d.publicKeyB64)}:{},...he(u.measurement)!==void 0?{measurement:he(u.measurement)}:{},...he(u.enforcement)!==void 0?{enforcement:he(u.enforcement)}:{},hasSlotAllocation:fe(e.slotAllocation),hasAttestation:fe(u.attestation),hasAgency:fe(e.agency),hasEpochLink:fe(f.epochLink),embeddedProofHash:a,chainless:h===void 0&&l===void 0};return n.set(i,m),o.push(m),"new"}function qf(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function he(t){return typeof t=="string"?t:void 0}function Ss(t,e){let n=e.get(t.sha256Hex);if(n!==void 0){n.paths.push(t.path);return}e.set(t.sha256Hex,{sha256Hex:t.sha256Hex,sha256B64:B.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function Gf(t){if(!fe(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function Wf(t,e,n){if(t.json===void 0)return n.push({code:"manifest-unparseable",path:t.path,message:"root manifest.json did not parse as a single JSON object; proceeding as if no manifest were present"}),{path:t.path,parsed:!1,recognized:!1,problems:[]};let o=t.json,r=o.version;if(r!==Wo)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(r)} is not "${Wo}"; the manifest was not interpreted`,...typeof r=="string"?{details:{version:r}}:{}}),{path:t.path,parsed:!0,...typeof r=="string"?{version:r}:{},recognized:!1,problems:[]};let i=Zf(o);for(let c of i)n.push({code:"manifest-field-invalid",path:t.path,message:c});let s={path:t.path,parsed:!0,version:Wo,recognized:!0,manifest:o,problems:i},a=o.contentsHashB64;if(typeof a=="string"&&a.length>0){let c=a===e;s.contentsHash={declaredB64:a,computedB64:e,match:c},c||n.push({code:"manifest-contents-hash-mismatch",path:t.path,message:"manifest contentsHashB64 does not match the computed contents hash; the bundle held is not byte-for-byte the bundle the manifest describes. Advisory: this does not fail any proof.",details:{declared:a,computed:e}})}return s}function Zf(t){let e=[],n=o=>Array.isArray(o)&&o.every(r=>typeof r=="string");if(t.epochIds!==void 0&&!n(t.epochIds)&&e.push("manifest.epochIds must be an array of strings when present"),t.chainIds!==void 0&&!n(t.chainIds)&&e.push("manifest.chainIds must be an array of strings when present"),t.proofCount!==void 0&&(typeof t.proofCount!="number"||!Number.isInteger(t.proofCount)||t.proofCount<0)&&e.push("manifest.proofCount must be a non-negative integer when present"),t.counterRanges!==void 0&&(Array.isArray(t.counterRanges)&&t.counterRanges.every(r=>fe(r)&&typeof r.epochId=="string"&&typeof r.chainId=="string"&&typeof r.min=="string"&&typeof r.max=="string")||e.push("manifest.counterRanges must be an array of { epochId, chainId, min, max } string fields when present")),t.generatedAt!==void 0&&typeof t.generatedAt!="string"&&e.push("manifest.generatedAt must be a string when present"),t.contentsHashB64!==void 0){let o=t.contentsHashB64,r=typeof o=="string"&&o.length>0;if(r){let i=B.Buffer.from(o,"base64");r=i.toString("base64")===o&&i.length===32}r||e.push("manifest.contentsHashB64 must be standard base64 of 32 bytes when present")}return t.artifactsIncluded!==void 0&&typeof t.artifactsIncluded!="boolean"&&e.push("manifest.artifactsIncluded must be a boolean when present"),t.openEpochs!==void 0&&(Array.isArray(t.openEpochs)&&t.openEpochs.every(r=>fe(r)&&typeof r.epochId=="string"&&typeof r.counterAtSnapshot=="string")||e.push("manifest.openEpochs must be an array of { epochId, counterAtSnapshot } string fields when present")),e}function $n(t){return B.Buffer.from(t).toString("hex")}function Yo(t,e){let n=new Uint8Array(e),o=0;for(let r of t)n.set(r,o),o+=r.length;return n}b();async function Xo(t,e){It();let n=e?.trustAnchors,o=new Map(t.proofs.map(f=>[f.proofHash,f])),r=new Map;for(let f of t.artifacts){if(f.matchedProofHashes.length===0)continue;let d=f.matchedProofHashes.map(u=>o.get(u)).filter(u=>u!==void 0);r.set(f.sha256Hex,d)}for await(let f of Kt(t)){let d=r.get(f.sha256Hex)??[];for(let u of d){if(u.verification!==void 0)continue;let h=await Ko({proof:u.proof,bytes:f.bytes,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"full",status:h.valid?"verified":"failed",...h.reason!==void 0?{reason:h.reason}:{},artifactPath:f.path};u.verification=l}}for(let f of t.proofs){if(f.verification!==void 0)continue;let d=await _t({proof:f.proof,...n!==void 0?{trustAnchors:n}:{}}),u={tier:"integrity",status:d.valid?"artifact-unavailable":"failed",...d.reason!==void 0?{reason:d.reason}:{}};f.verification=u}let i=0,s=0,a=0,c=0;for(let f of t.proofs){let d=f.verification?.status;d==="verified"?i++:d==="failed"?s++:d==="artifact-unavailable"&&a++,f.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}b();b();var Ps=new WeakMap;async function Oe(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=Ps.get(t);if(n!==void 0)return n;It();let o=!1;try{o=(await _t({proof:t.proof})).valid}catch{o=!1}return It(),Ps.set(t,o),o}function Y(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function Se(t,e){let n=Y(t.counter),o=Y(e.counter);return n!==void 0&&o!==void 0&&n!==o?n<o?-1:1:n!==void 0&&o===void 0?-1:n===void 0&&o!==void 0?1:t.proofHash<e.proofHash?-1:t.proofHash>e.proofHash?1:0}function de(t,e,n){let o=t.get(e);o===void 0?t.set(e,[n]):o.push(n)}async function Qo(t){let e=[],n=[],o=new Map;for(let f of t.proofs){if(f.chainless){e.push(f.proofHash);continue}if(f.publicKeyB64===void 0){n.push(f.proofHash);continue}let d={publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId},u=JSON.stringify([d.publicKeyB64,d.epochId??null,d.chainId]),h=o.get(u);h===void 0?o.set(u,{key:d,members:[f]}):h.members.push(f)}let r=[...o.values()].sort((f,d)=>Yf(f.key,d.key)),i=[],s=new Set,a=new Map;for(let f of r){let d=Xf(f.key,f.members,s);i.push(d);for(let u of d.memberProofHashes)a.set(u,f.key)}let c=await ed(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function Yf(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",o=e.epochId??"";return n!==o?n<o?-1:1:t.publicKeyB64!==e.publicKeyB64?t.publicKeyB64<e.publicKeyB64?-1:1:0}function Xf(t,e,n){let o=new Map(e.map(h=>[h.chainHash,h])),r=new Map,i=new Set,s=new Map;for(let h of e)s.set(h.proofHash,h.proofHash);let a=h=>{let l=h;for(;s.get(l)!==l;)l=s.get(l);let p=h;for(;p!==l;){let m=s.get(p);s.set(p,l),p=m}return l},c=(h,l)=>{let p=a(h),m=a(l);p!==m&&s.set(p,m)};for(let h of e){if(h.prevB64===void 0)continue;let l=o.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||(i.add(h.proofHash),de(r,l.proofHash,h),n.add(l.proofHash),c(l.proofHash,h.proofHash))}let f=new Map;for(let h of e)de(f,a(h.proofHash),h);let d=[];for(let h of f.values())d.push(Jf(h,r,i));d.sort(Qf);let u=[...e].sort(Se).map(h=>h.proofHash);return{key:t,memberProofHashes:u,components:d}}function Jf(t,e,n){let o=[...t].sort(Se),r=o.filter(h=>h.prevB64===void 0),i=o.filter(h=>h.prevB64!==void 0&&!n.has(h.proofHash)),s=o.filter(h=>(e.get(h.proofHash)??[]).length===0),a=new Set,c=[],f=h=>{let l=[h];for(;l.length>0;){let p=l.pop();if(a.has(p))continue;a.add(p),c.push(p);let m=[...e.get(p)??[]].sort(Se);for(let x=m.length-1;x>=0;x--)l.push(m[x].proofHash)}};for(let h of[...r,...i])f(h.proofHash);for(let h of o)a.has(h.proofHash)||f(h.proofHash);let d,u;for(let h of t)for(let l of[h.counter,h.slotCounter]){let p=Y(l);p!==void 0&&((d===void 0||p<d)&&(d=p),(u===void 0||p>u)&&(u=p))}return{memberProofHashes:c,genesisProofHashes:r.map(h=>h.proofHash),brokenLinkProofHashes:i.map(h=>h.proofHash),terminalProofHashes:s.map(h=>h.proofHash),hasCounterEvidence:d!==void 0,...d!==void 0&&u!==void 0?{positionRange:{min:String(d),max:String(u)}}:{}}}function Qf(t,e){let n=t.positionRange?.min,o=e.positionRange?.min;if(n!==void 0&&o!==void 0&&n!==o)return BigInt(n)<BigInt(o)?-1:1;if(n!==void 0&&o===void 0)return-1;if(n===void 0&&o!==void 0)return 1;let r=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return r<i?-1:r>i?1:0}async function ed(t,e,n,o){let r=new Map;for(let h of e){let l=h.key.epochId;if(l===void 0)continue;let p=r.get(l);p===void 0&&(p={chainIds:new Set,publicKeys:new Set,proofCount:0},r.set(l,p)),p.chainIds.add(h.key.chainId),p.publicKeys.add(h.key.publicKeyB64),p.proofCount+=h.memberProofHashes.length}let i=new Map(t.proofs.map(h=>[h.chainHash,h])),s=[];for(let h of t.proofs){if(!h.hasEpochLink)continue;let l=td(h);l!==null&&s.push(await nd(l,h,i,r,n,o))}let a=rd(s),c=new Set,f=new Map,d=new Map;for(let h of s)h.hardEdge&&(c.add(h.fromEpochId),c.add(h.toEpochId),Jo(f,h.toEpochId,h.fromEpochId),Jo(d,h.fromEpochId,h.toEpochId));return{epochs:[...r.entries()].sort(([h],[l])=>h<l?-1:h>l?1:0).map(([h,l])=>({epochId:h,chainIds:[...l.chainIds].sort(),publicKeysB64:[...l.publicKeys].sort(),proofCount:l.proofCount,ordering:c.has(h)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...f.get(h)??[]].sort(),linkedSuccessorEpochIds:[...d.get(h)??[]].sort()})),edges:s,orderedPairs:a}}function td(t){let e=t.proof.commit;if(e===null||typeof e!="object")return null;let n=e.epochLink;if(n===null||typeof n!="object"||Array.isArray(n))return null;let o=n,r=["prevEpochId","prevPublicKeyB64","prevCounter","prevProofHashB64","toEpochId","toPublicKeyB64"],i={};for(let s of r){let a=o[s];if(typeof a!="string"||a.length===0)return null;i[s]=a}return i}async function nd(t,e,n,o,r,i){let s=await Oe(e),a=n.get(t.prevProofHashB64);if(a===void 0){let h=o.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:h?"terminal-missing":"dangling",viaProofValid:s,hardEdge:!1}}let c=[];a.epochId!==t.prevEpochId&&c.push(`the referenced proof's epochId (${a.epochId??"absent"}) does not match epochLink.prevEpochId (${t.prevEpochId})`),a.publicKeyB64!==t.prevPublicKeyB64&&c.push("the referenced proof's signer key does not match epochLink.prevPublicKeyB64"),od(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await Oe(a),d=c.length===0,u=i.has(a.proofHash);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:"matched",predecessorProofHash:a.proofHash,metadataConsistent:d,...d?{}:{inconsistencies:c},...u?{referencedProofIsTerminal:!r.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:d&&s&&f}}function od(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=Y(t),o=Y(e);return n!==void 0&&o!==void 0&&n===o}function rd(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(Jo(e,i.fromEpochId,i.toEpochId),n.add(i.fromEpochId),n.add(i.toEpochId));let o=new Set;for(let i of n){let s=new Set,a=[...e.get(i)??[]];for(;a.length>0;){let c=a.pop();if(!s.has(c)){s.add(c);for(let f of e.get(c)??[])a.push(f)}}for(let c of s)c!==i&&o.add(`${i}\0${c}`)}let r=[];for(let i of o){let[s,a]=i.split("\0");o.has(`${a}\0${s}`)||r.push({beforeEpochId:s,afterEpochId:a})}return r.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),r}function Jo(t,e,n){let o=t.get(e);o===void 0?t.set(e,new Set([n])):o.add(n)}b();var id=1e4;async function er(t,e){let n=[],o=[],r=[],i=new Map(t.proofs.map(c=>[c.proofHash,c])),s=new Map(t.proofs.map(c=>[c.chainHash,c])),a=new Map;for(let c of e.partitions)for(let f of c.memberProofHashes)a.set(f,c.key);for(let c of e.partitions){let f=c.memberProofHashes.map(d=>i.get(d));sd(c,f,n),await Ds(c,f,"counter",n,o),await Ds(c,f,"slot",n,o),await ad(c,f,n,o),await cd(c,f,s,n,o),fd(c,f,s,a,n,r),await ud(c,f,n,o),hd(c,f,n)}return await ld(e.epochRelationships.edges,i,n,o),{anomalies:n,divergences:o,boundaryEntryPoints:r}}function sd(t,e,n){let o=new Set;for(let u of e){let h=Y(u.counter);h!==void 0&&o.add(h);let l=Y(u.slotCounter);l!==void 0&&o.add(l)}if(o.size<2)return;let r=[...o].sort((u,h)=>u<h?-1:u>h?1:0),i=[],s=[],a=0n;for(let u=1;u<r.length;u++){let h=r[u-1]+1n,l=r[u]-1n;if(!(h>l)){i.push({start:String(h),end:String(l)}),a+=l-h+1n;for(let p=h;p<=l&&s.length<id;p++)s.push(String(p))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},f=String(r[0]),d=String(r[r.length-1]);n.push({code:"unexplained-counter-positions",partition:t.key,proofHashes:[],message:`${a} counter position${a===1n?"":"s"} within the observed range [${f}, ${d}] of this partition ${a===1n?"is":"are"} neither a commit position nor a referenced slot position in the supplied bundle. Such ${a===1n?"a position":"positions"} may mean a proof is absent from the bundle, or a slot that was allocated but never committed (a routine, benign occurrence); this offline audit cannot distinguish the two. It does not, by itself, establish that the authority failed to create or withheld any proof.`,details:c})}async function Ds(t,e,n,o,r){let i=new Map;for(let s of e){let a=n==="counter"?s.counter:s.slotCounter;if(a===void 0)continue;let c=Y(a);de(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of tr(i)){if(a.length<2)continue;let{parties:c,context:f}=await Rn(a);if(c.length<2)continue;let d=s.startsWith("raw:")?s.slice(4):s,u=n==="counter"?"counter-collision":"slot-collision";o.push({code:u,partition:t.key,proofHashes:a.map(h=>h.proofHash),message:n==="counter"?`${c.length} distinct valid proofs claim commit counter ${d} in one partition. The audit does not choose between them; all parties are preserved for adjudication.`:`${c.length} distinct valid proofs reference slot counter ${d} in one partition. A slot position is consumed exactly once; all parties are preserved for adjudication.`,details:{position:d,validParties:c.map(h=>h.proofHash),invalidObserved:f.map(h=>h.proofHash)}}),r.push({kind:u,partition:t.key,contested:n==="counter"?{counter:d}:{slotCounter:d},parties:c.map(Ce),invalidContext:f.map(Ce),explanation:n==="counter"?`Two or more independently valid proof objects claim commit counter ${d} in the same signer, epoch, and chain partition. A commit counter position can be consumed only once, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them; every party and its predecessor relationship is preserved for adjudication.`:`Two or more independently valid proof objects reference slot counter ${d} in the same signer, epoch, and chain partition. A slot position is allocated once and consumed by one commit, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them.`})}}async function ad(t,e,n,o){let r=new Map,i=new Map;for(let a of e){let c=Y(a.counter);c!==void 0&&de(r,String(c),a);let f=Y(a.slotCounter);f!==void 0&&de(i,String(f),a)}let s=[...r.keys()].filter(a=>i.has(a)).sort((a,c)=>BigInt(a)<BigInt(c)?-1:BigInt(a)>BigInt(c)?1:0);for(let a of s){let c=r.get(a),f=i.get(a),d=[];for(let y of c)await Oe(y)&&d.push(y);let u=[];for(let y of f)await Oe(y)&&u.push(y);if(!d.some(y=>u.some(T=>T.proofHash!==y.proofHash)))continue;let l=new Map;for(let y of[...d,...u])l.set(y.proofHash,y);let p=[...l.values()],m=new Map;for(let y of[...c,...f])m.set(y.proofHash,y);let x=[...m.values()].filter(y=>!l.has(y.proofHash));n.push({code:"cross-kind-position-reuse",partition:t.key,proofHashes:[...m.keys()],message:`Counter position ${a} is committed by one proof and reserved as a slot by a different proof in the same partition. A single causal position is consumed once, as a slot or as a commit, never both across distinct proofs. The audit does not choose between them; all parties are preserved for adjudication.`,details:{position:a,commitParties:d.map(y=>y.proofHash),slotParties:u.map(y=>y.proofHash),validParties:p.map(y=>y.proofHash),invalidObserved:x.map(y=>y.proofHash)}}),o.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:p.map(Ce),invalidContext:x.map(Ce),explanation:`Two or more independently valid proof objects allocate counter position ${a} in the same signer, epoch, and chain partition through different roles: at least one commits at it and at least one reserves it as a slot. Each position in a chain is consumed exactly once, so at most one of these allocations can belong to the authoritative sequence. This pattern only arises through enclave malfunction, replay, or compromise. The audit tool does not choose between them; every party is preserved for adjudication.`})}}async function cd(t,e,n,o,r){let i=new Map;for(let s of e)s.prevB64!==void 0&&de(i,s.prevB64,s);for(let[s,a]of tr(i)){if(a.length<2)continue;let{parties:c,context:f}=await Rn(a);if(c.length<2)continue;let d=n.has(s);o.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(u=>u.proofHash),message:`${c.length} distinct valid proofs claim the same predecessor hash: a detectable fork. All branches are preserved; the audit does not choose between them.`,details:{prevB64:s,predecessorObserved:d,validParties:c.map(u=>u.proofHash),invalidObserved:f.map(u=>u.proofHash)}}),r.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map(Ce),invalidContext:f.map(Ce),explanation:`Two or more independently valid proof objects name the same predecessor proof in their prevB64 hash link. Each proof has exactly one successor in an intact chain, so this is a fork: the history diverges into multiple branches at that predecessor${d?", which is itself observed in the bundle":", which is absent from the bundle"}. All branches are shown; the audit tool does not select one.`})}}function fd(t,e,n,o,r,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let f=Y(c.counter);f!==void 0&&(a===void 0||f<a)&&(a=f)}for(let c of[...e].sort(Se)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!dd(c.prevB64)){r.push({code:"chain-break-malformed",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 is not standard base64 of 32 bytes, so it can never match a canonical proof hash. The predecessor link is unusable as reconstruction evidence.",details:{prevB64:c.prevB64}});continue}let f=n.get(c.prevB64);if(f!==void 0){let h=o.get(f.proofHash);r.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,f.proofHash],message:"commit.prevB64 resolves to an observed proof outside this proof's own signer, epoch, and chain partition. prevB64 never bridges partitions (each epoch and chain keeps its own hash chain), so this link does not join the two.",details:{prevB64:c.prevB64,predecessorProofHash:f.proofHash,predecessorPartition:h!==void 0?{publicKeyB64:h.publicKeyB64,...h.epochId!==void 0?{epochId:h.epochId}:{},chainId:h.chainId}:"unchained-or-unpartitioned"}});continue}let d=Y(c.counter);if(d===void 0||a===void 0||d<=a){i.push({partition:t.key,proofHash:c.proofHash,prevB64:c.prevB64});continue}r.push({code:"chain-break-missing",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 references a predecessor proof that is absent from the supplied bundle, and a lower-positioned proof IS present, so this is an interior break (a hole), not the excerpt's starting boundary. The chain cannot be reconstructed across this link from the supplied evidence; this does not, by itself, establish that the predecessor never existed.",details:{prevB64:c.prevB64}})}}function dd(t){if(t.length===0)return!1;let e=B.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function ud(t,e,n,o){let r=[...e.filter(a=>a.prevB64===void 0)].sort(Se);if(r.length<2)return;let{parties:i,context:s}=await Rn(r);n.push({code:"multiple-genesis",partition:t.key,proofHashes:r.map(a=>a.proofHash),message:`${r.length} proofs in one partition carry no prevB64 link. An epoch has exactly one first proof, so at most one of these can be the genesis of this partition's chain.`,details:{validParties:i.map(a=>a.proofHash),invalidObserved:s.map(a=>a.proofHash)}}),!(i.length<2)&&o.push({kind:"multiple-genesis",partition:t.key,contested:{...t.key.epochId!==void 0?{epochId:t.key.epochId}:{},chainId:t.key.chainId},parties:i.map(Ce),invalidContext:s.map(Ce),explanation:"Two or more independently valid proof objects in the same signer, epoch, and chain partition carry no predecessor link, each presenting itself as the first proof of the chain. An epoch has exactly one first proof, so at most one of these can be the genesis. The audit tool does not choose between them."})}function hd(t,e,n){for(let o of[...e].sort(Se)){let r=Y(o.slotCounter),i=Y(o.counter);r===void 0||i===void 0||r<i||n.push({code:"slot-order-violation",partition:t.key,proofHashes:[o.proofHash],message:"commit.slotCounter is not strictly less than commit.counter. The slot must be allocated before the commit that consumes it, so this proof's declared positions contradict the nonce-first construction order.",details:{slotCounter:o.slotCounter,counter:o.counter}})}}async function ld(t,e,n,o){for(let s of t)s.resolution==="terminal-missing"?n.push({code:"epochlink-terminal-missing",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch that is observed in the bundle, but the referenced terminal proof is absent from the bundle. The lineage claim cannot be confirmed from the supplied evidence; this does not, by itself, establish that the terminal never existed.",details:{link:{...s.link}}}):s.resolution==="dangling"?n.push({code:"epochlink-dangling",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch and terminal proof, neither of which is observed in the bundle. The lineage claim dangles into unobserved history; it cannot be confirmed from the supplied evidence.",details:{link:{...s.link}}}):s.metadataConsistent===!1&&n.push({code:"epochlink-mismatch",proofHashes:[s.viaProofHash,...s.predecessorProofHash!==void 0?[s.predecessorProofHash]:[]],message:"commit.epochLink's prevProofHashB64 matches an observed proof, but the link's declared epoch, signer key, or counter disagrees with that proof. The hash reference and the declared metadata cannot both be right.",details:{link:{...s.link},inconsistencies:s.inconsistencies??[]}});let r=new Map;for(let s of t)de(r,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of tr(r)){let a=new Set(s.map(h=>h.link.toEpochId));if(a.size<2)continue;let c=s.map(h=>e.get(h.viaProofHash)),{parties:f,context:d}=await Rn(c),u=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(h=>h.viaProofHash),message:`The same predecessor terminal (epoch ${u.prevEpochId}, counter ${u.prevCounter}) is consumed by genesis proofs of ${a.size} distinct successor epochs. A predecessor may be consumed by at most one successor epoch, so this is a detectable fork at the epoch boundary. All branches are preserved.`,details:{prevEpochId:u.prevEpochId,prevCounter:u.prevCounter,prevProofHashB64:u.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:f.map(h=>h.proofHash),invalidObserved:d.map(h=>h.proofHash)}}),!(f.length<2)&&o.push({kind:"epochlink-fork",contested:{prevEpochId:u.prevEpochId,prevCounter:u.prevCounter,prevProofHashB64:u.prevProofHashB64},parties:f.map(Ce),invalidContext:d.map(Ce),explanation:"Two or more independently valid epoch-genesis proofs consume the same terminal proof of a prior epoch through their epochLink. The single-successor rule allows a terminal to be consumed by exactly one successor epoch, so at most one of these lineages can be the authoritative continuation. Note that whichever party verified second in this run carries a fork-detection failure from the canonical verifier; that ordering is an artifact of verification order, not evidence of which branch is authoritative. The audit tool does not choose between them."})}let i=new Map;for(let s of t){if(s.resolution!=="matched")continue;let a=i.get(s.fromEpochId);a===void 0?i.set(s.fromEpochId,new Set([s.toEpochId])):a.add(s.toEpochId)}for(let s of pd(i)){let a=t.filter(c=>c.resolution==="matched"&&s.includes(c.fromEpochId)&&s.includes(c.toEpochId)).map(c=>c.viaProofHash);n.push({code:"epochlink-cycle",proofHashes:a,message:`Epoch lineage links form a cycle among ${s.length} epochs. Each link claims its successor epoch came after its predecessor, so a cycle means these ordering claims contradict each other; no ordering is asserted for the epochs involved.`,details:{epochIds:s}})}}function pd(t){let e=new Map,n=new Set,o=[...t.keys()].sort();for(let r of o){if(n.has(r))continue;let i=[],s=new Set,a=new Map,c=[r];for(;c.length>0;){let f=c[c.length-1];s.has(f)||(s.add(f),i.push(f),a.set(f,[...t.get(f)??[]].sort()));let u=a.get(f).shift();if(u===void 0){c.pop(),s.delete(f),i.pop(),n.add(f);continue}if(s.has(u)){let h=i.indexOf(u),l=i.slice(h),p=md(l);e.set(p.join("|"),p);continue}n.has(u)||c.push(u)}}return[...e.values()].sort((r,i)=>{let s=r.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function md(t){let e=0;for(let n=1;n<t.length;n++)t[n]<t[e]&&(e=n);return[...t.slice(e),...t.slice(0,e)]}async function Rn(t){let e=[],n=[];for(let o of t)await Oe(o)?e.push(o):n.push(o);return{parties:e,context:n}}function Ce(t){let e=t.verification;return{proofHash:t.proofHash,sourcePaths:t.sources.map(n=>n.path),...e!==void 0?{verificationTier:e.tier,verificationStatus:e.status,...e.reason!==void 0?{verificationReason:e.reason}:{}}:{},...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.prevB64!==void 0?{prevB64:t.prevB64}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.measurement!==void 0?{measurement:t.measurement}:{}}}function tr(t){return[...t.entries()].sort(([e],[n])=>{let o=/^[0-9]+$/.test(e)?BigInt(e):void 0,r=/^[0-9]+$/.test(n)?BigInt(n):void 0;return o!==void 0&&r!==void 0&&o!==r?o<r?-1:1:o!==void 0&&r===void 0?-1:o===void 0&&r!==void 0?1:e<n?-1:e>n?1:0})}b();function nr(t){let e=new Map;for(let a of t.proofs){let c=JSON.stringify([a.measurement??null,a.publicKeyB64??null,a.epochId??null,a.chainId,a.hasAttestation]),f=e.get(c);if(f!==void 0){f.proofHashes.push(a.proofHash);continue}e.set(c,{...a.measurement!==void 0?{measurement:a.measurement}:{},...a.publicKeyB64!==void 0?{publicKeyB64:a.publicKeyB64}:{},...a.epochId!==void 0?{epochId:a.epochId}:{},chainId:a.chainId,attestationPresent:a.hasAttestation,proofHashes:[a.proofHash]})}let n=[...e.values()].sort(gd),o=new Map;for(let a of t.proofs)a.epochId!==void 0&&de(o,a.epochId,a);let r=[];for(let[a,c]of[...o.entries()].sort(([f],[d])=>f<d?-1:f>d?1:0)){let f=new Set,d=new Set;for(let u of c)u.publicKeyB64!==void 0&&f.add(u.publicKeyB64),u.measurement!==void 0&&d.add(u.measurement);f.size>=2&&r.push({code:"mid-epoch-signer-change",proofHashes:c.map(u=>u.proofHash),message:`${f.size} distinct signer keys appear within epoch ${a}. A single enclave boot generates exactly one keypair per epoch, so multiple keys under one epochId cannot come from one healthy authority lifecycle. All key groups are preserved for adjudication.`,details:{epochId:a,publicKeysB64:[...f].sort()}}),d.size>=2&&r.push({code:"mid-epoch-measurement-change",proofHashes:c.map(u=>u.proofHash),message:`${d.size} distinct declared measurements appear within epoch ${a}. A single enclave boot has exactly one measurement, so multiple declared measurements under one epochId cannot come from one healthy authority lifecycle. Declared measurements are self-reported; attestation validation is reported separately.`,details:{epochId:a,measurements:[...d].sort()}})}let i=new Map;for(let a of t.proofs){if(a.publicKeyB64===void 0||a.epochId===void 0)continue;let c=i.get(a.publicKeyB64);c===void 0?i.set(a.publicKeyB64,new Set([a.epochId])):c.add(a.epochId)}let s=[...i.entries()].filter(([,a])=>a.size>=2).map(([a,c])=>({publicKeyB64:a,epochIds:[...c].sort()})).sort((a,c)=>a.publicKeyB64<c.publicKeyB64?-1:a.publicKeyB64>c.publicKeyB64?1:0);return{groups:n,anomalies:r,sharedSignersAcrossEpochs:s}}function gd(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",o=e.epochId??"";if(n!==o)return n<o?-1:1;let r=t.publicKeyB64??"",i=e.publicKeyB64??"";if(r!==i)return r<i?-1:1;let s=t.measurement??"",a=e.measurement??"";return s!==a?s<a?-1:1:t.attestationPresent!==e.attestationPresent?t.attestationPresent?-1:1:0}b();var bd="Ethereum Anchor",Ls="ethereum-anchor",yd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function ir(t){let e=[],n=[],o=[];for(let r of t.proofs){let i=or(r,"name"),s=wd(r);if(!(i===bd)){s===Ls&&(n.push(r.proofHash),o.push({code:"anchor-metadata-only-claim",...rr(r),message:"unsigned metadata.type claims ethereum-anchor, but the signed attribution does not identify this proof as an anchor. Metadata is advisory and unsigned; the proof is not treated as an anchor.",details:{proofHash:r.proofHash}}));continue}let c=s===Ls?"agrees":s===void 0?"absent":"disagrees";c==="disagrees"&&o.push({code:"anchor-metadata-disagreement",...rr(r),message:`signed attribution identifies an Ethereum anchor, but unsigned metadata.type is ${JSON.stringify(s)}. The signed field governs; the disagreement is recorded.`,details:{proofHash:r.proofHash,metadataType:s}});let f=or(r,"message"),d=or(r,"title"),u=d!==void 0?yd.exec(d)?.[1]??void 0:void 0;u===void 0&&o.push({code:"anchor-title-unparseable",...rr(r),message:d===void 0?"anchor proof carries no signed attribution.title; the signed block number is absent":"anchor attribution.title does not parse as an Etherscan block URL; the signed block number is treated as absent",details:{proofHash:r.proofHash,...d!==void 0?{title:d}:{}}});let h=r.verification;e.push({proofHash:r.proofHash,...r.epochId!==void 0?{epochId:r.epochId}:{},chainId:r.chainId,...r.counter!==void 0?{counter:r.counter}:{},...r.slotCounter!==void 0?{slotCounter:r.slotCounter}:{},...f!==void 0?{blockHash:f}:{},...u!==void 0?{blockNumber:u}:{},metadataCorroboration:c,...h!==void 0?{verificationTier:h.tier,verificationStatus:h.status,...h.reason!==void 0?{verificationReason:h.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:o}}function or(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let o=n[e];return typeof o=="string"?o:void 0}function wd(t){let e=t.proof.metadata;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.type;return typeof n=="string"?n:void 0}function rr(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}b();b();var xd=BigInt(0),jt=BigInt(1),Ed=BigInt(2),Bd=BigInt(7),vd=BigInt(256),Ad=BigInt(113),Os=[],Us=[],Fs=[];for(let t=0,e=jt,n=1,o=0;t<24;t++){[n,o]=[o,(2*n+3*o)%5],Os.push(2*(5*o+n)),Us.push((t+1)*(t+2)/2%64);let r=xd;for(let i=0;i<7;i++)e=(e<<jt^(e>>Bd)*Ad)%vd,e&Ed&&(r^=jt<<(jt<<BigInt(i))-jt);Fs.push(r)}var _s=sn(Fs,!0),kd=_s[0],Id=_s[1],Ms=(t,e,n)=>n>32?li(t,e,n):ui(t,e,n),Ns=(t,e,n)=>n>32?pi(t,e,n):hi(t,e,n);function Hd(t,e=24){let n=new Uint32Array(10);for(let o=24-e;o<24;o++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,f=n[c],d=n[c+1],u=Ms(f,d,1)^n[a],h=Ns(f,d,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=u,t[s+l+1]^=h}let r=t[2],i=t[3];for(let s=0;s<24;s++){let a=Us[s],c=Ms(r,i,a),f=Ns(r,i,a),d=Os[s];r=t[d],i=t[d+1],t[d]=c,t[d+1]=f}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=kd[o],t[1]^=Id[o]}ve(n)}var sr=class t extends bt{constructor(e,n,o,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=o,this.enableXOF=r,this.rounds=i,ao(o),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ai(this.state)}clone(){return this._cloneInto()}keccak(){co(this.state32),Hd(this.state32,this.rounds),co(this.state32),this.posOut=0,this.pos=0}update(e){yt(this),e=$t(e),ot(e);let{blockLen:n,state:o}=this,r=e.length;for(let i=0;i<r;){let s=Math.min(n-this.pos,r-i);for(let a=0;a<s;a++)o[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:o,blockLen:r}=this;e[o]^=n,(n&128)!==0&&o===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){yt(this,!1),ot(e),this.finish();let n=this.state,{blockLen:o}=this;for(let r=0,i=e.length;r<i;){this.posOut>=o&&this.keccak();let s=Math.min(o-this.posOut,i-r);e.set(n.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ao(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(nn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ve(this.state)}_cloneInto(e){let{blockLen:n,suffix:o,outputLen:r,rounds:i,enableXOF:s}=this;return e||(e=new t(n,o,r,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=o,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}},Sd=(t,e,n)=>Rt(()=>new sr(e,t,n));var Ks=Sd(1,136,256/8);b();function zs(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=qs(t,0);if(n!==t.length)throw new Error(`RLP: ${t.length-n} trailing byte(s) after the top-level item`);if(!Array.isArray(e))throw new Error("RLP: top-level item is not a list");return e}function qs(t,e){let n=Gs(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=Pn(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=Vs(t,e+1,a),f=e+1+a,d=Pn(t,f,c);return{item:t.subarray(f,d),next:d}}if(n<=247){let a=n-192,c=Pn(t,e+1,a);return{item:js(t,e+1,c),next:c}}let o=n-247,r=Vs(t,e+1,o),i=e+1+o,s=Pn(t,i,r);return{item:js(t,i,s),next:s}}function js(t,e,n){let o=[],r=e;for(;r<n;){let i=qs(t,r);if(i.next>n)throw new Error("RLP: list item overruns its list payload");o.push(i.item),r=i.next}return o}function Vs(t,e,n){if(n<1||n>8)throw new Error(`RLP: invalid length-of-length ${n}`);let o=0;for(let r=0;r<n;r++)o=o*256+Gs(t,e+r);if(o>t.length)throw new Error("RLP: declared length exceeds the input size");return o}function Pn(t,e,n){let o=e+n;if(o>t.length)throw new Error("RLP: item is truncated");return o}function Gs(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function ar(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function Ws(t){if(!t.startsWith("0x"))return null;let e=t.slice(2);if(e.length%2!==0||!/^[0-9a-fA-F]*$/.test(e))return null;let n=new Uint8Array(e.length/2);for(let o=0;o<n.length;o++)n[o]=Number.parseInt(e.slice(o*2,o*2+2),16);return n}function Zs(t){return`0x${B.Buffer.from(t).toString("hex")}`}var Ys=8,Xs=11,Cd=/^0x[0-9a-fA-F]{64}$/,Td=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function fr(t,e){let n=[],o=[],r=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=$d(i);if(s.failure!==void 0){let d={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(d),o.push(cr(d));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),f=e.anchors.filter(d=>{let u=d.blockHash?.toLowerCase();return u!==void 0&&(u===a||u===c)});if(f.length===0){let d={witnessPath:i.path,verified:!1,reason:"witness-unmatched",detail:"neither the locally recomputed block hash nor the claimed blockHash matches any observed anchor's signed attribution.message",computedBlockHash:a};n.push(d),o.push(cr(d));continue}for(let d of f){let u=r.get(d.proofHash),h=u!==void 0&&await Oe(u),l=Rd(s,i.path,d.proofHash,u,h);n.push(l),l.verified||o.push(cr(l))}}return{outcomes:n,findings:o}}function $d(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return Dn("headerRlpHex is missing or not a string");let o=e.blockNumber;if(typeof o!="number"||!Number.isInteger(o)||o<0)return Dn("blockNumber is missing or not a non-negative integer");let r=e.blockHash;if(typeof r!="string"||!Cd.test(r))return Dn("blockHash is missing or not 0x followed by 64 hex characters");let i=Ws(n);if(i===null)return Dn("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=zs(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:Zs(Ks(i)),items:s,claimedHash:r,claimedNumber:BigInt(o)}}function Dn(t){return{failure:{reason:"witness-malformed",detail:t}}}function Rd(t,e,n,o,r){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(y,T,C)=>({...s,verified:!1,reason:y,detail:T,...C?.blockNumber!==void 0?{blockNumber:C.blockNumber}:{}});if(o===void 0||!r)return a("witness-anchor-invalid","the candidate anchor proof is not cryptographically valid; the witness confers nothing");let c=Pd(o);if(c===void 0||c.toLowerCase()!==i)return a("witness-hash-mismatch",c===void 0?"the anchor carries no signed attribution.message to compare against":"the locally recomputed block hash does not equal the anchor's signed attribution.message");let f=Md(Ld(o));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let d=q(new TextEncoder().encode(c));if(!Nd(d,f))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let u=t.items,h=u[Ys];if(h===void 0||!(h instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Ys} (block number) is missing or not a byte string`);let l=ar(h);if(l!==t.claimedNumber)return a("witness-block-number-mismatch",`the witness claims blockNumber ${t.claimedNumber}, but the header's number field is ${l}`,{blockNumber:String(l)});let p=Dd(o);if(p!==void 0){let y=Td.exec(p)?.[1];if(y!==void 0&&BigInt(y)!==l)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${y}, but the header's number field is ${l}`,{blockNumber:String(l)})}if(t.claimedHash.toLowerCase()!==i)return a("witness-claimed-hash-mismatch","the witness's claimed blockHash does not equal the locally recomputed block hash",{blockNumber:String(l)});let m=u[Xs];if(m===void 0||!(m instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Xs} (timestamp) is missing or not a byte string`,{blockNumber:String(l)});let x=ar(m);return x>BigInt(Number.MAX_SAFE_INTEGER)?a("witness-header-shape","header timestamp does not fit a safe integer",{blockNumber:String(l)}):{...s,verified:!0,blockNumber:String(l),timestamp:Number(x)}}function Pd(t){return Js(t,"message")}function Dd(t){return Js(t,"title")}function Js(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let o=n[e];return typeof o=="string"?o:void 0}function Ld(t){let e=t.proof.artifact;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.digestB64;return typeof n=="string"?n:void 0}function Md(t){if(t===void 0||t.length===0)return null;let e=B.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function Nd(t,e){if(t.length!==e.length)return!1;let n=0;for(let o=0;o<t.length;o++)n|=t[o]^e[o];return n===0}function cr(t){return{code:t.reason,path:t.witnessPath,message:`anchor witness rejected: ${t.detail??"verification failed"}. The witness confers nothing; the anchor proof's own standing is unchanged.`,details:{...t.anchorProofHash!==void 0?{anchorProofHash:t.anchorProofHash}:{},...t.computedBlockHash!==void 0?{computedBlockHash:t.computedBlockHash}:{}}}}b();function dr(t,e,n,o){let r=new Map(t.proofs.map(d=>[d.proofHash,d])),i=new Map;for(let d of o.outcomes)!d.verified||d.anchorProofHash===void 0||i.has(d.anchorProofHash)||i.set(d.anchorProofHash,{anchorProofHash:d.anchorProofHash,timestamp:d.timestamp,blockHash:d.computedBlockHash,...d.blockNumber!==void 0?{blockNumber:d.blockNumber}:{}});let s=[...i.keys()].sort(),a=n.anchors.map(d=>d.proofHash).filter(d=>!i.has(d)).sort(),c=[];for(let d of e.partitions)c.push(...Od(d,r,i));let f=Vd(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function Od(t,e,n){let o=t.memberProofHashes.map(h=>e.get(h)),r=new Map(o.map(h=>[h.chainHash,h])),i=o.filter(h=>n.has(h.proofHash)),s=new Map;for(let h of o){if(h.prevB64===void 0)continue;let l=r.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||de(s,l.proofHash,h)}let a=new Map,c=new Map;for(let h of i)a.set(h.proofHash,Fd(h,s)),c.set(h.proofHash,_d(h,r));let f=o.map(h=>{let l=new Map,p=new Map,m=Y(h.counter);for(let x of i){let y=x.proofHash,T=Y(x.counter);h.proofHash===y||a.get(y).has(h.proofHash)?l.set(y,"chain-link"):m!==void 0&&T!==void 0&&m>T&&(l.has(y)||l.set(y,"counter-order")),c.get(y).has(h.proofHash)?p.set(y,"chain-link"):h.proofHash!==y&&m!==void 0&&T!==void 0&&m<T&&(p.has(y)||p.set(y,"counter-order"))}return{member:h,lower:Qs("not-before",l,n),upper:Qs("not-after",p,n)}}),d=new Map;for(let h of f)de(d,Ud(h),h);let u=[];for(let h of d.values()){let l=h.map(C=>C.member).sort(Se),p=h[0],m=p.lower,x=p.upper,y=m.length>0&&x.length>0?"lower-bounded-with-following-anchor":m.length>0?"lower-bounded":x.length>0?"upper-bounded":"ordered-but-unanchored",T=Kd(l);u.push({partition:t.key,memberProofHashes:l.map(C=>C.proofHash),...T!==void 0?{positionRange:T}:{},status:y,lowerBounds:m,upperBounds:x})}return u.sort(jd),u}function Qs(t,e,n){if(e.size===0)return[];let o=[...e.entries()].map(([c,f])=>({anchorHash:c,evidenceKind:f,info:n.get(c)})),r=(c,f)=>f===void 0?!0:c.info.timestamp!==f.info.timestamp?t==="not-before"?c.info.timestamp>f.info.timestamp:c.info.timestamp<f.info.timestamp:c.evidenceKind!==f.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<f.anchorHash,i,s;for(let c of o)r(c,i)&&(i=c),c.evidenceKind==="chain-link"&&r(c,s)&&(s=c);let a=[ea(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(ea(t,s)),a}function ea(t,e){let{info:n,evidenceKind:o}=e,r=new Date(n.timestamp*1e3).toISOString(),i=n.blockNumber!==void 0?`Ethereum block ${n.blockNumber}`:"an Ethereum block",s=o==="chain-link"?"Evidence: a verified hash-link path connects these proofs and the anchor.":"Evidence: commit-counter ordering within the partition only, which relies on the authority's counter discipline rather than verifiable hash links (weaker).",a=t==="not-before"?`These proofs were committed no earlier than ${r} (unix ${n.timestamp}), the timestamp of ${i}: the block hash was unpredictable before that time and the anchor commit consumed it. Reading this as a wall-clock floor additionally assumes the anchored header is a genuine, publicly published Ethereum block: this offline audit checks the header's structure and hash binding, not proof-of-work, consensus, or chain membership, so it cannot confirm the block is real. ${s}`:`These proofs existed before the anchor commit that consumed the hash of ${i} (block timestamp ${r}, unix ${n.timestamp}). The block timestamp proves the anchor commit came at or after it, not how promptly; reading it as a wall-clock ceiling additionally assumes the anchor consumed a recently published block. ${s}`;return{kind:t,anchorProofHash:e.anchorHash,...n.blockNumber!==void 0?{blockNumber:n.blockNumber}:{},blockHash:n.blockHash,timestamp:n.timestamp,evidence:o,weaker:o==="counter-order",basis:t==="not-before"?"block-hash-unpredictability":"causal-precedence",boundClass:t==="not-before"?"evidence":"assumption",claim:t==="not-before"?a:"NOT a proof-carried upper bound. "+a}}function Ud(t){let e=n=>n.map(o=>`${o.anchorProofHash}:${o.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function Fd(t,e){let n=new Set,o=[...e.get(t.proofHash)??[]];for(;o.length>0;){let r=o.pop();if(!n.has(r.proofHash)){n.add(r.proofHash);for(let i of e.get(r.proofHash)??[])o.push(i)}}return n}function _d(t,e){let n=new Set,o=t;for(;o!==void 0&&o.prevB64!==void 0;){let r=e.get(o.prevB64);if(r===void 0||n.has(r.proofHash)||r.proofHash===t.proofHash)break;n.add(r.proofHash),o=r}return n}function Kd(t){let e,n;for(let o of t)for(let r of[o.counter,o.slotCounter]){let i=Y(r);i!==void 0&&((e===void 0||i<e)&&(e=i),(n===void 0||i>n)&&(n=i))}return e!==void 0&&n!==void 0?{min:String(e),max:String(n)}:void 0}function jd(t,e){let n=t.positionRange?.min,o=e.positionRange?.min;if(n!==void 0&&o!==void 0&&n!==o)return BigInt(n)<BigInt(o)?-1:1;if(n!==void 0&&o===void 0)return-1;if(n===void 0&&o!==void 0)return 1;let r=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return r<i?-1:r>i?1:0}function ta(t){return t?" The representative bound rests on commit-counter ordering rather than a verified hash-link path, which relies on the authority's counter discipline (weaker evidence).":""}function Vd(t,e){let n=new Map;for(let i of t.epochRelationships.epochs)n.set(i.epochId,{totalProofCount:i.proofCount,lowerCovered:new Set,upperCovered:new Set});for(let i of e){let s=i.partition.epochId;if(s===void 0)continue;let a=n.get(s);if(a!==void 0){for(let c of i.lowerBounds){for(let f of i.memberProofHashes)a.lowerCovered.add(f);(a.lowerMin===void 0||c.timestamp<a.lowerMin.timestamp||c.timestamp===a.lowerMin.timestamp&&a.lowerMin.weaker&&!c.weaker)&&(a.lowerMin={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}for(let c of i.upperBounds){for(let f of i.memberProofHashes)a.upperCovered.add(f);(a.upperMax===void 0||c.timestamp>a.upperMax.timestamp||c.timestamp===a.upperMax.timestamp&&a.upperMax.weaker&&!c.weaker)&&(a.upperMax={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}}}for(let i of t.epochRelationships.epochs){let s=n.get(i.epochId),a=[];s.lowerMin!==void 0&&a.push({kind:"not-before",anchorProofHash:s.lowerMin.anchorProofHash,...s.lowerMin.blockNumber!==void 0?{blockNumber:s.lowerMin.blockNumber}:{},blockHash:s.lowerMin.blockHash,witnessTimestamp:s.lowerMin.timestamp,coverage:"members-after-anchor",coveredProofCount:s.lowerCovered.size,totalProofCount:s.totalProofCount,basis:"block-hash-unpredictability",evidence:s.lowerMin.evidence,weaker:s.lowerMin.weaker,claim:`${s.lowerCovered.size} of ${s.totalProofCount} observed proofs of this epoch were committed no earlier than unix ${s.lowerMin.timestamp}, grounded in block-hash unpredictability through verified anchor witnesses. This additionally assumes the anchored header is a genuine, publicly published Ethereum block, which this offline audit cannot confirm.`+ta(s.lowerMin.weaker)+" The remaining proofs sit causally before the covering anchors and carry no lower bound from this evidence."}),s.upperMax!==void 0&&a.push({kind:"not-after",anchorProofHash:s.upperMax.anchorProofHash,...s.upperMax.blockNumber!==void 0?{blockNumber:s.upperMax.blockNumber}:{},blockHash:s.upperMax.blockHash,witnessTimestamp:s.upperMax.timestamp,coverage:"members-before-anchor",coveredProofCount:s.upperCovered.size,totalProofCount:s.totalProofCount,basis:"causal-precedence",evidence:s.upperMax.evidence,weaker:s.upperMax.weaker,claim:`${s.upperCovered.size} of ${s.totalProofCount} observed proofs of this epoch existed before an anchor commit that consumed a block published at unix ${s.upperMax.timestamp}. Reading that timestamp as a wall-clock ceiling additionally assumes the anchor consumed a recently published block; the causal precedence itself is verified.`+ta(s.upperMax.weaker)+" Proofs after the covering anchors are not covered."}),a.length>0&&(i.anchorBounds=a)}let o=[],r=t.epochRelationships.epochs;for(let i of r){let s=n.get(i.epochId);if(s.upperMax!==void 0)for(let a of r){if(a.epochId===i.epochId)continue;let c=n.get(a.epochId);if(c.lowerMin===void 0||s.upperMax.timestamp>=c.lowerMin.timestamp)continue;let f=s.upperMax.evidence,d=c.lowerMin.evidence,u=s.upperMax.weaker||c.lowerMin.weaker;o.push({beforeEpochId:i.epochId,afterEpochId:a.epochId,upperAnchorProofHash:s.upperMax.anchorProofHash,upperBoundTimestamp:s.upperMax.timestamp,lowerAnchorProofHash:c.lowerMin.anchorProofHash,lowerBoundTimestamp:c.lowerMin.timestamp,basis:"anchor-bounds",assumptionDependent:!0,upperEvidence:f,lowerEvidence:d,weaker:u,beforeCoveredProofCount:s.upperCovered.size,beforeTotalProofCount:s.totalProofCount,afterCoveredProofCount:c.lowerCovered.size,afterTotalProofCount:c.totalProofCount,note:`The anchor-covered portion of epoch ${i.epochId} (${s.upperCovered.size} of ${s.totalProofCount} proofs) precedes the anchor-covered portion of epoch ${a.epochId} (${c.lowerCovered.size} of ${c.totalProofCount} proofs): the first is bounded not-after unix ${s.upperMax.timestamp} and the second not-before unix ${c.lowerMin.timestamp}. One-sided evidence about the covered portions only; the not-after side rests on the anchor-freshness assumption documented on its bound.`+(u?" At least one side rests on commit-counter ordering rather than a verified hash-link path (weaker evidence), which relies on the authority's counter discipline.":"")+" This is ordering evidence, never divergence."})}}return o.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),o}b();b();var na=`-----BEGIN CERTIFICATE-----
|
|
139
|
+
"use strict";(()=>{var fc=Object.create;var oi=Object.defineProperty;var uc=Object.getOwnPropertyDescriptor;var dc=Object.getOwnPropertyNames;var hc=Object.getPrototypeOf,lc=Object.prototype.hasOwnProperty;var pc=(t,e)=>()=>(t&&(e=t(t=0)),e);var nr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var mc=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of dc(e))!lc.call(t,o)&&o!==n&&oi(t,o,{get:()=>e[o],enumerable:!(r=uc(e,o))||r.enumerable});return t};var gc=(t,e,n)=>(n=t!=null?fc(hc(t)):{},mc(e||!t||!t.__esModule?oi(n,"default",{value:t,enumerable:!0}):n,t));var ai=nr(an=>{"use strict";w();an.byteLength=yc;an.toByteArray=xc;an.fromByteArray=vc;var ve=[],pe=[],bc=typeof Uint8Array<"u"?Uint8Array:Array,rr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(it=0,ii=rr.length;it<ii;++it)ve[it]=rr[it],pe[rr.charCodeAt(it)]=it;var it,ii;pe[45]=62;pe[95]=63;function si(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function yc(t){var e=si(t),n=e[0],r=e[1];return(n+r)*3/4-r}function wc(t,e,n){return(e+n)*3/4-n}function xc(t){var e,n=si(t),r=n[0],o=n[1],i=new bc(wc(t,r,o)),s=0,a=o>0?r-4:r,c;for(c=0;c<a;c+=4)e=pe[t.charCodeAt(c)]<<18|pe[t.charCodeAt(c+1)]<<12|pe[t.charCodeAt(c+2)]<<6|pe[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return o===2&&(e=pe[t.charCodeAt(c)]<<2|pe[t.charCodeAt(c+1)]>>4,i[s++]=e&255),o===1&&(e=pe[t.charCodeAt(c)]<<10|pe[t.charCodeAt(c+1)]<<4|pe[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function Ec(t){return ve[t>>18&63]+ve[t>>12&63]+ve[t>>6&63]+ve[t&63]}function Bc(t,e,n){for(var r,o=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Ec(r));return o.join("")}function vc(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(Bc(t,s,s+i>a?a:s+i));return r===1?(e=t[n-1],o.push(ve[e>>2]+ve[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],o.push(ve[e>>10]+ve[e>>4&63]+ve[e<<2&63]+"=")),o.join("")}});var ci=nr(or=>{w();or.read=function(t,e,n,r,o){var i,s,a=o*8-r-1,c=(1<<a)-1,f=c>>1,u=-7,d=n?o-1:0,h=n?-1:1,l=t[e+d];for(d+=h,i=l&(1<<-u)-1,l>>=-u,u+=a;u>0;i=i*256+t[e+d],d+=h,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=s*256+t[e+d],d+=h,u-=8);if(i===0)i=1-f;else{if(i===c)return s?NaN:(l?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-f}return(l?-1:1)*s*Math.pow(2,i-r)};or.write=function(t,e,n,r,o,i){var s,a,c,f=i*8-o-1,u=(1<<f)-1,d=u>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,m=r?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=h/c:e+=h*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(e*c-1)*Math.pow(2,o),s=s+d):(a=e*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;t[n+l]=a&255,l+=m,a/=256,o-=8);for(s=s<<o|a,f+=o;f>0;t[n+l]=s&255,l+=m,s/=256,f-=8);t[n+l-m]|=p*128}});var ki=nr(xt=>{"use strict";w();var ir=ai(),yt=ci(),fi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;xt.Buffer=g;xt.SlowBuffer=Tc;xt.INSPECT_MAX_BYTES=50;var cn=2147483647;xt.kMaxLength=cn;g.TYPED_ARRAY_SUPPORT=Ac();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Ac(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Pe(t){if(t>cn)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,g.prototype),e}function g(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return fr(t)}return li(t,e,n)}g.poolSize=8192;function li(t,e,n){if(typeof t=="string")return Ic(t,e);if(ArrayBuffer.isView(t))return Hc(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Ae(t,ArrayBuffer)||t&&Ae(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ae(t,SharedArrayBuffer)||t&&Ae(t.buffer,SharedArrayBuffer)))return ar(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return g.from(r,e,n);let o=Sc(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return g.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}g.from=function(t,e,n){return li(t,e,n)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function pi(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function kc(t,e,n){return pi(t),t<=0?Pe(t):e!==void 0?typeof n=="string"?Pe(t).fill(e,n):Pe(t).fill(e):Pe(t)}g.alloc=function(t,e,n){return kc(t,e,n)};function fr(t){return pi(t),Pe(t<0?0:ur(t)|0)}g.allocUnsafe=function(t){return fr(t)};g.allocUnsafeSlow=function(t){return fr(t)};function Ic(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=mi(t,e)|0,r=Pe(n),o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}function sr(t){let e=t.length<0?0:ur(t.length)|0,n=Pe(e);for(let r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Hc(t){if(Ae(t,Uint8Array)){let e=new Uint8Array(t);return ar(e.buffer,e.byteOffset,e.byteLength)}return sr(t)}function ar(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&n===void 0?r=new Uint8Array(t):n===void 0?r=new Uint8Array(t,e):r=new Uint8Array(t,e,n),Object.setPrototypeOf(r,g.prototype),r}function Sc(t){if(g.isBuffer(t)){let e=ur(t.length)|0,n=Pe(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||hr(t.length)?Pe(0):sr(t);if(t.type==="Buffer"&&Array.isArray(t.data))return sr(t.data)}function ur(t){if(t>=cn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+cn.toString(16)+" bytes");return t|0}function Tc(t){return+t!=t&&(t=0),g.alloc(+t)}g.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==g.prototype};g.compare=function(e,n){if(Ae(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),Ae(n,Uint8Array)&&(n=g.from(n,n.offset,n.byteLength)),!g.isBuffer(e)||!g.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;let r=e.length,o=n.length;for(let i=0,s=Math.min(r,o);i<s;++i)if(e[i]!==n[i]){r=e[i],o=n[i];break}return r<o?-1:o<r?1:0};g.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return g.alloc(0);let r;if(n===void 0)for(n=0,r=0;r<e.length;++r)n+=e[r].length;let o=g.allocUnsafe(n),i=0;for(r=0;r<e.length;++r){let s=e[r];if(Ae(s,Uint8Array))i+s.length>o.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(g.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function mi(t,e){if(g.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ae(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let n=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return cr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Ai(t).length;default:if(o)return r?-1:cr(t).length;e=(""+e).toLowerCase(),o=!0}}g.byteLength=mi;function Cc(t,e,n){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Uc(this,e,n);case"utf8":case"utf-8":return bi(this,e,n);case"ascii":return Mc(this,e,n);case"latin1":case"binary":return Fc(this,e,n);case"base64":return Oc(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _c(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}g.prototype._isBuffer=!0;function st(t,e,n){let r=t[e];t[e]=t[n],t[n]=r}g.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<e;n+=2)st(this,n,n+1);return this};g.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<e;n+=4)st(this,n,n+3),st(this,n+1,n+2);return this};g.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<e;n+=8)st(this,n,n+7),st(this,n+1,n+6),st(this,n+2,n+5),st(this,n+3,n+4);return this};g.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?bi(this,0,e):Cc.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(e){if(!g.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:g.compare(this,e)===0};g.prototype.inspect=function(){let e="",n=xt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};fi&&(g.prototype[fi]=g.prototype.inspect);g.prototype.compare=function(e,n,r,o,i){if(Ae(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(n===void 0&&(n=0),r===void 0&&(r=e?e.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),n<0||r>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&n>=r)return 0;if(o>=i)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,o>>>=0,i>>>=0,this===e)return 0;let s=i-o,a=r-n,c=Math.min(s,a),f=this.slice(o,i),u=e.slice(n,r);for(let d=0;d<c;++d)if(f[d]!==u[d]){s=f[d],a=u[d];break}return s<a?-1:a<s?1:0};function gi(t,e,n,r,o){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,hr(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof e=="string"&&(e=g.from(e,r)),g.isBuffer(e))return e.length===0?-1:ui(t,e,n,r,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):ui(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function ui(t,e,n,r,o){let i=1,s=t.length,a=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,n/=2}function c(u,d){return i===1?u[d]:u.readUInt16BE(d*i)}let f;if(o){let u=-1;for(f=n;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*i}else u!==-1&&(f-=f-u),u=-1}else for(n+a>s&&(n=s-a),f=n;f>=0;f--){let u=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){u=!1;break}if(u)return f}return-1}g.prototype.includes=function(e,n,r){return this.indexOf(e,n,r)!==-1};g.prototype.indexOf=function(e,n,r){return gi(this,e,n,r,!0)};g.prototype.lastIndexOf=function(e,n,r){return gi(this,e,n,r,!1)};function Rc(t,e,n,r){n=Number(n)||0;let o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;let i=e.length;r>i/2&&(r=i/2);let s;for(s=0;s<r;++s){let a=parseInt(e.substr(s*2,2),16);if(hr(a))return s;t[n+s]=a}return s}function $c(t,e,n,r){return fn(cr(e,t.length-n),t,n,r)}function Pc(t,e,n,r){return fn(zc(e),t,n,r)}function Dc(t,e,n,r){return fn(Ai(e),t,n,r)}function Nc(t,e,n,r){return fn(qc(e,t.length-n),t,n,r)}g.prototype.write=function(e,n,r,o){if(n===void 0)o="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")o=n,r=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(r)?(r=r>>>0,o===void 0&&(o="utf8")):(o=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-n;if((r===void 0||r>i)&&(r=i),e.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return Rc(this,e,n,r);case"utf8":case"utf-8":return $c(this,e,n,r);case"ascii":case"latin1":case"binary":return Pc(this,e,n,r);case"base64":return Dc(this,e,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nc(this,e,n,r);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Oc(t,e,n){return e===0&&n===t.length?ir.fromByteArray(t):ir.fromByteArray(t.slice(e,n))}function bi(t,e,n){n=Math.min(t.length,n);let r=[],o=e;for(;o<n;){let i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=n){let c,f,u,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[o+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[o+1],f=t[o+2],(c&192)===128&&(f&192)===128&&(d=(i&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=t[o+1],f=t[o+2],u=t[o+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(d=(i&15)<<18|(c&63)<<12|(f&63)<<6|u&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),o+=a}return Lc(r)}var di=4096;function Lc(t){let e=t.length;if(e<=di)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=di));return n}function Mc(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]&127);return r}function Fc(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function Uc(t,e,n){let r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let i=e;i<n;++i)o+=Gc[t[i]];return o}function _c(t,e,n){let r=t.slice(e,n),o="";for(let i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+r[i+1]*256);return o}g.prototype.slice=function(e,n){let r=this.length;e=~~e,n=n===void 0?r:~~n,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<e&&(n=e);let o=this.subarray(e,n);return Object.setPrototypeOf(o,g.prototype),o};function J(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return o};g.prototype.readUintBE=g.prototype.readUIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e+--n],i=1;for(;n>0&&(i*=256);)o+=this[e+--n]*i;return o};g.prototype.readUint8=g.prototype.readUInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]|this[e+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]<<8|this[e+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};g.prototype.readBigUInt64LE=qe(function(e){e=e>>>0,wt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Ft(e,this.length-8);let o=n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+r*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});g.prototype.readBigUInt64BE=qe(function(e){e=e>>>0,wt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Ft(e,this.length-8);let o=n*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r;return(BigInt(o)<<BigInt(32))+BigInt(i)});g.prototype.readIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o};g.prototype.readIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=n,i=1,s=this[e+--o];for(;o>0&&(i*=256);)s+=this[e+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s};g.prototype.readInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};g.prototype.readInt16LE=function(e,n){e=e>>>0,n||J(e,2,this.length);let r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};g.prototype.readInt16BE=function(e,n){e=e>>>0,n||J(e,2,this.length);let r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};g.prototype.readInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};g.prototype.readInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};g.prototype.readBigInt64LE=qe(function(e){e=e>>>0,wt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Ft(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});g.prototype.readBigInt64BE=qe(function(e){e=e>>>0,wt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Ft(e,this.length-8);let o=(n<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r)});g.prototype.readFloatLE=function(e,n){return e=e>>>0,n||J(e,4,this.length),yt.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,n){return e=e>>>0,n||J(e,4,this.length),yt.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||J(e,8,this.length),yt.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||J(e,8,this.length),yt.read(this,e,!1,52,8)};function ae(t,e,n,r,o,i){if(!g.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;ae(this,e,n,r,a,0)}let i=1,s=0;for(this[n]=e&255;++s<r&&(i*=256);)this[n+s]=e/i&255;return n+r};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;ae(this,e,n,r,a,0)}let i=r-1,s=1;for(this[n+i]=e&255;--i>=0&&(s*=256);)this[n+i]=e/s&255;return n+r};g.prototype.writeUint8=g.prototype.writeUInt8=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,1,255,0),this[n]=e&255,n+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=e&255,n+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};function yi(t,e,n,r,o){vi(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,n}function wi(t,e,n,r,o){vi(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i=i>>8,t[n+6]=i,i=i>>8,t[n+5]=i,i=i>>8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s=s>>8,t[n+2]=s,s=s>>8,t[n+1]=s,s=s>>8,t[n]=s,n+8}g.prototype.writeBigUInt64LE=qe(function(e,n=0){return yi(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=qe(function(e,n=0){return wi(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);ae(this,e,n,r,c-1,-c)}let i=0,s=1,a=0;for(this[n]=e&255;++i<r&&(s*=256);)e<0&&a===0&&this[n+i-1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};g.prototype.writeIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);ae(this,e,n,r,c-1,-c)}let i=r-1,s=1,a=0;for(this[n+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[n+i+1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};g.prototype.writeInt8=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};g.prototype.writeInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,4,2147483647,-2147483648),this[n]=e&255,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4};g.prototype.writeInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||ae(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};g.prototype.writeBigInt64LE=qe(function(e,n=0){return yi(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=qe(function(e,n=0){return wi(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xi(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ei(t,e,n,r,o){return e=+e,n=n>>>0,o||xi(t,e,n,4,34028234663852886e22,-34028234663852886e22),yt.write(t,e,n,r,23,4),n+4}g.prototype.writeFloatLE=function(e,n,r){return Ei(this,e,n,!0,r)};g.prototype.writeFloatBE=function(e,n,r){return Ei(this,e,n,!1,r)};function Bi(t,e,n,r,o){return e=+e,n=n>>>0,o||xi(t,e,n,8,17976931348623157e292,-17976931348623157e292),yt.write(t,e,n,r,52,8),n+8}g.prototype.writeDoubleLE=function(e,n,r){return Bi(this,e,n,!0,r)};g.prototype.writeDoubleBE=function(e,n,r){return Bi(this,e,n,!1,r)};g.prototype.copy=function(e,n,r,o){if(!g.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!o&&o!==0&&(o=this.length),n>=e.length&&(n=e.length),n||(n=0),o>0&&o<r&&(o=r),o===r||e.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n<o-r&&(o=e.length-n+r);let i=o-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,r,o):Uint8Array.prototype.set.call(e,this.subarray(r,o),n),i};g.prototype.fill=function(e,n,r,o){if(typeof e=="string"){if(typeof n=="string"?(o=n,n=0,r=this.length):typeof r=="string"&&(o=r,r=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!g.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);let i;if(typeof e=="number")for(i=n;i<r;++i)this[i]=e;else{let s=g.isBuffer(e)?e:g.from(e,o),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-n;++i)this[i+n]=s[i%a]}return this};var bt={};function dr(t,e,n){bt[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}dr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);dr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);dr("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=hi(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=hi(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r},RangeError);function hi(t){let e="",n=t.length,r=t[0]==="-"?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function Kc(t,e,n){wt(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&Ft(e,t.length-(n+1))}function vi(t,e,n,r,o,i){if(t>n||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${n}${s}`,new bt.ERR_OUT_OF_RANGE("value",a,t)}Kc(r,o,i)}function wt(t,e){if(typeof t!="number")throw new bt.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ft(t,e,n){throw Math.floor(t)!==t?(wt(t,n),new bt.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new bt.ERR_BUFFER_OUT_OF_BOUNDS:new bt.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var jc=/[^+/0-9A-Za-z-_]/g;function Vc(t){if(t=t.split("=")[0],t=t.trim().replace(jc,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function cr(t,e){e=e||1/0;let n,r=t.length,o=null,i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function zc(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function qc(t,e){let n,r,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}function Ai(t){return ir.toByteArray(Vc(t))}function fn(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function Ae(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function hr(t){return t!==t}var Gc=(function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let r=n*16;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e})();function qe(t){return typeof BigInt>"u"?Wc:t}function Wc(){throw new Error("BigInt not supported")}});var B,w=pc(()=>{"use strict";B=gc(ki(),1);globalThis.Buffer=B.Buffer});w();w();var Zc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ne,n:un,Gx:Ii,Gy:Hi,a:lr,d:pr}=Zc,Yc=8n,Ut=32,mr=64,me=(t="")=>{throw new Error(t)},Xc=t=>typeof t=="bigint",Pi=t=>typeof t=="string",Jc=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",Bt=(t,e)=>!Jc(t)||typeof e=="number"&&e>0&&t.length!==e?me("Uint8Array expected"):t,pn=t=>new Uint8Array(t),wr=t=>Uint8Array.from(t),Di=(t,e)=>t.toString(16).padStart(e,"0"),xr=t=>Array.from(Bt(t)).map(e=>Di(e,2)).join(""),De={_0:48,_9:57,A:65,F:70,a:97,f:102},Si=t=>{if(t>=De._0&&t<=De._9)return t-De._0;if(t>=De.A&&t<=De.F)return t-(De.A-10);if(t>=De.a&&t<=De.f)return t-(De.a-10)},Er=t=>{let e="hex invalid";if(!Pi(t))return me(e);let n=t.length,r=n/2;if(n%2)return me(e);let o=pn(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Si(t.charCodeAt(s)),c=Si(t.charCodeAt(s+1));if(a===void 0||c===void 0)return me(e);o[i]=a*16+c}return o},dn=(t,e)=>Bt(Pi(t)?Er(t):wr(Bt(t)),e),Ni=()=>globalThis?.crypto,Qc=()=>Ni()?.subtle??me("crypto.subtle must be defined"),gr=(...t)=>{let e=pn(t.reduce((r,o)=>r+Bt(o).length,0)),n=0;return t.forEach(r=>{e.set(r,n),n+=r.length}),e},ef=(t=Ut)=>Ni().getRandomValues(pn(t)),hn=BigInt,at=(t,e,n,r="bad number: out of range")=>Xc(t)&&e<=t&&t<n?t:me(r),S=(t,e=ne)=>{let n=t%e;return n>=0n?n:e+n},tf=t=>S(t,un),Oi=(t,e)=>{(t===0n||e<=0n)&&me("no inverse n="+t+" mod="+e);let n=S(t,e),r=e,o=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=r/n,f=r%n,u=o-s*c,d=i-a*c;r=n,n=f,o=s,i=a,s=u,a=d}return r===1n?S(o,e):me("no inverse")};var Ti=t=>t instanceof Ne?t:me("Point expected"),br=2n**256n,Ne=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,r,o){let i=br;this.ex=at(e,0n,i),this.ey=at(n,0n,i),this.ez=at(r,1n,i),this.et=at(o,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,S(e.x*e.y))}static fromBytes(e,n=!1){let r=pr,o=wr(Bt(e,Ut)),i=e[31];o[31]=i&-129;let s=Br(o);at(s,0n,n?br:ne);let c=S(s*s),f=S(c-1n),u=S(r*c+1n),{isValid:d,value:h}=of(f,u);d||me("bad point: y not sqrt");let l=(h&1n)===1n,m=(i&128)!==0;return!n&&h===0n&&m&&me("bad point: x==0, isLastByteOdd"),m!==l&&(h=S(-h)),new t(h,s,1n,S(h*s))}assertValidity(){let e=lr,n=pr,r=this;if(r.is0())throw new Error("bad point: ZERO");let{ex:o,ey:i,ez:s,et:a}=r,c=S(o*o),f=S(i*i),u=S(s*s),d=S(u*u),h=S(c*e),l=S(u*S(h+f)),m=S(d+S(n*S(c*f)));if(l!==m)throw new Error("bad point: equation left != right (1)");let p=S(o*i),y=S(s*a);if(p!==y)throw new Error("bad point: equation left != right (2)");return this}equals(e){let{ex:n,ey:r,ez:o}=this,{ex:i,ey:s,ez:a}=Ti(e),c=S(n*a),f=S(i*o),u=S(r*a),d=S(s*o);return c===f&&u===d}is0(){return this.equals(Et)}negate(){return new t(S(-this.ex),this.ey,this.ez,S(-this.et))}double(){let{ex:e,ey:n,ez:r}=this,o=lr,i=S(e*e),s=S(n*n),a=S(2n*S(r*r)),c=S(o*i),f=e+n,u=S(S(f*f)-i-s),d=c+s,h=d-a,l=c-s,m=S(u*h),p=S(d*l),y=S(u*l),b=S(h*d);return new t(m,p,b,y)}add(e){let{ex:n,ey:r,ez:o,et:i}=this,{ex:s,ey:a,ez:c,et:f}=Ti(e),u=lr,d=pr,h=S(n*s),l=S(r*a),m=S(i*d*f),p=S(o*c),y=S((n+r)*(s+a)-h-l),b=S(p-m),I=S(p+m),v=S(l-u*h),F=S(y*b),z=S(I*v),H=S(y*v),N=S(b*I);return new t(F,z,N,H)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return Et;if(at(e,1n,un),e===1n)return this;if(this.equals(vt))return hf(e).p;let r=Et,o=vt;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?r=r.add(i):n&&(o=o.add(i));return r}toAffine(){let{ex:e,ey:n,ez:r}=this;if(this.equals(Et))return{x:0n,y:1n};let o=Oi(r,ne);return S(r*o)!==1n&&me("invalid inverse"),{x:S(e*o),y:S(n*o)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),r=nf(n);return r[31]|=e&1n?128:0,r}toHex(){return xr(this.toBytes())}clearCofactor(){return this.multiply(hn(Yc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(un/2n,!1).double();return un%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(dn(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},vt=new Ne(Ii,Hi,1n,S(Ii*Hi)),Et=new Ne(0n,1n,1n,0n);Ne.BASE=vt;Ne.ZERO=Et;var nf=t=>Er(Di(at(t,0n,br),mr)).reverse(),Br=t=>hn("0x"+xr(wr(Bt(t)).reverse())),ke=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=ne;return n},rf=t=>{let n=t*t%ne*t%ne,r=ke(n,2n)*n%ne,o=ke(r,1n)*t%ne,i=ke(o,5n)*o%ne,s=ke(i,10n)*i%ne,a=ke(s,20n)*s%ne,c=ke(a,40n)*a%ne,f=ke(c,80n)*c%ne,u=ke(f,80n)*c%ne,d=ke(u,10n)*i%ne;return{pow_p_5_8:ke(d,2n)*t%ne,b2:n}},Ci=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,of=(t,e)=>{let n=S(e*e*e),r=S(n*n*e),o=rf(t*r).pow_p_5_8,i=S(t*n*o),s=S(e*i*i),a=i,c=S(i*Ci),f=s===t,u=s===S(-t),d=s===S(-t*Ci);return f&&(i=a),(u||d)&&(i=c),(S(i)&1n)===1n&&(i=S(-i)),{isValid:f||u,value:i}},sf=t=>tf(Br(t)),af=(...t)=>mn.sha512Async(...t);var cf=t=>af(t.hashable).then(t.finish);var Li={zip215:!0},ff=(t,e,n,r=Li)=>{t=dn(t,mr),e=dn(e),n=dn(n,Ut);let{zip215:o}=r,i,s,a,c,f=Uint8Array.of();try{i=Ne.fromHex(n,o),s=Ne.fromHex(t.slice(0,Ut),o),a=Br(t.slice(Ut,mr)),c=vt.multiply(a,!1),f=gr(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:d=>{if(c==null||!o&&i.isSmallOrder())return!1;let h=sf(d);return s.add(i.multiply(h,!1)).add(c.negate()).clearCofactor().is0()}}},vr=async(t,e,n,r=Li)=>cf(ff(t,e,n,r));var mn={sha512Async:async(...t)=>{let e=Qc(),n=gr(...t);return pn(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:xr,hexToBytes:Er,concatBytes:gr,mod:S,invert:Oi,randomBytes:ef};var ln=8,uf=256,Mi=Math.ceil(uf/ln)+1,yr=2**(ln-1),df=()=>{let t=[],e=vt,n=e;for(let r=0;r<Mi;r++){n=e,t.push(n);for(let o=1;o<yr;o++)n=n.add(e),t.push(n);e=n.double()}return t},Ri,$i=(t,e)=>{let n=e.negate();return t?n:e},hf=t=>{let e=Ri||(Ri=df()),n=Et,r=vt,o=2**ln,i=o,s=hn(o-1),a=hn(ln);for(let c=0;c<Mi;c++){let f=Number(t&s);t>>=a,f>yr&&(f-=i,t+=1n);let u=c*yr,d=u,h=u+Math.abs(f)-1,l=c%2!==0,m=f<0;f===0?r=r.add($i(l,e[d])):n=n.add($i(m,e[h]))}return{p:n,f:r}};w();w();w();function pf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ar(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ct(t,...e){if(!pf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function kt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function gn(t,e){ct(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Fi(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ie(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function bn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ye(t,e){return t<<32-e|t>>>e}var mf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function bf(t){for(let e=0;e<t.length;e++)t[e]=gf(t[e]);return t}var kr=mf?t=>t:bf;function yf(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function _t(t){return typeof t=="string"&&(t=yf(t)),ct(t),t}var At=class{};function Kt(t){let e=r=>t().update(_t(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function wf(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}function Ui(t,e,n){return t&e^~t&n}function _i(t,e,n){return t&e^t&n^e&n}var jt=class extends At{constructor(e,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=bn(this.buffer)}update(e){kt(this),e=_t(e),ct(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=bn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){kt(this),gn(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,Ie(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let d=s;d<o;d++)n[d]=0;wf(r,o-8,BigInt(this.length*8),i),this.process(r,0);let a=bn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Oe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);w();var yn=BigInt(4294967295),Ki=BigInt(32);function xf(t,e=!1){return e?{h:Number(t&yn),l:Number(t>>Ki&yn)}:{h:Number(t>>Ki&yn)|0,l:Number(t&yn)|0}}function wn(t,e=!1){let n=t.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=xf(t[i],e);[r[i],o[i]]=[s,a]}return[r,o]}var Ir=(t,e,n)=>t>>>n,Hr=(t,e,n)=>t<<32-n|e>>>n,ft=(t,e,n)=>t>>>n|e<<32-n,ut=(t,e,n)=>t<<32-n|e>>>n,Vt=(t,e,n)=>t<<64-n|e>>>n-32,zt=(t,e,n)=>t>>>n-32|e<<64-n;var ji=(t,e,n)=>t<<n|e>>>32-n,Vi=(t,e,n)=>e<<n|t>>>32-n,zi=(t,e,n)=>e<<n-32|t>>>64-n,qi=(t,e,n)=>t<<n-32|e>>>64-n;function He(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}var Gi=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Wi=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Zi=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Yi=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,Xi=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),Ji=(t,e,n,r,o,i)=>e+n+r+o+i+(t/2**32|0)|0;var Bf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array(64),xn=class extends jt{constructor(e=32){super(64,e,8,!1),this.A=Oe[0]|0,this.B=Oe[1]|0,this.C=Oe[2]|0,this.D=Oe[3]|0,this.E=Oe[4]|0,this.F=Oe[5]|0,this.G=Oe[6]|0,this.H=Oe[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)Ge[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=Ge[d-15],l=Ge[d-2],m=ye(h,7)^ye(h,18)^h>>>3,p=ye(l,17)^ye(l,19)^l>>>10;Ge[d]=p+Ge[d-7]+m+Ge[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=ye(a,6)^ye(a,11)^ye(a,25),l=u+h+Ui(a,c,f)+Bf[d]+Ge[d]|0,p=(ye(r,2)^ye(r,13)^ye(r,22))+_i(r,o,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=o,o=r,r=l+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){Ie(Ge)}destroy(){this.set(0,0,0,0,0,0,0,0),Ie(this.buffer)}};var Qi=wn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),vf=Qi[0],Af=Qi[1],We=new Uint32Array(80),Ze=new Uint32Array(80),Sr=class extends jt{constructor(e=64){super(128,e,16,!1),this.Ah=Q[0]|0,this.Al=Q[1]|0,this.Bh=Q[2]|0,this.Bl=Q[3]|0,this.Ch=Q[4]|0,this.Cl=Q[5]|0,this.Dh=Q[6]|0,this.Dl=Q[7]|0,this.Eh=Q[8]|0,this.El=Q[9]|0,this.Fh=Q[10]|0,this.Fl=Q[11]|0,this.Gh=Q[12]|0,this.Gl=Q[13]|0,this.Hh=Q[14]|0,this.Hl=Q[15]|0}get(){let{Ah:e,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:d,Fl:h,Gh:l,Gl:m,Hh:p,Hl:y}=this;return[e,n,r,o,i,s,a,c,f,u,d,h,l,m,p,y]}set(e,n,r,o,i,s,a,c,f,u,d,h,l,m,p,y){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=d|0,this.Fl=h|0,this.Gh=l|0,this.Gl=m|0,this.Hh=p|0,this.Hl=y|0}process(e,n){for(let v=0;v<16;v++,n+=4)We[v]=e.getUint32(n),Ze[v]=e.getUint32(n+=4);for(let v=16;v<80;v++){let F=We[v-15]|0,z=Ze[v-15]|0,H=ft(F,z,1)^ft(F,z,8)^Ir(F,z,7),N=ut(F,z,1)^ut(F,z,8)^Hr(F,z,7),U=We[v-2]|0,Z=Ze[v-2]|0,q=ft(U,Z,19)^Vt(U,Z,61)^Ir(U,Z,6),le=ut(U,Z,19)^zt(U,Z,61)^Hr(U,Z,6),O=Zi(N,le,Ze[v-7],Ze[v-16]),ie=Yi(O,H,q,We[v-7],We[v-16]);We[v]=ie|0,Ze[v]=O|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:h,Fh:l,Fl:m,Gh:p,Gl:y,Hh:b,Hl:I}=this;for(let v=0;v<80;v++){let F=ft(d,h,14)^ft(d,h,18)^Vt(d,h,41),z=ut(d,h,14)^ut(d,h,18)^zt(d,h,41),H=d&l^~d&p,N=h&m^~h&y,U=Xi(I,z,N,Af[v],Ze[v]),Z=Ji(U,b,F,H,vf[v],We[v]),q=U|0,le=ft(r,o,28)^Vt(r,o,34)^Vt(r,o,39),O=ut(r,o,28)^zt(r,o,34)^zt(r,o,39),ie=r&i^r&a^i&a,re=o&s^o&c^s&c;b=p|0,I=y|0,p=l|0,y=m|0,l=d|0,m=h|0,{h:d,l:h}=He(f|0,u|0,Z|0,q|0),f=a|0,u=c|0,a=i|0,c=s|0,i=r|0,s=o|0;let M=Gi(q,O,re);r=Wi(M,Z,le,ie),o=M|0}({h:r,l:o}=He(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=He(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=He(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=He(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:h}=He(this.Eh|0,this.El|0,d|0,h|0),{h:l,l:m}=He(this.Fh|0,this.Fl|0,l|0,m|0),{h:p,l:y}=He(this.Gh|0,this.Gl|0,p|0,y|0),{h:b,l:I}=He(this.Hh|0,this.Hl|0,b|0,I|0),this.set(r,o,i,s,a,c,f,u,d,h,l,m,p,y,b,I)}roundClean(){Ie(We,Ze)}destroy(){Ie(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var es=Kt(()=>new xn);var En=Kt(()=>new Sr);w();w();w();function ce(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var ts=ce("fs.createReadStream"),sl=ce("fs.readFileSync"),al=ce("fs.existsSync"),cl=ce("fs.writeFileSync"),kf=ce("fs.open"),If=ce("fs.readdir"),ns=ce("fs.readFile"),Hf=ce("fs.stat"),fl=ce("fs.mkdir"),ul=ce("fs.writeFile"),rs=ce("path.join"),dl=ce("path.basename"),os=ce("zlib.createGunzip"),Sf=ce("zlib.gzipSync");w();var _=es;w();w();w();w();w();w();w();var Tf=t=>t/2**32|0,Cf=t=>t>>>0;function is(t,e,n,r){let o=Tf(n),i=Cf(n);t.setUint32(e,r?i:o,r),t.setUint32(e+4,r?o:i,r)}w();function Bn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var Tr=t=>t?`"${t}" `:"";function Le(t,e=""){if(typeof t!="number")throw new TypeError(Tr(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(Tr(e)+"expected integer >= 0, got "+t);return t}function Se(t,e,n=""){if(Bn(t)&&(e===void 0||t.length===e))return t;e!==void 0&&Le(e,"length");let r=Bn(t),o=e!==void 0?` of length ${e}`:"",i=r?`length=${t.length}`:`type=${typeof t}`,s=Tr(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function vn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Le(t.outputLen),Le(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var ss=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function It(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function An(t,e){Se(t,void 0,"output");let n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function qt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function kn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function we(t,e){return t<<32-e|t>>>e}var cs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Rf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function In(t){if(Se(t),cs)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Rf[t[n]];return e}function as(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Cr(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(cs)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){let s=as(t.charCodeAt(i)),a=as(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=s*16+a}return r}function fs(...t){let e=0;for(let r=0;r<t.length;r++){let o=t[r];Se(o),e+=o.length}let n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){let i=t[r];n.set(i,o),o+=i.length}return n}function $f(t,e,n="opts"){return ss(t,"defaults"),e!==void 0&&ss(e,n),Object.assign(t,e)}function us(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=$f({},e,"info");let n=(o,i)=>t(i).update(o).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=o=>t(o),Object.assign(n,e),Object.freeze(n)}function ds(t=32){Le(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var hs=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ls(t,e,n){return t&e^~t&n}function ps(t,e,n){return t&e^t&n^e&n}var Hn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,r,o){this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=kn(this.buffer)}update(e){It(this),Se(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(o-this.pos,i-a);if(c===o){let f=kn(e);for(;o<=i-a;a+=o)this.process(f,a);s=!0;continue}r.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){It(this),An(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>o-s&&(this.process(r,0),n.fill(0)),is(r,o-8,this.length*8,i),this.process(r,0),this.roundClean();let a=e===n?r:kn(e),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneIntoMeta(e){let{buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,s&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ms=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Pf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ye=new Uint32Array(64),Rr=class extends Hn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,n){super(64,e,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let d=0;d<16;d++,n+=4)Ye[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=Ye[d-15],l=Ye[d-2],m=we(h,7)^we(h,18)^h>>>3,p=we(l,17)^we(l,19)^l>>>10;Ye[d]=p+Ye[d-7]+m+Ye[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=we(a,6)^we(a,11)^we(a,25),l=u+h+ls(a,c,f)+Pf[d]+Ye[d]|0,p=(we(r,2)^we(r,13)^we(r,22))+ps(r,o,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=o,o=r,r=l+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){qt(Ye)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),qt(this.buffer)}},$r=class extends Rr{constructor(){super(32,ms)}};var gs=us(()=>new $r,hs(1));w();function Tn(t,e,n=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let r=0;r<t.length;r++)n(t[r],`${e}[${r}]`);return t}var X=(t,e,n)=>Se(t,e,n),Pr=Le;function ys(t,e=""){if(typeof t!="string"){let n=e&&`"${e}" `;throw new TypeError(n+"expected string, got type="+typeof t)}return t}function Xe(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function dt(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var Dr=In,Me=(...t)=>fs(...t),Cn=t=>Cr(t),Ht=Bn,Rn=t=>ds(t),Sn=BigInt(0),bs=BigInt(1),Df=t=>t?`"${t}" `:"";function Te(t,e=""){if(typeof t!="boolean")throw new TypeError(Df(e)+"expected boolean, got type="+typeof t);return t}function $n(t){if(typeof t=="bigint"){if(!Je(t))throw new RangeError("positive bigint expected, got "+t)}else Pr(t);return t}function St(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(n+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let n=e&&`"${e}" `;throw new RangeError(n+"expected safe integer, got "+t)}}function Gt(t){let e=$n(t).toString(16);return e.length&1?"0"+e:e}function ws(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Sn:BigInt("0x"+t)}function Ce(t){return ws(In(t))}function Nr(t){return ws(In(Nf(Se(t)).reverse()))}function Pn(t,e){if(Le(e),e===0)throw new Error("zero output length is invalid");t=$n(t);let n=e*2,r=t.toString(16);if(r.length>n)throw new RangeError("number is too large");return Cr(r.padStart(n,"0"))}function Or(t,e){return Pn(t,e).reverse()}function Nf(t){return Uint8Array.from(X(t))}function Je(t){return typeof t=="bigint"&&Sn<=t}function Lr(t,e,n){return Je(t)&&Je(e)&&Je(n)&&e<=t&&t<n}function Mr(t,e,n,r){if(!Lr(e,n,r))throw new RangeError("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function Tt(t){if(t<Sn)throw new Error("expected non-negative bigint, got "+t);return t===Sn?0:t.toString(2).length}var Wt=t=>(St(t,"n"),(bs<<BigInt(t))-bs);function xs(t,e,n){if(Le(t,"hashLen"),Le(e,"qByteLen"),typeof n!="function")throw new TypeError("hmacFn must be a function");let r=y=>new Uint8Array(y),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=r(t),f=r(t),u=0,d=()=>{c.fill(1),f.fill(0),u=0},h=(...y)=>n(f,Me(c,...y)),l=(y=o)=>{f=h(i,y),c=h(),y.length!==0&&(f=h(s,y),c=h())},m=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let y=0,b=[];for(;y<e;){c=h();let I=c.slice();b.push(I),y+=c.length}return Me(...b)};return(y,b)=>{d(),l(y);let I;for(;(I=b(m()))===void 0;)l();return d(),I}}function Qe(t,e={},n={},r="object"){Xe(t,r),Xe(e,"fields"),Xe(n,"optFields");function o(s,a,c){let f=r==="object"?`param "${String(s)}"`:`"${r}.${String(s)}"`,u=t[s];if(!Object.hasOwn(t,s)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let d=typeof u;if(d!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${d}`)}let i=(s,a)=>Object.entries(s).forEach(([c,f])=>o(c,f,a));i(e,!1),i(n,!0)}w();w();var ee=BigInt(0),V=BigInt(1),et=BigInt(2),As=BigInt(3),Fr=BigInt(4),ks=BigInt(5),Of=BigInt(7),Is=BigInt(8),Lf=BigInt(9),Mf=BigInt(15),Hs=BigInt(16),Ff=BigInt("0x10000000000000000");function de(t,e){if(e<=ee)throw new Error("mod: expected positive modulus, got "+e);let n=t%e;return n>=ee?n:e+n}function Ss(t,e,n){if(n<=V)throw new Error("pow: expected modulus > 1, got "+n);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<ee)throw new Error("invalid exponent, negatives unsupported");if(e===ee)return V;if(e===V)return t;let r=t%n;if(r<ee&&(r+=n),e<Ff){let a=V;for(;e>ee;)e&V&&(a=a*r%n),r=r*r%n,e>>=V;return a}let o=[];for(;e>ee;)o.push(Number(e&Mf)),e>>=Fr;let i=new Array(16);i[0]=V,i[1]=r;for(let a=2;a<16;a++)i[a]=i[a-1]*r%n;let s=i[o[o.length-1]];for(let a=o.length-2;a>=0;a--){s=s*s%n,s=s*s%n,s=s*s%n,s=s*s%n;let c=o[a];c!==0&&(s=s*i[c]%n)}return s}function Es(t,e){if(t===ee)throw new Error("invert: expected non-zero number");if(e<=V)throw new Error("invert: expected modulus > 1, got "+e);let n=de(t,e),r=e,o=ee,i=V;for(;n!==ee;){let a=r/n,c=r-n*a,f=o-i*a;r=n,n=c,o=i,i=f}if(r!==V)throw new Error("invert: does not exist");return de(o,e)}function Ts(t,e){if(e<=V)throw new Error("invertCt: expected prime modulus > 1, got "+e);let n=de(t,e);if(n===ee)throw new Error("invertCt: expected non-zero number");let r=Ss(n,e-et,e);if(de(n*r,e)!==V)throw new Error("invertCt: does not exist");return r}function Ur(t,e,n){let r=t;if(!r.eql(r.sqr(e),n))throw new Error("Cannot find square root")}function _r(t,e){if((t&V)===ee)throw new Error(e+": expected odd modulus, got "+t)}function Cs(t,e){let n=t,r=(n.ORDER+V)/Fr,o=n.pow(e,r);return Ur(n,o,e),o}function Uf(t,e){let n=t,r=(n.ORDER-ks)/Is,o=n.mul(e,et),i=n.pow(o,r),s=n.mul(e,i),a=n.mul(n.mul(s,et),i),c=n.mul(s,n.sub(a,n.ONE));return Ur(n,c,e),c}function _f(t){let e=Nn(t),n=Rs(t),r=n(e,e.neg(e.ONE)),o=n(e,r),i=n(e,e.neg(r)),s=(t+Of)/Hs;return((a,c)=>{let f=a,u=f.pow(c,s),d=f.mul(u,r),h=f.mul(u,o),l=f.mul(u,i),m=f.eql(f.sqr(d),c),p=f.eql(f.sqr(h),c);u=f.cmov(u,d,m),d=f.cmov(l,h,p);let y=f.eql(f.sqr(d),c),b=f.cmov(u,d,y);return Ur(f,b,c),b})}function Rs(t){if(t<As)throw new Error("sqrt is not defined for small field");_r(t,"tonelliShanks");let e=t-V,n=0;for(;e%et===ee;)e/=et,n++;let r=et,o=Nn(t);for(;Bs(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Cs;let i=o.pow(r,e),s=(e+V)/et;return function(c,f){let u=c;if(u.is0(f))return f;if(Bs(u,f)!==1)throw new Error("Cannot find square root");let d=n,h=u.mul(u.ONE,i),l=u.pow(f,e),m=u.pow(f,s);for(;!u.eql(l,u.ONE);){if(u.is0(l))throw new Error("Cannot find square root: probably non-prime P");let p=1,y=u.sqr(l);for(;!u.eql(y,u.ONE);)if(p++,y=u.sqr(y),p===d)throw new Error("Cannot find square root");let b=V<<BigInt(d-p-1),I=u.pow(h,b);d=p,h=u.sqr(I),l=u.mul(l,h),m=u.mul(m,I)}return m}}function Kf(t){return _r(t,"Fp.sqrt"),t%Fr===As?Cs:t%Is===ks?Uf:t%Hs===Lf?_f(t):Rs(t)}var jf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ct(t){if(Xe(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);St(t.BYTES,"BYTES"),St(t.BITS,"BITS");for(let e of jf)dt(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=V)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Kr(t,e,n=!1){Ct(t),Tn(e,"nums"),Te(n,"passZero");let r=t,o=new Array(e.length).fill(n?r.ZERO:void 0),i=e.reduce((a,c,f)=>r.is0(c)?a:(o[f]=a,r.mul(a,c)),r.ONE),s=r.inv(i);return e.reduceRight((a,c,f)=>r.is0(c)?a:(o[f]=r.mul(a,o[f]),r.mul(a,c)),s),o}function Bs(t,e){Ct(t);let n=t;_r(n.ORDER,"FpLegendre");let r=(n.ORDER-V)/et,o=n.pow(e,r),i=n.eql(o,n.ONE),s=n.eql(o,n.ZERO),a=n.eql(o,n.neg(n.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function Vf(t,e){if(e!==void 0&&Pr(e),t<=ee)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let n=Tt(t);if(e!==void 0&&e<n)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${n})`);let r=e!==void 0?e:n,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}var vs=new WeakMap,Dn=class{ORDER;BITS;BYTES;isLE;ZERO=ee;ONE=V;_lengths;_mod;constructor(e,n={}){if(e<=V)throw new Error("invalid field: expected ORDER > 1, got "+e);let r;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(r=n.BITS),typeof n.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:n.sqrt,enumerable:!0}),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=Object.freeze(n.allowedLengths.slice())),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));let{nBitLength:o,nByteLength:i}=Vf(e,r);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return de(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ee<=e&&e<this.ORDER}is0(e){return e===ee}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&V)===V}neg(e){return de(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return de(e*e,this.ORDER)}add(e,n){return de(e+n,this.ORDER)}sub(e,n){return de(e-n,this.ORDER)}mul(e,n){return de(e*n,this.ORDER)}pow(e,n){return Ss(e,n,this.ORDER)}div(e,n){return de(e*Es(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return Es(e,this.ORDER)}sqrt(e){let n=vs.get(this);return n||vs.set(this,n=Kf(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?Or(e,this.BYTES):Pn(e,this.BYTES)}fromBytes(e,n=!1){X(e);let{_lengths:r,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Nr(e):Ce(e);if(a&&(c=de(c,s)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Kr(this,e,!0)}cmov(e,n,r){return Te(r,"condition"),r?n:e}};function Nn(t,e={}){return Object.freeze(Dn.prototype),new Dn(t,e)}function $s(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=V)throw new Error("field order must be greater than 1");let e=Tt(t-V);return Math.ceil(e/8)}function On(t){let e=$s(t);return e+Math.ceil(e/2)}function jr(t,e,n=!1){X(t);let r=t.length,o=$s(e),i=Math.max(On(e),16);if(r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);let s=n?Nr(t):Ce(t),a=de(s,e-V)+V;return n?Or(a,o):Pn(a,o)}var qr=BigInt(0),Zt=BigInt(1),zf=BigInt(4),Vr=16,Ps=128,qf=5,Ds=2**31;function Rt(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);dt(e.fromAffine,"Point.fromAffine"),dt(e.fromBytes,"Point.fromBytes"),dt(e.fromHex,"Point.fromHex"),Xe(e.BASE,"Point.BASE"),Xe(e.ZERO,"Point.ZERO"),Ct(e.Fp),Ct(e.Fn)}function Os(t,e){Rt(t),Ls(e,t);let n=Kr(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function Gf(t,e,n=1){if(!Number.isSafeInteger(t)||t<n||t>e)throw new Error("invalid window size, expected ["+n+".."+e+"], got W="+t)}function Wf(t,e){let n=t*(4*e+128);if(n>Ds)throw new Error("invalid window size: table would need ~"+Math.ceil(n/2**20)+" MiB, max "+Ds/2**20+" MiB")}function Gr(t,e){if(t!==void 0){dt(t,"randomBytes");try{let n=t(e);if(!Ht(n)||n.length!==e)return}catch{return}return t}}function Ls(t,e){Tn(t,"points"),t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function Zf(t,e,n){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,o)=>{if(!(n===void 0?e.isValid(r):Je(r)&&r<n))throw new Error("invalid scalar at index "+o)})}var Ms=new WeakMap;function zr(t){return Ms.get(t)||1}function Yf(t,e){let n=t.double(),r=[t];for(let o=1;o<e;o++)r.push(r[o-1].add(n));return r}function Xf(t,e){let n=2**e,r=n/2,o=BigInt(n-1),i=[];for(;t>qr;){let s=0;t&Zt&&(s=Number(t&o),s>=r&&(s-=n),t-=BigInt(s)),i.push(s),t>>=Zt}return i}function Jf(t,e,n){let r=2**e,o=r/2,i=BigInt(r-1),s=BigInt(e),a=[];for(let c=0;c<n;c++){let f=Number(t&i);t>>=s,f>o&&(f-=r,t+=Zt),a.push(f)}if(t!==qr)throw new Error("invalid wnaf");return a}function Qf(t,e,n){let r=0;for(let i of n)r=Math.max(r,i.length);let o=t;for(let i=r-1;i>=0;i--){i!==r-1&&(o=o.double());for(let s=0;s<n.length;s++){let a=n[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var Ln=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){Rt(e),this.randomBytes=Gr(n,Vr),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,n,r){let o=Math.ceil(r/n)+1,i=2**(n-1),s=[],a=e;for(let c=0;c<o;c++){let f=a;for(let u=0;u<i;u++)s.push(f),f=f.add(a);a=s[s.length-1].double()}return{W:n,bits:r,windows:o,comp:s}}wnafCachedCT(e,n){let{W:r,windows:o,comp:i}=e,s=2**(r-1),a=Jf(n,r,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let d=a[u],h=u*s,l=Math.abs(d)-1,m=i[h];for(let y=1;y<s;y++)m=y===l?i[h+y]:m;let p=m.negate();d===0?f=f.add(i[h]):c=c.add(d<0?p:m)}return{p:c,f}}getWnafPrecomputes(e,n,r,o){let i=this.wnafPrecomputes.get(n),s=i?.find(a=>a.W===e&&a.bits===r);return s||(s=this.buildWnafTable(n,e,r),typeof o=="function"&&(s={...s,comp:o(s.comp)}),i||(i=[],this.wnafPrecomputes.set(n,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,n){if(this.assertPoint(e),!Lr(n,Zt,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,r,o){let i=zr(e);return i===1?this.fixedWindowCT(e,n,r):this.wnafCachedCT(this.getWnafPrecomputes(i,e,r,o),n)}mulCT(e,n,r){return this.validateMulInput(e,n),this.runCT(e,n,this.bits,r)}mulCTBlinded(e,n,r){if(this.validateMulInput(e,n),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+Ps,i=this.randomBytes(Vr);if(!Ht(i)||i.length!==Vr)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=n+Ce(i)*this.Point.Fn.ORDER;return this.runCT(e,s,o,r)}fixedWindowCT(e,n,r){let o=qf,i=1<<o,s=Wt(o),a=new Array(i);a[0]=this.ZERO;for(let u=1;u<i;u++)a[u]=a[u-1].add(e);let c=Math.ceil(r/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let l=0;l<o;l++)f=f.double();let d=Number(n>>BigInt(u*o)&s),h=a[0];for(let l=1;l<i;l++)h=l===d?a[l]:h;f=f.add(h)}return{p:f,f}}shouldBlind(e,n){return this.randomBytes===void 0?!1:n===Zt?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,n,r,o){return this.shouldBlind(e,r)?this.mulCTBlinded(e,n,o):this.mulCT(e,n,o)}mulUnsafe(e,n,r){if(this.assertPoint(e),!Je(n))throw new Error("invalid scalar");let o=zr(e);if(o===1||n>=this.Point.Fn.ORDER)return Mn(this.Point,[e],[n],!0);let i=this.getWnafPrecomputes(o,e,this.bits,r);return this.wnafCachedCT(i,n).p}setWindowSize(e,n){this.assertPoint(e),Gf(n,this.bits);let r=Math.ceil((this.bits+Ps)/n)+1;Wf(r*2**(n-1),this.Point.Fp.BYTES),Ms.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return zr(e)!==1}};function Mn(t,e,n,r=!1){if(Rt(t),Ls(e,t),Te(r,"allowOversized"),Zf(n,t.Fn,r?t.Fn.ORDER**zf:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(s=>Yf(s,4)),i=n.map(s=>Xf(s,4));return Qf(t.ZERO,o,i)}function Ns(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ct(e),e}else return Nn(t,{isLE:n})}function Fs(t,e,n={},r){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);Qe(n);for(let c of["p","n","h"]){let f=e[c];if(!(Je(f)&&f!==qr))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ns(e.p,n.Fp,r),i=Ns(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function Us(t,e){return function(r){let o=t(r);return{secretKey:o,publicKey:e(o)}}}w();w();var Fn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(vn(e),Se(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),qt(o)}update(e){return It(this),this.iHash.update(e),this}digestInto(e){It(this),An(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_s=(()=>{let t=((e,n,r)=>new Fn(e,n).update(r).digest());return t.create=(e,n)=>new Fn(e,n),t})();w();var eu=BigInt(0),Wr=class extends Error{constructor(e=""){super(e)}},Fe={Err:Wr,_tlv:{encode:(t,e)=>{let{Err:n}=Fe;if(St(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(ys(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let r=e.length/2,o=Gt(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");let i=r>127?Gt(o.length/2|128):"";return Gt(t)+i+o+e},decode(t,e){let{Err:n}=Fe;e=X(e,void 0,"DER data");let r=0;if(t<0||t>255)throw new n("tlv.decode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");let o=e[r++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");let f=e.subarray(r,r+c);if(f.length!==c)throw new n("tlv.decode: length bytes not complete");if(f[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(r+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}let a=e.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+s)}}},_int:{encode(t){let{Err:e}=Fe;if($n(t),t<eu)throw new e("integer: negative integers are not allowed");let n=Gt(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){let{Err:e}=Fe;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ce(t)}},toSig(t){let{Err:e,_int:n,_tlv:r}=Fe,o=X(t,void 0,"signature"),{v:i,l:s}=r.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=r.decode(2,i),{v:f,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(f)}},hexFromSig(t){let{_tlv:e,_int:n}=Fe;Qe(t,{r:"bigint",s:"bigint"},{},"sig");let r=e.encode(2,n.encode(t.r)),o=e.encode(2,n.encode(t.s)),i=r+o;return e.encode(48,i)}},Zr=(Object.freeze(Fe._tlv),Object.freeze(Fe._int),Object.freeze(Fe));var Ks=(t,e)=>(t+(t>=0?e:-e)/js)/e;function tu(t,e,n){Mr("scalar",t,Ue,n);let[[r,o],[i,s]]=e,a=Ks(s*t,n),c=Ks(-o*t,n),f=t-a*r-c*i,u=-a*o-c*s,d=f<Ue,h=u<Ue;d&&(f=-f),h&&(u=-u);let l=Wt(Math.ceil(Tt(n)/2))+ht;if(f<Ue||f>=l||u<Ue||u>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:f,k2neg:h,k2:u}}function Jr(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Yr(t,e){Qe(t);let n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return Te(n.lowS,"lowS"),Te(n.prehash,"prehash"),n.format!==void 0&&Jr(n.format),n}var Ue=BigInt(0),ht=BigInt(1),js=BigInt(2),Xr=BigInt(3),nu=BigInt(4);function Vs(t,e={}){let n=Fs("weierstrass",t,e),r=n.Fp,o=n.Fn,i=n.CURVE,{h:s,n:a}=i;Qe(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=e,u=e.randomBytes===void 0?Rn:e.randomBytes;if(c&&(!r.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=qs(r,o);function h(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(M,E,A){if(f&&E.is0())return Uint8Array.of(0);let{x:C,y:D}=E.toAffine(),k=r.toBytes(C);if(Te(A,"isCompressed"),A){h();let x=!r.isOdd(D);return Me(zs(x),k)}else return Me(Uint8Array.of(4),k,r.toBytes(D))}function m(M){X(M,void 0,"Point");let{publicKey:E,publicKeyUncompressed:A}=d,C=M.length,D=M[0],k=M.subarray(1);if(f&&C===1&&D===0)return{x:r.ZERO,y:r.ZERO};if(C===E&&(D===2||D===3)){let x=r.fromBytes(k);if(!r.isValid(x))throw new Error("bad point: is not on curve, wrong x");let T=v(x),R;try{R=r.sqrt(T)}catch(j){let K=j instanceof Error?": "+j.message:"";throw new Error("bad point: is not on curve, sqrt error"+K)}h();let L=r.isOdd(R);return(D&1)===1!==L&&(R=r.neg(R)),{x,y:R}}else if(C===A&&D===4){let x=r.BYTES,T=r.fromBytes(k.subarray(0,x)),R=r.fromBytes(k.subarray(x,x*2));if(!F(T,R))throw new Error("bad point: is not on curve");return{x:T,y:R}}else throw new Error(`bad point: got length ${C}, expected compressed=${E} or uncompressed=${A}`)}let p=e.toBytes===void 0?l:e.toBytes,y=e.fromBytes===void 0?m:e.fromBytes,b=r.mul(i.b,Xr),I=r.is0(i.a)?M=>r.ZERO:M=>r.mul(i.a,M);function v(M){let E=r.sqr(M),A=r.mul(E,M);return r.add(r.add(A,r.mul(M,i.a)),i.b)}function F(M,E){let A=r.sqr(E),C=v(M);return r.eql(A,C)}if(!F(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let z=r.mul(r.pow(i.a,Xr),nu),H=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(z,H)))throw new Error("bad curve params: a or b");function N(M,E,A=!1){if(!r.isValid(E)||A&&r.is0(E))throw new Error(`bad point coordinate ${M}`);return E}function U(M){if(!(M instanceof O))throw new Error("Weierstrass Point expected")}function Z(M){if(!c||!c.basises)throw new Error("no endo");return tu(M,c.basises,o.ORDER)}function q(M,E,A,C){if(!o.isValid(C))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:D,k1:k,k2neg:x,k2:T}=Z(C),R=new O(r.mul(A.X,c.beta),A.Y,A.Z);M.push(D?A.negate():A,x?R.negate():R),E.push(k,T)}else M.push(A),E.push(C)}let le=new WeakSet;class O{static BASE=new O(i.Gx,i.Gy,r.ONE);static ZERO=new O(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=o;X;Y;Z;constructor(E,A,C){this.X=N("x",E),this.Y=N("y",A,!0),this.Z=N("z",C),Object.freeze(this)}static CURVE(){return i}static fromAffine(E){let{x:A,y:C}=E||{};if(!E||!r.isValid(A)||!r.isValid(C))throw new Error("invalid affine point");if(E instanceof O)throw new Error("projective point not allowed");return r.is0(A)&&r.is0(C)?O.ZERO:new O(A,C,r.ONE)}static fromBytes(E){let A=O.fromAffine(y(X(E,void 0,"point")));return A.assertValidity(),A}static fromHex(E){return O.fromBytes(Cn(E))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=6,A=!0){return re.setWindowSize(this,E),A||this.multiply(Xr),this}assertValidity(){let E=this;if(E.is0()){if(e.allowInfinityPoint&&r.is0(E.X)&&r.eql(E.Y,r.ONE)&&r.is0(E.Z))return;throw new Error("bad point: ZERO")}if(le.has(E))return;let{x:A,y:C}=E.toAffine();if(!r.isValid(A)||!r.isValid(C))throw new Error("bad point: x or y not field elements");if(!F(A,C))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");le.add(E)}hasEvenY(){let{y:E}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(E)}equals(E){U(E);let{X:A,Y:C,Z:D}=this,{X:k,Y:x,Z:T}=E,R=r.eql(r.mul(A,T),r.mul(k,D)),L=r.eql(r.mul(C,T),r.mul(x,D));return R&&L}negate(){return new O(this.X,r.neg(this.Y),this.Z)}double(){let{X:E,Y:A,Z:C}=this,D=r.ZERO,k=r.ZERO,x=r.ZERO,T=r.mul(E,E),R=r.mul(A,A),L=r.mul(C,C),P=r.mul(E,A);return P=r.add(P,P),x=r.mul(E,C),x=r.add(x,x),D=I(x),k=r.mul(b,L),k=r.add(D,k),D=r.sub(R,k),k=r.add(R,k),k=r.mul(D,k),D=r.mul(P,D),x=r.mul(b,x),L=I(L),P=r.sub(T,L),P=I(P),P=r.add(P,x),x=r.add(T,T),T=r.add(x,T),T=r.add(T,L),T=r.mul(T,P),k=r.add(k,T),L=r.mul(A,C),L=r.add(L,L),T=r.mul(L,P),D=r.sub(D,T),x=r.mul(L,R),x=r.add(x,x),x=r.add(x,x),new O(D,k,x)}add(E){U(E);let{X:A,Y:C,Z:D}=this,{X:k,Y:x,Z:T}=E,R=r.ZERO,L=r.ZERO,P=r.ZERO,j=r.mul(A,k),K=r.mul(C,x),W=r.mul(D,T),se=r.add(A,C),G=r.add(k,x);se=r.mul(se,G),G=r.add(j,K),se=r.sub(se,G),G=r.add(A,D);let te=r.add(k,T);return G=r.mul(G,te),te=r.add(j,W),G=r.sub(G,te),te=r.add(C,D),R=r.add(x,T),te=r.mul(te,R),R=r.add(K,W),te=r.sub(te,R),P=I(G),R=r.mul(b,W),P=r.add(R,P),R=r.sub(K,P),P=r.add(K,P),L=r.mul(R,P),K=r.add(j,j),K=r.add(K,j),W=I(W),G=r.mul(b,G),K=r.add(K,W),W=r.sub(j,W),W=I(W),G=r.add(G,W),j=r.mul(K,G),L=r.add(L,j),j=r.mul(te,G),R=r.mul(se,R),R=r.sub(R,j),j=r.mul(se,K),P=r.mul(te,P),P=r.add(P,j),new O(R,L,P)}subtract(E){return U(E),this.add(E.negate())}is0(){return this.equals(O.ZERO)}multiply(E){if(!o.isValidNot0(E))throw new RangeError("invalid scalar: out of range");let{p:A,f:C}=re.mulSecret(this,E,s,ie);return ie([A,C])[0]}multiplyUnsafe(E){let A=this,C=E;if(!o.isValid(C))throw new RangeError("invalid scalar: out of range");if(C===Ue||A.is0())return O.ZERO;if(C===ht)return A;if(re.hasWindowSize(this))return re.mulUnsafe(A,C,ie);let D=[],k=[];return q(D,k,A,C),Mn(O,D,k)}mulAddUnsafe(E,A,C){U(A);let D=[],k=[];return q(D,k,this,E),q(D,k,A,C),Mn(O,D,k)}toAffine(E){let A=this,C=E;if(C!=null&&!r.isValid(C))throw new RangeError('"invertedZ" expected valid field element');let{X:D,Y:k,Z:x}=A;if(r.eql(x,r.ONE))return{x:D,y:k};let T=A.is0();C==null&&(C=T?r.ONE:r.inv(x));let R=r.mul(D,C),L=r.mul(k,C),P=r.mul(x,C);if(T)return{x:r.ZERO,y:r.ZERO};if(!r.eql(P,r.ONE))throw new Error("invZ was invalid");return{x:R,y:L}}isTorsionFree(){let{isTorsionFree:E}=e;return s===ht?!0:E?E(O,this):re.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:E}=e;return s===ht?this:E?E(O,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===ht?this.is0():this.clearCofactor().is0()}toBytes(E=!0){return Te(E,"isCompressed"),this.assertValidity(),p(O,this,E)}toHex(E=!0){return Dr(this.toBytes(E))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ie=M=>Os(O,M),re=new Ln(O,u);return re.bits>=6&&O.BASE.precompute(6),Object.freeze(O.prototype),Object.freeze(O),O}function zs(t){return Uint8Array.of(t?2:3)}function qs(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function ru(t,e={}){Rt(t);let{Fn:n}=t,r=e.randomBytes===void 0?Rn:e.randomBytes,o=Object.assign(qs(t.Fp,n),{seed:Math.max(On(n.ORDER),16)});function i(l){try{let m=n.fromBytes(l);return n.isValidNot0(m)}catch{return!1}}function s(l,m){let{publicKey:p,publicKeyUncompressed:y}=o;try{let b=l.length;return m===!0&&b!==p||m===!1&&b!==y?!1:!!t.fromBytes(l)}catch{return!1}}function a(l){return l=l===void 0?r(o.seed):l,jr(X(l,o.seed,"seed"),n.ORDER)}function c(l,m=!0){return t.BASE.multiply(n.fromBytes(l)).toBytes(m)}function f(l){let{secretKey:m,publicKey:p,publicKeyUncompressed:y}=o,b=n._lengths;if(!Ht(l))return;let I=X(l,void 0,"key").length,v=I===p||I===y,F=I===m||!!b?.includes(I);if(!(v&&F))return v}function u(l,m,p=!0){if(f(l)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let y=n.fromBytes(l);return t.fromBytes(m).multiply(y).toBytes(p)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=Us(a,c);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:h,Point:t,utils:d,lengths:o})}function Gs(t,e,n={}){Rt(t);let r=e;vn(r),Qe(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},n),i=o.randomBytes===void 0?Rn:o.randomBytes,s=o.hmac===void 0?(k,x)=>_s(r,k,x):o.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:u}=c,d=On(f),h=Gr(i,d),{keygen:l,getPublicKey:m,getSharedSecret:p,utils:y,lengths:b}=ru(t,o),I={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},v=f*js+ht<a.ORDER;function F(k){let x=f>>ht;return k>x}function z(k,x){if(!c.isValidNot0(x))throw new Error(`invalid signature ${k}: out of range 1..Point.Fn.ORDER`);return x}function H(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function N(k,x,T){return H(),(k===T?0:2)|Number(a.isOdd(x))}function U(){if(v)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function Z(k,x){Jr(x);let T=b.signature,R=x==="compact"?T:x==="recovered"?T+1:void 0;return X(k,R)}class q{r;s;recovery;constructor(x,T,R){if(this.r=z("r",x),this.s=z("s",T),R!=null){if(U(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(x,T=I.format){Z(x,T);let R;if(T==="der"){let{r:K,s:W}=Zr.toSig(X(x));return new q(K,W)}T==="recovered"&&(R=x[0],T="compact",x=x.subarray(1));let L=b.signature/2,P=x.subarray(0,L),j=x.subarray(L,L*2);return new q(c.fromBytes(P),c.fromBytes(j),R)}static fromHex(x,T){return this.fromBytes(Cn(x),T)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new q(this.r,this.s,x)}recoverPublicKey(x){let{r:T,s:R}=this,L=this.assertRecovery(),P=L===2||L===3?T+f:T;if(!a.isValid(P))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let j=a.toBytes(P),K=t.fromBytes(Me(zs((L&1)===0),j)),W=c.inv(P),se=O(X(x,void 0,"msgHash")),G=c.create(-se*W),te=c.create(R*W),Ee=t.BASE.mulAddUnsafe(G,K,te);if(Ee.is0())throw new Error("invalid recovery: point at infinify");return Ee.assertValidity(),Ee}hasHighS(){return F(this.s)}toBytes(x=I.format){if(Jr(x),x==="der")return Cn(Zr.hexFromSig(this));let{r:T,s:R}=this,L=c.toBytes(T),P=c.toBytes(R);return x==="recovered"?(U(),Me(Uint8Array.of(this.assertRecovery()),L,P)):Me(L,P)}toHex(x){return Dr(this.toBytes(x))}}Object.freeze(q.prototype),Object.freeze(q);let le=o.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let T=Ce(x),R=x.length*8-u;return R>0?T>>BigInt(R):T}:o.bits2int,O=o.bits2int_modN===void 0?function(x){return c.create(le(x))}:o.bits2int_modN,ie=Wt(u);function re(k){return Mr("num < 2^"+u,k,Ue,ie),c.toBytes(k)}function M(k,x){return X(k,void 0,"message"),x?X(r(k),void 0,"prehashed message"):k}function E(k,x,T){let{lowS:R,prehash:L,extraEntropy:P}=Yr(T,I);k=M(k,L);let j=O(k),K=c.fromBytes(x);if(!c.isValidNot0(K))throw new Error("invalid private key");let W=[re(K),re(j)];if(P!=null&&P!==!1){let Ee=P===!0?i(b.secretKey):P;W.push(X(Ee,void 0,"extraEntropy"))}let se=Me(...W),G=j;function te(Ee){let gt=le(Ee);if(!c.isValidNot0(gt))return;let Lt=t.BASE.multiply(gt).toAffine(),ze=c.create(Lt.x);if(ze===Ue)return;let Be;if(h!==void 0){let Mt=Ce(jr(h(d),f)),sc=c.inv(c.mul(Mt,gt)),ac=c.mul(Mt,G),cc=c.mul(Mt,K);Be=c.create(sc*c.create(ac+cc*ze))}else{let Mt=Ts(gt,f);Be=c.create(Mt*c.create(G+ze*K))}if(Be===Ue)return;let tr=N(Lt.x,Lt.y,ze),ri=Be;return R&&F(Be)&&(ri=c.neg(Be),tr^=1),new q(ze,ri,v?void 0:tr)}return{seed:se,k2sig:te}}function A(k,x,T={}){let{seed:R,k2sig:L}=E(k,x,T);return xs(r.outputLen,c.BYTES,s)(R,L).toBytes(T.format)}function C(k,x,T,R={}){let{lowS:L,prehash:P,format:j}=Yr(R,I);if(T=X(T,void 0,"publicKey"),x=M(x,P),!Ht(k)){let K=k instanceof q?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}Z(k,j);try{let K=q.fromBytes(k,j),W=t.fromBytes(T);if(L&&K.hasHighS())return!1;let{r:se,s:G}=K,te=O(x),Ee=c.inv(G),gt=c.create(te*Ee),Lt=c.create(se*Ee),ze=t.BASE.mulAddUnsafe(gt,W,Lt);if(ze.is0())return!1;let Be=ze.toAffine();return!(c.create(Be.x)!==se||j==="recovered"&&K.recovery!==N(Be.x,Be.y,se))}catch{return!1}}function D(k,x,T={}){let{prehash:R}=Yr(T,I);return x=M(x,R),q.fromBytes(k,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:p,utils:y,lengths:b,Point:t,sign:A,verify:C,recoverPublicKey:D,Signature:q,hash:r})}var ou={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var iu=Vs(ou),Ws=Gs(iu,gs);var eo=globalThis.crypto,Qr=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=_.create();else if(n==="sha512")this.hasher=En.create();else throw new Error(`createHash: unsupported algorithm ${e} in the browser verifier`)}update(e){return this.hasher.update(typeof e=="string"?new TextEncoder().encode(e):e),this}digest(e){let n=this.hasher.digest(),r=B.Buffer.from(n);return e===void 0?r:r.toString(e)}};function Un(t){return new Qr(t)}function to(t){let e=[];return{update(n){return e.push(n),this},verify(n,r){try{let o=n instanceof Uint8Array?n:n.key,i=o.subarray(o.length-65);if(i.length!==65||i[0]!==4)return!1;let s=0;for(let f of e)s+=f.length;let a=new Uint8Array(s),c=0;for(let f of e)a.set(f,c),c+=f.length;return Ws.verify(r,_(a),i,{format:"der",prehash:!1,lowS:!1})}catch{return!1}}}}w();function xe(t){let e=Zs(t);return new TextEncoder().encode(e)}function Zs(t){return JSON.stringify(no(t))}function no(t){if(t===null||typeof t!="object"){if(typeof t>"u")throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");if(typeof t=="function"||typeof t=="symbol")throw new TypeError(`bitgraph-core/canonical: ${typeof t} values are not serializable to canonical JSON`);if(typeof t=="bigint")throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; convert to string (decimal) before canonicalizing");return t}if(Array.isArray(t))return t.map(no);let e={};for(let n of Object.keys(t).sort()){let r=t[n];typeof r>"u"||(e[n]=no(r))}return e}function _n(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}async function oo(t){let{proof:e,bytes:n,trustAnchors:r}=t,o=await Ys(e,n,r);return o===null?{valid:!0}:pu(o)}async function lt(t){let{proof:e,trustAnchors:n}=t,r=await Ys(e,void 0,n);return r===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:r}}async function Ys(t,e,n){let r=au(t);if(r!==null)return r;let o=e===void 0?void 0:_(e),i;try{i=$t(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(o!==void 0&&!_n(o,i))return"artifact digest mismatch: the provided bytes do not match the committed digest";let s;try{s=$t(t.signer.publicKeyB64)}catch{return"signer.publicKeyB64 is not valid base64"}if(s.length!==32)return`signer.publicKeyB64 decodes to ${s.length} bytes; expected 32 (Ed25519)`;let a={version:t.version,artifact:t.artifact,commit:t.commit,publicKeyB64:t.signer.publicKeyB64,enforcement:t.environment.enforcement,measurement:t.environment.measurement};t.environment.attestation!==void 0&&(a.attestationFormat=t.environment.attestation.format),t.agency!==void 0&&(a.actor=t.agency.actor),t.policy!==void 0&&(a.policy=t.policy),t.attribution!==void 0&&(a.attribution=t.attribution);let c=xe(a),f;try{f=$t(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(f.length!==64)return`signer.signatureB64 decodes to ${f.length} bytes; expected 64 (Ed25519)`;let u;try{u=await vr(f,c,s)}catch(d){return`signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!u)return"signature verification failed: signature does not match";if(t.agency!==void 0){let d=uu(t);if(d!==null)return d}if(t.slotAllocation!==void 0){let d=await du(t);if(d!==null)return d}if(t.commit.epochLink!==void 0){let d=lu(t);if(d!==null)return d}if(n!==void 0){let d=cu(t,n);if(d!==null)return d}return null}var su=new Set(["stub","hw-key","measured-tee"]);function au(t){if(t===null||typeof t!="object")return"proof must be an object";let e=t;if(e.version!=="bitgraph/1")return`unsupported proof version: ${String(e.version)}`;if(!Yt(e.artifact))return"proof.artifact is missing or not an object";let n=e.artifact;if(n.hashAlg!=="sha256")return`unsupported hashAlg: ${String(n.hashAlg)}`;if(typeof n.digestB64!="string"||n.digestB64.length===0)return"proof.artifact.digestB64 must be a non-empty string";if(!Yt(e.commit))return"proof.commit is missing or not an object";let r=e.commit;if(typeof r.nonceB64!="string"||r.nonceB64.length===0)return"proof.commit.nonceB64 must be a non-empty string";if(r.counter!==void 0&&typeof r.counter!="string")return"proof.commit.counter must be a string when present";if(r.time!==void 0&&(typeof r.time!="number"||!Number.isFinite(r.time)||r.time<0))return"proof.commit.time must be a non-negative finite number when present";if(r.prevB64!==void 0&&typeof r.prevB64!="string")return"proof.commit.prevB64 must be a string when present";if(r.epochId!==void 0&&typeof r.epochId!="string")return"proof.commit.epochId must be a string when present";if(!Yt(e.signer))return"proof.signer is missing or not an object";let o=e.signer;if(typeof o.publicKeyB64!="string"||o.publicKeyB64.length===0)return"proof.signer.publicKeyB64 must be a non-empty string";if(typeof o.signatureB64!="string"||o.signatureB64.length===0)return"proof.signer.signatureB64 must be a non-empty string";if(!Yt(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!su.has(i.enforcement))return"proof.environment.enforcement must be one of: stub, hw-key, measured-tee";if(typeof i.measurement!="string"||i.measurement.length===0)return"proof.environment.measurement must be a non-empty string";if(i.attestation!==void 0){if(!Yt(i.attestation))return"proof.environment.attestation must be an object when present";let s=i.attestation;if(typeof s.format!="string"||s.format.length===0)return"proof.environment.attestation.format must be a non-empty string";if(typeof s.reportB64!="string"||s.reportB64.length===0)return"proof.environment.attestation.reportB64 must be a non-empty string"}return null}function cu(t,e){if(e.requireEnforcement!==void 0&&t.environment.enforcement!==e.requireEnforcement)return`enforcement tier "${t.environment.enforcement}" does not meet required tier "${e.requireEnforcement}"`;if(e.allowedMeasurements!==void 0&&e.allowedMeasurements.length>0&&!e.allowedMeasurements.includes(t.environment.measurement))return`measurement "${t.environment.measurement}" is not in the allowed set`;if(e.allowedPublicKeys!==void 0&&e.allowedPublicKeys.length>0&&!e.allowedPublicKeys.includes(t.signer.publicKeyB64))return"proof public key is not in the allowed set";if(e.requireAttestation===!0&&t.environment.attestation===void 0)return"policy requires attestation but proof has none";if(e.requireAttestationFormat!==void 0&&e.requireAttestationFormat.length>0){if(t.environment.attestation===void 0)return"policy requires attestation format but proof has no attestation";if(!e.requireAttestationFormat.includes(t.environment.attestation.format))return`attestation format "${t.environment.attestation.format}" is not in the required set`}if(e.minCounter!==void 0||e.maxCounter!==void 0){if(t.commit.counter===void 0)return"policy requires a counter but proof has none";let n;try{n=BigInt(t.commit.counter)}catch{return"could not parse proof counter value as integer"}if(e.minCounter!==void 0){let r;try{r=BigInt(e.minCounter)}catch{return"could not parse policy minCounter as integer"}if(n<r)return`counter ${t.commit.counter} is below minimum ${e.minCounter}`}if(e.maxCounter!==void 0){let r;try{r=BigInt(e.maxCounter)}catch{return"could not parse policy maxCounter as integer"}if(n>r)return`counter ${t.commit.counter} is above maximum ${e.maxCounter}`}}if(e.minTime!==void 0||e.maxTime!==void 0){if(t.commit.time===void 0)return"policy requires a time field but proof has none";if(e.minTime!==void 0&&t.commit.time<e.minTime)return`commit time ${t.commit.time} is before minimum ${e.minTime}`;if(e.maxTime!==void 0&&t.commit.time>e.maxTime)return`commit time ${t.commit.time} is after maximum ${e.maxTime}`}if(e.requireEpochId===!0&&(t.commit.epochId===void 0||t.commit.epochId.length===0))return"policy requires epochId but proof has none";if(e.requireActor===!0&&t.agency===void 0)return"policy requires actor (agency) but proof has none";if(e.allowedActorKeyIds!==void 0&&e.allowedActorKeyIds.length>0){if(t.agency===void 0)return"policy requires allowed actor key ID but proof has no agency";if(!e.allowedActorKeyIds.includes(t.agency.actor.keyId))return"actor key ID is not in the allowed set"}if(e.allowedActorProviders!==void 0&&e.allowedActorProviders.length>0){if(t.agency===void 0)return"policy requires allowed actor provider but proof has no agency";if(!e.allowedActorProviders.includes(t.agency.actor.provider))return`actor provider "${t.agency.actor.provider}" is not in the allowed set`}if(e.allowedOrigins!==void 0&&e.allowedOrigins.length>0){if(t.agency===void 0)return"policy requires an allowed origin but proof has no agency";let n=t.agency.authorization;if(!("format"in n)||n.format!=="webauthn")return"policy requires an allowed WebAuthn origin but the authorization is not WebAuthn";let r;try{r=JSON.parse(n.clientDataJSON).origin}catch{r=void 0}if(typeof r!="string"||!e.allowedOrigins.includes(r))return`WebAuthn origin "${r??"(none)"}" is not in the allowed set`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function fu(t,e){if(typeof t!="string"||t.length===0)return"agency: clientDataJSON missing origin field";let n;try{n=new URL(t).hostname.toLowerCase()}catch{return"agency: clientDataJSON origin is not a valid origin"}if(!n)return"agency: clientDataJSON origin has no host";let r=e.subarray(0,32).toString("hex"),o=n.split("."),i=[];for(let a=0;a<o.length;a++){let c=o.slice(a).join(".");if(a>0&&o.length-a<2)break;i.push(c)}return i.some(a=>Un("sha256").update(a,"utf8").digest("hex")===r)?null:"agency: authenticatorData rpIdHash does not match the origin's domain"}function uu(t){let e=t.agency,{actor:n,authorization:r}=e,o="format"in r&&r.format==="webauthn";if(typeof n.keyId!="string"||n.keyId.length===0)return"agency.actor.keyId must be a non-empty string";if(typeof n.publicKeyB64!="string"||n.publicKeyB64.length===0)return"agency.actor.publicKeyB64 must be a non-empty string";if(n.algorithm!=="ES256")return`agency.actor.algorithm must be "ES256", got "${String(n.algorithm)}"`;if(typeof n.provider!="string"||n.provider.length===0)return"agency.actor.provider must be a non-empty string";if(r.purpose!=="bitgraph/commit-authorize/v1")return`agency.authorization.purpose must be "bitgraph/commit-authorize/v1", got "${String(r.purpose)}"`;if(typeof r.signatureB64!="string"||r.signatureB64.length===0)return"agency.authorization.signatureB64 must be a non-empty string";let i;try{i=B.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(Un("sha256").update(i).digest("hex")!==n.keyId)return"agency: actor.keyId does not match SHA-256 of public key";if(r.actorKeyId!==n.keyId)return"agency: authorization.actorKeyId does not match actor.keyId";if(r.artifactHash!==t.artifact.digestB64){let c=e.batchContext;if(!c||!Array.isArray(c.batchDigests)||!c.batchDigests.includes(t.artifact.digestB64)||c.batchDigests[0]!==r.artifactHash)return"agency: authorization.artifactHash does not match proof.artifact.digestB64"}let a;try{a=B.Buffer.from(r.signatureB64,"base64")}catch{return"agency.authorization.signatureB64 is not valid base64"}try{if(o){let c=r;if(typeof c.clientDataJSON!="string"||!c.clientDataJSON)return"agency: WebAuthn authorization missing clientDataJSON";if(typeof c.authenticatorDataB64!="string"||!c.authenticatorDataB64)return"agency: WebAuthn authorization missing authenticatorDataB64";let f;try{f=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(f.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${f.type}"`;if(!f.challenge)return"agency: clientDataJSON missing challenge field";let u=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;u.length%4;)u+="=";if(u!==r.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let d=B.Buffer.from(c.authenticatorDataB64,"base64");if(d.length<37)return"agency: authenticatorData too short";let h=d[32];if(!(h&1))return"agency: authenticatorData UP flag not set";if(!(h&4))return"agency: authenticatorData UV flag not set";let l=fu(f.origin,d);if(l!==null)return l;let m=Un("sha256").update(B.Buffer.from(c.clientDataJSON,"utf8")).digest(),p=B.Buffer.concat([d,m]),y=to("SHA256");if(y.update(p),!y.verify({key:i,format:"der",type:"spki"},a))return"agency: WebAuthn P-256 signature verification failed"}else{let c={purpose:r.purpose,actorKeyId:r.actorKeyId,artifactHash:r.artifactHash,challenge:r.challenge,timestamp:r.timestamp};"protocolVersion"in r&&r.protocolVersion!==void 0&&(c.protocolVersion=r.protocolVersion);let f=B.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),u=to("SHA256");if(u.update(f),!u.verify({key:i,format:"der",type:"spki"},a))return"agency: P-256 signature verification failed"}}catch(c){return`agency: P-256 signature verification error: ${c instanceof Error?c.message:String(c)}`}return null}async function du(t){let e=t.slotAllocation;if(e.version!=="bitgraph/slot/1")return`slotAllocation.version must be "bitgraph/slot/1", got "${String(e.version)}"`;if(typeof e.nonceB64!="string"||e.nonceB64.length===0)return"slotAllocation.nonceB64 must be a non-empty string";if(typeof e.counter!="string"||e.counter.length===0)return"slotAllocation.counter must be a non-empty string";if(e.time!==void 0&&(typeof e.time!="number"||!Number.isFinite(e.time)||e.time<0))return"slotAllocation.time must be a non-negative finite number when present";if(typeof e.epochId!="string"||e.epochId.length===0)return"slotAllocation.epochId must be a non-empty string";if(typeof e.publicKeyB64!="string"||e.publicKeyB64.length===0)return"slotAllocation.publicKeyB64 must be a non-empty string";if(typeof e.signatureB64!="string"||e.signatureB64.length===0)return"slotAllocation.signatureB64 must be a non-empty string";let n={version:e.version,nonceB64:e.nonceB64,counter:e.counter,...e.time!==void 0?{time:e.time}:{},epochId:e.epochId,publicKeyB64:e.publicKeyB64,...e.chainId?{chainId:e.chainId}:{}},r=xe(n),o,i;try{o=$t(e.signatureB64),i=$t(e.publicKeyB64)}catch{return"slotAllocation contains invalid base64"}if(o.length!==64)return`slotAllocation.signatureB64 decodes to ${o.length} bytes; expected 64 (Ed25519)`;if(i.length!==32)return`slotAllocation.publicKeyB64 decodes to ${i.length} bytes; expected 32 (Ed25519)`;let s;try{s=await vr(o,r,i)}catch(d){return`slotAllocation signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let d of c)if(a.has(d))return`slotAllocation body contains forbidden field '${d}' \u2014 causal independence violated`;if(typeof t.commit.slotHashB64!="string"||t.commit.slotHashB64.length===0)return"commit.slotHashB64 must be present when slotAllocation is present";let f=_(r),u;try{u=$t(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!_n(f,u))return"commit.slotHashB64 does not match SHA-256 of canonical slot body \u2014 slot binding broken";if(e.nonceB64!==t.commit.nonceB64)return"slotAllocation.nonceB64 does not match commit.nonceB64";if(typeof t.commit.slotCounter!="string"||t.commit.slotCounter.length===0)return"commit.slotCounter must be present when slotAllocation is present";if(t.commit.slotCounter!==e.counter)return"commit.slotCounter does not match slotAllocation.counter";if(t.commit.counter===void 0)return"commit.counter must be present for slot ordering verification";try{let d=BigInt(e.counter),h=BigInt(t.commit.counter);if(d>=h)return`slotAllocation.counter (${e.counter}) must be less than commit.counter (${t.commit.counter})`}catch{return"could not parse slot or commit counter as integer"}return e.publicKeyB64!==t.signer.publicKeyB64?"slotAllocation.publicKeyB64 does not match signer.publicKeyB64 \u2014 different enclave":t.commit.epochId!==void 0&&e.epochId!==t.commit.epochId?"slotAllocation.epochId does not match commit.epochId \u2014 different lifecycle":null}var ro=new Map;function hu(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=_(new TextEncoder().encode(e));return B.Buffer.from(n).toString("base64")}function lu(t){let e=t.commit.epochLink;if(typeof e.prevEpochId!="string"||e.prevEpochId.length===0)return"epochLink.prevEpochId must be a non-empty string";if(typeof e.prevPublicKeyB64!="string"||e.prevPublicKeyB64.length===0)return"epochLink.prevPublicKeyB64 must be a non-empty string";if(typeof e.prevCounter!="string"||e.prevCounter.length===0)return"epochLink.prevCounter must be a non-empty string";if(typeof e.prevProofHashB64!="string"||e.prevProofHashB64.length===0)return"epochLink.prevProofHashB64 must be a non-empty string";if(typeof e.toEpochId!="string"||e.toEpochId.length===0)return"epochLink.toEpochId must be a non-empty string";if(typeof e.toPublicKeyB64!="string"||e.toPublicKeyB64.length===0)return"epochLink.toPublicKeyB64 must be a non-empty string";try{BigInt(e.prevCounter)}catch{return"epochLink.prevCounter is not a valid decimal string"}if(t.commit.epochId!==void 0&&e.toEpochId!==t.commit.epochId)return`epochLink.toEpochId "${e.toEpochId}" does not match proof commit.epochId "${t.commit.epochId}" \u2014 successor binding broken`;if(e.toPublicKeyB64!==t.signer.publicKeyB64)return"epochLink.toPublicKeyB64 does not match proof signer.publicKeyB64 \u2014 successor binding broken";if(e.prevEpochId===e.toEpochId)return"epochLink.prevEpochId equals toEpochId \u2014 epoch link must cross epoch boundary";if(e.prevPublicKeyB64===e.toPublicKeyB64)return"epochLink.prevPublicKeyB64 equals toPublicKeyB64 \u2014 epochs must have different keys";let n=hu(e),r=ro.get(n);if(r!==void 0){if(r!==e.toEpochId)return`FORK DETECTED: predecessor (epoch=${e.prevEpochId.slice(0,12)}..., counter=${e.prevCounter}) already consumed by epoch ${r.slice(0,12)}..., but this proof claims consumption by epoch ${e.toEpochId.slice(0,12)}... \u2014 single-successor invariant violated`}else ro.set(n,e.toEpochId);return null}function _e(){ro.clear()}function pu(t){return{valid:!1,reason:t}}function Yt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function $t(t){let e=B.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}w();function Kn(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};e.attribution&&(o.attribution=e.attribution),r?.attestation&&(o.attestationFormat=r.attestation.format);let i=xe(o),s=_(i);return so(s)}var Xs=["proofHash","ethereum"];function io(t){let e=t,n=e;if(Xs.some(o=>Object.prototype.hasOwnProperty.call(e,o))){n={};for(let o of Object.keys(e))Xs.includes(o)||(n[o]=e[o])}let r=xe(n);return so(_(r))}function so(t){if(typeof B.Buffer<"u")return B.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Js(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};r?.attestation!==void 0&&(o.attestationFormat=r.attestation.format);let i=e.agency;return i!==void 0&&(o.actor=i.actor),e.policy!==void 0&&(o.policy=e.policy),e.attribution!==void 0&&(o.attribution=e.attribution),o}function ao(t){return so(_(xe(Js(t))))}w();var pt="bitgraph-fuse/1",ta=(()=>{let t=new TextEncoder().encode(pt),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})(),na=pt,co="BGFUSE01",jn=48,uo="bitgraph-fuse/manifest.json",ho="bitgraph-fuse/original",Pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xt={};for(let t=0;t<Pt.length;t++)Xt[Pt[t]]=t;function tt(t){let e="";for(let n=0;n<t.length;n+=3){let r=t[n],o=n+1<t.length?t[n+1]:0,i=n+2<t.length?t[n+2]:0;e+=Pt[r>>2]+Pt[(r&3)<<4|o>>4],e+=n+1<t.length?Pt[(o&15)<<2|i>>6]:"=",e+=n+2<t.length?Pt[i&63]:"="}return e}function Jt(t){if(typeof t!="string"||t.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))return null;let e=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-e),r=0;for(let o=0;o<t.length;o+=4){let i=Xt[t[o]]<<18|Xt[t[o+1]]<<12|(t[o+2]==="="?0:Xt[t[o+2]])<<6|(t[o+3]==="="?0:Xt[t[o+3]]);n[r++]=i>>16&255,r<n.length&&(n[r++]=i>>8&255),r<n.length&&(n[r++]=i&255)}return tt(n)!==t?null:n}function Nt(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function lo(t){if(typeof t!="string"||t.length%2!==0||!/^[0-9a-f]*$/.test(t))return null;let e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function nt(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function po(...t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}var ge=t=>new TextEncoder().encode(t);function ra(t){return{version:t.version,nonceB64:t.nonceB64,counter:t.counter,...t.time!==void 0?{time:t.time}:{},epochId:t.epochId,publicKeyB64:t.publicKeyB64,...t.chainId?{chainId:t.chainId}:{}}}function oa(t){return _(xe(ra(t)))}function ia(t){let e=Jt(t.nonceB64);if(e===null||e.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return po(ta,oa(t),e)}function zn(t){return _(ia(t))}function qn(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e!==void 0&&e.length!==32)throw new TypeError("originDigest must be 32 bytes");let n={type:pt,...e!==void 0?{origin:{algorithm:"sha256",digest:Nt(e)}}:{},slotCommitment:{algorithm:"sha256",digest:Nt(t)}};return xe(n)}function Dt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}function Vn(t){if(!Dt(t)||Object.keys(t).length!==2||t.algorithm!=="sha256"||typeof t.digest!="string")return null;let n=lo(t.digest);return n!==null&&n.length===32?n:null}function mo(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!Dt(n))return null;let r=Object.keys(n).sort(),o=r.length===2?["slotCommitment","type"]:r.length===3?["origin","slotCommitment","type"]:null;if(o===null||r.join(",")!==o.join(",")||n.type!==pt)return null;let i=Vn(n.slotCommitment);if(i===null)return null;let s;if("origin"in n){let a=Vn(n.origin);if(a===null)return null;s=a}return nt(qn(i,s),t)?s!==void 0?{commitment:i,originDigest:s}:{commitment:i}:null}var be=512,mu=8589934591;function gu(t,e){let n=t.toString(8).padStart(e-1,"0")+"\0";if(n.length!==e)throw new RangeError("field overflow");return ge(n)}function Qs(t,e){if(e>mu)throw new RangeError("container/1 entries are limited to 8 GiB");let n=new Uint8Array(be),r=ge(t);if(r.length>100)throw new RangeError("ustar name too long");n.set(r,0),n.set(ge("0000644\0"),100),n.set(ge("0000000\0"),108),n.set(ge("0000000\0"),116),n.set(gu(e,12),124),n.set(ge("00000000000\0"),136),n.set(ge(" "),148),n[156]=48,n.set(ge("ustar\0"),257),n.set(ge("00"),263);let o=0;for(let i of n)o+=i;return n.set(ge(o.toString(8).padStart(6,"0")+"\0 "),148),n}function fo(t){return(be-t%be)%be}function ea(t,e){return po(Qs(uo,e.length),e,new Uint8Array(fo(e.length)),Qs(ho,t.length),t,new Uint8Array(fo(t.length)),new Uint8Array(be*2))}function bu(t){let e=[],n=0;for(;n+be<=t.length;){let r=t.subarray(n,n+be);if(r.every(f=>f===0)){let f=t.subarray(n);return f.length!==be*2||!f.every(u=>u===0)?null:e}let o=r.indexOf(0,0),i=new TextDecoder().decode(r.subarray(0,o<0||o>100?100:o)),s=new TextDecoder().decode(r.subarray(124,135));if(!/^[0-7]{11}$/.test(s))return null;let a=parseInt(s,8);if(n+be+a>t.length)return null;let c=t.subarray(n+be,n+be+a);e.push({name:i,data:c,headerBytes:r}),n+=be+a+fo(a)}return null}var yu={id:"trailer/1",form:"A",byteExact:!0,build({original:t,commitment:e}){if(t===void 0)throw new TypeError("trailer/1 requires the original bytes");if(e.length!==32)throw new TypeError("commitment must be 32 bytes");return po(t,ge(co),new Uint8Array(8),e)},locate(t){if(t.length<jn)return null;let e=t.subarray(t.length-jn);return!nt(e.subarray(0,8),ge(co))||!e.subarray(8,16).every(n=>n===0)?null:{commitment:new Uint8Array(e.subarray(16,48)),originalBytes:t.subarray(0,t.length-jn)}}},wu={id:"container/1",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/1 requires the original bytes");let r=e??_(t);return ea(t,qn(n,r))},locate(t){let e=bu(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==uo||r.name!==ho)return null;let o=mo(n.data);if(o===null||o.originDigest===void 0)return null;let i=ea(r.data,n.data);return nt(i,t)?{commitment:o.commitment,originDigest:o.originDigest,originalBytes:r.data}:null}},xu={id:"produced/1",form:"C",byteExact:!1,build({original:t,originDigest:e,commitment:n}){if(t!==void 0)throw new TypeError("produced/1 takes no original; pass originDigest for a source reference");return qn(n,e)},locate(t){let e=mo(t);return e===null?null:e.originDigest!==void 0?{commitment:e.commitment,originDigest:e.originDigest}:{commitment:e.commitment}}},Qt=Object.freeze([yu,wu,xu]);function Gn(t){return Qt.find(e=>e.id===t)}function Ot(t){let e=t.attribution;if(e===void 0||e.name!==na)return null;let n=typeof e.title=="string"&&e.title.length>0,r={placement:n?e.title:null,placementSource:n?"attribution":null,source:"attribution"};if(typeof e.message=="string"&&e.message.length>0){let o=Jt(e.message);o!==null&&o.length===32&&(r.originDigest=o,r.originSource="attribution")}return r}function go(t,e){if(t===null)return e;if(e===null)return t;let n={...t};return n.placement===null&&e.placement!==null&&(n.placement=e.placement,n.placementSource="manifest"),n.originDigest===void 0&&e.originDigest!==void 0&&(n.originDigest=e.originDigest,n.originSource="manifest"),n}function bo(t){let e=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return null}})():t;if(!Dt(e)||e.type!==pt)return null;let n=e.manifest;if(!Dt(n)||n.placement!==void 0&&typeof n.placement!="string"||Vn(n.artifact)===null||n.origin!==void 0&&Vn(n.origin)===null||n.fusedFile!==null&&typeof n.fusedFile!="string")return null;let o=e.proof;if(!Dt(o)||o.version!=="bitgraph/1")return null;let i={type:pt,manifest:{placement:typeof n.placement=="string"?n.placement:"",...n.origin!==void 0?{origin:n.origin}:{},artifact:n.artifact,fusedFile:n.fusedFile},proof:o};if(e.fusePayload!==void 0){if(!Dt(e.fusePayload))return null;i.fusePayload=e.fusePayload}return i}function yo(t){let e=t.manifest.placement.length>0,n={placement:e?t.manifest.placement:null,placementSource:e?"manifest":null,source:"manifest"};if(t.manifest.origin!==void 0){let r=lo(t.manifest.origin.digest);r!==null&&r.length===32&&(n.originDigest=r,n.originSource="manifest")}return n}w();function Eu(t){let e=t.commit;if(typeof e.counter!="string"||typeof e.slotCounter!="string"||typeof e.epochId!="string")return null;let n;try{n=(BigInt(e.counter)-BigInt(e.slotCounter)).toString()}catch{return null}return{slotCounter:e.slotCounter,commitCounter:e.counter,epochId:e.epochId,chainId:typeof e.chainId=="string"?e.chainId:null,positions:n}}function wo(t,e,n){if(e===null)return[];let r=[];return t==="FUSED_FROM_ORIGIN"?r.push(`The supplied original rebuilds the committed fused artifact byte for byte, so these exact original bytes existed no later than commit position ${e.commitCounter}.`):t==="FUSED_DIRECT"&&n&&r.push("The fused bytes carry an origin digest that matches the signed marker; the original itself was not supplied and was not checked."),(t==="FUSED_DIRECT"||t==="FUSED_FROM_ORIGIN")&&r.push(`The exact fused bytes could not feasibly have been finalized before their signed slot allocation at position ${e.slotCounter}, and were committed no later than position ${e.commitCounter}.`),t==="RECORDED"&&r.push(`These exact bytes existed no later than commit position ${e.commitCounter}.`),r}async function xo(t){let{proof:e,bytes:n}=t,r=t.frame===void 0||t.frame===null?null:bo(t.frame)??null,o=_(n),i=tt(o),s=e?.artifact?.digestB64??"",a=(y,b,I)=>({category:y,proof:b.proof??{valid:!0},marker:b.marker??null,placement:b.placement??null,fileDigestB64:i,artifactDigestB64:s,originDigestB64:b.originDigestB64??null,slotCommitmentB64:b.slotCommitmentB64??null,span:b.span??null,policy:b.policy??{spanExceeded:!1,maxPositions:null},statements:b.statements??[],reason:I}),c=await lt(t.trustAnchors!==void 0?{proof:e,trustAnchors:t.trustAnchors}:{proof:e});if(!c.valid){let y=c.reason??"proof failed verification";return a("INVALID_UNDERLYING_PROOF",{proof:{valid:!1,reason:y}},y)}let f=go(Ot(e),r!==null?yo(r):null),u=f?.originDigest,d=u!==void 0?tt(u):null,h=Eu(e),l=t.maxPositions===void 0?null:BigInt(t.maxPositions),m={spanExceeded:l!==null&&h!==null&&BigInt(h.positions)>l,maxPositions:l===null?null:l.toString()},p={proof:{valid:!0},marker:f,originDigestB64:d,span:h,policy:m};if(i===s){if(f===null)return a("RECORDED",{...p,statements:wo("RECORDED",h,!1)},null);let y=e.slotAllocation;if(y===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so no commitment can be recomputed");let b;try{b=zn(y)}catch(H){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${H instanceof Error?H.message:String(H)}`)}let I=tt(b),v=f.placement===null?void 0:Gn(f.placement),F=v===void 0?null:v.locate(n);if(f.placement===null){for(let H of Qt){let N=H.locate(n);if(N!==null){v=H,F=N;break}}if(v===void 0)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:I},"no registered placement finds a commitment in the fused bytes")}else if(v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:I},`placement "${f.placement}" is not registered; the commitment cannot be located`);if(F===null)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:I,placement:v.id},`no ${v.id} commitment found in the fused bytes`);if(!nt(F.commitment,b))return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:I,placement:v.id},"the commitment in the fused bytes does not match the proof's slot record");let z=!1;if(u!==void 0){let H=F.originDigest??(F.originalBytes!==void 0?_(F.originalBytes):void 0);if(H!==void 0){if(!nt(H,u))return a("INVALID_ORIGIN_ATTRIBUTION",{...p,slotCommitmentB64:I,placement:v.id},f.originSource==="attribution"?"the origin digest in the signed attribution does not match the origin inside the fused bytes":"the origin digest in the manifest does not match the origin inside the fused bytes");z=!0}}return a("FUSED_DIRECT",{...p,slotCommitmentB64:I,placement:v.id,statements:wo("FUSED_DIRECT",h,z)},null)}if(u!==void 0&&nt(o,u)){let y=e.slotAllocation;if(y===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so the fused bytes cannot be rebuilt");let b;try{b=zn(y)}catch(H){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${H instanceof Error?H.message:String(H)}`)}let I=tt(b),v=f!==null&&f.placement!==null?Gn(f.placement):void 0;if(f!==null&&f.placement!==null&&v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:I},`placement "${f.placement}" is not registered; the fused bytes cannot be rebuilt`);let F=v!==void 0?[v]:Qt.filter(H=>H.byteExact),z=e.artifact.digestB64;for(let H of F){if(!H.byteExact)continue;let N;try{N=H.build({original:n,originDigest:u,commitment:b})}catch{continue}if(tt(_(N))===z)return a("FUSED_FROM_ORIGIN",{...p,slotCommitmentB64:I,placement:H.id,statements:wo("FUSED_FROM_ORIGIN",h,!0)},null)}return a("RECONSTRUCTION_MISMATCH",{...p,slotCommitmentB64:I,placement:v?.id??null},v!==void 0?`rebuilding ${v.id} from this file and the proof's slot record does not reproduce the committed artifact digest`:"no registered byte-exact placement rebuilds the committed artifact digest from this file")}return a("NO_MATCH",p,"this file matches neither the committed artifact digest nor the origin digest; the proof proves nothing about it")}w();async function*aa(t,e){let n=new Bo(t,e?.maxTotalBytes),r=e?.maxEntryCount??Number.POSITIVE_INFINITY,o=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(u,d)=>{if(u>o)throw new Error(`tar: ${d} metadata entry of ${u} bytes exceeds the ${o}-byte cap`)};for(;;){let u=await n.readExact(512);if(u===null||ku(u))return;if(++c>r)throw new Error(`tar: archive exceeds the maximum of ${r} entries`);let d=vu(u),h=d.typeflag;if(h==="x"||h==="g"){f(d.size,"PAX");let v=await sa(n,d.size);await n.skip(Wn(d.size));let F=Iu(v);h==="x"?i=F:s=Hu(s,F);continue}if(h==="L"){f(d.size,"GNU long-name");let v=await sa(n,d.size);await n.skip(Wn(d.size)),a=mt(Su(v));continue}if(h==="K"){await n.skip(d.size+Wn(d.size));continue}let l=d.name;s!==null&&s.has("path")&&(l=s.get("path")),a!==null&&(l=a),i!==null&&i.has("path")&&(l=i.get("path"));let m=d.size,p=i?.get("size")??s?.get("size");if(p!==void 0){let v=Number(p);if(!Number.isSafeInteger(v)||v<0)throw new Error("tar: invalid PAX size value");m=v}i=null,a=null;let y=h==="0"||h==="\0",b={remaining:m},I=Bu(n,b);yield{path:l,size:m,kind:y?"file":"other",typeflag:h,body:I},b.remaining>0&&(await n.skip(b.remaining),b.remaining=0),await n.skip(Wn(m))}}async function*Bu(t,e){for(;e.remaining>0;){let n=await t.readSome(e.remaining);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");e.remaining-=n.length,yield n}}async function sa(t,e){if(e===0)return new Uint8Array(0);let n=await t.readExact(e);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream)");return n}function vu(t){Au(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),r=mt(Eo(t,0,100));if(mt(Eo(t,257,6))==="ustar"){let s=mt(Eo(t,345,155));s.length>0&&(r=`${s}/${r}`)}let i=ca(t.subarray(124,136));return{name:r,size:i,typeflag:n}}function Eo(t,e,n){let r=t.subarray(e,e+n),o=r.indexOf(0);return o===-1&&(o=r.length),r.subarray(0,o)}function ca(t){if(t.length>0&&(t[0]&128)!==0){let r=0n;for(let o=0;o<t.length;o++){let i=o===0?t[0]&127:t[o];r=r<<8n|BigInt(i)}if(r>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("tar: numeric field exceeds the supported range");return Number(r)}let e=mt(t).trim().replace(/\0+$/,"").trim();if(e.length===0)return 0;let n=Number.parseInt(e,8);if(!Number.isSafeInteger(n)||n<0)throw new Error(`tar: invalid octal numeric field: "${e}"`);return n}function Au(t){let e=ca(t.subarray(148,156)),n=0;for(let r=0;r<512;r++)n+=r>=148&&r<156?32:t[r];if(n!==e)throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)")}function ku(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function Iu(t){let e=new Map,n=0;for(;n<t.length;){let r=n;for(;r<t.length&&t[r]!==32;)r++;if(r>=t.length)throw new Error("tar: malformed PAX record (no length delimiter)");let o=Number(mt(t.subarray(n,r)));if(!Number.isInteger(o)||o<=0||n+o>t.length)throw new Error("tar: malformed PAX record (bad length)");let i=t.subarray(r+1,n+o);if(i.length===0||i[i.length-1]!==10)throw new Error("tar: malformed PAX record (missing newline)");let s=mt(i.subarray(0,i.length-1)),a=s.indexOf("=");if(a===-1)throw new Error("tar: malformed PAX record (missing '=')");e.set(s.slice(0,a),s.slice(a+1)),n+=o}return e}function Hu(t,e){let n=new Map(t??[]);for(let[r,o]of e)n.set(r,o);return n}function mt(t){return new TextDecoder("utf-8").decode(t)}function Su(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var Bo=class{iter;chunks=[];head=0;available=0;ended=!1;totalPulled=0;maxTotalBytes;constructor(e,n){this.iter=e[Symbol.asyncIterator](),this.maxTotalBytes=n??Number.POSITIVE_INFINITY}async fill(){if(this.ended)return!1;let e=await this.iter.next();if(e.done===!0)return this.ended=!0,!1;let n=e.value;if(n.length>0){if(this.totalPulled+=n.length,this.totalPulled>this.maxTotalBytes)throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);this.chunks.push(n),this.available+=n.length}return!0}async readExact(e){for(;this.available<e;)if(!await this.fill()){if(this.available===0)return null;throw new Error("tar: truncated archive (unexpected end of stream)")}return this.take(e)}async readSome(e){for(;this.available===0;)if(!await this.fill())return null;let n=this.chunks[0],r=Math.min(e,n.length-this.head),o=n.subarray(this.head,this.head+r);return this.advance(r,n),o}async skip(e){let n=e;for(;n>0;){let r=await this.readSome(n);if(r===null)throw new Error("tar: truncated archive (unexpected end of stream)");n-=r.length}}take(e){let n=new Uint8Array(e),r=0;for(;r<e;){let o=this.chunks[0],i=Math.min(e-r,o.length-this.head);n.set(o.subarray(this.head,this.head+i),r),r+=i,this.advance(i,o)}return n}advance(e,n){this.head+=e,this.available-=e,this.head===n.length&&(this.chunks.shift(),this.head=0)}};function Wn(t){return(512-t%512)%512}w();var Zp=new Uint8Array([0]);function fa(t){let e=Array.from(t,r=>({pathBytes:Tu(r.path),entryDigest:r.entryDigest}));e.sort((r,o)=>Cu(r.pathBytes,o.pathBytes));let n=_.create();for(let r of e)n.update(r.entryDigest);return B.Buffer.from(n.digest()).toString("base64")}function Tu(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Cu(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let o=t[r]-e[r];if(o!==0)return o}return t.length-e.length}var ua=8*1024*1024,pa={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},da=new Uint8Array([0]),ha="manifest.json",vo="bitgraph-bundle/1",Ru="bitgraph-anchor-witness/1";var ma=new WeakMap;async function Ao(t,e){let n=[],r=0,o=0,i=[],s=new Map,a=Array.from(t).sort((f,u)=>f.path<u.path?-1:f.path>u.path?1:0);for(let f of a){o++;let u=ya(f.path);if(u.unsafe){r++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${u.reason}`});continue}let d=await Nu(u.path,void 0,void 0,ga(f.open()));i.push(Ou(u.path,d)),s.set(u.path,f)}let c=Pu({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:o,skippedUnsafePaths:r});return ma.set(c,s),c}async function*ga(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function $u(t){let e=[],n=0;for await(let r of ga(t.open()))e.push(r),n+=r.length;return Io(e,n)}function Pu(t){let{bundlePath:e,container:n,scanned:r,strippedRootPrefix:o,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let H of r){let N=H.rawPath,U=H.entryDigestFull;o!==void 0&&(N=H.rawPath.slice(o.length+1),U=H.entryDigestStripped),c.has(N)&&i.push({code:"duplicate-path",path:N,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(N,{path:N,sha256Hex:H.sha256Hex,byteLength:H.byteLength,entryDigest:U,...H.json!==void 0?{json:H.json}:{}})}let f=Array.from(c.values()),u=fa(f.filter(H=>H.path!==ha).map(H=>({path:H.path,entryDigest:H.entryDigest}))),d=[],h=new Map,l=[],m=[],p=new Map,y,b=0,I=0,v=0;for(let H of f){if(H.path===ha){y=Ku(H,u,i);continue}let N=H.json;if(N!==void 0&&Mu(N)){let U=N.version;if(U==="bitgraph/1"){b++;let Z=Fu(H,N,h,d,i);Z==="exact-duplicate"&&I++,Z==="semantic-duplicate"&&v++;continue}l.push({code:"unsupported-version",path:H.path,version:U,fileSha256Hex:H.sha256Hex}),i.push({code:"unsupported-version",path:H.path,message:`proof-shaped file rejected: version "${U}" is not "bitgraph/1"`,details:{version:U}}),la(H,p);continue}if(N!==void 0&&N.version===Ru){m.push({path:H.path,fileSha256Hex:H.sha256Hex,witness:N});continue}la(H,p)}for(let H of d){let N=_u(H.proof.artifact);if(N===null)continue;let U=p.get(N);U!==void 0&&U.matchedProofHashes.push(H.proofHash)}let F=Array.from(p.values()),z={observed:d.length,proofFiles:b,exactDuplicates:I,semanticDuplicates:v,unsupportedVersion:l.length,artifacts:F.length,witnesses:m.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...o!==void 0?{strippedRootPrefix:o}:{},entriesScanned:s,proofs:d,unsupportedVersions:l,artifacts:F,witnesses:m,...y!==void 0?{manifest:y}:{},computedContentsHashB64:u,findings:i,counts:z}}async function*en(t){yield*ba(t,t.artifacts.filter(e=>e.matchedProofHashes.length>0))}async function*ko(t,e){let n=new Set(e);n.size!==0&&(yield*ba(t,t.artifacts.filter(r=>n.has(r.sha256Hex))))}async function*ba(t,e){if(e.length===0)return;if(t.container==="memory"){let s=ma.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let f=s.get(c);if(f===void 0)continue;let u;try{u=await $u(f)}catch{continue}if(Zn(_(u))===a.sha256Hex){yield{sha256Hex:a.sha256Hex,path:c,bytes:u};break}}return}if(t.container==="directory"){for(let s of e)for(let a of s.paths){let c;try{c=new Uint8Array(await ns(rs(t.bundlePath,...a.split("/"))))}catch{continue}if(Zn(_(c))===s.sha256Hex){yield{sha256Hex:s.sha256Hex,path:a,bytes:c};break}}return}let n=new Map;for(let s of e)for(let a of s.paths)n.set(a,s);let r=new Set,{stream:o,close:i}=Du(t.bundlePath,t.container);try{for await(let s of aa(o,pa)){if(r.size===e.length)break;if(s.kind!=="file")continue;let a=ya(s.path);if(a.unsafe)continue;let c=a.path;if(t.strippedRootPrefix!==void 0){if(!c.startsWith(`${t.strippedRootPrefix}/`))continue;c=c.slice(t.strippedRootPrefix.length+1)}let f=n.get(c);if(f===void 0||r.has(f.sha256Hex))continue;let u=[],d=0;for await(let l of s.body)u.push(l.slice()),d+=l.length;let h=Io(u,d);Zn(_(h))===f.sha256Hex&&(r.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:h})}}finally{i()}}function Du(t,e){let n=ts(t);if(e==="tar-gz"){let r=os();return n.pipe(r),n.on("error",o=>r.destroy(o)),{stream:r,close:()=>{r.destroy(),n.destroy()}}}return{stream:n,close:()=>n.destroy()}}async function Nu(t,e,n,r){let o=new TextEncoder,i=_.create(),s=_.create();s.update(o.encode(t)),s.update(da);let a=e===void 0?void 0:_.create();a!==void 0&&(a.update(o.encode(e)),a.update(da));let c=n===void 0||n<=ua,f=[],u=0;for await(let d of r)i.update(d),s.update(d),a?.update(d),u+=d.length,c&&(u>ua?(f.length=0,c=!1):f.push(d.slice()));return{sha256Hex:Zn(i.digest()),byteLength:u,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:Io(f,u)}:{}}}function Ou(t,e){let n=e.buffered===void 0?void 0:Lu(e.buffered);return{rawPath:t,sha256Hex:e.sha256Hex,byteLength:e.byteLength,entryDigestFull:e.entryDigestFull,...e.entryDigestStripped!==void 0?{entryDigestStripped:e.entryDigestStripped}:{},...n!==void 0?{json:n}:{}}}function Lu(t){let e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let n;try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}let r;try{r=JSON.parse(n)}catch{return}if(!(r===null||typeof r!="object"||Array.isArray(r)))return r}function ya(t){if(t.includes("\0"))return{path:t,unsafe:!0,reason:"path contains a NUL byte"};let e=t.startsWith("/"),n=t.split("/").filter(o=>o!==""&&o!=="."),r=n.join("/");return e?{path:r,unsafe:!0,reason:"absolute path"}:n.some(o=>o==="..")?{path:r,unsafe:!0,reason:"path escapes the bundle root"}:r===""?{path:r,unsafe:!0,reason:"empty path"}:{path:r,unsafe:!1}}function fe(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Mu(t){return fe(t)?typeof t.version=="string"&&fe(t.artifact)&&fe(t.commit)&&fe(t.signer):!1}function Fu(t,e,n,r,o){let i=Kn(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=Uu(e,i);a==="mismatch"&&o.push({code:"proofhash-mismatch",path:t.path,message:"embedded proofHash does not match the computed canonical proof hash",details:{embedded:e.proofHash,computed:i}});let c=n.get(i);if(c!==void 0){let y=c.sources.some(b=>b.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),o.push({code:y?"exact-duplicate":"semantic-duplicate",path:t.path,message:y?"byte-identical copy of an already observed proof":"different byte encoding of an already observed proof (same canonical identity)",details:{proofHash:i,firstObservedAt:c.sources[0].path}}),y?"exact-duplicate":"semantic-duplicate"}let f=fe(e.commit)?e.commit:{},u=fe(e.signer)?e.signer:{},d=fe(e.environment)?e.environment:{},h=he(f.counter),l=he(f.epochId),m=he(f.chainId),p={proofHash:i,chainHash:io(e),proof:e,sources:[s],version:"bitgraph/1",...h!==void 0?{counter:h}:{},...he(f.slotCounter)!==void 0?{slotCounter:he(f.slotCounter)}:{},...he(f.prevB64)!==void 0?{prevB64:he(f.prevB64)}:{},...l!==void 0?{epochId:l}:{},chainId:m!==void 0&&m.length>0?m:"global",...he(u.publicKeyB64)!==void 0?{publicKeyB64:he(u.publicKeyB64)}:{},...he(d.measurement)!==void 0?{measurement:he(d.measurement)}:{},...he(d.enforcement)!==void 0?{enforcement:he(d.enforcement)}:{},hasSlotAllocation:fe(e.slotAllocation),hasAttestation:fe(d.attestation),hasAgency:fe(e.agency),hasEpochLink:fe(f.epochLink),embeddedProofHash:a,chainless:h===void 0&&l===void 0};return n.set(i,p),r.push(p),"new"}function Uu(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function he(t){return typeof t=="string"?t:void 0}function la(t,e){let n=e.get(t.sha256Hex);if(n!==void 0){n.paths.push(t.path);return}e.set(t.sha256Hex,{sha256Hex:t.sha256Hex,sha256B64:B.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function _u(t){if(!fe(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function Ku(t,e,n){if(t.json===void 0)return n.push({code:"manifest-unparseable",path:t.path,message:"root manifest.json did not parse as a single JSON object; proceeding as if no manifest were present"}),{path:t.path,parsed:!1,recognized:!1,problems:[]};let r=t.json,o=r.version;if(o!==vo)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(o)} is not "${vo}"; the manifest was not interpreted`,...typeof o=="string"?{details:{version:o}}:{}}),{path:t.path,parsed:!0,...typeof o=="string"?{version:o}:{},recognized:!1,problems:[]};let i=ju(r);for(let c of i)n.push({code:"manifest-field-invalid",path:t.path,message:c});let s={path:t.path,parsed:!0,version:vo,recognized:!0,manifest:r,problems:i},a=r.contentsHashB64;if(typeof a=="string"&&a.length>0){let c=a===e;s.contentsHash={declaredB64:a,computedB64:e,match:c},c||n.push({code:"manifest-contents-hash-mismatch",path:t.path,message:"manifest contentsHashB64 does not match the computed contents hash; the bundle held is not byte-for-byte the bundle the manifest describes. Advisory: this does not fail any proof.",details:{declared:a,computed:e}})}return s}function ju(t){let e=[],n=r=>Array.isArray(r)&&r.every(o=>typeof o=="string");if(t.epochIds!==void 0&&!n(t.epochIds)&&e.push("manifest.epochIds must be an array of strings when present"),t.chainIds!==void 0&&!n(t.chainIds)&&e.push("manifest.chainIds must be an array of strings when present"),t.proofCount!==void 0&&(typeof t.proofCount!="number"||!Number.isInteger(t.proofCount)||t.proofCount<0)&&e.push("manifest.proofCount must be a non-negative integer when present"),t.counterRanges!==void 0&&(Array.isArray(t.counterRanges)&&t.counterRanges.every(o=>fe(o)&&typeof o.epochId=="string"&&typeof o.chainId=="string"&&typeof o.min=="string"&&typeof o.max=="string")||e.push("manifest.counterRanges must be an array of { epochId, chainId, min, max } string fields when present")),t.generatedAt!==void 0&&typeof t.generatedAt!="string"&&e.push("manifest.generatedAt must be a string when present"),t.contentsHashB64!==void 0){let r=t.contentsHashB64,o=typeof r=="string"&&r.length>0;if(o){let i=B.Buffer.from(r,"base64");o=i.toString("base64")===r&&i.length===32}o||e.push("manifest.contentsHashB64 must be standard base64 of 32 bytes when present")}return t.artifactsIncluded!==void 0&&typeof t.artifactsIncluded!="boolean"&&e.push("manifest.artifactsIncluded must be a boolean when present"),t.openEpochs!==void 0&&(Array.isArray(t.openEpochs)&&t.openEpochs.every(o=>fe(o)&&typeof o.epochId=="string"&&typeof o.counterAtSnapshot=="string")||e.push("manifest.openEpochs must be an array of { epochId, counterAtSnapshot } string fields when present")),e}function Zn(t){return B.Buffer.from(t).toString("hex")}function Io(t,e){let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}w();async function Ho(t,e){_e();let n=e?.trustAnchors,r=new Map(t.proofs.map(f=>[f.proofHash,f])),o=new Map;for(let f of t.artifacts){if(f.matchedProofHashes.length===0)continue;let u=f.matchedProofHashes.map(d=>r.get(d)).filter(d=>d!==void 0);o.set(f.sha256Hex,u)}for await(let f of en(t)){let u=o.get(f.sha256Hex)??[];for(let d of u){if(d.verification!==void 0)continue;let h=await oo({proof:d.proof,bytes:f.bytes,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"full",status:h.valid?"verified":"failed",...h.reason!==void 0?{reason:h.reason}:{},artifactPath:f.path};d.verification=l}}for(let f of t.proofs){if(f.verification!==void 0)continue;let u=await lt({proof:f.proof,...n!==void 0?{trustAnchors:n}:{}}),d={tier:"integrity",status:u.valid?"artifact-unavailable":"failed",...u.reason!==void 0?{reason:u.reason}:{}};f.verification=d}let i=0,s=0,a=0,c=0;for(let f of t.proofs){let u=f.verification?.status;u==="verified"?i++:u==="failed"?s++:u==="artifact-unavailable"&&a++,f.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}w();w();var wa=new WeakMap;async function Ke(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=wa.get(t);if(n!==void 0)return n;_e();let r=!1;try{r=(await lt({proof:t.proof})).valid}catch{r=!1}return _e(),wa.set(t,r),r}function Y(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function Re(t,e){let n=Y(t.counter),r=Y(e.counter);return n!==void 0&&r!==void 0&&n!==r?n<r?-1:1:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:t.proofHash<e.proofHash?-1:t.proofHash>e.proofHash?1:0}function ue(t,e,n){let r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}async function To(t){let e=[],n=[],r=new Map;for(let f of t.proofs){if(f.chainless){e.push(f.proofHash);continue}if(f.publicKeyB64===void 0){n.push(f.proofHash);continue}let u={publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId},d=JSON.stringify([u.publicKeyB64,u.epochId??null,u.chainId]),h=r.get(d);h===void 0?r.set(d,{key:u,members:[f]}):h.members.push(f)}let o=[...r.values()].sort((f,u)=>Vu(f.key,u.key)),i=[],s=new Set,a=new Map;for(let f of o){let u=zu(f.key,f.members,s);i.push(u);for(let d of u.memberProofHashes)a.set(d,f.key)}let c=await Wu(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function Vu(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";return n!==r?n<r?-1:1:t.publicKeyB64!==e.publicKeyB64?t.publicKeyB64<e.publicKeyB64?-1:1:0}function zu(t,e,n){let r=new Map(e.map(h=>[h.chainHash,h])),o=new Map,i=new Set,s=new Map;for(let h of e)s.set(h.proofHash,h.proofHash);let a=h=>{let l=h;for(;s.get(l)!==l;)l=s.get(l);let m=h;for(;m!==l;){let p=s.get(m);s.set(m,l),m=p}return l},c=(h,l)=>{let m=a(h),p=a(l);m!==p&&s.set(m,p)};for(let h of e){if(h.prevB64===void 0)continue;let l=r.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||(i.add(h.proofHash),ue(o,l.proofHash,h),n.add(l.proofHash),c(l.proofHash,h.proofHash))}let f=new Map;for(let h of e)ue(f,a(h.proofHash),h);let u=[];for(let h of f.values())u.push(qu(h,o,i));u.sort(Gu);let d=[...e].sort(Re).map(h=>h.proofHash);return{key:t,memberProofHashes:d,components:u}}function qu(t,e,n){let r=[...t].sort(Re),o=r.filter(h=>h.prevB64===void 0),i=r.filter(h=>h.prevB64!==void 0&&!n.has(h.proofHash)),s=r.filter(h=>(e.get(h.proofHash)??[]).length===0),a=new Set,c=[],f=h=>{let l=[h];for(;l.length>0;){let m=l.pop();if(a.has(m))continue;a.add(m),c.push(m);let p=[...e.get(m)??[]].sort(Re);for(let y=p.length-1;y>=0;y--)l.push(p[y].proofHash)}};for(let h of[...o,...i])f(h.proofHash);for(let h of r)a.has(h.proofHash)||f(h.proofHash);let u,d;for(let h of t)for(let l of[h.counter,h.slotCounter]){let m=Y(l);m!==void 0&&((u===void 0||m<u)&&(u=m),(d===void 0||m>d)&&(d=m))}return{memberProofHashes:c,genesisProofHashes:o.map(h=>h.proofHash),brokenLinkProofHashes:i.map(h=>h.proofHash),terminalProofHashes:s.map(h=>h.proofHash),hasCounterEvidence:u!==void 0,...u!==void 0&&d!==void 0?{positionRange:{min:String(u),max:String(d)}}:{}}}function Gu(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}async function Wu(t,e,n,r){let o=new Map;for(let h of e){let l=h.key.epochId;if(l===void 0)continue;let m=o.get(l);m===void 0&&(m={chainIds:new Set,publicKeys:new Set,proofCount:0},o.set(l,m)),m.chainIds.add(h.key.chainId),m.publicKeys.add(h.key.publicKeyB64),m.proofCount+=h.memberProofHashes.length}let i=new Map(t.proofs.map(h=>[h.chainHash,h])),s=[];for(let h of t.proofs){if(!h.hasEpochLink)continue;let l=Zu(h);l!==null&&s.push(await Yu(l,h,i,o,n,r))}let a=Ju(s),c=new Set,f=new Map,u=new Map;for(let h of s)h.hardEdge&&(c.add(h.fromEpochId),c.add(h.toEpochId),So(f,h.toEpochId,h.fromEpochId),So(u,h.fromEpochId,h.toEpochId));return{epochs:[...o.entries()].sort(([h],[l])=>h<l?-1:h>l?1:0).map(([h,l])=>({epochId:h,chainIds:[...l.chainIds].sort(),publicKeysB64:[...l.publicKeys].sort(),proofCount:l.proofCount,ordering:c.has(h)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...f.get(h)??[]].sort(),linkedSuccessorEpochIds:[...u.get(h)??[]].sort()})),edges:s,orderedPairs:a}}function Zu(t){let e=t.proof.commit;if(e===null||typeof e!="object")return null;let n=e.epochLink;if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,o=["prevEpochId","prevPublicKeyB64","prevCounter","prevProofHashB64","toEpochId","toPublicKeyB64"],i={};for(let s of o){let a=r[s];if(typeof a!="string"||a.length===0)return null;i[s]=a}return i}async function Yu(t,e,n,r,o,i){let s=await Ke(e),a=n.get(t.prevProofHashB64);if(a===void 0){let h=r.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:h?"terminal-missing":"dangling",viaProofValid:s,hardEdge:!1}}let c=[];a.epochId!==t.prevEpochId&&c.push(`the referenced proof's epochId (${a.epochId??"absent"}) does not match epochLink.prevEpochId (${t.prevEpochId})`),a.publicKeyB64!==t.prevPublicKeyB64&&c.push("the referenced proof's signer key does not match epochLink.prevPublicKeyB64"),Xu(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await Ke(a),u=c.length===0,d=i.has(a.proofHash);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:"matched",predecessorProofHash:a.proofHash,metadataConsistent:u,...u?{}:{inconsistencies:c},...d?{referencedProofIsTerminal:!o.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:u&&s&&f}}function Xu(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=Y(t),r=Y(e);return n!==void 0&&r!==void 0&&n===r}function Ju(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(So(e,i.fromEpochId,i.toEpochId),n.add(i.fromEpochId),n.add(i.toEpochId));let r=new Set;for(let i of n){let s=new Set,a=[...e.get(i)??[]];for(;a.length>0;){let c=a.pop();if(!s.has(c)){s.add(c);for(let f of e.get(c)??[])a.push(f)}}for(let c of s)c!==i&&r.add(`${i}\0${c}`)}let o=[];for(let i of r){let[s,a]=i.split("\0");r.has(`${a}\0${s}`)||o.push({beforeEpochId:s,afterEpochId:a})}return o.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),o}function So(t,e,n){let r=t.get(e);r===void 0?t.set(e,new Set([n])):r.add(n)}w();var Qu=1e4;async function Co(t,e){let n=[],r=[],o=[],i=new Map(t.proofs.map(c=>[c.proofHash,c])),s=new Map(t.proofs.map(c=>[c.chainHash,c])),a=new Map;for(let c of e.partitions)for(let f of c.memberProofHashes)a.set(f,c.key);for(let c of e.partitions){let f=c.memberProofHashes.map(u=>i.get(u));ed(c,f,n),await xa(c,f,"counter",n,r),await xa(c,f,"slot",n,r),await td(c,f,n,r),await nd(c,f,s,n,r),rd(c,f,s,a,n,o),await id(c,f,n,r),sd(c,f,n)}return await ad(e.epochRelationships.edges,i,n,r),{anomalies:n,divergences:r,boundaryEntryPoints:o}}function ed(t,e,n){let r=new Set;for(let d of e){let h=Y(d.counter);h!==void 0&&r.add(h);let l=Y(d.slotCounter);l!==void 0&&r.add(l)}if(r.size<2)return;let o=[...r].sort((d,h)=>d<h?-1:d>h?1:0),i=[],s=[],a=0n;for(let d=1;d<o.length;d++){let h=o[d-1]+1n,l=o[d]-1n;if(!(h>l)){i.push({start:String(h),end:String(l)}),a+=l-h+1n;for(let m=h;m<=l&&s.length<Qu;m++)s.push(String(m))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},f=String(o[0]),u=String(o[o.length-1]);n.push({code:"unexplained-counter-positions",partition:t.key,proofHashes:[],message:`${a} counter position${a===1n?"":"s"} within the observed range [${f}, ${u}] of this partition ${a===1n?"is":"are"} neither a commit position nor a referenced slot position in the supplied bundle. Such ${a===1n?"a position":"positions"} may mean a proof is absent from the bundle, or a slot that was allocated but never committed (a routine, benign occurrence); this offline audit cannot distinguish the two. It does not, by itself, establish that the authority failed to create or withheld any proof.`,details:c})}async function xa(t,e,n,r,o){let i=new Map;for(let s of e){let a=n==="counter"?s.counter:s.slotCounter;if(a===void 0)continue;let c=Y(a);ue(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of Ro(i)){if(a.length<2)continue;let{parties:c,context:f}=await Yn(a);if(c.length<2)continue;let u=s.startsWith("raw:")?s.slice(4):s,d=n==="counter"?"counter-collision":"slot-collision";r.push({code:d,partition:t.key,proofHashes:a.map(h=>h.proofHash),message:n==="counter"?`${c.length} distinct valid proofs claim commit counter ${u} in one partition. The audit does not choose between them; all parties are preserved for adjudication.`:`${c.length} distinct valid proofs reference slot counter ${u} in one partition. A slot position is consumed exactly once; all parties are preserved for adjudication.`,details:{position:u,validParties:c.map(h=>h.proofHash),invalidObserved:f.map(h=>h.proofHash)}}),o.push({kind:d,partition:t.key,contested:n==="counter"?{counter:u}:{slotCounter:u},parties:c.map($e),invalidContext:f.map($e),explanation:n==="counter"?`Two or more independently valid proof objects claim commit counter ${u} in the same signer, epoch, and chain partition. A commit counter position can be consumed only once, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them; every party and its predecessor relationship is preserved for adjudication.`:`Two or more independently valid proof objects reference slot counter ${u} in the same signer, epoch, and chain partition. A slot position is allocated once and consumed by one commit, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them.`})}}async function td(t,e,n,r){let o=new Map,i=new Map;for(let a of e){let c=Y(a.counter);c!==void 0&&ue(o,String(c),a);let f=Y(a.slotCounter);f!==void 0&&ue(i,String(f),a)}let s=[...o.keys()].filter(a=>i.has(a)).sort((a,c)=>BigInt(a)<BigInt(c)?-1:BigInt(a)>BigInt(c)?1:0);for(let a of s){let c=o.get(a),f=i.get(a),u=[];for(let b of c)await Ke(b)&&u.push(b);let d=[];for(let b of f)await Ke(b)&&d.push(b);if(!u.some(b=>d.some(I=>I.proofHash!==b.proofHash)))continue;let l=new Map;for(let b of[...u,...d])l.set(b.proofHash,b);let m=[...l.values()],p=new Map;for(let b of[...c,...f])p.set(b.proofHash,b);let y=[...p.values()].filter(b=>!l.has(b.proofHash));n.push({code:"cross-kind-position-reuse",partition:t.key,proofHashes:[...p.keys()],message:`Counter position ${a} is committed by one proof and reserved as a slot by a different proof in the same partition. A single causal position is consumed once, as a slot or as a commit, never both across distinct proofs. The audit does not choose between them; all parties are preserved for adjudication.`,details:{position:a,commitParties:u.map(b=>b.proofHash),slotParties:d.map(b=>b.proofHash),validParties:m.map(b=>b.proofHash),invalidObserved:y.map(b=>b.proofHash)}}),r.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:m.map($e),invalidContext:y.map($e),explanation:`Two or more independently valid proof objects allocate counter position ${a} in the same signer, epoch, and chain partition through different roles: at least one commits at it and at least one reserves it as a slot. Each position in a chain is consumed exactly once, so at most one of these allocations can belong to the authoritative sequence. This pattern only arises through enclave malfunction, replay, or compromise. The audit tool does not choose between them; every party is preserved for adjudication.`})}}async function nd(t,e,n,r,o){let i=new Map;for(let s of e)s.prevB64!==void 0&&ue(i,s.prevB64,s);for(let[s,a]of Ro(i)){if(a.length<2)continue;let{parties:c,context:f}=await Yn(a);if(c.length<2)continue;let u=n.has(s);r.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(d=>d.proofHash),message:`${c.length} distinct valid proofs claim the same predecessor hash: a detectable fork. All branches are preserved; the audit does not choose between them.`,details:{prevB64:s,predecessorObserved:u,validParties:c.map(d=>d.proofHash),invalidObserved:f.map(d=>d.proofHash)}}),o.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map($e),invalidContext:f.map($e),explanation:`Two or more independently valid proof objects name the same predecessor proof in their prevB64 hash link. Each proof has exactly one successor in an intact chain, so this is a fork: the history diverges into multiple branches at that predecessor${u?", which is itself observed in the bundle":", which is absent from the bundle"}. All branches are shown; the audit tool does not select one.`})}}function rd(t,e,n,r,o,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let f=Y(c.counter);f!==void 0&&(a===void 0||f<a)&&(a=f)}for(let c of[...e].sort(Re)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!od(c.prevB64)){o.push({code:"chain-break-malformed",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 is not standard base64 of 32 bytes, so it can never match a canonical proof hash. The predecessor link is unusable as reconstruction evidence.",details:{prevB64:c.prevB64}});continue}let f=n.get(c.prevB64);if(f!==void 0){let h=r.get(f.proofHash);o.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,f.proofHash],message:"commit.prevB64 resolves to an observed proof outside this proof's own signer, epoch, and chain partition. prevB64 never bridges partitions (each epoch and chain keeps its own hash chain), so this link does not join the two.",details:{prevB64:c.prevB64,predecessorProofHash:f.proofHash,predecessorPartition:h!==void 0?{publicKeyB64:h.publicKeyB64,...h.epochId!==void 0?{epochId:h.epochId}:{},chainId:h.chainId}:"unchained-or-unpartitioned"}});continue}let u=Y(c.counter);if(u===void 0||a===void 0||u<=a){i.push({partition:t.key,proofHash:c.proofHash,prevB64:c.prevB64});continue}o.push({code:"chain-break-missing",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 references a predecessor proof that is absent from the supplied bundle, and a lower-positioned proof IS present, so this is an interior break (a hole), not the excerpt's starting boundary. The chain cannot be reconstructed across this link from the supplied evidence; this does not, by itself, establish that the predecessor never existed.",details:{prevB64:c.prevB64}})}}function od(t){if(t.length===0)return!1;let e=B.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function id(t,e,n,r){let o=[...e.filter(a=>a.prevB64===void 0)].sort(Re);if(o.length<2)return;let{parties:i,context:s}=await Yn(o);n.push({code:"multiple-genesis",partition:t.key,proofHashes:o.map(a=>a.proofHash),message:`${o.length} proofs in one partition carry no prevB64 link. An epoch has exactly one first proof, so at most one of these can be the genesis of this partition's chain.`,details:{validParties:i.map(a=>a.proofHash),invalidObserved:s.map(a=>a.proofHash)}}),!(i.length<2)&&r.push({kind:"multiple-genesis",partition:t.key,contested:{...t.key.epochId!==void 0?{epochId:t.key.epochId}:{},chainId:t.key.chainId},parties:i.map($e),invalidContext:s.map($e),explanation:"Two or more independently valid proof objects in the same signer, epoch, and chain partition carry no predecessor link, each presenting itself as the first proof of the chain. An epoch has exactly one first proof, so at most one of these can be the genesis. The audit tool does not choose between them."})}function sd(t,e,n){for(let r of[...e].sort(Re)){let o=Y(r.slotCounter),i=Y(r.counter);o===void 0||i===void 0||o<i||n.push({code:"slot-order-violation",partition:t.key,proofHashes:[r.proofHash],message:"commit.slotCounter is not strictly less than commit.counter. The slot must be allocated before the commit that consumes it, so this proof's declared positions contradict the nonce-first construction order.",details:{slotCounter:r.slotCounter,counter:r.counter}})}}async function ad(t,e,n,r){for(let s of t)s.resolution==="terminal-missing"?n.push({code:"epochlink-terminal-missing",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch that is observed in the bundle, but the referenced terminal proof is absent from the bundle. The lineage claim cannot be confirmed from the supplied evidence; this does not, by itself, establish that the terminal never existed.",details:{link:{...s.link}}}):s.resolution==="dangling"?n.push({code:"epochlink-dangling",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch and terminal proof, neither of which is observed in the bundle. The lineage claim dangles into unobserved history; it cannot be confirmed from the supplied evidence.",details:{link:{...s.link}}}):s.metadataConsistent===!1&&n.push({code:"epochlink-mismatch",proofHashes:[s.viaProofHash,...s.predecessorProofHash!==void 0?[s.predecessorProofHash]:[]],message:"commit.epochLink's prevProofHashB64 matches an observed proof, but the link's declared epoch, signer key, or counter disagrees with that proof. The hash reference and the declared metadata cannot both be right.",details:{link:{...s.link},inconsistencies:s.inconsistencies??[]}});let o=new Map;for(let s of t)ue(o,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of Ro(o)){let a=new Set(s.map(h=>h.link.toEpochId));if(a.size<2)continue;let c=s.map(h=>e.get(h.viaProofHash)),{parties:f,context:u}=await Yn(c),d=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(h=>h.viaProofHash),message:`The same predecessor terminal (epoch ${d.prevEpochId}, counter ${d.prevCounter}) is consumed by genesis proofs of ${a.size} distinct successor epochs. A predecessor may be consumed by at most one successor epoch, so this is a detectable fork at the epoch boundary. All branches are preserved.`,details:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:f.map(h=>h.proofHash),invalidObserved:u.map(h=>h.proofHash)}}),!(f.length<2)&&r.push({kind:"epochlink-fork",contested:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64},parties:f.map($e),invalidContext:u.map($e),explanation:"Two or more independently valid epoch-genesis proofs consume the same terminal proof of a prior epoch through their epochLink. The single-successor rule allows a terminal to be consumed by exactly one successor epoch, so at most one of these lineages can be the authoritative continuation. Note that whichever party verified second in this run carries a fork-detection failure from the canonical verifier; that ordering is an artifact of verification order, not evidence of which branch is authoritative. The audit tool does not choose between them."})}let i=new Map;for(let s of t){if(s.resolution!=="matched")continue;let a=i.get(s.fromEpochId);a===void 0?i.set(s.fromEpochId,new Set([s.toEpochId])):a.add(s.toEpochId)}for(let s of cd(i)){let a=t.filter(c=>c.resolution==="matched"&&s.includes(c.fromEpochId)&&s.includes(c.toEpochId)).map(c=>c.viaProofHash);n.push({code:"epochlink-cycle",proofHashes:a,message:`Epoch lineage links form a cycle among ${s.length} epochs. Each link claims its successor epoch came after its predecessor, so a cycle means these ordering claims contradict each other; no ordering is asserted for the epochs involved.`,details:{epochIds:s}})}}function cd(t){let e=new Map,n=new Set,r=[...t.keys()].sort();for(let o of r){if(n.has(o))continue;let i=[],s=new Set,a=new Map,c=[o];for(;c.length>0;){let f=c[c.length-1];s.has(f)||(s.add(f),i.push(f),a.set(f,[...t.get(f)??[]].sort()));let d=a.get(f).shift();if(d===void 0){c.pop(),s.delete(f),i.pop(),n.add(f);continue}if(s.has(d)){let h=i.indexOf(d),l=i.slice(h),m=fd(l);e.set(m.join("|"),m);continue}n.has(d)||c.push(d)}}return[...e.values()].sort((o,i)=>{let s=o.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function fd(t){let e=0;for(let n=1;n<t.length;n++)t[n]<t[e]&&(e=n);return[...t.slice(e),...t.slice(0,e)]}async function Yn(t){let e=[],n=[];for(let r of t)await Ke(r)?e.push(r):n.push(r);return{parties:e,context:n}}function $e(t){let e=t.verification;return{proofHash:t.proofHash,sourcePaths:t.sources.map(n=>n.path),...e!==void 0?{verificationTier:e.tier,verificationStatus:e.status,...e.reason!==void 0?{verificationReason:e.reason}:{}}:{},...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.prevB64!==void 0?{prevB64:t.prevB64}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.measurement!==void 0?{measurement:t.measurement}:{}}}function Ro(t){return[...t.entries()].sort(([e],[n])=>{let r=/^[0-9]+$/.test(e)?BigInt(e):void 0,o=/^[0-9]+$/.test(n)?BigInt(n):void 0;return r!==void 0&&o!==void 0&&r!==o?r<o?-1:1:r!==void 0&&o===void 0?-1:r===void 0&&o!==void 0?1:e<n?-1:e>n?1:0})}w();function $o(t){let e=new Map;for(let a of t.proofs){let c=JSON.stringify([a.measurement??null,a.publicKeyB64??null,a.epochId??null,a.chainId,a.hasAttestation]),f=e.get(c);if(f!==void 0){f.proofHashes.push(a.proofHash);continue}e.set(c,{...a.measurement!==void 0?{measurement:a.measurement}:{},...a.publicKeyB64!==void 0?{publicKeyB64:a.publicKeyB64}:{},...a.epochId!==void 0?{epochId:a.epochId}:{},chainId:a.chainId,attestationPresent:a.hasAttestation,proofHashes:[a.proofHash]})}let n=[...e.values()].sort(ud),r=new Map;for(let a of t.proofs)a.epochId!==void 0&&ue(r,a.epochId,a);let o=[];for(let[a,c]of[...r.entries()].sort(([f],[u])=>f<u?-1:f>u?1:0)){let f=new Set,u=new Set;for(let d of c)d.publicKeyB64!==void 0&&f.add(d.publicKeyB64),d.measurement!==void 0&&u.add(d.measurement);f.size>=2&&o.push({code:"mid-epoch-signer-change",proofHashes:c.map(d=>d.proofHash),message:`${f.size} distinct signer keys appear within epoch ${a}. A single enclave boot generates exactly one keypair per epoch, so multiple keys under one epochId cannot come from one healthy authority lifecycle. All key groups are preserved for adjudication.`,details:{epochId:a,publicKeysB64:[...f].sort()}}),u.size>=2&&o.push({code:"mid-epoch-measurement-change",proofHashes:c.map(d=>d.proofHash),message:`${u.size} distinct declared measurements appear within epoch ${a}. A single enclave boot has exactly one measurement, so multiple declared measurements under one epochId cannot come from one healthy authority lifecycle. Declared measurements are self-reported; attestation validation is reported separately.`,details:{epochId:a,measurements:[...u].sort()}})}let i=new Map;for(let a of t.proofs){if(a.publicKeyB64===void 0||a.epochId===void 0)continue;let c=i.get(a.publicKeyB64);c===void 0?i.set(a.publicKeyB64,new Set([a.epochId])):c.add(a.epochId)}let s=[...i.entries()].filter(([,a])=>a.size>=2).map(([a,c])=>({publicKeyB64:a,epochIds:[...c].sort()})).sort((a,c)=>a.publicKeyB64<c.publicKeyB64?-1:a.publicKeyB64>c.publicKeyB64?1:0);return{groups:n,anomalies:o,sharedSignersAcrossEpochs:s}}function ud(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";if(n!==r)return n<r?-1:1;let o=t.publicKeyB64??"",i=e.publicKeyB64??"";if(o!==i)return o<i?-1:1;let s=t.measurement??"",a=e.measurement??"";return s!==a?s<a?-1:1:t.attestationPresent!==e.attestationPresent?t.attestationPresent?-1:1:0}w();var dd="Ethereum Anchor",Ea="ethereum-anchor",hd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function No(t){let e=[],n=[],r=[];for(let o of t.proofs){let i=Po(o,"name"),s=ld(o);if(!(i===dd)){s===Ea&&(n.push(o.proofHash),r.push({code:"anchor-metadata-only-claim",...Do(o),message:"unsigned metadata.type claims ethereum-anchor, but the signed attribution does not identify this proof as an anchor. Metadata is advisory and unsigned; the proof is not treated as an anchor.",details:{proofHash:o.proofHash}}));continue}let c=s===Ea?"agrees":s===void 0?"absent":"disagrees";c==="disagrees"&&r.push({code:"anchor-metadata-disagreement",...Do(o),message:`signed attribution identifies an Ethereum anchor, but unsigned metadata.type is ${JSON.stringify(s)}. The signed field governs; the disagreement is recorded.`,details:{proofHash:o.proofHash,metadataType:s}});let f=Po(o,"message"),u=Po(o,"title"),d=u!==void 0?hd.exec(u)?.[1]??void 0:void 0;d===void 0&&r.push({code:"anchor-title-unparseable",...Do(o),message:u===void 0?"anchor proof carries no signed attribution.title; the signed block number is absent":"anchor attribution.title does not parse as an Etherscan block URL; the signed block number is treated as absent",details:{proofHash:o.proofHash,...u!==void 0?{title:u}:{}}});let h=o.verification;e.push({proofHash:o.proofHash,...o.epochId!==void 0?{epochId:o.epochId}:{},chainId:o.chainId,...o.counter!==void 0?{counter:o.counter}:{},...o.slotCounter!==void 0?{slotCounter:o.slotCounter}:{},...f!==void 0?{blockHash:f}:{},...d!==void 0?{blockNumber:d}:{},metadataCorroboration:c,...h!==void 0?{verificationTier:h.tier,verificationStatus:h.status,...h.reason!==void 0?{verificationReason:h.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:r}}function Po(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function ld(t){let e=t.proof.metadata;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.type;return typeof n=="string"?n:void 0}function Do(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}w();w();var pd=BigInt(0),tn=BigInt(1),md=BigInt(2),gd=BigInt(7),bd=BigInt(256),yd=BigInt(113),Aa=[],ka=[],Ia=[];for(let t=0,e=tn,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Aa.push(2*(5*r+n)),ka.push((t+1)*(t+2)/2%64);let o=pd;for(let i=0;i<7;i++)e=(e<<tn^(e>>gd)*yd)%bd,e&md&&(o^=tn<<(tn<<BigInt(i))-tn);Ia.push(o)}var Ha=wn(Ia,!0),wd=Ha[0],xd=Ha[1],Ba=(t,e,n)=>n>32?zi(t,e,n):ji(t,e,n),va=(t,e,n)=>n>32?qi(t,e,n):Vi(t,e,n);function Ed(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,f=n[c],u=n[c+1],d=Ba(f,u,1)^n[a],h=va(f,u,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=d,t[s+l+1]^=h}let o=t[2],i=t[3];for(let s=0;s<24;s++){let a=ka[s],c=Ba(o,i,a),f=va(o,i,a),u=Aa[s];o=t[u],i=t[u+1],t[u]=c,t[u+1]=f}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=wd[r],t[1]^=xd[r]}Ie(n)}var Oo=class t extends At{constructor(e,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Ar(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Fi(this.state)}clone(){return this._cloneInto()}keccak(){kr(this.state32),Ed(this.state32,this.rounds),kr(this.state32),this.posOut=0,this.pos=0}update(e){kt(this),e=_t(e),ct(e);let{blockLen:n,state:r}=this,o=e.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){kt(this,!1),ct(e),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=e.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);e.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ar(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ie(this.state)}_cloneInto(e){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return e||(e=new t(n,r,o,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=o,e.enableXOF=s,e.destroyed=this.destroyed,e}},Bd=(t,e,n)=>Kt(()=>new Oo(e,t,n));var Sa=Bd(1,136,256/8);w();function Ra(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=$a(t,0);if(n!==t.length)throw new Error(`RLP: ${t.length-n} trailing byte(s) after the top-level item`);if(!Array.isArray(e))throw new Error("RLP: top-level item is not a list");return e}function $a(t,e){let n=Pa(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=Xn(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=Ca(t,e+1,a),f=e+1+a,u=Xn(t,f,c);return{item:t.subarray(f,u),next:u}}if(n<=247){let a=n-192,c=Xn(t,e+1,a);return{item:Ta(t,e+1,c),next:c}}let r=n-247,o=Ca(t,e+1,r),i=e+1+r,s=Xn(t,i,o);return{item:Ta(t,i,s),next:s}}function Ta(t,e,n){let r=[],o=e;for(;o<n;){let i=$a(t,o);if(i.next>n)throw new Error("RLP: list item overruns its list payload");r.push(i.item),o=i.next}return r}function Ca(t,e,n){if(n<1||n>8)throw new Error(`RLP: invalid length-of-length ${n}`);let r=0;for(let o=0;o<n;o++)r=r*256+Pa(t,e+o);if(r>t.length)throw new Error("RLP: declared length exceeds the input size");return r}function Xn(t,e,n){let r=e+n;if(r>t.length)throw new Error("RLP: item is truncated");return r}function Pa(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function Lo(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function Da(t){if(!t.startsWith("0x"))return null;let e=t.slice(2);if(e.length%2!==0||!/^[0-9a-fA-F]*$/.test(e))return null;let n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++)n[r]=Number.parseInt(e.slice(r*2,r*2+2),16);return n}function Na(t){return`0x${B.Buffer.from(t).toString("hex")}`}var Oa=8,La=11,vd=/^0x[0-9a-fA-F]{64}$/,Ad=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function Fo(t,e){let n=[],r=[],o=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=kd(i);if(s.failure!==void 0){let u={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(u),r.push(Mo(u));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),f=e.anchors.filter(u=>{let d=u.blockHash?.toLowerCase();return d!==void 0&&(d===a||d===c)});if(f.length===0){let u={witnessPath:i.path,verified:!1,reason:"witness-unmatched",detail:"neither the locally recomputed block hash nor the claimed blockHash matches any observed anchor's signed attribution.message",computedBlockHash:a};n.push(u),r.push(Mo(u));continue}for(let u of f){let d=o.get(u.proofHash),h=d!==void 0&&await Ke(d),l=Id(s,i.path,u.proofHash,d,h);n.push(l),l.verified||r.push(Mo(l))}}return{outcomes:n,findings:r}}function kd(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return Jn("headerRlpHex is missing or not a string");let r=e.blockNumber;if(typeof r!="number"||!Number.isInteger(r)||r<0)return Jn("blockNumber is missing or not a non-negative integer");let o=e.blockHash;if(typeof o!="string"||!vd.test(o))return Jn("blockHash is missing or not 0x followed by 64 hex characters");let i=Da(n);if(i===null)return Jn("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=Ra(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:Na(Sa(i)),items:s,claimedHash:o,claimedNumber:BigInt(r)}}function Jn(t){return{failure:{reason:"witness-malformed",detail:t}}}function Id(t,e,n,r,o){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(b,I,v)=>({...s,verified:!1,reason:b,detail:I,...v?.blockNumber!==void 0?{blockNumber:v.blockNumber}:{}});if(r===void 0||!o)return a("witness-anchor-invalid","the candidate anchor proof is not cryptographically valid; the witness confers nothing");let c=Hd(r);if(c===void 0||c.toLowerCase()!==i)return a("witness-hash-mismatch",c===void 0?"the anchor carries no signed attribution.message to compare against":"the locally recomputed block hash does not equal the anchor's signed attribution.message");let f=Cd(Td(r));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let u=_(new TextEncoder().encode(c));if(!Rd(u,f))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let d=t.items,h=d[Oa];if(h===void 0||!(h instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Oa} (block number) is missing or not a byte string`);let l=Lo(h);if(l!==t.claimedNumber)return a("witness-block-number-mismatch",`the witness claims blockNumber ${t.claimedNumber}, but the header's number field is ${l}`,{blockNumber:String(l)});let m=Sd(r);if(m!==void 0){let b=Ad.exec(m)?.[1];if(b!==void 0&&BigInt(b)!==l)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${b}, but the header's number field is ${l}`,{blockNumber:String(l)})}if(t.claimedHash.toLowerCase()!==i)return a("witness-claimed-hash-mismatch","the witness's claimed blockHash does not equal the locally recomputed block hash",{blockNumber:String(l)});let p=d[La];if(p===void 0||!(p instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${La} (timestamp) is missing or not a byte string`,{blockNumber:String(l)});let y=Lo(p);return y>BigInt(Number.MAX_SAFE_INTEGER)?a("witness-header-shape","header timestamp does not fit a safe integer",{blockNumber:String(l)}):{...s,verified:!0,blockNumber:String(l),timestamp:Number(y)}}function Hd(t){return Ma(t,"message")}function Sd(t){return Ma(t,"title")}function Ma(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function Td(t){let e=t.proof.artifact;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.digestB64;return typeof n=="string"?n:void 0}function Cd(t){if(t===void 0||t.length===0)return null;let e=B.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function Rd(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function Mo(t){return{code:t.reason,path:t.witnessPath,message:`anchor witness rejected: ${t.detail??"verification failed"}. The witness confers nothing; the anchor proof's own standing is unchanged.`,details:{...t.anchorProofHash!==void 0?{anchorProofHash:t.anchorProofHash}:{},...t.computedBlockHash!==void 0?{computedBlockHash:t.computedBlockHash}:{}}}}w();function Uo(t,e,n,r){let o=new Map(t.proofs.map(u=>[u.proofHash,u])),i=new Map;for(let u of r.outcomes)!u.verified||u.anchorProofHash===void 0||i.has(u.anchorProofHash)||i.set(u.anchorProofHash,{anchorProofHash:u.anchorProofHash,timestamp:u.timestamp,blockHash:u.computedBlockHash,...u.blockNumber!==void 0?{blockNumber:u.blockNumber}:{}});let s=[...i.keys()].sort(),a=n.anchors.map(u=>u.proofHash).filter(u=>!i.has(u)).sort(),c=[];for(let u of e.partitions)c.push(...$d(u,o,i));let f=Md(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function $d(t,e,n){let r=t.memberProofHashes.map(h=>e.get(h)),o=new Map(r.map(h=>[h.chainHash,h])),i=r.filter(h=>n.has(h.proofHash)),s=new Map;for(let h of r){if(h.prevB64===void 0)continue;let l=o.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||ue(s,l.proofHash,h)}let a=new Map,c=new Map;for(let h of i)a.set(h.proofHash,Dd(h,s)),c.set(h.proofHash,Nd(h,o));let f=r.map(h=>{let l=new Map,m=new Map,p=Y(h.counter);for(let y of i){let b=y.proofHash,I=Y(y.counter);h.proofHash===b||a.get(b).has(h.proofHash)?l.set(b,"chain-link"):p!==void 0&&I!==void 0&&p>I&&(l.has(b)||l.set(b,"counter-order")),c.get(b).has(h.proofHash)?m.set(b,"chain-link"):h.proofHash!==b&&p!==void 0&&I!==void 0&&p<I&&(m.has(b)||m.set(b,"counter-order"))}return{member:h,lower:Fa("not-before",l,n),upper:Fa("not-after",m,n)}}),u=new Map;for(let h of f)ue(u,Pd(h),h);let d=[];for(let h of u.values()){let l=h.map(v=>v.member).sort(Re),m=h[0],p=m.lower,y=m.upper,b=p.length>0&&y.length>0?"lower-bounded-with-following-anchor":p.length>0?"lower-bounded":y.length>0?"upper-bounded":"ordered-but-unanchored",I=Od(l);d.push({partition:t.key,memberProofHashes:l.map(v=>v.proofHash),...I!==void 0?{positionRange:I}:{},status:b,lowerBounds:p,upperBounds:y})}return d.sort(Ld),d}function Fa(t,e,n){if(e.size===0)return[];let r=[...e.entries()].map(([c,f])=>({anchorHash:c,evidenceKind:f,info:n.get(c)})),o=(c,f)=>f===void 0?!0:c.info.timestamp!==f.info.timestamp?t==="not-before"?c.info.timestamp>f.info.timestamp:c.info.timestamp<f.info.timestamp:c.evidenceKind!==f.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<f.anchorHash,i,s;for(let c of r)o(c,i)&&(i=c),c.evidenceKind==="chain-link"&&o(c,s)&&(s=c);let a=[Ua(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(Ua(t,s)),a}function Ua(t,e){let{info:n,evidenceKind:r}=e,o=new Date(n.timestamp*1e3).toISOString(),i=n.blockNumber!==void 0?`Ethereum block ${n.blockNumber}`:"an Ethereum block",s=r==="chain-link"?"Evidence: a verified hash-link path connects these proofs and the anchor.":"Evidence: commit-counter ordering within the partition only, which relies on the authority's counter discipline rather than verifiable hash links (weaker).",a=t==="not-before"?`These proofs were committed no earlier than ${o} (unix ${n.timestamp}), the timestamp of ${i}: the block hash was unpredictable before that time and the anchor commit consumed it. Reading this as a wall-clock floor additionally assumes the anchored header is a genuine, publicly published Ethereum block: this offline audit checks the header's structure and hash binding, not proof-of-work, consensus, or chain membership, so it cannot confirm the block is real. ${s}`:`These proofs existed before the anchor commit that consumed the hash of ${i} (block timestamp ${o}, unix ${n.timestamp}). The block timestamp proves the anchor commit came at or after it, not how promptly; reading it as a wall-clock ceiling additionally assumes the anchor consumed a recently published block. ${s}`;return{kind:t,anchorProofHash:e.anchorHash,...n.blockNumber!==void 0?{blockNumber:n.blockNumber}:{},blockHash:n.blockHash,timestamp:n.timestamp,evidence:r,weaker:r==="counter-order",basis:t==="not-before"?"block-hash-unpredictability":"causal-precedence",boundClass:t==="not-before"?"evidence":"assumption",claim:t==="not-before"?a:"NOT a proof-carried upper bound. "+a}}function Pd(t){let e=n=>n.map(r=>`${r.anchorProofHash}:${r.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function Dd(t,e){let n=new Set,r=[...e.get(t.proofHash)??[]];for(;r.length>0;){let o=r.pop();if(!n.has(o.proofHash)){n.add(o.proofHash);for(let i of e.get(o.proofHash)??[])r.push(i)}}return n}function Nd(t,e){let n=new Set,r=t;for(;r!==void 0&&r.prevB64!==void 0;){let o=e.get(r.prevB64);if(o===void 0||n.has(o.proofHash)||o.proofHash===t.proofHash)break;n.add(o.proofHash),r=o}return n}function Od(t){let e,n;for(let r of t)for(let o of[r.counter,r.slotCounter]){let i=Y(o);i!==void 0&&((e===void 0||i<e)&&(e=i),(n===void 0||i>n)&&(n=i))}return e!==void 0&&n!==void 0?{min:String(e),max:String(n)}:void 0}function Ld(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}function _a(t){return t?" The representative bound rests on commit-counter ordering rather than a verified hash-link path, which relies on the authority's counter discipline (weaker evidence).":""}function Md(t,e){let n=new Map;for(let i of t.epochRelationships.epochs)n.set(i.epochId,{totalProofCount:i.proofCount,lowerCovered:new Set,upperCovered:new Set});for(let i of e){let s=i.partition.epochId;if(s===void 0)continue;let a=n.get(s);if(a!==void 0){for(let c of i.lowerBounds){for(let f of i.memberProofHashes)a.lowerCovered.add(f);(a.lowerMin===void 0||c.timestamp<a.lowerMin.timestamp||c.timestamp===a.lowerMin.timestamp&&a.lowerMin.weaker&&!c.weaker)&&(a.lowerMin={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}for(let c of i.upperBounds){for(let f of i.memberProofHashes)a.upperCovered.add(f);(a.upperMax===void 0||c.timestamp>a.upperMax.timestamp||c.timestamp===a.upperMax.timestamp&&a.upperMax.weaker&&!c.weaker)&&(a.upperMax={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}}}for(let i of t.epochRelationships.epochs){let s=n.get(i.epochId),a=[];s.lowerMin!==void 0&&a.push({kind:"not-before",anchorProofHash:s.lowerMin.anchorProofHash,...s.lowerMin.blockNumber!==void 0?{blockNumber:s.lowerMin.blockNumber}:{},blockHash:s.lowerMin.blockHash,witnessTimestamp:s.lowerMin.timestamp,coverage:"members-after-anchor",coveredProofCount:s.lowerCovered.size,totalProofCount:s.totalProofCount,basis:"block-hash-unpredictability",evidence:s.lowerMin.evidence,weaker:s.lowerMin.weaker,claim:`${s.lowerCovered.size} of ${s.totalProofCount} observed proofs of this epoch were committed no earlier than unix ${s.lowerMin.timestamp}, grounded in block-hash unpredictability through verified anchor witnesses. This additionally assumes the anchored header is a genuine, publicly published Ethereum block, which this offline audit cannot confirm.`+_a(s.lowerMin.weaker)+" The remaining proofs sit causally before the covering anchors and carry no lower bound from this evidence."}),s.upperMax!==void 0&&a.push({kind:"not-after",anchorProofHash:s.upperMax.anchorProofHash,...s.upperMax.blockNumber!==void 0?{blockNumber:s.upperMax.blockNumber}:{},blockHash:s.upperMax.blockHash,witnessTimestamp:s.upperMax.timestamp,coverage:"members-before-anchor",coveredProofCount:s.upperCovered.size,totalProofCount:s.totalProofCount,basis:"causal-precedence",evidence:s.upperMax.evidence,weaker:s.upperMax.weaker,claim:`${s.upperCovered.size} of ${s.totalProofCount} observed proofs of this epoch existed before an anchor commit that consumed a block published at unix ${s.upperMax.timestamp}. Reading that timestamp as a wall-clock ceiling additionally assumes the anchor consumed a recently published block; the causal precedence itself is verified.`+_a(s.upperMax.weaker)+" Proofs after the covering anchors are not covered."}),a.length>0&&(i.anchorBounds=a)}let r=[],o=t.epochRelationships.epochs;for(let i of o){let s=n.get(i.epochId);if(s.upperMax!==void 0)for(let a of o){if(a.epochId===i.epochId)continue;let c=n.get(a.epochId);if(c.lowerMin===void 0||s.upperMax.timestamp>=c.lowerMin.timestamp)continue;let f=s.upperMax.evidence,u=c.lowerMin.evidence,d=s.upperMax.weaker||c.lowerMin.weaker;r.push({beforeEpochId:i.epochId,afterEpochId:a.epochId,upperAnchorProofHash:s.upperMax.anchorProofHash,upperBoundTimestamp:s.upperMax.timestamp,lowerAnchorProofHash:c.lowerMin.anchorProofHash,lowerBoundTimestamp:c.lowerMin.timestamp,basis:"anchor-bounds",assumptionDependent:!0,upperEvidence:f,lowerEvidence:u,weaker:d,beforeCoveredProofCount:s.upperCovered.size,beforeTotalProofCount:s.totalProofCount,afterCoveredProofCount:c.lowerCovered.size,afterTotalProofCount:c.totalProofCount,note:`The anchor-covered portion of epoch ${i.epochId} (${s.upperCovered.size} of ${s.totalProofCount} proofs) precedes the anchor-covered portion of epoch ${a.epochId} (${c.lowerCovered.size} of ${c.totalProofCount} proofs): the first is bounded not-after unix ${s.upperMax.timestamp} and the second not-before unix ${c.lowerMin.timestamp}. One-sided evidence about the covered portions only; the not-after side rests on the anchor-freshness assumption documented on its bound.`+(d?" At least one side rests on commit-counter ordering rather than a verified hash-link path (weaker evidence), which relies on the authority's counter discipline.":"")+" This is ordering evidence, never divergence."})}}return r.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),r}w();w();var Ka=`-----BEGIN CERTIFICATE-----
|
|
140
140
|
MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTEL
|
|
141
141
|
MAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYD
|
|
142
142
|
VQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4
|
|
@@ -149,10 +149,10 @@ R+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYC
|
|
|
149
149
|
MQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPW
|
|
150
150
|
rfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6N
|
|
151
151
|
IwLz3/Y=
|
|
152
|
-
-----END CERTIFICATE-----`;function zd(){return na.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function oa(){return new Uint8Array(B.Buffer.from(zd(),"base64"))}async function ia(t,e){let n=[],o={},r,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(d=>!d.pass)?.detail,...r!==void 0?{pcr0:r}:{},pcrs:o,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},...a!==void 0?{certChainLength:a}:{},...c!==void 0?{userDataB64:c}:{}});try{let d=Wd(t);if(d===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let u=Ue(d,0).value;if(!Array.isArray(u)||u.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),f();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let h=u[0],l=u[2],p=u[3];if(!(h instanceof Uint8Array)||!(l instanceof Uint8Array)||!(p instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),f();let m=Ue(l,0).value;if(!m||typeof m!="object"||Array.isArray(m))return n.push({name:"Payload Decode",pass:!1,detail:"Could not decode attestation payload"}),f();o=eu(m),r=o[0],i=typeof m.module_id=="string"?m.module_id:void 0,s=typeof m.timestamp=="number"?m.timestamp:void 0;let x=m.user_data;c=x instanceof Uint8Array&&x.length>0?B.Buffer.from(x).toString("base64"):void 0;let y=m.cabundle,T=m.certificate;if(!(T instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),f();a=(Array.isArray(y)?y.length:0)+1;let C=lr(T),_=Xd(h,l),G=await pr(p,_,C.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:G,detail:G?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!G)return f();if(!Array.isArray(y)||y.length===0||!y.every(v=>v instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let $=[...y,T].map(lr),O=!0,U="";for(let v=1;v<$.length;v++){let H=$[v],D=$[v-1];if(!await pr(H.signature,H.tbsCertificate,D.publicKey)){O=!1,U=`Certificate ${v} signature invalid (parent: ${v-1})`;break}}if(n.push({name:"Certificate Chain",pass:O,detail:O?`${$.length} certificates, each signed by parent`:U}),!O)return f();let Z=e?.trustedRootCaDer===void 0,V=lr(e?.trustedRootCaDer??oa()),le=$[0],L=await pr(le.signature,le.tbsCertificate,V.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:L,detail:L?Z?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":Z?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!L)return f();let ie=!0,oe=`All ${$.length} certificate validity windows contain the document timestamp`;if(s===void 0)ie=!1,oe="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let v=0;v<$.length;v++){let H=$[v];if(s<H.notBeforeMs||s>H.notAfterMs){ie=!1,oe=`Certificate ${v} validity window [${new Date(H.notBeforeMs).toISOString()}, ${new Date(H.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:ie,detail:oe}),!ie)return f();let N;e?.expectedPcr0!==void 0&&(N=r===e.expectedPcr0,n.push({name:"PCR0 Match",pass:N,detail:N?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(r??"").slice(0,16)}...`}));let E;return e?.expectedUserDataB64!==void 0&&(E=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:E,detail:E?"Attestation user_data matches this proof's canonical hash":c!==void 0?"Attestation user_data does not match this proof":"Attestation carries no user_data to bind"})),{documentValid:!0,checks:n,...r!==void 0?{pcr0:r}:{},pcrs:o,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},certChainLength:a,...c!==void 0?{userDataB64:c}:{},...N!==void 0?{pcr0Matches:N}:{},...E!==void 0?{userDataMatches:E}:{}}}catch(d){return n.push({name:"Verification Error",pass:!1,detail:d instanceof Error?d.message:String(d)}),f()}}async function mr(t,e,n){let o=[],r=[],i={proofsWithDeclaredMeasurement:0,proofsWithDocument:0,documentsValidated:0,documentsFailed:0,pcr0Matches:0,pcr0Mismatches:0,userDataBound:0,userDataUnbound:0};for(let s of t.proofs){let a=s.measurement!==void 0&&s.measurement.length>0?s.measurement:void 0;a!==void 0&&i.proofsWithDeclaredMeasurement++;let c=Gd(s),f={proofHash:s.proofHash,declaredMeasurementPresent:a!==void 0,...a!==void 0?{declaredMeasurement:a}:{},documentPresent:c!==void 0,...c?.format!==void 0?{attestationFormat:c.format}:{},documentValidated:!1,checks:[]};if(c!==void 0){i.proofsWithDocument++;let d=await ia(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:zo(s.proof),...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});f.documentValidated=d.documentValid,f.checks=d.checks,d.pcr0!==void 0&&(f.attestedPcr0=d.pcr0),f.pcrs=d.pcrs,d.moduleId!==void 0&&(f.moduleId=d.moduleId),d.timestamp!==void 0&&(f.timestamp=d.timestamp),d.certChainLength!==void 0&&(f.certChainLength=d.certChainLength),d.userDataB64!==void 0&&(f.userDataB64=d.userDataB64),d.documentValid?(i.documentsValidated++,d.pcr0Matches!==void 0&&(f.pcr0MatchesDeclared=d.pcr0Matches,d.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,r.push({code:"attestation-measurement-mismatch",...ur(s),message:"the validated attestation document's PCR0 does not equal the proof's declared environment.measurement. Declared and attested measurements are reported separately and disagree here.",details:{proofHash:s.proofHash,declared:a,...d.pcr0!==void 0?{attested:d.pcr0}:{}}}))),d.userDataMatches!==void 0&&(f.userDataBoundToProof=d.userDataMatches,d.userDataMatches?i.userDataBound++:(i.userDataUnbound++,r.push({code:"attestation-user-data-mismatch",...ur(s),message:"the validated attestation document's user_data is not bound to this proof's canonical hash. A genuine attestation lifted from another proof would look exactly like this.",details:{proofHash:s.proofHash,...d.userDataB64!==void 0?{userDataB64:d.userDataB64}:{}}})))):(i.documentsFailed++,d.failure!==void 0&&(f.validationFailure=d.failure),r.push({code:"attestation-invalid",...ur(s),message:`attestation document failed offline validation: ${d.failure??"unknown"}. Presence of a document is reported separately and proves nothing by itself.`,details:{proofHash:s.proofHash}}))}o.push(f)}return e!==void 0&&qd(e,o),{records:o,findings:r,counts:i}}function qd(t,e){let n=new Map(e.map(o=>[o.proofHash,o]));for(let o of t.groups){if(!o.attestationPresent)continue;let r=o.proofHashes.map(f=>n.get(f)).filter(f=>f!==void 0&&f.documentPresent);if(r.length===0)continue;let i=r.filter(f=>f.documentValidated),s=r.length-i.length,a=[...new Set(i.map(f=>f.attestedPcr0).filter(f=>f!==void 0))].sort(),c=a.length===1?a[0]:void 0;o.attested={status:s===0&&i.length>0?"validated":"validation-failed",...c!==void 0?{attestedMeasurement:c}:{},...c!==void 0&&o.measurement!==void 0?{matchesDeclared:c===o.measurement}:{},validatedProofCount:i.length,failedProofCount:s,...a.length>1?{attestedMeasurements:a}:{}}}}function Gd(t){let e=t.proof.environment;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.attestation;if(n===null||typeof n!="object"||Array.isArray(n))return;let o=n.reportB64;if(typeof o!="string"||o.length===0)return;let r=n.format;return{reportB64:o,...typeof r=="string"?{format:r}:{}}}function ur(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function Wd(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function gr(t){return t<24?new Uint8Array([t]):t<256?new Uint8Array([24,t]):t<65536?new Uint8Array([25,t>>8,t&255]):new Uint8Array([26,t>>>24&255,t>>>16&255,t>>>8&255,t&255])}function hr(t){let e=gr(t.length);e[0]=e[0]&31|64;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function Zd(t){let e=new TextEncoder().encode(t),n=gr(e.length);n[0]=n[0]&31|96;let o=new Uint8Array(n.length+e.length);return o.set(n,0),o.set(e,n.length),o}function Yd(t){let e=gr(t.length);e[0]=e[0]&31|128;let n=e.length+t.reduce((i,s)=>i+s.length,0),o=new Uint8Array(n),r=0;o.set(e,r),r+=e.length;for(let i of t)o.set(i,r),r+=i.length;return o}function Xd(t,e){return Yd([Zd("Signature1"),hr(t),hr(new Uint8Array(0)),hr(e)])}function Ue(t,e=0){let n=t[e];if(n===void 0)throw new Error("CBOR: unexpected end of input");let o=n>>5,r=n&31;e++;let i=a=>{let c=t[a];if(c===void 0)throw new Error("CBOR: unexpected end of input");return c};function s(){if(r<24)return r;if(r===24){let a=i(e);return e+=1,a}if(r===25){let a=i(e)<<8|i(e+1);return e+=2,a}if(r===26){let a=(i(e)<<24|i(e+1)<<16|i(e+2)<<8|i(e+3))>>>0;return e+=4,a}if(r===27){let a=0;for(let c=0;c<8;c++)a=a*256+i(e+c);return e+=8,a}throw new Error(`Unsupported CBOR length info: ${r}`)}switch(o){case 0:return{value:s(),offset:e};case 1:return{value:-1-s(),offset:e};case 2:{let a=s();if(e+a>t.length)throw new Error("CBOR: byte string is truncated");return{value:t.slice(e,e+a),offset:e+a}}case 3:{let a=s();if(e+a>t.length)throw new Error("CBOR: text string is truncated");return{value:new TextDecoder().decode(t.slice(e,e+a)),offset:e+a}}case 4:{if(r===31){let f=[];for(;i(e)!==255;){let d=Ue(t,e);f.push(d.value),e=d.offset}return{value:f,offset:e+1}}let a=s(),c=[];for(let f=0;f<a;f++){let d=Ue(t,e);c.push(d.value),e=d.offset}return{value:c,offset:e}}case 5:{if(r===31){let f={};for(;i(e)!==255;){let d=Ue(t,e);e=d.offset;let u=Ue(t,e);e=u.offset,f[String(d.value)]=u.value}return{value:f,offset:e+1}}let a=s(),c={};for(let f=0;f<a;f++){let d=Ue(t,e);e=d.offset;let u=Ue(t,e);e=u.offset,c[String(d.value)]=u.value}return{value:c,offset:e}}case 6:return s(),Ue(t,e);case 7:{if(r===20)return{value:!1,offset:e};if(r===21)return{value:!0,offset:e};if(r===22)return{value:null,offset:e};if(r===23)return{value:void 0,offset:e};throw new Error(`Unsupported CBOR simple value: ${r}`)}default:throw new Error(`Unsupported CBOR major type: ${o}`)}}function lr(t){let n=Vt(t,0).contentStart,o=re(t,n),r=t.slice(n,o.end);n=o.end,n=re(t,n).end;let s=re(t,n),a=t.slice(s.contentStart+1,s.end),c=Qd(a,48),{publicKey:f,notBeforeMs:d,notAfterMs:u}=Jd(r);return{tbsCertificate:r,signature:c,publicKey:f,notBeforeMs:d,notAfterMs:u}}function re(t,e){let n=t[e];if(n===void 0)throw new Error("DER: unexpected end of input");let o=e+1,r=t[o++];if(r===void 0)throw new Error("DER: unexpected end of input");if(r&128){let s=r&127;r=0;for(let a=0;a<s;a++){let c=t[o++];if(c===void 0)throw new Error("DER: unexpected end of input");r=r*256+c}}let i=o+r;if(i>t.length)throw new Error("DER: element is truncated");return{tag:n,contentStart:o,contentEnd:i,end:i}}function Vt(t,e){let n=re(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function Jd(t){let n=Vt(t,0).contentStart;t[n]===160&&(n=re(t,n).end),n=re(t,n).end,n=re(t,n).end,n=re(t,n).end;let o=Vt(t,n),r=o.contentStart,i=re(t,r);r=i.end;let s=re(t,r),a=ra(t,i),c=ra(t,s);n=o.end,n=re(t,n).end;let d=Vt(t,n).contentStart;d=re(t,d).end;let h=re(t,d);return{publicKey:t.slice(h.contentStart+1,h.end),notBeforeMs:a,notAfterMs:c}}function ra(t,e){let n=String.fromCharCode(...t.slice(e.contentStart,e.contentEnd)),o,r;if(e.tag===23){if(!/^\d{12}Z$/.test(n))throw new Error(`DER: malformed UTCTime "${n}"`);let d=Number.parseInt(n.slice(0,2),10);o=d<50?2e3+d:1900+d,r=n.slice(2)}else if(e.tag===24){if(!/^\d{14}Z$/.test(n))throw new Error(`DER: malformed GeneralizedTime "${n}"`);o=Number.parseInt(n.slice(0,4),10),r=n.slice(4)}else throw new Error(`DER: expected a Time value, got tag 0x${e.tag.toString(16)}`);let i=Number.parseInt(r.slice(0,2),10),s=Number.parseInt(r.slice(2,4),10),a=Number.parseInt(r.slice(4,6),10),c=Number.parseInt(r.slice(6,8),10),f=Number.parseInt(r.slice(8,10),10);return Date.UTC(o,i-1,s,a,c,f)}function Qd(t,e){let o=Vt(t,0).contentStart,r=re(t,o);if(r.tag!==2)throw new Error("Expected INTEGER for r");let i=t.slice(r.contentStart,r.end);o=r.end;let s=re(t,o);if(s.tag!==2)throw new Error("Expected INTEGER for s");let a=t.slice(s.contentStart,s.end);if(i[0]===0&&i.length>e&&(i=i.slice(1)),a[0]===0&&a.length>e&&(a=a.slice(1)),i.length>e||a.length>e)throw new Error("ECDSA signature component longer than the curve coordinate size");let c=new Uint8Array(e*2);return c.set(i,e-i.length),c.set(a,e*2-a.length),c}async function pr(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let o=await Oo.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await Oo.subtle.verify({name:"ECDSA",hash:"SHA-384"},o,t,e)}catch{return!1}}function eu(t){let e={},n=t.pcrs;if(!n||typeof n!="object")return e;for(let[o,r]of Object.entries(n))if(r instanceof Uint8Array){let i=B.Buffer.from(r).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(o)]=i)}return e}b();var Ln="0.3.0";function sa(){return Ln}async function br(t,e){let n=e?.startedAt??new Date().toISOString(),o=await Xo(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),r=await Qo(t),i=await er(t,r),s=nr(t),a=ir(t),c=await fr(t,a),f=dr(t,r,a,c),d=await mr(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:sa(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:o,reconstruction:r,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:f,attestations:d}}b();b();b();b();b();var aa=1048576;b();function Mn(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}b();b();var yr="0.7.0";var iu=[{pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92",label:"genesis",period:"2026-05-15 to 2026-06-27"},{pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a",label:"enclave v2 (reproducible)",period:"2026-06-27 to 2026-07-05"},{pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb",label:"enclave v4 (reproducible)",period:"2026-07-05 to 2026-07-29"},{pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f",label:"enclave v5 (reproducible)",period:"2026-07-29 onward"}],su=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function ua(t,e){let n=e;if(n?.from!==void 0&&n.sigEvidence===void 0){let r=new Map;for await(let i of Kt(t))i.bytes.length>aa||r.has(i.sha256Hex)||r.set(i.sha256Hex,i.bytes);n={...n,sigEvidence:r}}let o=await br(t,{startedAt:""});return au(o,n)}function au(t,e){let n=e?.webCryptoAvailable??!0,o=new Map(t.anchors.anchors.map(m=>[m.proofHash,m])),r=new Map(t.attestations.records.map(m=>[m.proofHash,m])),i=new Map;for(let m of t.temporal.segments)for(let x of m.memberProofHashes)i.set(x,m);let s=new Map;for(let m of t.witnesses.outcomes){if(m.anchorProofHash===void 0)continue;let x=s.get(m.anchorProofHash)??[];x.push(m),s.set(m.anchorProofHash,x)}let a=new Map;for(let m of t.ingest.artifacts)for(let x of m.matchedProofHashes)!a.has(x)&&m.paths[0]!==void 0&&a.set(x,m.paths[0]);let c=[],f=[];for(let m of t.ingest.proofs){let x=o.get(m.proofHash);x!==void 0?f.push(bu(m,x,s.get(m.proofHash)??[])):c.push(cu(m,r.get(m.proofHash),i.get(m.proofHash),a.get(m.proofHash),n,e?.from,e?.sigEvidence))}ca(c),ca(f);let d=yu(t),u=wu(t,c,f),h=xu(f.length>0,e?.from?.domain),l=[...c.map(m=>m.result),...f.map(m=>m.result),...d.map(m=>m.result)],p=l.length===0?"UNDETERMINED":Mn(l);return{check:e?.from!==void 0?"bitgraph-check/2":"bitgraph-check/1",...e?.from!==void 0?{from:{domain:e.from.domain,party:e.from.party}}:{},result:p,summary:Eu(p,c,f,d),recordings:c,anchors:f,contradictions:d,notes:u,notChecked:h,evaluator:{name:"bitgraph-player",version:yr,audit:Ln},network:"none"}}function ca(t){let e=n=>[n.epochId??"",n.counter!==void 0&&/^[0-9]+$/.test(n.counter)?BigInt(n.counter):void 0];t.sort((n,o)=>{let[r,i]=e(n),[s,a]=e(o);return r!==s?r<s?-1:1:i===void 0||a===void 0?i===void 0?a===void 0?0:1:-1:i<a?-1:i>a?1:0})}function cu(t,e,n,o,r,i,s){let a=[],c=t.verification,f=t.proof.artifact.digestB64;c?.tier==="full"?a.push({name:"file",result:c.status==="verified"||c.status==="failed"?"TRUE":"UNDETERMINED",detail:c.status==="verified"||c.status==="failed"?`${o??"the matched file"} hashes to the recorded digest ${f}`:`no file in this bundle hashes to the recorded digest ${f}`}):a.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${f}; the recording cannot be bound to bytes in hand`}),c===void 0?a.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):c.status==="failed"?a.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${c.reason??"unspecified failure"}`}):a.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${xr(t.publicKeyB64)}`});let d=fu(e,r);if(a.push(d.line),a.push(lu(d.attestedPcr0,d.line.result)),i!==void 0){let h=c!==void 0&&c.status!=="failed";a.push(uu(t,h,i,s??du))}let u=Mn(a.map(h=>h.result));return{proofHash:t.proofHash,digestB64:f,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...o!==void 0&&c?.tier==="full"?{filePath:o}:{},lines:a,result:u,bounds:pu(n)}}function fu(t,e){return t===void 0||!t.documentPresent?{line:{name:"attestation",result:"UNDETERMINED",detail:"no attestation document in this proof"}}:e?t.documentValidated?t.userDataBoundToProof!==!0?{line:{name:"attestation",result:"FALSE",detail:"attestation document validates but its user_data is not this proof: the document belongs to some other proof"},attestedPcr0:t.attestedPcr0}:t.pcr0MatchesDeclared!==!0?{line:{name:"attestation",result:"FALSE",detail:`attestation validates and binds this proof, but its PCR0 ${zt(t.attestedPcr0)} is not the measurement the signed body declares ${zt(t.declaredMeasurement)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"TRUE",detail:`AWS Nitro attestation validates to the AWS root, binds this exact proof (user_data), and attests PCR0 ${zt(t.attestedPcr0)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"FALSE",detail:`attestation document does not validate: ${t.validationFailure??"unspecified failure"}`}}:{line:{name:"attestation",result:"UNDETERMINED",detail:"attestation not checked: this environment cannot verify ECDSA P-384 (no WebCrypto); open the verifier from a file or https page, or run bitgraph-play check"}}}var du=new Map;function uu(t,e,n,o){if(!e)return{name:"domain",result:"UNDETERMINED",detail:`the recording is not verified here, so nothing binds it to ${n.domain}`};let r=t.proof.agency?.actor?.keyId;if(r!==void 0){let s=n.actorKeyName(r);if(s!==void 0)return{name:"domain",result:"TRUE",detail:`actor key "${s}" \xB7 published by ${n.domain} (${n.party})`}}let i=hu(t.proof.artifact.digestB64);if(i!==void 0&&o.size>0){let s=n.signatureKeyName(i.toString("hex"),o);if(s!==void 0)return{name:"domain",result:"TRUE",detail:`signature by "${s}" \xB7 published by ${n.domain} (${n.party})`}}return r!==void 0?{name:"domain",result:"UNDETERMINED",detail:`actor key ${r.slice(0,12)}\u2026 is not among the ${n.keyCount} key(s) ${n.domain} publishes`}:{name:"domain",result:"UNDETERMINED",detail:`no evidence binds this recording to ${n.domain}`}}function hu(t){if(!/^[A-Za-z0-9+/]+=*$/.test(t))return;let e=B.Buffer.from(t,"base64");return e.toString("base64")===t?e:void 0}function lu(t,e){if(e!=="TRUE"||t===void 0)return{name:"enclave",result:"UNDETERMINED",detail:"enclave identity rests on a validated attestation, which this recording does not have here"};let n=iu.find(o=>o.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${zt(t)} is not among the BitGraph enclave measurements this verifier knows (player ${yr}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${zt(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function pu(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=fa(t.lowerBounds,"not-before"),n=fa(t.upperBounds,"not-after"),o=e===void 0?void 0:da(e),r=n===void 0?void 0:da(n),i=o!==void 0&&r!==void 0?"lower-bounded-with-following-anchor":o!==void 0?"lower-bounded":r!==void 0?"upper-bounded":"unanchored",s=i==="unanchored"?"no verified Ethereum anchor bounds this recording in this bundle":`recorded ${mu(i,o,r)}`;return{status:i,...o!==void 0?{notBefore:o}:{},...r!==void 0?{notAfter:r}:{},detail:s}}function mu(t,e,n){switch(t){case"lower-bounded-with-following-anchor":return`after Ethereum block ${Je(e)} (header verified in this bundle); precedes an anchor that consumed block ${Je(n)} (header verified), an anchor-latency assumption rather than an upper bound on this recording`+wr(e.weaker||n.weaker);case"lower-bounded":return`after Ethereum block ${Je(e)} (header verified in this bundle); no verified upper bound here`+wr(e.weaker);case"upper-bounded":return`before Ethereum block ${Je(n)} (header verified in this bundle); no verified lower bound here`+wr(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function fa(t,e){let n=t.filter(r=>r.kind===e);return n.length===0?void 0:[...n].sort((r,i)=>{let s=r.blockNumber!==void 0?BigInt(r.blockNumber):BigInt(r.timestamp),a=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);return s!==a?e==="not-before"?s>a?-1:1:s<a?-1:1:r.weaker!==i.weaker?r.weaker?1:-1:0})[0]}function da(t){return{...t.blockNumber!==void 0?{blockNumber:t.blockNumber}:{},blockHash:t.blockHash,timestamp:t.timestamp,anchorProofHash:t.anchorProofHash,evidence:t.evidence,weaker:t.weaker}}function gu(t){switch(t.status){case"lower-bounded-with-following-anchor":return`after Ethereum block ${Je(t.notBefore)}, then an anchor at block ${Je(t.notAfter)}`;case"lower-bounded":return`after Ethereum block ${Je(t.notBefore)}`;case"upper-bounded":return`before Ethereum block ${Je(t.notAfter)}`;default:return"with no Ethereum bound in this bundle"}}function Je(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function wr(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function bu(t,e,n){let o=[],r=t.verification;r===void 0?o.push({name:"signature",result:"UNDETERMINED",detail:"the anchor proof was not verified"}):r.status==="failed"?o.push({name:"signature",result:"FALSE",detail:`the anchor proof does not verify: ${r.reason??"unspecified failure"}`}):o.push({name:"signature",result:"TRUE",detail:`anchor proof verifies under signer key ${xr(t.publicKeyB64)}`});let i;if(n.length>0){let s=n.find(a=>a.verified);if(s!==void 0)i=s.witnessPath,o.push({name:"witness",result:"TRUE",detail:`block header ${s.witnessPath} hashes (keccak-256) to the anchored block hash${e.blockNumber!==void 0?` of block ${e.blockNumber}`:""}`});else{let a=n[0];i=a.witnessPath,o.push({name:"witness",result:"FALSE",detail:`block header ${a.witnessPath} contradicts this anchor: ${a.detail??a.reason??"witness verification failed"}`})}}return{proofHash:t.proofHash,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...e.blockNumber!==void 0?{blockNumber:e.blockNumber}:{},...e.blockHash!==void 0?{blockHash:e.blockHash}:{},...i!==void 0?{witnessPath:i}:{},lines:o,result:Mn(o.map(s=>s.result))}}function yu(t){let e=[],n=new Set,o=r=>{n.has(r)||(n.add(r),e.push({name:"contradiction",result:"FALSE",detail:r}))};for(let r of t.anomalies.anomalies)su.has(r.code)||o(`${r.code}: ${r.message}`);for(let r of t.anomalies.divergences)o(`${r.kind}: ${r.explanation}`);for(let r of t.authorities.anomalies)o(`${r.code}: ${r.message}`);for(let r of t.witnesses.findings)(r.code==="witness-unmatched"||r.code==="witness-malformed"||r.code==="witness-rlp-invalid")&&o(`${r.code}: ${r.message}`);for(let r of t.ingest.findings)r.code==="proofhash-mismatch"&&o(`${r.code}: ${r.message}${r.path!==void 0?` (${r.path})`:""}`);return e}function wu(t,e,n){let o=[],r=0n,i=0;for(let f of t.anomalies.anomalies)if(f.code==="unexplained-counter-positions"){let d=f.details?.count;d!==void 0&&/^[0-9]+$/.test(d)&&(r+=BigInt(d))}else f.code==="chain-break-missing"&&(i+=f.proofHashes.length);r>0n&&o.push(`${r} causal position${r===1n?"":"s"} between the earliest and latest recording here ${r===1n?"is":"are"} not in this bundle: normal for an export, which is an excerpt of the chain; a full-epoch audit checks them`),i>0&&o.push(`${i} recording${i===1?"":"s"} link${i===1?"s":""} to a predecessor that is not in this bundle: normal for an export`);let s=t.ingest.artifacts.filter(f=>f.matchedProofHashes.length===0);if(s.length>0&&e.length>0){let f=s.slice(0,5).map(d=>`${d.paths[0]??"(unnamed)"} (sha256:${d.sha256Hex.slice(0,16)}\u2026)`).join(", ");o.push(`${s.length} file${s.length===1?"":"s"} in this bundle match${s.length===1?"es":""} no recording here: ${f}${s.length>5?", \u2026":""}. If ${s.length===1?"it":"one of them"} was meant to be a recorded file, its bytes differ from what was recorded`)}let a=n.filter(f=>f.witnessPath===void 0);a.length>0&&o.push(`${a.length} Ethereum anchor${a.length===1?"":"s"} in this bundle ha${a.length===1?"s":"ve"} no block-header witness file, so ${a.length===1?"its":"their"} block hash${a.length===1?" is":"es are"} not verified here and no bound is derived from ${a.length===1?"it":"them"}`);for(let f of t.ingest.unsupportedVersions)o.push(`${f.path} is proof-shaped but its version "${f.version}" is not bitgraph/1; it was not checked`);let c=t.ingest.counts;if((c.exactDuplicates>0||c.semanticDuplicates>0)&&o.push(`${c.exactDuplicates+c.semanticDuplicates} duplicate proof file${c.exactDuplicates+c.semanticDuplicates===1?"":"s"} collapsed to one recording each`),t.ingest.manifest!==void 0)for(let f of t.ingest.findings)typeof f.code=="string"&&f.code.startsWith("manifest-")&&o.push(`${f.code}: ${f.message}`);return e.length===0&&n.length===0&&o.push("no BitGraph proofs were found in this bundle"),o}function xu(t,e){let n=[];return t&&n.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e!==void 0&&n.push(`whether ${e}'s published key file has changed since it was pinned: a pin is read as stored; pin the domain again to refresh it`),n.push("whether the public ledger holds these exact recordings at these positions: this is an offline check; drop the file on bitgraph.ing to compare against the ledger"),n.push("whether an epoch key was later quarantined: that is published outside any bundle"),n}function Eu(t,e,n,o){if(e.length===0&&n.length===0)return"UNDETERMINED: no BitGraph proofs were found in this bundle.";let r=e.length,i=`${r} recording${r===1?"":"s"}`;if(t==="TRUE"){let a=e[0];return r===1&&a!==void 0?`TRUE: this file was recorded${a.counter!==void 0?` at position ${a.counter}${a.epochId!==void 0?` of epoch ${xr(a.epochId)}`:""}`:""}, ${gu(a.bounds)}.`:`TRUE: ${i} verified: files match, signatures and attestations hold, enclave measurements published${n.length>0?", Ethereum bounds verified from block headers in the bundle":""}.`}if(t==="FALSE")return`FALSE: evidence in this bundle contradicts itself. ${[...e.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...n.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...o.map(c=>c.detail)][0]??""}`.trim();let s=[...e.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail)),...n.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail))];return`UNDETERMINED: nothing here contradicts the ${i}, but the evidence does not fully decide. ${s[0]??""}`.trim()}function xr(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function zt(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}tn.sha512Async=async(...t)=>cn(tn.concatBytes(...t));var ba=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function ya(t){return new Promise((e,n)=>{let o=[],r=()=>{t.readEntries(i=>{if(i.length===0){e(o);return}o.push(...i),r()},n)};r()})}function Bu(t){return new Promise((e,n)=>t.file(e,n))}async function vr(t,e,n){if(t.isFile){let o=await Bu(t);n.push({path:e+t.name,file:o});return}if(t.isDirectory){let o=t.createReader(),r=await ya(o);for(let i of r)i.name!==".DS_Store"&&await vr(i,`${e}${t.name}/`,n)}}async function vu(t){let n=Array.from(t.items??[]).map(r=>typeof r.webkitGetAsEntry=="function"?r.webkitGetAsEntry():null).filter(r=>r!==null);if(n.length===0)return Array.from(t.files??[]).map(r=>({path:r.name,file:r}));let o=[];if(n.length===1&&n[0]!==void 0&&n[0].isDirectory){let r=n[0];for(let i of await ya(r.createReader()))i.name!==".DS_Store"&&await vr(i,"",o)}else for(let r of n)await vr(r,"",o);return o.length===0?Array.from(t.files??[]).map(r=>({path:r.name,file:r})):o}function ha(t){let e=Array.from(t.files??[]),n=e.map(s=>s.webkitRelativePath||s.name),o=n.map(s=>s.indexOf("/")),r=n.length>0&&o.every(s=>s>0)?n[0].slice(0,o[0]):void 0,i=r!==void 0&&n.every(s=>s.startsWith(`${r}/`));return e.map((s,a)=>({path:i?n[a].slice(r.length+1):n[a],file:s})).filter(s=>!s.path.endsWith("/.DS_Store")&&s.path!==".DS_Store")}function Au(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function P(t,e={},n=[]){let o=document.createElement(t);for(let[r,i]of Object.entries(e))r==="class"?o.className=i:o.setAttribute(r,i);for(let r of n)o.append(typeof r=="string"?document.createTextNode(r):r);return o}function Ar(t){return t==="TRUE"?null:P("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function qt(t,e,n={}){let o=P("div",{class:"field-head"},[P("span",{class:"field-label"},[t])]),r=n.mark!==void 0?Ar(n.mark):null;return r!==null&&o.append(r),P("div",{class:"field"},[o,P("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function Qe(t,e,n={}){let o=n.open===!0,r=P("span",{class:"chev","aria-hidden":"true"});r.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 6 L15 12 L9 18"/></svg>';let i=P("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(o)},[P("span",{},[t]),r]),s=P("div",{class:"opener-body"},e),a=P("section",{class:"card"},[i,s]),c=()=>{i.classList.toggle("open",o),i.setAttribute("aria-expanded",String(o)),s.hidden=!o,r.classList.toggle("open",o)};return i.addEventListener("click",()=>{o=!o,c()}),c(),a}function ku(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function Iu(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function Hu(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function Nn(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function Su(t){return new Date(t*1e3).toLocaleString("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",timeZoneName:"short"})}function la(t){let e=t.bounds,n=i=>P("span",{class:"when-grey"},[i]),o=i=>P("span",{class:"when-dark"},[i]),r=P("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;r.append(P("div",{class:"when-date"},[Hu(i.timestamp)]));let s=P("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("after "),o(Nn(e.notBefore.timestamp,!0)),n(", then an anchor at "),o(Nn(e.notAfter.timestamp,!1)),n(" (not an upper bound)")):e.notBefore!==void 0?s.append(n("after "),o(Nn(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("no lower bound in this bundle; an anchor followed at "),o(Nn(e.notAfter.timestamp,!0)),n(" (not an upper bound)")),r.append(s)}else r.append(P("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return r}var Cu=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,Tu=/\.(mp4|m4v|mov|webm|ogv)$/i,$u=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,Ru=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function Pu(t){let e=t.subarray(0,Math.min(2048,t.length));if(!e.length)return!1;let n=0;for(let o of e){if(o===0)return!1;(o===9||o===10||o===13||o>=32)&&n++}return n/e.length>.97}function Du(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":Cu.test(n)?"image":Tu.test(n)?"video":$u.test(n)?"audio":Ru.test(n)||Pu(e)?"text":"other"}function Lu(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Mu(t,e,n){if(n==="image"||n==="video"){let o=URL.createObjectURL(t),r=n==="image"?P("img",{src:o,alt:t.name,style:"display:block;max-width:100%;max-height:min(70vh,640px);width:auto;height:auto;object-fit:contain;border-radius:0"}):P("video",{src:o,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return P("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[r])}if(n==="audio"){let o=URL.createObjectURL(t);return P("div",{style:"padding:20px 16px"},[P("audio",{src:o,controls:"",style:"display:block;width:100%"})])}if(n==="text")try{let o=new TextDecoder("utf-8",{fatal:!1}).decode(e.subarray(0,6e3)),r=o.split(`
|
|
153
|
-
`),i=
|
|
154
|
-
`).slice(0,3e3),s=
|
|
155
|
-
\u2026`:"")])}catch{return null}return null}function
|
|
152
|
+
-----END CERTIFICATE-----`;function Fd(){return Ka.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function ja(){return new Uint8Array(B.Buffer.from(Fd(),"base64"))}async function za(t,e){let n=[],r={},o,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(u=>!u.pass)?.detail,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},...a!==void 0?{certChainLength:a}:{},...c!==void 0?{userDataB64:c}:{}});try{let u=Kd(t);if(u===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let d=je(u,0).value;if(!Array.isArray(d)||d.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),f();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let h=d[0],l=d[2],m=d[3];if(!(h instanceof Uint8Array)||!(l instanceof Uint8Array)||!(m instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),f();let p=je(l,0).value;if(!p||typeof p!="object"||Array.isArray(p))return n.push({name:"Payload Decode",pass:!1,detail:"Could not decode attestation payload"}),f();r=Wd(p),o=r[0],i=typeof p.module_id=="string"?p.module_id:void 0,s=typeof p.timestamp=="number"?p.timestamp:void 0;let y=p.user_data;c=y instanceof Uint8Array&&y.length>0?B.Buffer.from(y).toString("base64"):void 0;let b=p.cabundle,I=p.certificate;if(!(I instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),f();a=(Array.isArray(b)?b.length:0)+1;let v=jo(I),F=zd(h,l),z=await Vo(m,F,v.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:z,detail:z?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!z)return f();if(!Array.isArray(b)||b.length===0||!b.every(A=>A instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let H=[...b,I].map(jo),N=!0,U="";for(let A=1;A<H.length;A++){let C=H[A],D=H[A-1];if(!await Vo(C.signature,C.tbsCertificate,D.publicKey)){N=!1,U=`Certificate ${A} signature invalid (parent: ${A-1})`;break}}if(n.push({name:"Certificate Chain",pass:N,detail:N?`${H.length} certificates, each signed by parent`:U}),!N)return f();let Z=e?.trustedRootCaDer===void 0,q=jo(e?.trustedRootCaDer??ja()),le=H[0],O=await Vo(le.signature,le.tbsCertificate,q.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:O,detail:O?Z?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":Z?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!O)return f();let ie=!0,re=`All ${H.length} certificate validity windows contain the document timestamp`;if(s===void 0)ie=!1,re="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let A=0;A<H.length;A++){let C=H[A];if(s<C.notBeforeMs||s>C.notAfterMs){ie=!1,re=`Certificate ${A} validity window [${new Date(C.notBeforeMs).toISOString()}, ${new Date(C.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:ie,detail:re}),!ie)return f();let M;e?.expectedPcr0!==void 0&&(M=o===e.expectedPcr0,n.push({name:"PCR0 Match",pass:M,detail:M?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(o??"").slice(0,16)}...`}));let E;return e?.expectedUserDataB64!==void 0&&(E=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:E,detail:E?"Attestation user_data matches this proof's canonical hash":c!==void 0?"Attestation user_data does not match this proof":"Attestation carries no user_data to bind"})),{documentValid:!0,checks:n,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},certChainLength:a,...c!==void 0?{userDataB64:c}:{},...M!==void 0?{pcr0Matches:M}:{},...E!==void 0?{userDataMatches:E}:{}}}catch(u){return n.push({name:"Verification Error",pass:!1,detail:u instanceof Error?u.message:String(u)}),f()}}async function zo(t,e,n){let r=[],o=[],i={proofsWithDeclaredMeasurement:0,proofsWithDocument:0,documentsValidated:0,documentsFailed:0,pcr0Matches:0,pcr0Mismatches:0,userDataBound:0,userDataUnbound:0};for(let s of t.proofs){let a=s.measurement!==void 0&&s.measurement.length>0?s.measurement:void 0;a!==void 0&&i.proofsWithDeclaredMeasurement++;let c=_d(s),f={proofHash:s.proofHash,declaredMeasurementPresent:a!==void 0,...a!==void 0?{declaredMeasurement:a}:{},documentPresent:c!==void 0,...c?.format!==void 0?{attestationFormat:c.format}:{},documentValidated:!1,checks:[]};if(c!==void 0){i.proofsWithDocument++;let u=await za(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:ao(s.proof),...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});f.documentValidated=u.documentValid,f.checks=u.checks,u.pcr0!==void 0&&(f.attestedPcr0=u.pcr0),f.pcrs=u.pcrs,u.moduleId!==void 0&&(f.moduleId=u.moduleId),u.timestamp!==void 0&&(f.timestamp=u.timestamp),u.certChainLength!==void 0&&(f.certChainLength=u.certChainLength),u.userDataB64!==void 0&&(f.userDataB64=u.userDataB64),u.documentValid?(i.documentsValidated++,u.pcr0Matches!==void 0&&(f.pcr0MatchesDeclared=u.pcr0Matches,u.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,o.push({code:"attestation-measurement-mismatch",..._o(s),message:"the validated attestation document's PCR0 does not equal the proof's declared environment.measurement. Declared and attested measurements are reported separately and disagree here.",details:{proofHash:s.proofHash,declared:a,...u.pcr0!==void 0?{attested:u.pcr0}:{}}}))),u.userDataMatches!==void 0&&(f.userDataBoundToProof=u.userDataMatches,u.userDataMatches?i.userDataBound++:(i.userDataUnbound++,o.push({code:"attestation-user-data-mismatch",..._o(s),message:"the validated attestation document's user_data is not bound to this proof's canonical hash. A genuine attestation lifted from another proof would look exactly like this.",details:{proofHash:s.proofHash,...u.userDataB64!==void 0?{userDataB64:u.userDataB64}:{}}})))):(i.documentsFailed++,u.failure!==void 0&&(f.validationFailure=u.failure),o.push({code:"attestation-invalid",..._o(s),message:`attestation document failed offline validation: ${u.failure??"unknown"}. Presence of a document is reported separately and proves nothing by itself.`,details:{proofHash:s.proofHash}}))}r.push(f)}return e!==void 0&&Ud(e,r),{records:r,findings:o,counts:i}}function Ud(t,e){let n=new Map(e.map(r=>[r.proofHash,r]));for(let r of t.groups){if(!r.attestationPresent)continue;let o=r.proofHashes.map(f=>n.get(f)).filter(f=>f!==void 0&&f.documentPresent);if(o.length===0)continue;let i=o.filter(f=>f.documentValidated),s=o.length-i.length,a=[...new Set(i.map(f=>f.attestedPcr0).filter(f=>f!==void 0))].sort(),c=a.length===1?a[0]:void 0;r.attested={status:s===0&&i.length>0?"validated":"validation-failed",...c!==void 0?{attestedMeasurement:c}:{},...c!==void 0&&r.measurement!==void 0?{matchesDeclared:c===r.measurement}:{},validatedProofCount:i.length,failedProofCount:s,...a.length>1?{attestedMeasurements:a}:{}}}}function _d(t){let e=t.proof.environment;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.attestation;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n.reportB64;if(typeof r!="string"||r.length===0)return;let o=n.format;return{reportB64:r,...typeof o=="string"?{format:o}:{}}}function _o(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function Kd(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function qo(t){return t<24?new Uint8Array([t]):t<256?new Uint8Array([24,t]):t<65536?new Uint8Array([25,t>>8,t&255]):new Uint8Array([26,t>>>24&255,t>>>16&255,t>>>8&255,t&255])}function Ko(t){let e=qo(t.length);e[0]=e[0]&31|64;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function jd(t){let e=new TextEncoder().encode(t),n=qo(e.length);n[0]=n[0]&31|96;let r=new Uint8Array(n.length+e.length);return r.set(n,0),r.set(e,n.length),r}function Vd(t){let e=qo(t.length);e[0]=e[0]&31|128;let n=e.length+t.reduce((i,s)=>i+s.length,0),r=new Uint8Array(n),o=0;r.set(e,o),o+=e.length;for(let i of t)r.set(i,o),o+=i.length;return r}function zd(t,e){return Vd([jd("Signature1"),Ko(t),Ko(new Uint8Array(0)),Ko(e)])}function je(t,e=0){let n=t[e];if(n===void 0)throw new Error("CBOR: unexpected end of input");let r=n>>5,o=n&31;e++;let i=a=>{let c=t[a];if(c===void 0)throw new Error("CBOR: unexpected end of input");return c};function s(){if(o<24)return o;if(o===24){let a=i(e);return e+=1,a}if(o===25){let a=i(e)<<8|i(e+1);return e+=2,a}if(o===26){let a=(i(e)<<24|i(e+1)<<16|i(e+2)<<8|i(e+3))>>>0;return e+=4,a}if(o===27){let a=0;for(let c=0;c<8;c++)a=a*256+i(e+c);return e+=8,a}throw new Error(`Unsupported CBOR length info: ${o}`)}switch(r){case 0:return{value:s(),offset:e};case 1:return{value:-1-s(),offset:e};case 2:{let a=s();if(e+a>t.length)throw new Error("CBOR: byte string is truncated");return{value:t.slice(e,e+a),offset:e+a}}case 3:{let a=s();if(e+a>t.length)throw new Error("CBOR: text string is truncated");return{value:new TextDecoder().decode(t.slice(e,e+a)),offset:e+a}}case 4:{if(o===31){let f=[];for(;i(e)!==255;){let u=je(t,e);f.push(u.value),e=u.offset}return{value:f,offset:e+1}}let a=s(),c=[];for(let f=0;f<a;f++){let u=je(t,e);c.push(u.value),e=u.offset}return{value:c,offset:e}}case 5:{if(o===31){let f={};for(;i(e)!==255;){let u=je(t,e);e=u.offset;let d=je(t,e);e=d.offset,f[String(u.value)]=d.value}return{value:f,offset:e+1}}let a=s(),c={};for(let f=0;f<a;f++){let u=je(t,e);e=u.offset;let d=je(t,e);e=d.offset,c[String(u.value)]=d.value}return{value:c,offset:e}}case 6:return s(),je(t,e);case 7:{if(o===20)return{value:!1,offset:e};if(o===21)return{value:!0,offset:e};if(o===22)return{value:null,offset:e};if(o===23)return{value:void 0,offset:e};throw new Error(`Unsupported CBOR simple value: ${o}`)}default:throw new Error(`Unsupported CBOR major type: ${r}`)}}function jo(t){let n=nn(t,0).contentStart,r=oe(t,n),o=t.slice(n,r.end);n=r.end,n=oe(t,n).end;let s=oe(t,n),a=t.slice(s.contentStart+1,s.end),c=Gd(a,48),{publicKey:f,notBeforeMs:u,notAfterMs:d}=qd(o);return{tbsCertificate:o,signature:c,publicKey:f,notBeforeMs:u,notAfterMs:d}}function oe(t,e){let n=t[e];if(n===void 0)throw new Error("DER: unexpected end of input");let r=e+1,o=t[r++];if(o===void 0)throw new Error("DER: unexpected end of input");if(o&128){let s=o&127;o=0;for(let a=0;a<s;a++){let c=t[r++];if(c===void 0)throw new Error("DER: unexpected end of input");o=o*256+c}}let i=r+o;if(i>t.length)throw new Error("DER: element is truncated");return{tag:n,contentStart:r,contentEnd:i,end:i}}function nn(t,e){let n=oe(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function qd(t){let n=nn(t,0).contentStart;t[n]===160&&(n=oe(t,n).end),n=oe(t,n).end,n=oe(t,n).end,n=oe(t,n).end;let r=nn(t,n),o=r.contentStart,i=oe(t,o);o=i.end;let s=oe(t,o),a=Va(t,i),c=Va(t,s);n=r.end,n=oe(t,n).end;let u=nn(t,n).contentStart;u=oe(t,u).end;let h=oe(t,u);return{publicKey:t.slice(h.contentStart+1,h.end),notBeforeMs:a,notAfterMs:c}}function Va(t,e){let n=String.fromCharCode(...t.slice(e.contentStart,e.contentEnd)),r,o;if(e.tag===23){if(!/^\d{12}Z$/.test(n))throw new Error(`DER: malformed UTCTime "${n}"`);let u=Number.parseInt(n.slice(0,2),10);r=u<50?2e3+u:1900+u,o=n.slice(2)}else if(e.tag===24){if(!/^\d{14}Z$/.test(n))throw new Error(`DER: malformed GeneralizedTime "${n}"`);r=Number.parseInt(n.slice(0,4),10),o=n.slice(4)}else throw new Error(`DER: expected a Time value, got tag 0x${e.tag.toString(16)}`);let i=Number.parseInt(o.slice(0,2),10),s=Number.parseInt(o.slice(2,4),10),a=Number.parseInt(o.slice(4,6),10),c=Number.parseInt(o.slice(6,8),10),f=Number.parseInt(o.slice(8,10),10);return Date.UTC(r,i-1,s,a,c,f)}function Gd(t,e){let r=nn(t,0).contentStart,o=oe(t,r);if(o.tag!==2)throw new Error("Expected INTEGER for r");let i=t.slice(o.contentStart,o.end);r=o.end;let s=oe(t,r);if(s.tag!==2)throw new Error("Expected INTEGER for s");let a=t.slice(s.contentStart,s.end);if(i[0]===0&&i.length>e&&(i=i.slice(1)),a[0]===0&&a.length>e&&(a=a.slice(1)),i.length>e||a.length>e)throw new Error("ECDSA signature component longer than the curve coordinate size");let c=new Uint8Array(e*2);return c.set(i,e-i.length),c.set(a,e*2-a.length),c}async function Vo(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let r=await eo.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await eo.subtle.verify({name:"ECDSA",hash:"SHA-384"},r,t,e)}catch{return!1}}function Wd(t){let e={},n=t.pcrs;if(!n||typeof n!="object")return e;for(let[r,o]of Object.entries(n))if(o instanceof Uint8Array){let i=B.Buffer.from(o).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(r)]=i)}return e}w();var Qn="0.4.0";function qa(){return Qn}async function Go(t,e){let n=e?.startedAt??new Date().toISOString(),r=await Ho(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),o=await To(t),i=await Co(t,o),s=$o(t),a=No(t),c=await Fo(t,a),f=Uo(t,o,a,c),u=await zo(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:qa(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:r,reconstruction:o,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:f,attestations:u}}w();w();w();w();w();var Ga=1048576;w();function er(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}w();w();var Wo="0.8.0";var Qd=[{pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92",label:"genesis",period:"2026-05-15 to 2026-06-27"},{pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a",label:"enclave v2 (reproducible)",period:"2026-06-27 to 2026-07-05"},{pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb",label:"enclave v4 (reproducible)",period:"2026-07-05 to 2026-07-29"},{pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f",label:"enclave v5 (reproducible)",period:"2026-07-29 onward"}],eh=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function Ja(t,e){let n=e;if(n?.from!==void 0&&n.sigEvidence===void 0){let o=new Map;for await(let i of en(t))i.bytes.length>Ga||o.has(i.sha256Hex)||o.set(i.sha256Hex,i.bytes);n={...n,sigEvidence:o}}let r=await Go(t,{startedAt:""});if(n?.fuseEvidence===void 0){let o=await th(t);n={...n,fuseEvidence:o.evidence,fuseOriginHexes:o.originHexes}}return nh(r,n)}async function th(t){let e=new Map,n=new Set,r=[],o=new Set;for(let s of t.proofs){let a=Ot(s.proof);if(a===null)continue;let c=Jt(s.proof.artifact.digestB64),f=c!==null?Nt(c):null,u=a.originDigest!==void 0?Nt(a.originDigest):null;r.push({proof:s,artifactHex:f,originHex:u}),f!==null&&o.add(f),u!==null&&o.add(u)}if(r.length===0)return{evidence:e,originHexes:n};let i=new Map;for await(let s of ko(t,o))i.has(s.sha256Hex)||i.set(s.sha256Hex,s.bytes);_e();try{for(let s of r){let a=s.artifactHex!==null?i.get(s.artifactHex):void 0,c=s.originHex!==null?i.get(s.originHex):void 0;c!==void 0&&s.originHex!==null&&n.add(s.originHex);let f=a??c;f!==void 0&&e.set(s.proof.proofHash,await xo({proof:s.proof.proof,bytes:f}))}}finally{_e()}return{evidence:e,originHexes:n}}function nh(t,e){let n=e?.webCryptoAvailable??!0,r=new Map(t.anchors.anchors.map(p=>[p.proofHash,p])),o=new Map(t.attestations.records.map(p=>[p.proofHash,p])),i=new Map;for(let p of t.temporal.segments)for(let y of p.memberProofHashes)i.set(y,p);let s=new Map;for(let p of t.witnesses.outcomes){if(p.anchorProofHash===void 0)continue;let y=s.get(p.anchorProofHash)??[];y.push(p),s.set(p.anchorProofHash,y)}let a=new Map;for(let p of t.ingest.artifacts)for(let y of p.matchedProofHashes)!a.has(y)&&p.paths[0]!==void 0&&a.set(y,p.paths[0]);let c=[],f=[];for(let p of t.ingest.proofs){let y=r.get(p.proofHash);y!==void 0?f.push(mh(p,y,s.get(p.proofHash)??[])):c.push(rh(p,o.get(p.proofHash),i.get(p.proofHash),a.get(p.proofHash),n,e?.from,e?.sigEvidence,e?.fuseEvidence,r))}Wa(c),Wa(f);let u=gh(t),d=bh(t,c,f,e?.fuseOriginHexes),h=yh(f.length>0,e?.from?.domain),l=[...c.map(p=>p.result),...f.map(p=>p.result),...u.map(p=>p.result)],m=l.length===0?"UNDETERMINED":er(l);return{check:e?.from!==void 0?"bitgraph-check/2":"bitgraph-check/1",...e?.from!==void 0?{from:{domain:e.from.domain,party:e.from.party}}:{},result:m,summary:wh(m,c,f,u),recordings:c,anchors:f,contradictions:u,notes:d,notChecked:h,evaluator:{name:"bitgraph-player",version:Wo,audit:Qn},network:"none"}}function Wa(t){let e=n=>[n.epochId??"",n.counter!==void 0&&/^[0-9]+$/.test(n.counter)?BigInt(n.counter):void 0];t.sort((n,r)=>{let[o,i]=e(n),[s,a]=e(r);return o!==s?o<s?-1:1:i===void 0||a===void 0?i===void 0?a===void 0?0:1:-1:i<a?-1:i>a?1:0})}function rh(t,e,n,r,o,i,s,a,c){let f=[],u=t.verification,d=t.proof.artifact.digestB64;u?.tier==="full"?f.push({name:"file",result:u.status==="verified"||u.status==="failed"?"TRUE":"UNDETERMINED",detail:u.status==="verified"||u.status==="failed"?`${r??"the matched file"} hashes to the recorded digest ${d}`:`no file in this bundle hashes to the recorded digest ${d}`}):f.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${d}; the recording cannot be bound to bytes in hand`}),u===void 0?f.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):u.status==="failed"?f.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${u.reason??"unspecified failure"}`}):f.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${Xo(t.publicKeyB64)}`});let h=ah(e,o);if(f.push(h.line),f.push(dh(h.attestedPcr0,h.line.result)),i!==void 0){let y=u!==void 0&&u.status!=="failed";f.push(fh(t,y,i,s??ch))}let l=Ot(t.proof),m;if(l!==null){let y=oh(n,c,t.slotCounter,t.chainId),b=sh(l.placement,l.originDigest!==void 0?t.proof.attribution?.message??null:null,a?.get(t.proofHash),y,t);f.push(b.line),m=b.fused}let p=er(f.map(y=>y.result));return{proofHash:t.proofHash,digestB64:d,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...r!==void 0&&u?.tier==="full"?{filePath:r}:{},lines:f,result:p,bounds:hh(n),...m!==void 0?{fused:m}:{}}}var Yo="bitgraph:main";function oh(t,e,n,r=Yo){if(r!==Yo||t===void 0||e===void 0||n===void 0||!/^[0-9]+$/.test(n))return null;let o=BigInt(n),i;for(let s of t.lowerBounds){if(s.kind!=="not-before")continue;let a=e.get(s.anchorProofHash);if(a===void 0||a.counter===void 0||!/^[0-9]+$/.test(a.counter)||BigInt(a.counter)>=o)continue;if(i===void 0){i=s;continue}let c=s.blockNumber!==void 0?BigInt(s.blockNumber):BigInt(s.timestamp),f=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);c>f&&(i=s)}return i===void 0?null:{...i.blockNumber!==void 0?{blockNumber:i.blockNumber}:{},blockHash:i.blockHash,timestamp:i.timestamp,anchorProofHash:i.anchorProofHash,evidence:"counter-order"}}var ih="floor undetermined: no anchor precedes this slot in its epoch";function Za(t){return`anchored block ${t.blockNumber!==void 0?`#${t.blockNumber}`:t.blockHash} (${new Date(t.timestamp*1e3).toISOString()})`}function sh(t,e,n,r,o){let i=o.slotCounter??"?",s=t!==null?` (placement ${t})`:" (placement undeclared)",a=r!==null?`assembled after ${Za(r)}, the last verified anchor preceding slot ${i} in this epoch`:o.chainId!==Yo?`floor undetermined: the slot is on chain "${o.chainId}", not the anchored chain`:ih,c=n?.span!==void 0&&n.span!==null?{slotCounter:n.span.slotCounter,commitCounter:n.span.commitCounter,positions:n.span.positions}:o.slotCounter!==void 0&&o.counter!==void 0?{slotCounter:o.slotCounter,commitCounter:o.counter,positions:(BigInt(o.counter)-BigInt(o.slotCounter)).toString()}:null,f=(n?.statements??[]).map(h=>r!==null?h.replace(`at position ${i},`,`at position ${i}, which followed ${Za(r)},`):h),u=(h,l)=>({category:h,placement:n?.placement??t,originDigestB64:n?.originDigestB64??e,evidence:l,statements:f,floor:r,floorDetail:a,span:c});if(n===void 0)return{line:{name:"fused",result:"UNDETERMINED",detail:`marked fused${s}, but neither the fused bytes nor ${e!==null?"the original":"an original"} is in this bundle, so the commitment to slot ${i} cannot be checked`},fused:u("NO_EVIDENCE",null)};let d=n.category==="FUSED_FROM_ORIGIN"||n.fileDigestB64!==n.artifactDigestB64&&n.category!=="NO_MATCH"?"original":"fused-bytes";switch(n.category){case"FUSED_DIRECT":return{line:{name:"fused",result:"TRUE",detail:`the fused bytes carry the commitment to slot ${i}${s}`},fused:u(n.category,"fused-bytes")};case"FUSED_FROM_ORIGIN":return{line:{name:"fused",result:"TRUE",detail:`the original rebuilds the committed fused bytes${s}; they carry the commitment to slot ${i}`},fused:u(n.category,"original")};case"INVALID_SLOT_COMMITMENT":return{line:{name:"fused",result:"FALSE",detail:`the fused bytes do not carry the commitment to this proof's slot ${i}: ${n.reason??""}`},fused:u(n.category,d)};case"INVALID_ORIGIN_ATTRIBUTION":return{line:{name:"fused",result:"FALSE",detail:`the declared origin contradicts the origin inside the fused bytes: ${n.reason??""}`},fused:u(n.category,d)};case"RECONSTRUCTION_MISMATCH":return{line:{name:"fused",result:"FALSE",detail:`the file matching the declared origin does not rebuild the committed fused bytes: ${n.reason??""}`},fused:u(n.category,"original")};case"UNDETERMINED_PLACEMENT":return{line:{name:"fused",result:"UNDETERMINED",detail:`${n.reason??"the placement is not registered"}; this verifier cannot check the commitment`},fused:u(n.category,d)};case"INVALID_UNDERLYING_PROOF":return{line:{name:"fused",result:"UNDETERMINED",detail:"not checked: the proof itself does not verify (see the signature line)"},fused:u(n.category,d)};default:return{line:{name:"fused",result:"UNDETERMINED",detail:`the commitment could not be checked: ${n.reason??n.category}`},fused:u(n.category,d)}}}function ah(t,e){return t===void 0||!t.documentPresent?{line:{name:"attestation",result:"UNDETERMINED",detail:"no attestation document in this proof"}}:e?t.documentValidated?t.userDataBoundToProof!==!0?{line:{name:"attestation",result:"FALSE",detail:"attestation document validates but its user_data is not this proof: the document belongs to some other proof"},attestedPcr0:t.attestedPcr0}:t.pcr0MatchesDeclared!==!0?{line:{name:"attestation",result:"FALSE",detail:`attestation validates and binds this proof, but its PCR0 ${rn(t.attestedPcr0)} is not the measurement the signed body declares ${rn(t.declaredMeasurement)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"TRUE",detail:`AWS Nitro attestation validates to the AWS root, binds this exact proof (user_data), and attests PCR0 ${rn(t.attestedPcr0)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"FALSE",detail:`attestation document does not validate: ${t.validationFailure??"unspecified failure"}`}}:{line:{name:"attestation",result:"UNDETERMINED",detail:"attestation not checked: this environment cannot verify ECDSA P-384 (no WebCrypto); open the verifier from a file or https page, or run bitgraph-play check"}}}var ch=new Map;function fh(t,e,n,r){if(!e)return{name:"domain",result:"UNDETERMINED",detail:`the recording is not verified here, so nothing binds it to ${n.domain}`};let o=t.proof.agency?.actor?.keyId;if(o!==void 0){let s=n.actorKeyName(o);if(s!==void 0)return{name:"domain",result:"TRUE",detail:`actor key "${s}" \xB7 published by ${n.domain} (${n.party})`}}let i=uh(t.proof.artifact.digestB64);if(i!==void 0&&r.size>0){let s=n.signatureKeyName(i.toString("hex"),r);if(s!==void 0)return{name:"domain",result:"TRUE",detail:`signature by "${s}" \xB7 published by ${n.domain} (${n.party})`}}return o!==void 0?{name:"domain",result:"UNDETERMINED",detail:`actor key ${o.slice(0,12)}\u2026 is not among the ${n.keyCount} key(s) ${n.domain} publishes`}:{name:"domain",result:"UNDETERMINED",detail:`no evidence binds this recording to ${n.domain}`}}function uh(t){if(!/^[A-Za-z0-9+/]+=*$/.test(t))return;let e=B.Buffer.from(t,"base64");return e.toString("base64")===t?e:void 0}function dh(t,e){if(e!=="TRUE"||t===void 0)return{name:"enclave",result:"UNDETERMINED",detail:"enclave identity rests on a validated attestation, which this recording does not have here"};let n=Qd.find(r=>r.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${rn(t)} is not among the BitGraph enclave measurements this verifier knows (player ${Wo}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${rn(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function hh(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=Ya(t.lowerBounds,"not-before"),n=Ya(t.upperBounds,"not-after"),r=e===void 0?void 0:Xa(e),o=n===void 0?void 0:Xa(n),i=r!==void 0&&o!==void 0?"lower-bounded-with-following-anchor":r!==void 0?"lower-bounded":o!==void 0?"upper-bounded":"unanchored",s=i==="unanchored"?"no verified Ethereum anchor bounds this recording in this bundle":`recorded ${lh(i,r,o)}`;return{status:i,...r!==void 0?{notBefore:r}:{},...o!==void 0?{notAfter:o}:{},detail:s}}function lh(t,e,n){switch(t){case"lower-bounded-with-following-anchor":return`after Ethereum block ${rt(e)} (header verified in this bundle); precedes an anchor that consumed block ${rt(n)} (header verified), an anchor-latency assumption rather than an upper bound on this recording`+Zo(e.weaker||n.weaker);case"lower-bounded":return`after Ethereum block ${rt(e)} (header verified in this bundle); no verified upper bound here`+Zo(e.weaker);case"upper-bounded":return`before Ethereum block ${rt(n)} (header verified in this bundle); no verified lower bound here`+Zo(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function Ya(t,e){let n=t.filter(o=>o.kind===e);return n.length===0?void 0:[...n].sort((o,i)=>{let s=o.blockNumber!==void 0?BigInt(o.blockNumber):BigInt(o.timestamp),a=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);return s!==a?e==="not-before"?s>a?-1:1:s<a?-1:1:o.weaker!==i.weaker?o.weaker?1:-1:0})[0]}function Xa(t){return{...t.blockNumber!==void 0?{blockNumber:t.blockNumber}:{},blockHash:t.blockHash,timestamp:t.timestamp,anchorProofHash:t.anchorProofHash,evidence:t.evidence,weaker:t.weaker}}function ph(t){switch(t.status){case"lower-bounded-with-following-anchor":return`after Ethereum block ${rt(t.notBefore)}, then an anchor at block ${rt(t.notAfter)}`;case"lower-bounded":return`after Ethereum block ${rt(t.notBefore)}`;case"upper-bounded":return`before Ethereum block ${rt(t.notAfter)}`;default:return"with no Ethereum bound in this bundle"}}function rt(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function Zo(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function mh(t,e,n){let r=[],o=t.verification;o===void 0?r.push({name:"signature",result:"UNDETERMINED",detail:"the anchor proof was not verified"}):o.status==="failed"?r.push({name:"signature",result:"FALSE",detail:`the anchor proof does not verify: ${o.reason??"unspecified failure"}`}):r.push({name:"signature",result:"TRUE",detail:`anchor proof verifies under signer key ${Xo(t.publicKeyB64)}`});let i;if(n.length>0){let s=n.find(a=>a.verified);if(s!==void 0)i=s.witnessPath,r.push({name:"witness",result:"TRUE",detail:`block header ${s.witnessPath} hashes (keccak-256) to the anchored block hash${e.blockNumber!==void 0?` of block ${e.blockNumber}`:""}`});else{let a=n[0];i=a.witnessPath,r.push({name:"witness",result:"FALSE",detail:`block header ${a.witnessPath} contradicts this anchor: ${a.detail??a.reason??"witness verification failed"}`})}}return{proofHash:t.proofHash,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...e.blockNumber!==void 0?{blockNumber:e.blockNumber}:{},...e.blockHash!==void 0?{blockHash:e.blockHash}:{},...i!==void 0?{witnessPath:i}:{},lines:r,result:er(r.map(s=>s.result))}}function gh(t){let e=[],n=new Set,r=o=>{n.has(o)||(n.add(o),e.push({name:"contradiction",result:"FALSE",detail:o}))};for(let o of t.anomalies.anomalies)eh.has(o.code)||r(`${o.code}: ${o.message}`);for(let o of t.anomalies.divergences)r(`${o.kind}: ${o.explanation}`);for(let o of t.authorities.anomalies)r(`${o.code}: ${o.message}`);for(let o of t.witnesses.findings)(o.code==="witness-unmatched"||o.code==="witness-malformed"||o.code==="witness-rlp-invalid")&&r(`${o.code}: ${o.message}`);for(let o of t.ingest.findings)o.code==="proofhash-mismatch"&&r(`${o.code}: ${o.message}${o.path!==void 0?` (${o.path})`:""}`);return e}function bh(t,e,n,r){let o=[],i=0n,s=0;for(let d of t.anomalies.anomalies)if(d.code==="unexplained-counter-positions"){let h=d.details?.count;h!==void 0&&/^[0-9]+$/.test(h)&&(i+=BigInt(h))}else d.code==="chain-break-missing"&&(s+=d.proofHashes.length);i>0n&&o.push(`${i} causal position${i===1n?"":"s"} between the earliest and latest recording here ${i===1n?"is":"are"} not in this bundle: normal for an export, which is an excerpt of the chain; a full-epoch audit checks them`),s>0&&o.push(`${s} recording${s===1?"":"s"} link${s===1?"s":""} to a predecessor that is not in this bundle: normal for an export`);let a=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&r?.has(d.sha256Hex)===!0);a.length>0&&o.push(`${a.length} file${a.length===1?"":"s"} in this bundle ${a.length===1?"is":"are"} the original of a fused recording: ${a.slice(0,5).map(d=>d.paths[0]??"(unnamed)").join(", ")}${a.length>5?", \u2026":""}. The original itself receives only the ceiling (it existed no later than the commit); the fused bytes receive the interval`);let c=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&r?.has(d.sha256Hex)!==!0);if(c.length>0&&e.length>0){let d=c.slice(0,5).map(h=>`${h.paths[0]??"(unnamed)"} (sha256:${h.sha256Hex.slice(0,16)}\u2026)`).join(", ");o.push(`${c.length} file${c.length===1?"":"s"} in this bundle match${c.length===1?"es":""} no recording here: ${d}${c.length>5?", \u2026":""}. If ${c.length===1?"it":"one of them"} was meant to be a recorded file, its bytes differ from what was recorded`)}let f=n.filter(d=>d.witnessPath===void 0);f.length>0&&o.push(`${f.length} Ethereum anchor${f.length===1?"":"s"} in this bundle ha${f.length===1?"s":"ve"} no block-header witness file, so ${f.length===1?"its":"their"} block hash${f.length===1?" is":"es are"} not verified here and no bound is derived from ${f.length===1?"it":"them"}`);for(let d of t.ingest.unsupportedVersions)o.push(`${d.path} is proof-shaped but its version "${d.version}" is not bitgraph/1; it was not checked`);let u=t.ingest.counts;if((u.exactDuplicates>0||u.semanticDuplicates>0)&&o.push(`${u.exactDuplicates+u.semanticDuplicates} duplicate proof file${u.exactDuplicates+u.semanticDuplicates===1?"":"s"} collapsed to one recording each`),t.ingest.manifest!==void 0)for(let d of t.ingest.findings)typeof d.code=="string"&&d.code.startsWith("manifest-")&&o.push(`${d.code}: ${d.message}`);return e.length===0&&n.length===0&&o.push("no BitGraph proofs were found in this bundle"),o}function yh(t,e){let n=[];return t&&n.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e!==void 0&&n.push(`whether ${e}'s published key file has changed since it was pinned: a pin is read as stored; pin the domain again to refresh it`),n.push("whether the public ledger holds these exact recordings at these positions: this is an offline check; drop the file on bitgraph.ing to compare against the ledger"),n.push("whether an epoch key was later quarantined: that is published outside any bundle"),n}function wh(t,e,n,r){if(e.length===0&&n.length===0)return"UNDETERMINED: no BitGraph proofs were found in this bundle.";let o=e.length,i=`${o} recording${o===1?"":"s"}`;if(t==="TRUE"){let a=e[0];return o===1&&a!==void 0?`TRUE: this file was recorded${a.counter!==void 0?` at position ${a.counter}${a.epochId!==void 0?` of epoch ${Xo(a.epochId)}`:""}`:""}, ${ph(a.bounds)}.`:`TRUE: ${i} verified: files match, signatures and attestations hold, enclave measurements published${n.length>0?", Ethereum bounds verified from block headers in the bundle":""}.`}if(t==="FALSE")return`FALSE: evidence in this bundle contradicts itself. ${[...e.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...n.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...r.map(c=>c.detail)][0]??""}`.trim();let s=[...e.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail)),...n.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail))];return`UNDETERMINED: nothing here contradicts the ${i}, but the evidence does not fully decide. ${s[0]??""}`.trim()}function Xo(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function rn(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}mn.sha512Async=async(...t)=>En(mn.concatBytes(...t));var oc=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function ic(t){return new Promise((e,n)=>{let r=[],o=()=>{t.readEntries(i=>{if(i.length===0){e(r);return}r.push(...i),o()},n)};o()})}function xh(t){return new Promise((e,n)=>t.file(e,n))}async function ti(t,e,n){if(t.isFile){let r=await xh(t);n.push({path:e+t.name,file:r});return}if(t.isDirectory){let r=t.createReader(),o=await ic(r);for(let i of o)i.name!==".DS_Store"&&await ti(i,`${e}${t.name}/`,n)}}async function Eh(t){let n=Array.from(t.items??[]).map(o=>typeof o.webkitGetAsEntry=="function"?o.webkitGetAsEntry():null).filter(o=>o!==null);if(n.length===0)return Array.from(t.files??[]).map(o=>({path:o.name,file:o}));let r=[];if(n.length===1&&n[0]!==void 0&&n[0].isDirectory){let o=n[0];for(let i of await ic(o.createReader()))i.name!==".DS_Store"&&await ti(i,"",r)}else for(let o of n)await ti(o,"",r);return r.length===0?Array.from(t.files??[]).map(o=>({path:o.name,file:o})):r}function Qa(t){let e=Array.from(t.files??[]),n=e.map(s=>s.webkitRelativePath||s.name),r=n.map(s=>s.indexOf("/")),o=n.length>0&&r.every(s=>s>0)?n[0].slice(0,r[0]):void 0,i=o!==void 0&&n.every(s=>s.startsWith(`${o}/`));return e.map((s,a)=>({path:i?n[a].slice(o.length+1):n[a],file:s})).filter(s=>!s.path.endsWith("/.DS_Store")&&s.path!==".DS_Store")}function Bh(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function $(t,e={},n=[]){let r=document.createElement(t);for(let[o,i]of Object.entries(e))o==="class"?r.className=i:r.setAttribute(o,i);for(let o of n)r.append(typeof o=="string"?document.createTextNode(o):o);return r}function ni(t){return t==="TRUE"?null:$("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function sn(t,e,n={}){let r=$("div",{class:"field-head"},[$("span",{class:"field-label"},[t])]),o=n.mark!==void 0?ni(n.mark):null;return o!==null&&r.append(o),$("div",{class:"field"},[r,$("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function ot(t,e,n={}){let r=n.open===!0,o=$("span",{class:"chev","aria-hidden":"true"});o.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 6 L15 12 L9 18"/></svg>';let i=$("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(r)},[$("span",{},[t]),o]),s=$("div",{class:"opener-body"},e),a=$("section",{class:"card"},[i,s]),c=()=>{i.classList.toggle("open",r),i.setAttribute("aria-expanded",String(r)),s.hidden=!r,o.classList.toggle("open",r)};return i.addEventListener("click",()=>{r=!r,c()}),c(),a}function vh(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function Ah(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function kh(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function on(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function Ih(t){return new Date(t*1e3).toLocaleString("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",timeZoneName:"short"})}function ec(t){let e=t.bounds,n=i=>$("span",{class:"when-grey"},[i]),r=i=>$("span",{class:"when-dark"},[i]),o=$("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;o.append($("div",{class:"when-date"},[kh(i.timestamp)]));let s=$("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("after "),r(on(e.notBefore.timestamp,!0)),n(", then an anchor at "),r(on(e.notAfter.timestamp,!1)),n(" (not an upper bound)")):e.notBefore!==void 0?s.append(n("after "),r(on(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("no lower bound in this bundle; an anchor followed at "),r(on(e.notAfter.timestamp,!0)),n(" (not an upper bound)")),o.append(s)}else o.append($("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return o}function Jo(t){if(t.fused===void 0)return null;let e=i=>$("span",{class:"when-grey"},[i]),n=i=>$("span",{class:"when-dark"},[i]),r=$("div",{class:"when"}),o=$("div",{class:"when-line"});return t.fused.floor!==null?o.append(e("fused bytes assembled after "),n(on(t.fused.floor.timestamp,!0)),e(`, the last anchor before slot ${t.fused.span?.slotCounter??"?"}`)):o.append(e(t.fused.floorDetail)),r.append(o),r}var Hh=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,Sh=/\.(mp4|m4v|mov|webm|ogv)$/i,Th=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,Ch=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function Rh(t){let e=t.subarray(0,Math.min(2048,t.length));if(!e.length)return!1;let n=0;for(let r of e){if(r===0)return!1;(r===9||r===10||r===13||r>=32)&&n++}return n/e.length>.97}function $h(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":Hh.test(n)?"image":Sh.test(n)?"video":Th.test(n)?"audio":Ch.test(n)||Rh(e)?"text":"other"}function Ph(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Dh(t,e,n){if(n==="image"||n==="video"){let r=URL.createObjectURL(t),o=n==="image"?$("img",{src:r,alt:t.name,style:"display:block;max-width:100%;max-height:min(70vh,640px);width:auto;height:auto;object-fit:contain;border-radius:0"}):$("video",{src:r,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return $("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[o])}if(n==="audio"){let r=URL.createObjectURL(t);return $("div",{style:"padding:20px 16px"},[$("audio",{src:r,controls:"",style:"display:block;width:100%"})])}if(n==="text")try{let r=new TextDecoder("utf-8",{fatal:!1}).decode(e.subarray(0,6e3)),o=r.split(`
|
|
153
|
+
`),i=o.slice(0,24).join(`
|
|
154
|
+
`).slice(0,3e3),s=o.length>24||r.length>i.length||e.byteLength>6e3;return $("pre",{class:"excerpt"},[i+(s?`
|
|
155
|
+
\u2026`:"")])}catch{return null}return null}function tc(t,e,n,r){let o=t.lines.find(s=>s.name==="file"),i=$("div",{class:r?"file-row above":"file-row"});if(t.filePath!==void 0){let s=$("span",{class:"file-ident"},[$("span",{class:"file-name"},[t.filePath])]);e!==void 0&&s.append(document.createTextNode(` \xB7 ${Ph(e.size)}`)),i.append(s);let a=$("span",{class:"file-right"});e!==void 0&&n!==void 0&&(n==="image"||n==="text"||n==="pdf")&&a.append($("a",{class:"bg-arrow-link",href:URL.createObjectURL(e),target:"_blank",rel:"noopener"},["Open ",$("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]));let c=o!==void 0?ni(o.result):null;c!==null&&a.append(c),a.childNodes.length>0&&i.append(a)}else{i.append($("span",{class:"file-missing"},["file not in this bundle"]));let s=o!==void 0?ni(o.result):null;s!==null&&i.append(s)}return i}function Ve(t,e,n=!1){return sn(t,e,{mono:n})}function nc(t,e){let n=document.getElementById("title-action");if(n===null)return;let r=$("a",{class:"bg-arrow-link",href:"#"},[t+" ",$("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]);r.addEventListener("click",o=>{o.preventDefault(),e()}),n.replaceChildren(r)}function rc(t){let e={file:"File",signature:"Signature",attestation:"Hardware Enclave attestation",enclave:"Enclave identity",witness:"Block header",contradiction:"Contradiction",fused:"Fused artifact"};return t.lines.map(n=>sn(e[n.name]??n.name,n.detail,{mark:n.result}))}function Nh(t,e,n,r){let o=e==="before"?"Recorded after this block":e==="after"?"An anchor followed this recording (not an upper bound)":`Ethereum anchor ${n+1}`,i=[];if(t.blockNumber!==void 0&&i.push(Ve("Block",Ah(t.blockNumber),!0)),r!==void 0&&i.push(Ve("Block Time",Ih(r))),t.blockHash!==void 0&&i.push(Ve("Block Hash",t.blockHash,!0)),t.counter!==void 0&&i.push(Ve("Anchor position",`#${t.counter}`,!0)),t.blockNumber!==void 0){let s=$("a",{class:"field-link",href:`https://etherscan.io/block/${t.blockNumber}`,target:"_blank",rel:"noopener"},[`https://etherscan.io/block/${t.blockNumber}`]);i.push($("div",{class:"field"},[$("span",{class:"field-label"},["Etherscan"]),s]))}for(let s of t.lines)i.push(sn(s.name==="witness"?"Block header":"Anchor signature",s.detail,{mark:s.result}));return t.witnessPath===void 0&&i.push(sn("Block header","no block-header witness in this bundle, so this anchor's block hash is not verified here and it bounds nothing")),ot(t.result==="TRUE"?o:`${o} [${t.result}]`,i)}async function Oh(t,e,n,r){e.replaceChildren();let o=()=>location.reload();if(t.recordings.length===0&&t.anchors.length===0){n.textContent="No BitGraph Found",e.append($("section",{class:"card primary"},[$("div",{class:"notice"},["No BitGraph proof was found in what you chose. A recording is a folder named for the file it holds, like BitGraph (photo.jpg). Inside it are proof.json, the file itself, and an ethereum-anchors folder."])])),nc("Choose a recording folder",o),e.append(ot("Report JSON",[$("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let f=document.getElementById("more");f.replaceChildren(),f.hidden=!0;return}n.textContent=vh(t.result);let i=t.recordings.length===1?t.recordings[0]:void 0,s=$("section",{class:"card primary"});if(t.result!=="TRUE"&&s.append($("div",{class:`notice ${t.result.toLowerCase()}`},[t.summary])),i!==void 0){s.append(ec(i));let f=Jo(i);f!==null&&s.append(f);let u=i.filePath!==void 0?r.get(i.filePath):void 0,d,h=null;if(u!==void 0){let l=new Uint8Array(await u.arrayBuffer());d=$h(u.name,l),h=Dh(u,l,d)}h!==null&&s.append(h),s.append(tc(i,u,d,h!==null)),i.counter!==void 0&&s.append(Ve("Position",`#${i.counter}${i.epochId!==void 0?` \xB7 epoch ${i.epochId}`:""}`,!0)),s.append(Ve("File Hash",i.digestB64,!0))}else if(t.recordings.length>1)for(let f of t.recordings)s.append(tc(f,f.filePath!==void 0?r.get(f.filePath):void 0,void 0,!1));else s.append(Ve("Recordings","no recordings in this bundle"));if(e.append(s),nc("Check another BitGraph",o),i!==void 0){let f=i.lines.filter(u=>u.result!=="TRUE").length;e.append(ot(f===0?"Recording checks":`Recording checks ${f} not verified`,rc(i),{open:t.result!=="TRUE"}))}else t.recordings.forEach((f,u)=>{e.append(ot(`Recording ${u+1}: ${f.filePath??f.digestB64.slice(0,16)+"\u2026"} [${f.result}]`,[ec(f),...Jo(f)!==null?[Jo(f)]:[],...f.counter!==void 0?[Ve("Position",`#${f.counter}${f.epochId!==void 0?` \xB7 epoch ${f.epochId}`:""}`,!0)]:[],Ve("File Hash",f.digestB64,!0),...rc(f)],{open:f.result!=="TRUE"}))});let a=new Map;for(let f of t.recordings)f.bounds.notBefore&&a.set(f.bounds.notBefore.anchorProofHash,f.bounds.notBefore.timestamp),f.bounds.notAfter&&a.set(f.bounds.notAfter.anchorProofHash,f.bounds.notAfter.timestamp);t.anchors.forEach((f,u)=>{let d="other";i!==void 0&&(i.bounds.notBefore?.anchorProofHash===f.proofHash?d="before":i.bounds.notAfter?.anchorProofHash===f.proofHash&&(d="after")),e.append(Nh(f,d,u,a.get(f.proofHash)))}),t.contradictions.length>0&&e.append(ot(`Contradictions ${t.contradictions.length}`,t.contradictions.map(f=>sn("Contradiction",f.detail,{mark:"FALSE"})),{open:!0,tone:"danger"})),t.notes.length>0&&e.append(ot(`Notes ${t.notes.length}`,[$("ul",{class:"list"},t.notes.map(f=>$("li",{},[f])))])),e.append(ot("Not checked",[$("ul",{class:"list"},t.notChecked.map(f=>$("li",{},[f])))])),e.append(ot("Report JSON",[$("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let c=document.getElementById("more");c.replaceChildren(),c.hidden=!0}async function Qo(t){let e=document.getElementById("drop"),n=document.getElementById("results"),r=document.getElementById("status");if(t.length===0){r.textContent="Nothing readable was dropped.";return}e.classList.add("busy"),r.textContent=`Checking ${t.length} file${t.length===1?"":"s"}\u2026`;try{let o=await Ao(Bh(t),{label:"dropped"}),i=await Ja(o,{webCryptoAvailable:oc});document.getElementById("camera").hidden=!0,document.getElementById("deck").hidden=!0,document.querySelector(".bitgraph-wrap")?.classList.add("bitgraph-results"),document.querySelector(".bitgraph-hero")?.classList.add("results"),r.textContent="",n.hidden=!1;let s=new Map(t.map(a=>[a.path,a.file]));await Oh(i,n,document.getElementById("title"),s),document.title=`${i.result} \xB7 BitGraph verify`}catch(o){r.textContent=`The check could not run: ${o.message}`}finally{e.classList.remove("busy")}}function ei(){let t=document.querySelector(".bitgraph-wrap");t&&t.style.setProperty("--bg-wrap-min",`${Math.round(window.innerHeight)}px`)}function Lh(){let t=document.getElementById("drop"),e=document.getElementById("status"),n=document.getElementById("pick-files"),r=document.getElementById("pick-folder");ei(),window.addEventListener("resize",ei),window.addEventListener("orientationchange",ei),oc||(e.textContent="This browser context has no WebCrypto, so attestations will read UNDETERMINED here; open the file directly (file://) or over https, or run bitgraph-play check.");let o=!1,i=!1,s=!1,a=()=>{t.classList.toggle("hot",o||i||s),t.classList.toggle("over",s)};t.addEventListener("mouseenter",()=>{o=!0,a()}),t.addEventListener("mouseleave",()=>{o=!1,a()}),t.addEventListener("focusin",()=>{i=!0,a()}),t.addEventListener("focusout",()=>{i=!1,a()});let c=f=>{f.preventDefault(),f.stopPropagation()};for(let f of["dragenter","dragover"])t.addEventListener(f,u=>{c(u),s=!0,a()}),document.body.addEventListener(f,c);for(let f of["dragleave","drop"])t.addEventListener(f,u=>{c(u),s=!1,a()}),document.body.addEventListener(f,c);t.addEventListener("drop",f=>{let u=f.dataTransfer;u!==null&&(e.textContent="Reading the drop\u2026",Eh(u).then(d=>{if(d.length===0){e.textContent="Nothing readable was dropped. Click the box and choose the recording's folder instead.";return}return Qo(d)},d=>{e.textContent=`The drop could not be read here: ${d.message}. Click the box and choose the recording's folder instead.`}))}),t.addEventListener("click",()=>r.click()),t.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),r.click())}),n.addEventListener("change",()=>void Qo(Qa(n))),r.addEventListener("change",()=>void Qo(Qa(r)))}document.addEventListener("DOMContentLoaded",Lh);})();
|
|
156
156
|
|
|
157
157
|
</script>
|
|
158
158
|
</body>
|