@mikeargento/bitgraph-player 0.4.0 → 0.5.1
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__/check.test.js +31 -0
- package/dist/__tests__/check.test.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 -3
- package/src/__tests__/check.test.ts +34 -0
- package/src/__tests__/fixtures/declared-12010/proof.json +1 -0
- package/src/verdict.ts +1 -1
package/dist-web/verify.html
CHANGED
|
@@ -131,12 +131,12 @@ h1.bg-page-title { font-size: clamp(26px, 6vw, 40px); font-weight: 600; letter-s
|
|
|
131
131
|
</div>
|
|
132
132
|
<div id="status"></div>
|
|
133
133
|
<div id="results" hidden></div>
|
|
134
|
-
<div class="hero-more" id="more"><div class="edition" id="edition" data-version="1.14.
|
|
134
|
+
<div class="hero-more" id="more"><div class="edition" id="edition" data-version="1.14.1">BitGraph Folder 1.14.1</div><a class="bg-arrow-link" id="folder-link" href="https://bitgraph.ing/docs/folder">Check for updates <span class="arrow" aria-hidden="true">→</span></a></div>
|
|
135
135
|
</div>
|
|
136
136
|
</div>
|
|
137
137
|
</main>
|
|
138
138
|
<script>
|
|
139
|
-
"use strict";(()=>{var jr=Object.create;var Fn=Object.defineProperty;var Vr=Object.getOwnPropertyDescriptor;var zr=Object.getOwnPropertyNames;var Gr=Object.getPrototypeOf,qr=Object.prototype.hasOwnProperty;var Wr=(t,e)=>()=>(t&&(e=t(t=0)),e);var Et=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Jr=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of zr(e))!qr.call(t,r)&&r!==n&&Fn(t,r,{get:()=>e[r],enumerable:!(o=Vr(e,r))||o.enumerable});return t};var Xr=(t,e,n)=>(n=t!=null?jr(Gr(t)):{},Jr(e||!t||!t.__esModule?Fn(n,"default",{value:t,enumerable:!0}):n,t));var Kn=Et(Ze=>{"use strict";y();Ze.byteLength=Zr;Ze.toByteArray=ei;Ze.fromByteArray=oi;var G=[],j=[],Yr=typeof Uint8Array<"u"?Uint8Array:Array,kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ge=0,On=kt.length;ge<On;++ge)G[ge]=kt[ge],j[kt.charCodeAt(ge)]=ge;var ge,On;j[45]=62;j[95]=63;function _n(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 Zr(t){var e=_n(t),n=e[0],o=e[1];return(n+o)*3/4-o}function Qr(t,e,n){return(e+n)*3/4-n}function ei(t){var e,n=_n(t),o=n[0],r=n[1],i=new Yr(Qr(t,o,r)),s=0,a=r>0?o-4:o,c;for(c=0;c<a;c+=4)e=j[t.charCodeAt(c)]<<18|j[t.charCodeAt(c+1)]<<12|j[t.charCodeAt(c+2)]<<6|j[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return r===2&&(e=j[t.charCodeAt(c)]<<2|j[t.charCodeAt(c+1)]>>4,i[s++]=e&255),r===1&&(e=j[t.charCodeAt(c)]<<10|j[t.charCodeAt(c+1)]<<4|j[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function ti(t){return G[t>>18&63]+G[t>>12&63]+G[t>>6&63]+G[t&63]}function ni(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(ti(o));return r.join("")}function oi(t){for(var e,n=t.length,o=n%3,r=[],i=16383,s=0,a=n-o;s<a;s+=i)r.push(ni(t,s,s+i>a?a:s+i));return o===1?(e=t[n-1],r.push(G[e>>2]+G[e<<4&63]+"==")):o===2&&(e=(t[n-2]<<8)+t[n-1],r.push(G[e>>10]+G[e>>4&63]+G[e<<2&63]+"=")),r.join("")}});var jn=Et(At=>{y();At.read=function(t,e,n,o,r){var i,s,a=r*8-o-1,c=(1<<a)-1,u=c>>1,d=-7,h=n?r-1:0,f=n?-1:1,l=t[e+h];for(h+=f,i=l&(1<<-d)-1,l>>=-d,d+=a;d>0;i=i*256+t[e+h],h+=f,d-=8);for(s=i&(1<<-d)-1,i>>=-d,d+=o;d>0;s=s*256+t[e+h],h+=f,d-=8);if(i===0)i=1-u;else{if(i===c)return s?NaN:(l?-1:1)*(1/0);s=s+Math.pow(2,o),i=i-u}return(l?-1:1)*s*Math.pow(2,i-o)};At.write=function(t,e,n,o,r,i){var s,a,c,u=i*8-r-1,d=(1<<u)-1,h=d>>1,f=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,l=o?0:i-1,g=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+h>=1?e+=f/c:e+=f*Math.pow(2,1-h),e*c>=2&&(s++,c/=2),s+h>=d?(a=0,s=d):s+h>=1?(a=(e*c-1)*Math.pow(2,r),s=s+h):(a=e*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;t[n+l]=a&255,l+=g,a/=256,r-=8);for(s=s<<r|a,u+=r;u>0;t[n+l]=s&255,l+=g,s/=256,u-=8);t[n+l-g]|=m*128}});var so=Et($e=>{"use strict";y();var It=Kn(),He=jn(),Vn=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$e.Buffer=p;$e.SlowBuffer=ui;$e.INSPECT_MAX_BYTES=50;var Qe=2147483647;$e.kMaxLength=Qe;p.TYPED_ARRAY_SUPPORT=ri();!p.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 ri(){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(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}});Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function Q(t){if(t>Qe)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,p.prototype),e}function p(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 St(t)}return Wn(t,e,n)}p.poolSize=8192;function Wn(t,e,n){if(typeof t=="string")return si(t,e);if(ArrayBuffer.isView(t))return ai(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return Ct(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 p.from(o,e,n);let r=ci(t);if(r)return r;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return p.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)}p.from=function(t,e,n){return Wn(t,e,n)};Object.setPrototypeOf(p.prototype,Uint8Array.prototype);Object.setPrototypeOf(p,Uint8Array);function Jn(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 ii(t,e,n){return Jn(t),t<=0?Q(t):e!==void 0?typeof n=="string"?Q(t).fill(e,n):Q(t).fill(e):Q(t)}p.alloc=function(t,e,n){return ii(t,e,n)};function St(t){return Jn(t),Q(t<0?0:Pt(t)|0)}p.allocUnsafe=function(t){return St(t)};p.allocUnsafeSlow=function(t){return St(t)};function si(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=Xn(t,e)|0,o=Q(n),r=o.write(t,e);return r!==n&&(o=o.slice(0,r)),o}function Ht(t){let e=t.length<0?0:Pt(t.length)|0,n=Q(e);for(let o=0;o<e;o+=1)n[o]=t[o]&255;return n}function ai(t){if(q(t,Uint8Array)){let e=new Uint8Array(t);return Ct(e.buffer,e.byteOffset,e.byteLength)}return Ht(t)}function Ct(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,p.prototype),o}function ci(t){if(p.isBuffer(t)){let e=Pt(t.length)|0,n=Q(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||Rt(t.length)?Q(0):Ht(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ht(t.data)}function Pt(t){if(t>=Qe)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Qe.toString(16)+" bytes");return t|0}function ui(t){return+t!=t&&(t=0),p.alloc(+t)}p.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==p.prototype};p.compare=function(e,n){if(q(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),q(n,Uint8Array)&&(n=p.from(n,n.offset,n.byteLength)),!p.isBuffer(e)||!p.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};p.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}};p.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return p.alloc(0);let o;if(n===void 0)for(n=0,o=0;o<e.length;++o)n+=e[o].length;let r=p.allocUnsafe(n),i=0;for(o=0;o<e.length;++o){let s=e[o];if(q(s,Uint8Array))i+s.length>r.length?(p.isBuffer(s)||(s=p.from(s)),s.copy(r,i)):Uint8Array.prototype.set.call(r,s,i);else if(p.isBuffer(s))s.copy(r,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return r};function Xn(t,e){if(p.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 $t(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return io(t).length;default:if(r)return o?-1:$t(t).length;e=(""+e).toLowerCase(),r=!0}}p.byteLength=Xn;function di(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 xi(this,e,n);case"utf8":case"utf-8":return Zn(this,e,n);case"ascii":return bi(this,e,n);case"latin1":case"binary":return wi(this,e,n);case"base64":return gi(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vi(this,e,n);default:if(o)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}p.prototype._isBuffer=!0;function ye(t,e,n){let o=t[e];t[e]=t[n],t[n]=o}p.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)ye(this,n,n+1);return this};p.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)ye(this,n,n+3),ye(this,n+1,n+2);return this};p.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)ye(this,n,n+7),ye(this,n+1,n+6),ye(this,n+2,n+5),ye(this,n+3,n+4);return this};p.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Zn(this,0,e):di.apply(this,arguments)};p.prototype.toLocaleString=p.prototype.toString;p.prototype.equals=function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:p.compare(this,e)===0};p.prototype.inspect=function(){let e="",n=$e.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};Vn&&(p.prototype[Vn]=p.prototype.inspect);p.prototype.compare=function(e,n,o,r,i){if(q(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),!p.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),u=this.slice(r,i),d=e.slice(n,o);for(let h=0;h<c;++h)if(u[h]!==d[h]){s=u[h],a=d[h];break}return s<a?-1:a<s?1:0};function Yn(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,Rt(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=p.from(e,o)),p.isBuffer(e))return e.length===0?-1:zn(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):zn(t,[e],n,o,r);throw new TypeError("val must be string, number or Buffer")}function zn(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,h){return i===1?d[h]:d.readUInt16BE(h*i)}let u;if(r){let d=-1;for(u=n;u<s;u++)if(c(t,u)===c(e,d===-1?0:u-d)){if(d===-1&&(d=u),u-d+1===a)return d*i}else d!==-1&&(u-=u-d),d=-1}else for(n+a>s&&(n=s-a),u=n;u>=0;u--){let d=!0;for(let h=0;h<a;h++)if(c(t,u+h)!==c(e,h)){d=!1;break}if(d)return u}return-1}p.prototype.includes=function(e,n,o){return this.indexOf(e,n,o)!==-1};p.prototype.indexOf=function(e,n,o){return Yn(this,e,n,o,!0)};p.prototype.lastIndexOf=function(e,n,o){return Yn(this,e,n,o,!1)};function hi(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(Rt(a))return s;t[n+s]=a}return s}function fi(t,e,n,o){return et($t(e,t.length-n),t,n,o)}function li(t,e,n,o){return et(Ai(e),t,n,o)}function pi(t,e,n,o){return et(io(e),t,n,o)}function mi(t,e,n,o){return et(Ii(e,t.length-n),t,n,o)}p.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 hi(this,e,n,o);case"utf8":case"utf-8":return fi(this,e,n,o);case"ascii":case"latin1":case"binary":return li(this,e,n,o);case"base64":return pi(this,e,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mi(this,e,n,o);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}};p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function gi(t,e,n){return e===0&&n===t.length?It.fromByteArray(t):It.fromByteArray(t.slice(e,n))}function Zn(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,u,d,h;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[r+1],(c&192)===128&&(h=(i&31)<<6|c&63,h>127&&(s=h));break;case 3:c=t[r+1],u=t[r+2],(c&192)===128&&(u&192)===128&&(h=(i&15)<<12|(c&63)<<6|u&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:c=t[r+1],u=t[r+2],d=t[r+3],(c&192)===128&&(u&192)===128&&(d&192)===128&&(h=(i&15)<<18|(c&63)<<12|(u&63)<<6|d&63,h>65535&&h<1114112&&(s=h))}}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 yi(o)}var Gn=4096;function yi(t){let e=t.length;if(e<=Gn)return String.fromCharCode.apply(String,t);let n="",o=0;for(;o<e;)n+=String.fromCharCode.apply(String,t.slice(o,o+=Gn));return n}function bi(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 wi(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 xi(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+=Hi[t[i]];return r}function vi(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}p.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,p.prototype),r};function P(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")}p.prototype.readUintLE=p.prototype.readUIntLE=function(e,n,o){e=e>>>0,n=n>>>0,o||P(e,n,this.length);let r=this[e],i=1,s=0;for(;++s<n&&(i*=256);)r+=this[e+s]*i;return r};p.prototype.readUintBE=p.prototype.readUIntBE=function(e,n,o){e=e>>>0,n=n>>>0,o||P(e,n,this.length);let r=this[e+--n],i=1;for(;n>0&&(i*=256);)r+=this[e+--n]*i;return r};p.prototype.readUint8=p.prototype.readUInt8=function(e,n){return e=e>>>0,n||P(e,1,this.length),this[e]};p.prototype.readUint16LE=p.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||P(e,2,this.length),this[e]|this[e+1]<<8};p.prototype.readUint16BE=p.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||P(e,2,this.length),this[e]<<8|this[e+1]};p.prototype.readUint32LE=p.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};p.prototype.readUint32BE=p.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||P(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};p.prototype.readBigUInt64LE=ue(function(e){e=e>>>0,Ce(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Fe(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))});p.prototype.readBigUInt64BE=ue(function(e){e=e>>>0,Ce(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Fe(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)});p.prototype.readIntLE=function(e,n,o){e=e>>>0,n=n>>>0,o||P(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};p.prototype.readIntBE=function(e,n,o){e=e>>>0,n=n>>>0,o||P(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};p.prototype.readInt8=function(e,n){return e=e>>>0,n||P(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};p.prototype.readInt16LE=function(e,n){e=e>>>0,n||P(e,2,this.length);let o=this[e]|this[e+1]<<8;return o&32768?o|4294901760:o};p.prototype.readInt16BE=function(e,n){e=e>>>0,n||P(e,2,this.length);let o=this[e+1]|this[e]<<8;return o&32768?o|4294901760:o};p.prototype.readInt32LE=function(e,n){return e=e>>>0,n||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};p.prototype.readInt32BE=function(e,n){return e=e>>>0,n||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};p.prototype.readBigInt64LE=ue(function(e){e=e>>>0,Ce(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Fe(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)});p.prototype.readBigInt64BE=ue(function(e){e=e>>>0,Ce(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Fe(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)});p.prototype.readFloatLE=function(e,n){return e=e>>>0,n||P(e,4,this.length),He.read(this,e,!0,23,4)};p.prototype.readFloatBE=function(e,n){return e=e>>>0,n||P(e,4,this.length),He.read(this,e,!1,23,4)};p.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||P(e,8,this.length),He.read(this,e,!0,52,8)};p.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||P(e,8,this.length),He.read(this,e,!1,52,8)};function N(t,e,n,o,r,i){if(!p.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")}p.prototype.writeUintLE=p.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;N(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};p.prototype.writeUintBE=p.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;N(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};p.prototype.writeUint8=p.prototype.writeUInt8=function(e,n,o){return e=+e,n=n>>>0,o||N(this,e,n,1,255,0),this[n]=e&255,n+1};p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(e,n,o){return e=+e,n=n>>>0,o||N(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(e,n,o){return e=+e,n=n>>>0,o||N(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(e,n,o){return e=+e,n=n>>>0,o||N(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};p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(e,n,o){return e=+e,n=n>>>0,o||N(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 Qn(t,e,n,o,r){ro(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 eo(t,e,n,o,r){ro(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}p.prototype.writeBigUInt64LE=ue(function(e,n=0){return Qn(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeBigUInt64BE=ue(function(e,n=0){return eo(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeIntLE=function(e,n,o,r){if(e=+e,n=n>>>0,!r){let c=Math.pow(2,8*o-1);N(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};p.prototype.writeIntBE=function(e,n,o,r){if(e=+e,n=n>>>0,!r){let c=Math.pow(2,8*o-1);N(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};p.prototype.writeInt8=function(e,n,o){return e=+e,n=n>>>0,o||N(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};p.prototype.writeInt16LE=function(e,n,o){return e=+e,n=n>>>0,o||N(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};p.prototype.writeInt16BE=function(e,n,o){return e=+e,n=n>>>0,o||N(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};p.prototype.writeInt32LE=function(e,n,o){return e=+e,n=n>>>0,o||N(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};p.prototype.writeInt32BE=function(e,n,o){return e=+e,n=n>>>0,o||N(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};p.prototype.writeBigInt64LE=ue(function(e,n=0){return Qn(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});p.prototype.writeBigInt64BE=ue(function(e,n=0){return eo(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function to(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 no(t,e,n,o,r){return e=+e,n=n>>>0,r||to(t,e,n,4,34028234663852886e22,-34028234663852886e22),He.write(t,e,n,o,23,4),n+4}p.prototype.writeFloatLE=function(e,n,o){return no(this,e,n,!0,o)};p.prototype.writeFloatBE=function(e,n,o){return no(this,e,n,!1,o)};function oo(t,e,n,o,r){return e=+e,n=n>>>0,r||to(t,e,n,8,17976931348623157e292,-17976931348623157e292),He.write(t,e,n,o,52,8),n+8}p.prototype.writeDoubleLE=function(e,n,o){return oo(this,e,n,!0,o)};p.prototype.writeDoubleBE=function(e,n,o){return oo(this,e,n,!1,o)};p.prototype.copy=function(e,n,o,r){if(!p.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};p.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"&&!p.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=p.isBuffer(e)?e:p.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 Ie={};function Tt(t,e,n){Ie[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}`}}}Tt("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Tt("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Tt("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=qn(String(n)):typeof n=="bigint"&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=qn(r)),r+="n"),o+=` It must be ${e}. Received ${r}`,o},RangeError);function qn(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 Bi(t,e,n){Ce(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&Fe(e,t.length-(n+1))}function ro(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 Ie.ERR_OUT_OF_RANGE("value",a,t)}Bi(o,r,i)}function Ce(t,e){if(typeof t!="number")throw new Ie.ERR_INVALID_ARG_TYPE(e,"number",t)}function Fe(t,e,n){throw Math.floor(t)!==t?(Ce(t,n),new Ie.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new Ie.ERR_BUFFER_OUT_OF_BOUNDS:new Ie.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var Ei=/[^+/0-9A-Za-z-_]/g;function ki(t){if(t=t.split("=")[0],t=t.trim().replace(Ei,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function $t(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 Ai(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function Ii(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 io(t){return It.toByteArray(ki(t))}function et(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 q(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Rt(t){return t!==t}var Hi=(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 ue(t){return typeof BigInt>"u"?Ci:t}function Ci(){throw new Error("BigInt not supported")}});var w,y=Wr(()=>{"use strict";w=Xr(so(),1);globalThis.Buffer=w.Buffer});y();y();var $i={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:M,n:tt,Gx:ao,Gy:co,a:Mt,d:Dt}=$i,Si=8n,Oe=32,Lt=64,V=(t="")=>{throw new Error(t)},Pi=t=>typeof t=="bigint",mo=t=>typeof t=="string",Ti=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",Pe=(t,e)=>!Ti(t)||typeof e=="number"&&e>0&&t.length!==e?V("Uint8Array expected"):t,it=t=>new Uint8Array(t),Ot=t=>Uint8Array.from(t),go=(t,e)=>t.toString(16).padStart(e,"0"),_t=t=>Array.from(Pe(t)).map(e=>go(e,2)).join(""),ee={_0:48,_9:57,A:65,F:70,a:97,f:102},uo=t=>{if(t>=ee._0&&t<=ee._9)return t-ee._0;if(t>=ee.A&&t<=ee.F)return t-(ee.A-10);if(t>=ee.a&&t<=ee.f)return t-(ee.a-10)},Kt=t=>{let e="hex invalid";if(!mo(t))return V(e);let n=t.length,o=n/2;if(n%2)return V(e);let r=it(o);for(let i=0,s=0;i<o;i++,s+=2){let a=uo(t.charCodeAt(s)),c=uo(t.charCodeAt(s+1));if(a===void 0||c===void 0)return V(e);r[i]=a*16+c}return r},nt=(t,e)=>Pe(mo(t)?Kt(t):Ot(Pe(t)),e),yo=()=>globalThis?.crypto,Ri=()=>yo()?.subtle??V("crypto.subtle must be defined"),Nt=(...t)=>{let e=it(t.reduce((o,r)=>o+Pe(r).length,0)),n=0;return t.forEach(o=>{e.set(o,n),n+=o.length}),e},Mi=(t=Oe)=>yo().getRandomValues(it(t)),ot=BigInt,be=(t,e,n,o="bad number: out of range")=>Pi(t)&&e<=t&&t<n?t:V(o),x=(t,e=M)=>{let n=t%e;return n>=0n?n:e+n},Di=t=>x(t,tt),bo=(t,e)=>{(t===0n||e<=0n)&&V("no inverse n="+t+" mod="+e);let n=x(t,e),o=e,r=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=o/n,u=o%n,d=r-s*c,h=i-a*c;o=n,n=u,r=s,i=a,s=d,a=h}return o===1n?x(r,e):V("no inverse")};var ho=t=>t instanceof te?t:V("Point expected"),Ut=2n**256n,te=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,o,r){let i=Ut;this.ex=be(e,0n,i),this.ey=be(n,0n,i),this.ez=be(o,1n,i),this.et=be(r,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,x(e.x*e.y))}static fromBytes(e,n=!1){let o=Dt,r=Ot(Pe(e,Oe)),i=e[31];r[31]=i&-129;let s=jt(r);be(s,0n,n?Ut:M);let c=x(s*s),u=x(c-1n),d=x(o*c+1n),{isValid:h,value:f}=Ui(u,d);h||V("bad point: y not sqrt");let l=(f&1n)===1n,g=(i&128)!==0;return!n&&f===0n&&g&&V("bad point: x==0, isLastByteOdd"),g!==l&&(f=x(-f)),new t(f,s,1n,x(f*s))}assertValidity(){let e=Mt,n=Dt,o=this;if(o.is0())throw new Error("bad point: ZERO");let{ex:r,ey:i,ez:s,et:a}=o,c=x(r*r),u=x(i*i),d=x(s*s),h=x(d*d),f=x(c*e),l=x(d*x(f+u)),g=x(h+x(n*x(c*u)));if(l!==g)throw new Error("bad point: equation left != right (1)");let m=x(r*i),v=x(s*a);if(m!==v)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}=ho(e),c=x(n*a),u=x(i*r),d=x(o*a),h=x(s*r);return c===u&&d===h}is0(){return this.equals(Se)}negate(){return new t(x(-this.ex),this.ey,this.ez,x(-this.et))}double(){let{ex:e,ey:n,ez:o}=this,r=Mt,i=x(e*e),s=x(n*n),a=x(2n*x(o*o)),c=x(r*i),u=e+n,d=x(x(u*u)-i-s),h=c+s,f=h-a,l=c-s,g=x(d*f),m=x(h*l),v=x(d*l),b=x(f*h);return new t(g,m,b,v)}add(e){let{ex:n,ey:o,ez:r,et:i}=this,{ex:s,ey:a,ez:c,et:u}=ho(e),d=Mt,h=Dt,f=x(n*s),l=x(o*a),g=x(i*h*u),m=x(r*c),v=x((n+o)*(s+a)-f-l),b=x(m-g),A=x(m+g),B=x(l-d*f),S=x(v*b),R=x(A*B),k=x(v*B),I=x(b*A);return new t(S,R,I,k)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return Se;if(be(e,1n,tt),e===1n)return this;if(this.equals(Te))return zi(e).p;let o=Se,r=Te;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(Se))return{x:0n,y:1n};let r=bo(o,M);return x(o*r)!==1n&&V("invalid inverse"),{x:x(e*r),y:x(n*r)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),o=Li(n);return o[31]|=e&1n?128:0,o}toHex(){return _t(this.toBytes())}clearCofactor(){return this.multiply(ot(Si),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(tt/2n,!1).double();return tt%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(nt(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},Te=new te(ao,co,1n,x(ao*co)),Se=new te(0n,1n,1n,0n);te.BASE=Te;te.ZERO=Se;var Li=t=>Kt(go(be(t,0n,Ut),Lt)).reverse(),jt=t=>ot("0x"+_t(Ot(Pe(t)).reverse())),W=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=M;return n},Ni=t=>{let n=t*t%M*t%M,o=W(n,2n)*n%M,r=W(o,1n)*t%M,i=W(r,5n)*r%M,s=W(i,10n)*i%M,a=W(s,20n)*s%M,c=W(a,40n)*a%M,u=W(c,80n)*c%M,d=W(u,80n)*c%M,h=W(d,10n)*i%M;return{pow_p_5_8:W(h,2n)*t%M,b2:n}},fo=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ui=(t,e)=>{let n=x(e*e*e),o=x(n*n*e),r=Ni(t*o).pow_p_5_8,i=x(t*n*r),s=x(e*i*i),a=i,c=x(i*fo),u=s===t,d=s===x(-t),h=s===x(-t*fo);return u&&(i=a),(d||h)&&(i=c),(x(i)&1n)===1n&&(i=x(-i)),{isValid:u||d,value:i}},Fi=t=>Di(jt(t)),Oi=(...t)=>st.sha512Async(...t);var _i=t=>Oi(t.hashable).then(t.finish);var wo={zip215:!0},Ki=(t,e,n,o=wo)=>{t=nt(t,Lt),e=nt(e),n=nt(n,Oe);let{zip215:r}=o,i,s,a,c,u=Uint8Array.of();try{i=te.fromHex(n,r),s=te.fromHex(t.slice(0,Oe),r),a=jt(t.slice(Oe,Lt)),c=Te.multiply(a,!1),u=Nt(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:u,finish:h=>{if(c==null||!r&&i.isSmallOrder())return!1;let f=Fi(h);return s.add(i.multiply(f,!1)).add(c.negate()).clearCofactor().is0()}}},Vt=async(t,e,n,o=wo)=>_i(Ki(t,e,n,o));var st={sha512Async:async(...t)=>{let e=Ri(),n=Nt(...t);return it(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:_t,hexToBytes:Kt,concatBytes:Nt,mod:x,invert:bo,randomBytes:Mi};var rt=8,ji=256,xo=Math.ceil(ji/rt)+1,Ft=2**(rt-1),Vi=()=>{let t=[],e=Te,n=e;for(let o=0;o<xo;o++){n=e,t.push(n);for(let r=1;r<Ft;r++)n=n.add(e),t.push(n);e=n.double()}return t},lo,po=(t,e)=>{let n=e.negate();return t?n:e},zi=t=>{let e=lo||(lo=Vi()),n=Se,o=Te,r=2**rt,i=r,s=ot(r-1),a=ot(rt);for(let c=0;c<xo;c++){let u=Number(t&s);t>>=a,u>Ft&&(u-=i,t+=1n);let d=c*Ft,h=d,f=d+Math.abs(u)-1,l=c%2!==0,g=u<0;u===0?o=o.add(po(l,e[h])):n=n.add(po(g,e[f]))}return{p:n,f:o}};y();y();y();function qi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function we(t,...e){if(!qi(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 Me(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 at(t,e){we(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function vo(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function J(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ct(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function z(t,e){return t<<32-e|t>>>e}var Wi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ji(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Xi(t){for(let e=0;e<t.length;e++)t[e]=Ji(t[e]);return t}var Gt=Wi?t=>t:Xi;function Yi(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function _e(t){return typeof t=="string"&&(t=Yi(t)),we(t),t}var Re=class{};function Ke(t){let e=o=>t().update(_e(o)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Zi(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,u=o?0:4;t.setUint32(e+c,s,o),t.setUint32(e+u,a,o)}function Bo(t,e,n){return t&e^~t&n}function Eo(t,e,n){return t&e^t&n^e&n}var je=class extends Re{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=ct(this.buffer)}update(e){Me(this),e=_e(e),we(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=ct(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){Me(this),at(e,this),this.finished=!0;let{buffer:n,view:o,blockLen:r,isLE:i}=this,{pos:s}=this;n[s++]=128,J(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(o,0),s=0);for(let h=s;h<r;h++)n[h]=0;Zi(o,r-8,BigInt(this.length*8),i),this.process(o,0);let a=ct(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,d[h],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()}},ne=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var T=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);y();var ut=BigInt(4294967295),ko=BigInt(32);function Qi(t,e=!1){return e?{h:Number(t&ut),l:Number(t>>ko&ut)}:{h:Number(t>>ko&ut)|0,l:Number(t&ut)|0}}function dt(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}=Qi(t[i],e);[o[i],r[i]]=[s,a]}return[o,r]}var qt=(t,e,n)=>t>>>n,Wt=(t,e,n)=>t<<32-n|e>>>n,xe=(t,e,n)=>t>>>n|e<<32-n,ve=(t,e,n)=>t<<32-n|e>>>n,Ve=(t,e,n)=>t<<64-n|e>>>n-32,ze=(t,e,n)=>t>>>n-32|e<<64-n;var Ao=(t,e,n)=>t<<n|e>>>32-n,Io=(t,e,n)=>e<<n|t>>>32-n,Ho=(t,e,n)=>e<<n-32|t>>>64-n,Co=(t,e,n)=>t<<n-32|e>>>64-n;function X(t,e,n,o){let r=(e>>>0)+(o>>>0);return{h:t+n+(r/2**32|0)|0,l:r|0}}var $o=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),So=(t,e,n,o)=>e+n+o+(t/2**32|0)|0,Po=(t,e,n,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),To=(t,e,n,o,r)=>e+n+o+r+(t/2**32|0)|0,Ro=(t,e,n,o,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0)+(r>>>0),Mo=(t,e,n,o,r,i)=>e+n+o+r+i+(t/2**32|0)|0;var ts=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]),de=new Uint32Array(64),ht=class extends je{constructor(e=32){super(64,e,8,!1),this.A=ne[0]|0,this.B=ne[1]|0,this.C=ne[2]|0,this.D=ne[3]|0,this.E=ne[4]|0,this.F=ne[5]|0,this.G=ne[6]|0,this.H=ne[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 h=0;h<16;h++,n+=4)de[h]=e.getUint32(n,!1);for(let h=16;h<64;h++){let f=de[h-15],l=de[h-2],g=z(f,7)^z(f,18)^f>>>3,m=z(l,17)^z(l,19)^l>>>10;de[h]=m+de[h-7]+g+de[h-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:u,H:d}=this;for(let h=0;h<64;h++){let f=z(a,6)^z(a,11)^z(a,25),l=d+f+Bo(a,c,u)+ts[h]+de[h]|0,m=(z(o,2)^z(o,13)^z(o,22))+Eo(o,r,i)|0;d=u,u=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,u=u+this.G|0,d=d+this.H|0,this.set(o,r,i,s,a,c,u,d)}roundClean(){J(de)}destroy(){this.set(0,0,0,0,0,0,0,0),J(this.buffer)}};var Do=dt(["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))),ns=Do[0],os=Do[1],he=new Uint32Array(80),fe=new Uint32Array(80),Jt=class extends je{constructor(e=64){super(128,e,16,!1),this.Ah=T[0]|0,this.Al=T[1]|0,this.Bh=T[2]|0,this.Bl=T[3]|0,this.Ch=T[4]|0,this.Cl=T[5]|0,this.Dh=T[6]|0,this.Dl=T[7]|0,this.Eh=T[8]|0,this.El=T[9]|0,this.Fh=T[10]|0,this.Fl=T[11]|0,this.Gh=T[12]|0,this.Gl=T[13]|0,this.Hh=T[14]|0,this.Hl=T[15]|0}get(){let{Ah:e,Al:n,Bh:o,Bl:r,Ch:i,Cl:s,Dh:a,Dl:c,Eh:u,El:d,Fh:h,Fl:f,Gh:l,Gl:g,Hh:m,Hl:v}=this;return[e,n,o,r,i,s,a,c,u,d,h,f,l,g,m,v]}set(e,n,o,r,i,s,a,c,u,d,h,f,l,g,m,v){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=u|0,this.El=d|0,this.Fh=h|0,this.Fl=f|0,this.Gh=l|0,this.Gl=g|0,this.Hh=m|0,this.Hl=v|0}process(e,n){for(let B=0;B<16;B++,n+=4)he[B]=e.getUint32(n),fe[B]=e.getUint32(n+=4);for(let B=16;B<80;B++){let S=he[B-15]|0,R=fe[B-15]|0,k=xe(S,R,1)^xe(S,R,8)^qt(S,R,7),I=ve(S,R,1)^ve(S,R,8)^Wt(S,R,7),H=he[B-2]|0,D=fe[B-2]|0,ke=xe(H,D,19)^Ve(H,D,61)^qt(H,D,6),Ae=ve(H,D,19)^ze(H,D,61)^Wt(H,D,6),se=Po(I,Ae,fe[B-7],fe[B-16]),ae=To(se,k,ke,he[B-7],he[B-16]);he[B]=ae|0,fe[B]=se|0}let{Ah:o,Al:r,Bh:i,Bl:s,Ch:a,Cl:c,Dh:u,Dl:d,Eh:h,El:f,Fh:l,Fl:g,Gh:m,Gl:v,Hh:b,Hl:A}=this;for(let B=0;B<80;B++){let S=xe(h,f,14)^xe(h,f,18)^Ve(h,f,41),R=ve(h,f,14)^ve(h,f,18)^ze(h,f,41),k=h&l^~h&m,I=f&g^~f&v,H=Ro(A,R,I,os[B],fe[B]),D=Mo(H,b,S,k,ns[B],he[B]),ke=H|0,Ae=xe(o,r,28)^Ve(o,r,34)^Ve(o,r,39),se=ve(o,r,28)^ze(o,r,34)^ze(o,r,39),ae=o&i^o&a^i&a,Ne=r&s^r&c^s&c;b=m|0,A=v|0,m=l|0,v=g|0,l=h|0,g=f|0,{h,l:f}=X(u|0,d|0,D|0,ke|0),u=a|0,d=c|0,a=i|0,c=s|0,i=o|0,s=r|0;let ce=$o(ke,se,Ne);o=So(ce,D,Ae,ae),r=ce|0}({h:o,l:r}=X(this.Ah|0,this.Al|0,o|0,r|0)),{h:i,l:s}=X(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=X(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:d}=X(this.Dh|0,this.Dl|0,u|0,d|0),{h,l:f}=X(this.Eh|0,this.El|0,h|0,f|0),{h:l,l:g}=X(this.Fh|0,this.Fl|0,l|0,g|0),{h:m,l:v}=X(this.Gh|0,this.Gl|0,m|0,v|0),{h:b,l:A}=X(this.Hh|0,this.Hl|0,b|0,A|0),this.set(o,r,i,s,a,c,u,d,h,f,l,g,m,v,b,A)}roundClean(){J(he,fe)}destroy(){J(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Lo=Ke(()=>new ht);var ft=Ke(()=>new Jt);y();y();y();function U(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var No=U("fs.createReadStream"),Wc=U("fs.readFileSync"),Jc=U("fs.existsSync"),Xc=U("fs.writeFileSync"),rs=U("fs.open"),is=U("fs.readdir"),Uo=U("fs.readFile"),ss=U("fs.stat"),Yc=U("fs.mkdir"),Zc=U("fs.writeFile"),Fo=U("path.join"),Qc=U("path.basename"),Oo=U("zlib.createGunzip"),as=U("zlib.gzipSync");y();var C=Lo;y();y();y();var Yt=globalThis.crypto,Xt=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=C.create();else if(n==="sha512")this.hasher=ft.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=w.Buffer.from(n);return e===void 0?o:o.toString(e)}};function Zt(t){return new Xt(t)}function Qt(t){return{update(){return this},verify(){throw new Error("P-256 agency signature verification is not available in the browser verifier")}}}y();function Be(t){let e=_o(t);return new TextEncoder().encode(e)}function _o(t){return JSON.stringify(en(t))}function en(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(en);let e={};for(let n of Object.keys(t).sort()){let o=t[n];typeof o>"u"||(e[n]=en(o))}return e}function lt(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 nn(t){let{proof:e,bytes:n,trustAnchors:o}=t,r=await Ko(e,n,o);return r===null?{valid:!0}:ms(r)}async function qe(t){let{proof:e,trustAnchors:n}=t,o=await Ko(e,void 0,n);return o===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:o}}async function Ko(t,e,n){let o=us(t);if(o!==null)return o;let r=e===void 0?void 0:C(e),i;try{i=De(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(r!==void 0&&!lt(r,i))return"artifact digest mismatch: the provided bytes do not match the committed digest";let s;try{s=De(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=Be(a),u;try{u=De(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(u.length!==64)return`signer.signatureB64 decodes to ${u.length} bytes; expected 64 (Ed25519)`;let d;try{d=await Vt(u,c,s)}catch(h){return`signature verification error: ${h instanceof Error?h.message:String(h)}`}if(!d)return"signature verification failed: signature does not match";if(t.agency!==void 0){let h=hs(t);if(h!==null)return h}if(t.slotAllocation!==void 0){let h=await fs(t);if(h!==null)return h}if(t.commit.epochLink!==void 0){let h=ps(t);if(h!==null)return h}if(n!==void 0){let h=ds(t,n);if(h!==null)return h}return null}var cs=new Set(["stub","hw-key","measured-tee"]);function us(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(!Ge(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(!Ge(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(!Ge(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(!Ge(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!cs.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(!Ge(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 ds(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`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function hs(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=w.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(Zt("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=w.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 u;try{u=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(u.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${u.type}"`;if(!u.challenge)return"agency: clientDataJSON missing challenge field";let d=u.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;d.length%4;)d+="=";if(d!==o.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let h=w.Buffer.from(c.authenticatorDataB64,"base64");if(h.length<37)return"agency: authenticatorData too short";let f=h[32];if(!(f&1))return"agency: authenticatorData UP flag not set";if(!(f&4))return"agency: authenticatorData UV flag not set";let l=Zt("sha256").update(w.Buffer.from(c.clientDataJSON,"utf8")).digest(),g=w.Buffer.concat([h,l]),m=Qt("SHA256");if(m.update(g),!m.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 u=w.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),d=Qt("SHA256");if(d.update(u),!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 fs(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=Be(n),r,i;try{r=De(e.signatureB64),i=De(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 Vt(r,o,i)}catch(h){return`slotAllocation signature verification error: ${h instanceof Error?h.message:String(h)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let h of c)if(a.has(h))return`slotAllocation body contains forbidden field '${h}' \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 u=C(o),d;try{d=De(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!lt(u,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 h=BigInt(e.counter),f=BigInt(t.commit.counter);if(h>=f)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 tn=new Map;function ls(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=C(new TextEncoder().encode(e));return w.Buffer.from(n).toString("base64")}function ps(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=ls(e),o=tn.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 tn.set(n,e.toEpochId);return null}function Le(){tn.clear()}function ms(t){return{valid:!1,reason:t}}function Ge(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function De(t){let e=w.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}y();function pt(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=Be(r),s=C(i);return Vo(s)}var jo=["proofHash","ethereum"];function on(t){let e=t,n=e;if(jo.some(r=>Object.prototype.hasOwnProperty.call(e,r))){n={};for(let r of Object.keys(e))jo.includes(r)||(n[r]=e[r])}let o=Be(n);return Vo(C(o))}function Vo(t){if(typeof w.Buffer<"u")return w.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}y();async function*Go(t,e){let n=new sn(t,e?.maxTotalBytes),o=e?.maxEntryCount??Number.POSITIVE_INFINITY,r=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,u=(d,h)=>{if(d>r)throw new Error(`tar: ${h} metadata entry of ${d} bytes exceeds the ${r}-byte cap`)};for(;;){let d=await n.readExact(512);if(d===null||ws(d))return;if(++c>o)throw new Error(`tar: archive exceeds the maximum of ${o} entries`);let h=ys(d),f=h.typeflag;if(f==="x"||f==="g"){u(h.size,"PAX");let B=await zo(n,h.size);await n.skip(mt(h.size));let S=xs(B);f==="x"?i=S:s=vs(s,S);continue}if(f==="L"){u(h.size,"GNU long-name");let B=await zo(n,h.size);await n.skip(mt(h.size)),a=Ee(Bs(B));continue}if(f==="K"){await n.skip(h.size+mt(h.size));continue}let l=h.name;s!==null&&s.has("path")&&(l=s.get("path")),a!==null&&(l=a),i!==null&&i.has("path")&&(l=i.get("path"));let g=h.size,m=i?.get("size")??s?.get("size");if(m!==void 0){let B=Number(m);if(!Number.isSafeInteger(B)||B<0)throw new Error("tar: invalid PAX size value");g=B}i=null,a=null;let v=f==="0"||f==="\0",b={remaining:g},A=gs(n,b);yield{path:l,size:g,kind:v?"file":"other",typeflag:f,body:A},b.remaining>0&&(await n.skip(b.remaining),b.remaining=0),await n.skip(mt(g))}}async function*gs(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 zo(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 ys(t){bs(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),o=Ee(rn(t,0,100));if(Ee(rn(t,257,6))==="ustar"){let s=Ee(rn(t,345,155));s.length>0&&(o=`${s}/${o}`)}let i=qo(t.subarray(124,136));return{name:o,size:i,typeflag:n}}function rn(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 qo(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=Ee(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 bs(t){let e=qo(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 ws(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function xs(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(Ee(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=Ee(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 vs(t,e){let n=new Map(t??[]);for(let[o,r]of e)n.set(o,r);return n}function Ee(t){return new TextDecoder("utf-8").decode(t)}function Bs(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var sn=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 mt(t){return(512-t%512)%512}y();var Pu=new Uint8Array([0]);function Wo(t){let e=Array.from(t,o=>({pathBytes:Es(o.path),entryDigest:o.entryDigest}));e.sort((o,r)=>ks(o.pathBytes,r.pathBytes));let n=C.create();for(let o of e)n.update(o.entryDigest);return w.Buffer.from(n.digest()).toString("base64")}function Es(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function ks(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 Jo=8*1024*1024,Qo={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},Xo=new Uint8Array([0]),Yo="manifest.json",an="bitgraph-bundle/1",As="bitgraph-anchor-witness/1";var er=new WeakMap;async function cn(t,e){let n=[],o=0,r=0,i=[],s=new Map,a=Array.from(t).sort((u,d)=>u.path<d.path?-1:u.path>d.path?1:0);for(let u of a){r++;let d=nr(u.path);if(d.unsafe){o++,n.push({code:"unsafe-path",path:u.path,message:`entry skipped: ${d.reason}`});continue}let h=await $s(d.path,void 0,void 0,tr(u.open()));i.push(Ss(d.path,h)),s.set(d.path,u)}let c=Hs({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:r,skippedUnsafePaths:o});return er.set(c,s),c}async function*tr(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function Is(t){let e=[],n=0;for await(let o of tr(t.open()))e.push(o),n+=o.length;return dn(e,n)}function Hs(t){let{bundlePath:e,container:n,scanned:o,strippedRootPrefix:r,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let k of o){let I=k.rawPath,H=k.entryDigestFull;r!==void 0&&(I=k.rawPath.slice(r.length+1),H=k.entryDigestStripped),c.has(I)&&i.push({code:"duplicate-path",path:I,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(I,{path:I,sha256Hex:k.sha256Hex,byteLength:k.byteLength,entryDigest:H,...k.json!==void 0?{json:k.json}:{}})}let u=Array.from(c.values()),d=Wo(u.filter(k=>k.path!==Yo).map(k=>({path:k.path,entryDigest:k.entryDigest}))),h=[],f=new Map,l=[],g=[],m=new Map,v,b=0,A=0,B=0;for(let k of u){if(k.path===Yo){v=Ls(k,d,i);continue}let I=k.json;if(I!==void 0&&Ts(I)){let H=I.version;if(H==="bitgraph/1"){b++;let D=Rs(k,I,f,h,i);D==="exact-duplicate"&&A++,D==="semantic-duplicate"&&B++;continue}l.push({code:"unsupported-version",path:k.path,version:H,fileSha256Hex:k.sha256Hex}),i.push({code:"unsupported-version",path:k.path,message:`proof-shaped file rejected: version "${H}" is not "bitgraph/1"`,details:{version:H}}),Zo(k,m);continue}if(I!==void 0&&I.version===As){g.push({path:k.path,fileSha256Hex:k.sha256Hex,witness:I});continue}Zo(k,m)}for(let k of h){let I=Ds(k.proof.artifact);if(I===null)continue;let H=m.get(I);H!==void 0&&H.matchedProofHashes.push(k.proofHash)}let S=Array.from(m.values()),R={observed:h.length,proofFiles:b,exactDuplicates:A,semanticDuplicates:B,unsupportedVersion:l.length,artifacts:S.length,witnesses:g.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...r!==void 0?{strippedRootPrefix:r}:{},entriesScanned:s,proofs:h,unsupportedVersions:l,artifacts:S,witnesses:g,...v!==void 0?{manifest:v}:{},computedContentsHashB64:d,findings:i,counts:R}}async function*un(t){let e=t.artifacts.filter(s=>s.matchedProofHashes.length>0);if(e.length===0)return;if(t.container==="memory"){let s=er.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let u=s.get(c);if(u===void 0)continue;let d;try{d=await Is(u)}catch{continue}if(gt(C(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 Uo(Fo(t.bundlePath,...a.split("/"))))}catch{continue}if(gt(C(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}=Cs(t.bundlePath,t.container);try{for await(let s of Go(r,Qo)){if(o.size===e.length)break;if(s.kind!=="file")continue;let a=nr(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 u=n.get(c);if(u===void 0||o.has(u.sha256Hex))continue;let d=[],h=0;for await(let l of s.body)d.push(l.slice()),h+=l.length;let f=dn(d,h);gt(C(f))===u.sha256Hex&&(o.add(u.sha256Hex),yield{sha256Hex:u.sha256Hex,path:c,bytes:f})}}finally{i()}}function Cs(t,e){let n=No(t);if(e==="tar-gz"){let o=Oo();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 $s(t,e,n,o){let r=new TextEncoder,i=C.create(),s=C.create();s.update(r.encode(t)),s.update(Xo);let a=e===void 0?void 0:C.create();a!==void 0&&(a.update(r.encode(e)),a.update(Xo));let c=n===void 0||n<=Jo,u=[],d=0;for await(let h of o)i.update(h),s.update(h),a?.update(h),d+=h.length,c&&(d>Jo?(u.length=0,c=!1):u.push(h.slice()));return{sha256Hex:gt(i.digest()),byteLength:d,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:dn(u,d)}:{}}}function Ss(t,e){let n=e.buffered===void 0?void 0:Ps(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 Ps(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 nr(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 F(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ts(t){return F(t)?typeof t.version=="string"&&F(t.artifact)&&F(t.commit)&&F(t.signer):!1}function Rs(t,e,n,o,r){let i=pt(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=Ms(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 v=c.sources.some(b=>b.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),r.push({code:v?"exact-duplicate":"semantic-duplicate",path:t.path,message:v?"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}}),v?"exact-duplicate":"semantic-duplicate"}let u=F(e.commit)?e.commit:{},d=F(e.signer)?e.signer:{},h=F(e.environment)?e.environment:{},f=K(u.counter),l=K(u.epochId),g=K(u.chainId),m={proofHash:i,chainHash:on(e),proof:e,sources:[s],version:"bitgraph/1",...f!==void 0?{counter:f}:{},...K(u.slotCounter)!==void 0?{slotCounter:K(u.slotCounter)}:{},...K(u.prevB64)!==void 0?{prevB64:K(u.prevB64)}:{},...l!==void 0?{epochId:l}:{},chainId:g!==void 0&&g.length>0?g:"global",...K(d.publicKeyB64)!==void 0?{publicKeyB64:K(d.publicKeyB64)}:{},...K(h.measurement)!==void 0?{measurement:K(h.measurement)}:{},...K(h.enforcement)!==void 0?{enforcement:K(h.enforcement)}:{},hasSlotAllocation:F(e.slotAllocation),hasAttestation:F(h.attestation),hasAgency:F(e.agency),hasEpochLink:F(u.epochLink),embeddedProofHash:a,chainless:f===void 0&&l===void 0};return n.set(i,m),o.push(m),"new"}function Ms(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function K(t){return typeof t=="string"?t:void 0}function Zo(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:w.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function Ds(t){if(!F(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=w.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function Ls(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!==an)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(r)} is not "${an}"; 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=Ns(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:an,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 Ns(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=>F(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=w.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=>F(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 gt(t){return w.Buffer.from(t).toString("hex")}function dn(t,e){let n=new Uint8Array(e),o=0;for(let r of t)n.set(r,o),o+=r.length;return n}y();async function hn(t,e){Le();let n=e?.trustAnchors,o=new Map(t.proofs.map(u=>[u.proofHash,u])),r=new Map;for(let u of t.artifacts){if(u.matchedProofHashes.length===0)continue;let d=u.matchedProofHashes.map(h=>o.get(h)).filter(h=>h!==void 0);r.set(u.sha256Hex,d)}for await(let u of un(t)){let d=r.get(u.sha256Hex)??[];for(let h of d){if(h.verification!==void 0)continue;let f=await nn({proof:h.proof,bytes:u.bytes,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"full",status:f.valid?"verified":"failed",...f.reason!==void 0?{reason:f.reason}:{},artifactPath:u.path};h.verification=l}}for(let u of t.proofs){if(u.verification!==void 0)continue;let d=await qe({proof:u.proof,...n!==void 0?{trustAnchors:n}:{}}),h={tier:"integrity",status:d.valid?"artifact-unavailable":"failed",...d.reason!==void 0?{reason:d.reason}:{}};u.verification=h}let i=0,s=0,a=0,c=0;for(let u of t.proofs){let d=u.verification?.status;d==="verified"?i++:d==="failed"?s++:d==="artifact-unavailable"&&a++,u.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}y();y();var or=new WeakMap;async function oe(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=or.get(t);if(n!==void 0)return n;Le();let o=!1;try{o=(await qe({proof:t.proof})).valid}catch{o=!1}return Le(),or.set(t,o),o}function $(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function Y(t,e){let n=$(t.counter),o=$(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 O(t,e,n){let o=t.get(e);o===void 0?t.set(e,[n]):o.push(n)}async function ln(t){let e=[],n=[],o=new Map;for(let u of t.proofs){if(u.chainless){e.push(u.proofHash);continue}if(u.publicKeyB64===void 0){n.push(u.proofHash);continue}let d={publicKeyB64:u.publicKeyB64,...u.epochId!==void 0?{epochId:u.epochId}:{},chainId:u.chainId},h=JSON.stringify([d.publicKeyB64,d.epochId??null,d.chainId]),f=o.get(h);f===void 0?o.set(h,{key:d,members:[u]}):f.members.push(u)}let r=[...o.values()].sort((u,d)=>Us(u.key,d.key)),i=[],s=new Set,a=new Map;for(let u of r){let d=Fs(u.key,u.members,s);i.push(d);for(let h of d.memberProofHashes)a.set(h,u.key)}let c=await Ks(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function Us(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 Fs(t,e,n){let o=new Map(e.map(f=>[f.chainHash,f])),r=new Map,i=new Set,s=new Map;for(let f of e)s.set(f.proofHash,f.proofHash);let a=f=>{let l=f;for(;s.get(l)!==l;)l=s.get(l);let g=f;for(;g!==l;){let m=s.get(g);s.set(g,l),g=m}return l},c=(f,l)=>{let g=a(f),m=a(l);g!==m&&s.set(g,m)};for(let f of e){if(f.prevB64===void 0)continue;let l=o.get(f.prevB64);l===void 0||l.proofHash===f.proofHash||(i.add(f.proofHash),O(r,l.proofHash,f),n.add(l.proofHash),c(l.proofHash,f.proofHash))}let u=new Map;for(let f of e)O(u,a(f.proofHash),f);let d=[];for(let f of u.values())d.push(Os(f,r,i));d.sort(_s);let h=[...e].sort(Y).map(f=>f.proofHash);return{key:t,memberProofHashes:h,components:d}}function Os(t,e,n){let o=[...t].sort(Y),r=o.filter(f=>f.prevB64===void 0),i=o.filter(f=>f.prevB64!==void 0&&!n.has(f.proofHash)),s=o.filter(f=>(e.get(f.proofHash)??[]).length===0),a=new Set,c=[],u=f=>{let l=[f];for(;l.length>0;){let g=l.pop();if(a.has(g))continue;a.add(g),c.push(g);let m=[...e.get(g)??[]].sort(Y);for(let v=m.length-1;v>=0;v--)l.push(m[v].proofHash)}};for(let f of[...r,...i])u(f.proofHash);for(let f of o)a.has(f.proofHash)||u(f.proofHash);let d,h;for(let f of t)for(let l of[f.counter,f.slotCounter]){let g=$(l);g!==void 0&&((d===void 0||g<d)&&(d=g),(h===void 0||g>h)&&(h=g))}return{memberProofHashes:c,genesisProofHashes:r.map(f=>f.proofHash),brokenLinkProofHashes:i.map(f=>f.proofHash),terminalProofHashes:s.map(f=>f.proofHash),hasCounterEvidence:d!==void 0,...d!==void 0&&h!==void 0?{positionRange:{min:String(d),max:String(h)}}:{}}}function _s(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 Ks(t,e,n,o){let r=new Map;for(let f of e){let l=f.key.epochId;if(l===void 0)continue;let g=r.get(l);g===void 0&&(g={chainIds:new Set,publicKeys:new Set,proofCount:0},r.set(l,g)),g.chainIds.add(f.key.chainId),g.publicKeys.add(f.key.publicKeyB64),g.proofCount+=f.memberProofHashes.length}let i=new Map(t.proofs.map(f=>[f.chainHash,f])),s=[];for(let f of t.proofs){if(!f.hasEpochLink)continue;let l=js(f);l!==null&&s.push(await Vs(l,f,i,r,n,o))}let a=Gs(s),c=new Set,u=new Map,d=new Map;for(let f of s)f.hardEdge&&(c.add(f.fromEpochId),c.add(f.toEpochId),fn(u,f.toEpochId,f.fromEpochId),fn(d,f.fromEpochId,f.toEpochId));return{epochs:[...r.entries()].sort(([f],[l])=>f<l?-1:f>l?1:0).map(([f,l])=>({epochId:f,chainIds:[...l.chainIds].sort(),publicKeysB64:[...l.publicKeys].sort(),proofCount:l.proofCount,ordering:c.has(f)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...u.get(f)??[]].sort(),linkedSuccessorEpochIds:[...d.get(f)??[]].sort()})),edges:s,orderedPairs:a}}function js(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 Vs(t,e,n,o,r,i){let s=await oe(e),a=n.get(t.prevProofHashB64);if(a===void 0){let f=o.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:f?"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"),zs(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let u=await oe(a),d=c.length===0,h=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},...h?{referencedProofIsTerminal:!r.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:u,hardEdge:d&&s&&u}}function zs(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=$(t),o=$(e);return n!==void 0&&o!==void 0&&n===o}function Gs(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(fn(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 u of e.get(c)??[])a.push(u)}}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 fn(t,e,n){let o=t.get(e);o===void 0?t.set(e,new Set([n])):o.add(n)}y();var qs=1e4;async function pn(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 u of c.memberProofHashes)a.set(u,c.key);for(let c of e.partitions){let u=c.memberProofHashes.map(d=>i.get(d));Ws(c,u,n),await rr(c,u,"counter",n,o),await rr(c,u,"slot",n,o),await Js(c,u,n,o),await Xs(c,u,s,n,o),Ys(c,u,s,a,n,r),await Qs(c,u,n,o),ea(c,u,n)}return await ta(e.epochRelationships.edges,i,n,o),{anomalies:n,divergences:o,boundaryEntryPoints:r}}function Ws(t,e,n){let o=new Set;for(let h of e){let f=$(h.counter);f!==void 0&&o.add(f);let l=$(h.slotCounter);l!==void 0&&o.add(l)}if(o.size<2)return;let r=[...o].sort((h,f)=>h<f?-1:h>f?1:0),i=[],s=[],a=0n;for(let h=1;h<r.length;h++){let f=r[h-1]+1n,l=r[h]-1n;if(!(f>l)){i.push({start:String(f),end:String(l)}),a+=l-f+1n;for(let g=f;g<=l&&s.length<qs;g++)s.push(String(g))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},u=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 [${u}, ${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 rr(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=$(a);O(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of mn(i)){if(a.length<2)continue;let{parties:c,context:u}=await yt(a);if(c.length<2)continue;let d=s.startsWith("raw:")?s.slice(4):s,h=n==="counter"?"counter-collision":"slot-collision";o.push({code:h,partition:t.key,proofHashes:a.map(f=>f.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(f=>f.proofHash),invalidObserved:u.map(f=>f.proofHash)}}),r.push({kind:h,partition:t.key,contested:n==="counter"?{counter:d}:{slotCounter:d},parties:c.map(Z),invalidContext:u.map(Z),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 Js(t,e,n,o){let r=new Map,i=new Map;for(let a of e){let c=$(a.counter);c!==void 0&&O(r,String(c),a);let u=$(a.slotCounter);u!==void 0&&O(i,String(u),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),u=i.get(a),d=[];for(let b of c)await oe(b)&&d.push(b);let h=[];for(let b of u)await oe(b)&&h.push(b);if(!d.some(b=>h.some(A=>A.proofHash!==b.proofHash)))continue;let l=new Map;for(let b of[...d,...h])l.set(b.proofHash,b);let g=[...l.values()],m=new Map;for(let b of[...c,...u])m.set(b.proofHash,b);let v=[...m.values()].filter(b=>!l.has(b.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(b=>b.proofHash),slotParties:h.map(b=>b.proofHash),validParties:g.map(b=>b.proofHash),invalidObserved:v.map(b=>b.proofHash)}}),o.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:g.map(Z),invalidContext:v.map(Z),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 Xs(t,e,n,o,r){let i=new Map;for(let s of e)s.prevB64!==void 0&&O(i,s.prevB64,s);for(let[s,a]of mn(i)){if(a.length<2)continue;let{parties:c,context:u}=await yt(a);if(c.length<2)continue;let d=n.has(s);o.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(h=>h.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(h=>h.proofHash),invalidObserved:u.map(h=>h.proofHash)}}),r.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map(Z),invalidContext:u.map(Z),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 Ys(t,e,n,o,r,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let u=$(c.counter);u!==void 0&&(a===void 0||u<a)&&(a=u)}for(let c of[...e].sort(Y)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!Zs(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 u=n.get(c.prevB64);if(u!==void 0){let f=o.get(u.proofHash);r.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,u.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:u.proofHash,predecessorPartition:f!==void 0?{publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId}:"unchained-or-unpartitioned"}});continue}let d=$(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 Zs(t){if(t.length===0)return!1;let e=w.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function Qs(t,e,n,o){let r=[...e.filter(a=>a.prevB64===void 0)].sort(Y);if(r.length<2)return;let{parties:i,context:s}=await yt(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(Z),invalidContext:s.map(Z),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 ea(t,e,n){for(let o of[...e].sort(Y)){let r=$(o.slotCounter),i=$(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 ta(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)O(r,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of mn(r)){let a=new Set(s.map(f=>f.link.toEpochId));if(a.size<2)continue;let c=s.map(f=>e.get(f.viaProofHash)),{parties:u,context:d}=await yt(c),h=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(f=>f.viaProofHash),message:`The same predecessor terminal (epoch ${h.prevEpochId}, counter ${h.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:h.prevEpochId,prevCounter:h.prevCounter,prevProofHashB64:h.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:u.map(f=>f.proofHash),invalidObserved:d.map(f=>f.proofHash)}}),!(u.length<2)&&o.push({kind:"epochlink-fork",contested:{prevEpochId:h.prevEpochId,prevCounter:h.prevCounter,prevProofHashB64:h.prevProofHashB64},parties:u.map(Z),invalidContext:d.map(Z),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 na(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 na(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 u=c[c.length-1];s.has(u)||(s.add(u),i.push(u),a.set(u,[...t.get(u)??[]].sort()));let h=a.get(u).shift();if(h===void 0){c.pop(),s.delete(u),i.pop(),n.add(u);continue}if(s.has(h)){let f=i.indexOf(h),l=i.slice(f),g=oa(l);e.set(g.join("|"),g);continue}n.has(h)||c.push(h)}}return[...e.values()].sort((r,i)=>{let s=r.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function oa(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 yt(t){let e=[],n=[];for(let o of t)await oe(o)?e.push(o):n.push(o);return{parties:e,context:n}}function Z(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 mn(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})}y();function gn(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]),u=e.get(c);if(u!==void 0){u.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(ra),o=new Map;for(let a of t.proofs)a.epochId!==void 0&&O(o,a.epochId,a);let r=[];for(let[a,c]of[...o.entries()].sort(([u],[d])=>u<d?-1:u>d?1:0)){let u=new Set,d=new Set;for(let h of c)h.publicKeyB64!==void 0&&u.add(h.publicKeyB64),h.measurement!==void 0&&d.add(h.measurement);u.size>=2&&r.push({code:"mid-epoch-signer-change",proofHashes:c.map(h=>h.proofHash),message:`${u.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:[...u].sort()}}),d.size>=2&&r.push({code:"mid-epoch-measurement-change",proofHashes:c.map(h=>h.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 ra(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}y();var ia="Ethereum Anchor",ir="ethereum-anchor",sa=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function wn(t){let e=[],n=[],o=[];for(let r of t.proofs){let i=yn(r,"name"),s=aa(r);if(!(i===ia)){s===ir&&(n.push(r.proofHash),o.push({code:"anchor-metadata-only-claim",...bn(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===ir?"agrees":s===void 0?"absent":"disagrees";c==="disagrees"&&o.push({code:"anchor-metadata-disagreement",...bn(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 u=yn(r,"message"),d=yn(r,"title"),h=d!==void 0?sa.exec(d)?.[1]??void 0:void 0;h===void 0&&o.push({code:"anchor-title-unparseable",...bn(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 f=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}:{},...u!==void 0?{blockHash:u}:{},...h!==void 0?{blockNumber:h}:{},metadataCorroboration:c,...f!==void 0?{verificationTier:f.tier,verificationStatus:f.status,...f.reason!==void 0?{verificationReason:f.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:o}}function yn(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 aa(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 bn(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}y();y();var ca=BigInt(0),We=BigInt(1),ua=BigInt(2),da=BigInt(7),ha=BigInt(256),fa=BigInt(113),cr=[],ur=[],dr=[];for(let t=0,e=We,n=1,o=0;t<24;t++){[n,o]=[o,(2*n+3*o)%5],cr.push(2*(5*o+n)),ur.push((t+1)*(t+2)/2%64);let r=ca;for(let i=0;i<7;i++)e=(e<<We^(e>>da)*fa)%ha,e&ua&&(r^=We<<(We<<BigInt(i))-We);dr.push(r)}var hr=dt(dr,!0),la=hr[0],pa=hr[1],sr=(t,e,n)=>n>32?Ho(t,e,n):Ao(t,e,n),ar=(t,e,n)=>n>32?Co(t,e,n):Io(t,e,n);function ma(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,u=n[c],d=n[c+1],h=sr(u,d,1)^n[a],f=ar(u,d,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=h,t[s+l+1]^=f}let r=t[2],i=t[3];for(let s=0;s<24;s++){let a=ur[s],c=sr(r,i,a),u=ar(r,i,a),d=cr[s];r=t[d],i=t[d+1],t[d]=c,t[d+1]=u}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]^=la[o],t[1]^=pa[o]}J(n)}var xn=class t extends Re{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,zt(o),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=vo(this.state)}clone(){return this._cloneInto()}keccak(){Gt(this.state32),ma(this.state32,this.rounds),Gt(this.state32),this.posOut=0,this.pos=0}update(e){Me(this),e=_e(e),we(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){Me(this,!1),we(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 zt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(at(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,J(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}},ga=(t,e,n)=>Ke(()=>new xn(e,t,n));var fr=ga(1,136,256/8);y();function mr(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=gr(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 gr(t,e){let n=yr(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=bt(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=pr(t,e+1,a),u=e+1+a,d=bt(t,u,c);return{item:t.subarray(u,d),next:d}}if(n<=247){let a=n-192,c=bt(t,e+1,a);return{item:lr(t,e+1,c),next:c}}let o=n-247,r=pr(t,e+1,o),i=e+1+o,s=bt(t,i,r);return{item:lr(t,i,s),next:s}}function lr(t,e,n){let o=[],r=e;for(;r<n;){let i=gr(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 pr(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+yr(t,e+r);if(o>t.length)throw new Error("RLP: declared length exceeds the input size");return o}function bt(t,e,n){let o=e+n;if(o>t.length)throw new Error("RLP: item is truncated");return o}function yr(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function vn(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function br(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 wr(t){return`0x${w.Buffer.from(t).toString("hex")}`}var xr=8,vr=11,ya=/^0x[0-9a-fA-F]{64}$/,ba=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function En(t,e){let n=[],o=[],r=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=wa(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(Bn(d));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),u=e.anchors.filter(d=>{let h=d.blockHash?.toLowerCase();return h!==void 0&&(h===a||h===c)});if(u.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(Bn(d));continue}for(let d of u){let h=r.get(d.proofHash),f=h!==void 0&&await oe(h),l=xa(s,i.path,d.proofHash,h,f);n.push(l),l.verified||o.push(Bn(l))}}return{outcomes:n,findings:o}}function wa(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return wt("headerRlpHex is missing or not a string");let o=e.blockNumber;if(typeof o!="number"||!Number.isInteger(o)||o<0)return wt("blockNumber is missing or not a non-negative integer");let r=e.blockHash;if(typeof r!="string"||!ya.test(r))return wt("blockHash is missing or not 0x followed by 64 hex characters");let i=br(n);if(i===null)return wt("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=mr(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:wr(fr(i)),items:s,claimedHash:r,claimedNumber:BigInt(o)}}function wt(t){return{failure:{reason:"witness-malformed",detail:t}}}function xa(t,e,n,o,r){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(b,A,B)=>({...s,verified:!1,reason:b,detail:A,...B?.blockNumber!==void 0?{blockNumber:B.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=va(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 u=ka(Ea(o));if(u===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let d=C(new TextEncoder().encode(c));if(!Aa(d,u))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let h=t.items,f=h[xr];if(f===void 0||!(f instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${xr} (block number) is missing or not a byte string`);let l=vn(f);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 g=Ba(o);if(g!==void 0){let b=ba.exec(g)?.[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 m=h[vr];if(m===void 0||!(m instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${vr} (timestamp) is missing or not a byte string`,{blockNumber:String(l)});let v=vn(m);return v>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(v)}}function va(t){return Br(t,"message")}function Ba(t){return Br(t,"title")}function Br(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 Ea(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 ka(t){if(t===void 0||t.length===0)return null;let e=w.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function Aa(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 Bn(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}:{}}}}y();function kn(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(...Ia(d,r,i));let u=Ta(e,c);return{segments:c,anchorOrderedPairs:u,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function Ia(t,e,n){let o=t.memberProofHashes.map(f=>e.get(f)),r=new Map(o.map(f=>[f.chainHash,f])),i=o.filter(f=>n.has(f.proofHash)),s=new Map;for(let f of o){if(f.prevB64===void 0)continue;let l=r.get(f.prevB64);l===void 0||l.proofHash===f.proofHash||O(s,l.proofHash,f)}let a=new Map,c=new Map;for(let f of i)a.set(f.proofHash,Ca(f,s)),c.set(f.proofHash,$a(f,r));let u=o.map(f=>{let l=new Map,g=new Map,m=$(f.counter);for(let v of i){let b=v.proofHash,A=$(v.counter);f.proofHash===b||a.get(b).has(f.proofHash)?l.set(b,"chain-link"):m!==void 0&&A!==void 0&&m>A&&(l.has(b)||l.set(b,"counter-order")),c.get(b).has(f.proofHash)?g.set(b,"chain-link"):f.proofHash!==b&&m!==void 0&&A!==void 0&&m<A&&(g.has(b)||g.set(b,"counter-order"))}return{member:f,lower:Er("not-before",l,n),upper:Er("not-after",g,n)}}),d=new Map;for(let f of u)O(d,Ha(f),f);let h=[];for(let f of d.values()){let l=f.map(B=>B.member).sort(Y),g=f[0],m=g.lower,v=g.upper,b=m.length>0&&v.length>0?"bracketed":m.length>0?"lower-bounded":v.length>0?"upper-bounded":"ordered-but-unanchored",A=Sa(l);h.push({partition:t.key,memberProofHashes:l.map(B=>B.proofHash),...A!==void 0?{positionRange:A}:{},status:b,lowerBounds:m,upperBounds:v})}return h.sort(Pa),h}function Er(t,e,n){if(e.size===0)return[];let o=[...e.entries()].map(([c,u])=>({anchorHash:c,evidenceKind:u,info:n.get(c)})),r=(c,u)=>u===void 0?!0:c.info.timestamp!==u.info.timestamp?t==="not-before"?c.info.timestamp>u.info.timestamp:c.info.timestamp<u.info.timestamp:c.evidenceKind!==u.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<u.anchorHash,i,s;for(let c of o)r(c,i)&&(i=c),c.evidenceKind==="chain-link"&&r(c,s)&&(s=c);let a=[kr(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(kr(t,s)),a}function kr(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",claim:a}}function Ha(t){let e=n=>n.map(o=>`${o.anchorProofHash}:${o.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function Ca(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 $a(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 Sa(t){let e,n;for(let o of t)for(let r of[o.counter,o.slotCounter]){let i=$(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 Pa(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 Ar(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 Ta(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 u of i.memberProofHashes)a.lowerCovered.add(u);(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 u of i.memberProofHashes)a.upperCovered.add(u);(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.`+Ar(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.`+Ar(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 u=s.upperMax.evidence,d=c.lowerMin.evidence,h=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:u,lowerEvidence:d,weaker:h,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.`+(h?" 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}y();y();var Ir=`-----BEGIN CERTIFICATE-----
|
|
139
|
+
"use strict";(()=>{var Ea=Object.create;var Ir=Object.defineProperty;var Ba=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var Aa=Object.getPrototypeOf,ka=Object.prototype.hasOwnProperty;var Ia=(t,e)=>()=>(t&&(e=t(t=0)),e);var Fn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ha=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of va(e))!ka.call(t,r)&&r!==n&&Ir(t,r,{get:()=>e[r],enumerable:!(o=Ba(e,r))||o.enumerable});return t};var Sa=(t,e,n)=>(n=t!=null?Ea(Aa(t)):{},Ha(e||!t||!t.__esModule?Ir(n,"default",{value:t,enumerable:!0}):n,t));var Cr=Fn(qt=>{"use strict";b();qt.byteLength=Ta;qt.toByteArray=Ra;qt.fromByteArray=Da;var xe=[],pe=[],Ca=typeof Uint8Array<"u"?Uint8Array:Array,Un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(et=0,Hr=Un.length;et<Hr;++et)xe[et]=Un[et],pe[Un.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 Ta(t){var e=Sr(t),n=e[0],o=e[1];return(n+o)*3/4-o}function $a(t,e,n){return(e+n)*3/4-n}function Ra(t){var e,n=Sr(t),o=n[0],r=n[1],i=new Ca($a(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 Pa(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(Pa(o));return r.join("")}function Da(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=Fn(Nn=>{b();Nn.read=function(t,e,n,o,r){var i,s,a=r*8-o-1,c=(1<<a)-1,f=c>>1,u=-7,d=n?r-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+=o;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,o),i=i-f}return(l?-1:1)*s*Math.pow(2,i-o)};Nn.write=function(t,e,n,o,r,i){var s,a,c,f=i*8-r-1,u=(1<<f)-1,d=u>>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=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,r),s=s+d):(a=e*Math.pow(2,d-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=Fn(lt=>{"use strict";b();var On=Cr(),dt=Tr(),$r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;lt.Buffer=g;lt.SlowBuffer=_a;lt.INSPECT_MAX_BYTES=50;var Gt=2147483647;lt.kMaxLength=Gt;g.TYPED_ARRAY_SUPPORT=Ma();!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 Ma(){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>Gt)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 Vn(t)}return Dr(t,e,n)}g.poolSize=8192;function Dr(t,e,n){if(typeof t=="string")return Ua(t,e);if(ArrayBuffer.isView(t))return Na(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 Kn(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=Oa(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 Dr(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 Fa(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 Fa(t,e,n)};function Vn(t){return Mr(t),Te(t<0?0:zn(t)|0)}g.allocUnsafe=function(t){return Vn(t)};g.allocUnsafeSlow=function(t){return Vn(t)};function Ua(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=Fr(t,e)|0,o=Te(n),r=o.write(t,e);return r!==n&&(o=o.slice(0,r)),o}function _n(t){let e=t.length<0?0:zn(t.length)|0,n=Te(e);for(let o=0;o<e;o+=1)n[o]=t[o]&255;return n}function Na(t){if(Ee(t,Uint8Array)){let e=new Uint8Array(t);return Kn(e.buffer,e.byteOffset,e.byteLength)}return _n(t)}function Kn(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 Oa(t){if(g.isBuffer(t)){let e=zn(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"||Gn(t.length)?Te(0):_n(t);if(t.type==="Buffer"&&Array.isArray(t.data))return _n(t.data)}function zn(t){if(t>=Gt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Gt.toString(16)+" bytes");return t|0}function _a(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 Fr(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 jn(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:jn(t).length;e=(""+e).toLowerCase(),r=!0}}g.byteLength=Fr;function Ka(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 Ja(this,e,n);case"utf8":case"utf-8":return Nr(this,e,n);case"ascii":return Ya(this,e,n);case"latin1":case"binary":return Xa(this,e,n);case"base64":return Wa(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qa(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?Nr(this,0,e):Ka.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),u=e.slice(n,o);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 Ur(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,Gn(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(u,d){return i===1?u[d]:u.readUInt16BE(d*i)}let f;if(r){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,o){return this.indexOf(e,n,o)!==-1};g.prototype.indexOf=function(e,n,o){return Ur(this,e,n,o,!0)};g.prototype.lastIndexOf=function(e,n,o){return Ur(this,e,n,o,!1)};function ja(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(Gn(a))return s;t[n+s]=a}return s}function Va(t,e,n,o){return Wt(jn(e,t.length-n),t,n,o)}function za(t,e,n,o){return Wt(oc(e),t,n,o)}function qa(t,e,n,o){return Wt(qr(e),t,n,o)}function Ga(t,e,n,o){return Wt(rc(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 ja(this,e,n,o);case"utf8":case"utf-8":return Va(this,e,n,o);case"ascii":case"latin1":case"binary":return za(this,e,n,o);case"base64":return qa(this,e,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ga(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 Wa(t,e,n){return e===0&&n===t.length?On.fromByteArray(t):On.fromByteArray(t.slice(e,n))}function Nr(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,u,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[r+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[r+1],f=t[r+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[r+1],f=t[r+2],u=t[r+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,o.push(s>>>10&1023|55296),s=56320|s&1023),o.push(s),r+=a}return Za(o)}var Pr=4096;function Za(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 Ya(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 Xa(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 Ja(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+=ic[t[i]];return r}function Qa(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),dt.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,n){return e=e>>>0,n||J(e,4,this.length),dt.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||J(e,8,this.length),dt.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||J(e,8,this.length),dt.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 Or(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 Or(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 Or(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),dt.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),dt.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 ut={};function qn(t,e,n){ut[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}`}}}qn("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);qn("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);qn("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=Lr(String(n)):typeof n=="bigint"&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=Lr(r)),r+="n"),o+=` It must be ${e}. Received ${r}`,o},RangeError);function Lr(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 ec(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 ut.ERR_OUT_OF_RANGE("value",a,t)}ec(o,r,i)}function ht(t,e){if(typeof t!="number")throw new ut.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ct(t,e,n){throw Math.floor(t)!==t?(ht(t,n),new ut.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new ut.ERR_BUFFER_OUT_OF_BOUNDS:new ut.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var tc=/[^+/0-9A-Za-z-_]/g;function nc(t){if(t=t.split("=")[0],t=t.trim().replace(tc,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function jn(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 oc(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function rc(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 On.toByteArray(nc(t))}function Wt(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 Gn(t){return t!==t}var ic=(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"?sc:t}function sc(){throw new Error("BigInt not supported")}});var B,b=Ia(()=>{"use strict";B=Sa(Gr(),1);globalThis.Buffer=B.Buffer});b();b();var ac={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ne,n:Zt,Gx:Wr,Gy:Zr,a:Wn,d:Zn}=ac,cc=8n,Tt=32,Yn=64,me=(t="")=>{throw new Error(t)},fc=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,Qt=t=>new Uint8Array(t),eo=t=>Uint8Array.from(t),ni=(t,e)=>t.toString(16).padStart(e,"0"),to=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)},no=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=Qt(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},Yt=(t,e)=>mt(ti(t)?no(t):eo(mt(t)),e),oi=()=>globalThis?.crypto,dc=()=>oi()?.subtle??me("crypto.subtle must be defined"),Xn=(...t)=>{let e=Qt(t.reduce((o,r)=>o+mt(r).length,0)),n=0;return t.forEach(o=>{e.set(o,n),n+=o.length}),e},hc=(t=Tt)=>oi().getRandomValues(Qt(t)),Xt=BigInt,nt=(t,e,n,o="bad number: out of range")=>fc(t)&&e<=t&&t<n?t:me(o),k=(t,e=ne)=>{let n=t%e;return n>=0n?n:e+n},lc=t=>k(t,Zt),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,u=r-s*c,d=i-a*c;o=n,n=f,r=s,i=a,s=u,a=d}return o===1n?k(r,e):me("no inverse")};var Xr=t=>t instanceof Re?t:me("Point expected"),Jn=2n**256n,Re=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,o,r){let i=Jn;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=Zn,r=eo(mt(e,Tt)),i=e[31];r[31]=i&-129;let s=oo(r);nt(s,0n,n?Jn:ne);let c=k(s*s),f=k(c-1n),u=k(o*c+1n),{isValid:d,value:h}=gc(f,u);d||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=Wn,n=Zn,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),u=k(s*s),d=k(u*u),h=k(c*e),l=k(u*k(h+f)),p=k(d+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),u=k(o*a),d=k(s*r);return c===f&&u===d}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=Wn,i=k(e*e),s=k(n*n),a=k(2n*k(o*o)),c=k(r*i),f=e+n,u=k(k(f*f)-i-s),d=c+s,h=d-a,l=c-s,p=k(u*h),m=k(d*l),x=k(u*l),w=k(h*d);return new t(p,m,w,x)}add(e){let{ex:n,ey:o,ez:r,et:i}=this,{ex:s,ey:a,ez:c,et:f}=Xr(e),u=Wn,d=Zn,h=k(n*s),l=k(o*a),p=k(i*d*f),m=k(r*c),x=k((n+o)*(s+a)-h-l),w=k(m-p),T=k(m+p),C=k(l-u*h),_=k(x*w),G=k(T*C),$=k(x*C),U=k(w*T);return new t(_,G,U,$)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return pt;if(nt(e,1n,Zt),e===1n)return this;if(this.equals(gt))return vc(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=pc(n);return o[31]|=e&1n?128:0,o}toHex(){return to(this.toBytes())}clearCofactor(){return this.multiply(Xt(cc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(Zt/2n,!1).double();return Zt%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(Yt(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 pc=t=>no(ni(nt(t,0n,Jn),Yn)).reverse(),oo=t=>Xt("0x"+to(eo(mt(t)).reverse())),Be=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=ne;return n},mc=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,u=Be(f,80n)*c%ne,d=Be(u,10n)*i%ne;return{pow_p_5_8:Be(d,2n)*t%ne,b2:n}},Jr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,gc=(t,e)=>{let n=k(e*e*e),o=k(n*n*e),r=mc(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,u=s===k(-t),d=s===k(-t*Jr);return f&&(i=a),(u||d)&&(i=c),(k(i)&1n)===1n&&(i=k(-i)),{isValid:f||u,value:i}},bc=t=>lc(oo(t)),yc=(...t)=>en.sha512Async(...t);var wc=t=>yc(t.hashable).then(t.finish);var ii={zip215:!0},xc=(t,e,n,o=ii)=>{t=Yt(t,Yn),e=Yt(e),n=Yt(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=oo(t.slice(Tt,Yn)),c=gt.multiply(a,!1),f=Xn(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:d=>{if(c==null||!r&&i.isSmallOrder())return!1;let h=bc(d);return s.add(i.multiply(h,!1)).add(c.negate()).clearCofactor().is0()}}},ro=async(t,e,n,o=ii)=>wc(xc(t,e,n,o));var en={sha512Async:async(...t)=>{let e=dc(),n=Xn(...t);return Qt(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:to,hexToBytes:no,concatBytes:Xn,mod:k,invert:ri,randomBytes:hc};var Jt=8,Ec=256,si=Math.ceil(Ec/Jt)+1,Qn=2**(Jt-1),Bc=()=>{let t=[],e=gt,n=e;for(let o=0;o<si;o++){n=e,t.push(n);for(let r=1;r<Qn;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},vc=t=>{let e=Qr||(Qr=Bc()),n=pt,o=gt,r=2**Jt,i=r,s=Xt(r-1),a=Xt(Jt);for(let c=0;c<si;c++){let f=Number(t&s);t>>=a,f>Qn&&(f-=i,t+=1n);let u=c*Qn,d=u,h=u+Math.abs(f)-1,l=c%2!==0,p=f<0;f===0?o=o.add(ei(l,e[d])):n=n.add(ei(p,e[h]))}return{p:n,f:o}};b();b();b();function kc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function io(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ot(t,...e){if(!kc(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 tn(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 nn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ge(t,e){return t<<32-e|t>>>e}var Ic=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hc(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Sc(t){for(let e=0;e<t.length;e++)t[e]=Hc(t[e]);return t}var so=Ic?t=>t:Sc;function Cc(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=Cc(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 Tc(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=nn(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=nn(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),tn(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 d=s;d<r;d++)n[d]=0;Tc(o,r-8,BigInt(this.length*8),i),this.process(o,0);let a=nn(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 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 on=BigInt(4294967295),ui=BigInt(32);function $c(t,e=!1){return e?{h:Number(t&on),l:Number(t>>ui&on)}:{h:Number(t>>ui&on)|0,l:Number(t&on)|0}}function rn(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}=$c(t[i],e);[o[i],r[i]]=[s,a]}return[o,r]}var ao=(t,e,n)=>t>>>n,co=(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,Lt=(t,e,n)=>t<<64-n|e>>>n-32,Dt=(t,e,n)=>t>>>n-32|e<<64-n;var di=(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 Pc=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),sn=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 d=0;d<16;d++,n+=4)je[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=je[d-15],l=je[d-2],p=ge(h,7)^ge(h,18)^h>>>3,m=ge(l,17)^ge(l,19)^l>>>10;je[d]=m+je[d-7]+p+je[d-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=ge(a,6)^ge(a,11)^ge(a,25),l=u+h+ci(a,c,f)+Pc[d]+je[d]|0,m=(ge(o,2)^ge(o,13)^ge(o,22))+fi(o,r,i)|0;u=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,u=u+this.H|0,this.set(o,r,i,s,a,c,f,u)}roundClean(){ve(je)}destroy(){this.set(0,0,0,0,0,0,0,0),ve(this.buffer)}};var Ei=rn(["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],Dc=Ei[1],Ve=new Uint32Array(80),ze=new Uint32Array(80),fo=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:u,Fh:d,Fl:h,Gh:l,Gl:p,Hh:m,Hl:x}=this;return[e,n,o,r,i,s,a,c,f,u,d,h,l,p,m,x]}set(e,n,o,r,i,s,a,c,f,u,d,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=u|0,this.Fh=d|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)^ao(_,G,7),U=it(_,G,1)^it(_,G,8)^co(_,G,7),N=Ve[C-2]|0,Z=ze[C-2]|0,V=rt(N,Z,19)^Lt(N,Z,61)^ao(N,Z,6),le=it(N,Z,19)^Dt(N,Z,61)^co(N,Z,6),D=bi(U,le,ze[C-7],ze[C-16]),ie=yi(D,$,V,Ve[C-7],Ve[C-16]);Ve[C]=ie|0,ze[C]=D|0}let{Ah:o,Al:r,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:h,Fh:l,Fl:p,Gh:m,Gl:x,Hh:w,Hl:T}=this;for(let C=0;C<80;C++){let _=rt(d,h,14)^rt(d,h,18)^Lt(d,h,41),G=it(d,h,14)^it(d,h,18)^Dt(d,h,41),$=d&l^~d&m,U=h&p^~h&x,N=wi(T,G,U,Dc[C],ze[C]),Z=xi(N,w,_,$,Lc[C],Ve[C]),V=N|0,le=rt(o,r,28)^Lt(o,r,34)^Lt(o,r,39),D=it(o,r,28)^Dt(o,r,34)^Dt(o,r,39),ie=o&i^o&a^i&a,oe=r&s^r&c^s&c;w=m|0,T=x|0,m=l|0,x=p|0,l=d|0,p=h|0,{h:d,l:h}=Ae(f|0,u|0,Z|0,V|0),f=a|0,u=c|0,a=i|0,c=s|0,i=o|0,s=r|0;let F=mi(V,D,oe);o=gi(F,Z,le,ie),r=F|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:u}=Ae(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:h}=Ae(this.Eh|0,this.El|0,d|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:w,l:T}=Ae(this.Hh|0,this.Hl|0,w|0,T|0),this.set(o,r,i,s,a,c,f,u,d,h,l,p,m,x,w,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 sn);var an=Rt(()=>new fo);b();b();b();function ce(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var vi=ce("fs.createReadStream"),oh=ce("fs.readFileSync"),rh=ce("fs.existsSync"),ih=ce("fs.writeFileSync"),Mc=ce("fs.open"),Fc=ce("fs.readdir"),Ai=ce("fs.readFile"),Uc=ce("fs.stat"),sh=ce("fs.mkdir"),ah=ce("fs.writeFile"),ki=ce("path.join"),ch=ce("path.basename"),Ii=ce("zlib.createGunzip"),Nc=ce("zlib.gzipSync");b();var q=Bi;b();b();b();b();b();b();b();var Oc=t=>t/2**32|0,_c=t=>t>>>0;function Hi(t,e,n,o){let r=Oc(n),i=_c(n);t.setUint32(e,o?i:r,o),t.setUint32(e+4,o?r:i,o)}b();function cn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var uo=t=>t?`"${t}" `:"";function Le(t,e=""){if(typeof t!="number")throw new TypeError(uo(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(uo(e)+"expected integer >= 0, got "+t);return t}function ke(t,e,n=""){if(cn(t)&&(e===void 0||t.length===e))return t;e!==void 0&&Le(e,"length");let o=cn(t),r=e!==void 0?` of length ${e}`:"",i=o?`length=${t.length}`:`type=${typeof t}`,s=uo(n)+"expected Uint8Array"+r+", got "+i;throw o?new RangeError(s):new TypeError(s)}function fn(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 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 dn(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",Kc=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function hn(t){if(ke(t),Ti)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Kc[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 ho(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 jc(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=jc({},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){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 Li=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Di(t,e,n){return t&e^~t&n}function Mi(t,e,n){return t&e^t&n^e&n}var ln=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=dn(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=dn(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:dn(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 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()}},Fi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Vc=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),lo=class extends ln{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 d=0;d<16;d++,n+=4)qe[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=qe[d-15],l=qe[d-2],p=be(h,7)^be(h,18)^h>>>3,m=be(l,17)^be(l,19)^l>>>10;qe[d]=m+qe[d-7]+p+qe[d-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=be(a,6)^be(a,11)^be(a,25),l=u+h+Di(a,c,f)+Vc[d]+qe[d]|0,m=(be(o,2)^be(o,13)^be(o,22))+Mi(o,r,i)|0;u=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,u=u+this.H|0,this.set(o,r,i,s,a,c,f,u)}roundClean(){Mt(qe)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Mt(this.buffer)}},po=class extends lo{constructor(){super(32,Fi)}};var Ui=Ri(()=>new po,Li(1));b();function mn(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),mo=Le;function Oi(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 go=hn,De=(...t)=>$i(...t),gn=t=>ho(t),xt=cn,bn=t=>Pi(t),pn=BigInt(0),Ni=BigInt(1),zc=t=>t?`"${t}" `:"";function Ie(t,e=""){if(typeof t!="boolean")throw new TypeError(zc(e)+"expected boolean, got type="+typeof t);return t}function yn(t){if(typeof t=="bigint"){if(!We(t))throw new RangeError("positive bigint expected, got "+t)}else mo(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 Ft(t){let e=yn(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===""?pn:BigInt("0x"+t)}function He(t){return _i(hn(t))}function bo(t){return _i(hn(qc(ke(t)).reverse()))}function wn(t,e){if(Le(e),e===0)throw new Error("zero output length is invalid");t=yn(t);let n=e*2,o=t.toString(16);if(o.length>n)throw new RangeError("number is too large");return ho(o.padStart(n,"0"))}function yo(t,e){return wn(t,e).reverse()}function qc(t){return Uint8Array.from(X(t))}function We(t){return typeof t=="bigint"&&pn<=t}function wo(t,e,n){return We(t)&&We(e)&&We(n)&&e<=t&&t<n}function xo(t,e,n,o){if(!wo(e,n,o))throw new RangeError("expected valid "+t+": "+n+" <= n < "+o+", got "+e)}function Bt(t){if(t<pn)throw new Error("expected non-negative bigint, got "+t);return t===pn?0:t.toString(2).length}var Ut=t=>(Et(t,"n"),(Ni<<BigInt(t))-Ni);function Ki(t,e,n){if(Le(t,"hashLen"),Le(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),u=0,d=()=>{c.fill(1),f.fill(0),u=0},h=(...x)=>n(f,De(c,...x)),l=(x=r)=>{f=h(i,x),c=h(),x.length!==0&&(f=h(s,x),c=h())},p=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let x=0,w=[];for(;x<e;){c=h();let T=c.slice();w.push(T),x+=c.length}return De(...w)};return(x,w)=>{d(),l(x);let T;for(;(T=w(p()))===void 0;)l();return d(),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)}"`,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])=>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),Eo=BigInt(4),Gi=BigInt(5),Gc=BigInt(7),Wi=BigInt(8),Wc=BigInt(9),Zc=BigInt(15),Zi=BigInt(16),Yc=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 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<Yc){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&Zc)),e>>=Eo;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=de(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 de(r,e)}function Xi(t,e){if(e<=j)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 o=Yi(n,e-Ye,e);if(de(n*o,e)!==j)throw new Error("invertCt: does not exist");return o}function Bo(t,e,n){let o=t;if(!o.eql(o.sqr(e),n))throw new Error("Cannot find square root")}function vo(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)/Eo,r=n.pow(e,o);return Bo(n,r,e),r}function Xc(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 Bo(n,c,e),c}function Jc(t){let e=En(t),n=Qi(t),o=n(e,e.neg(e.ONE)),r=n(e,o),i=n(e,e.neg(o)),s=(t+Gc)/Zi;return((a,c)=>{let f=a,u=f.pow(c,s),d=f.mul(u,o),h=f.mul(u,r),l=f.mul(u,i),p=f.eql(f.sqr(d),c),m=f.eql(f.sqr(h),c);u=f.cmov(u,d,p),d=f.cmov(l,h,m);let x=f.eql(f.sqr(d),c),w=f.cmov(u,d,x);return Bo(f,w,c),w})}function Qi(t){if(t<qi)throw new Error("sqrt is not defined for small field");vo(t,"tonelliShanks");let e=t-j,n=0;for(;e%Ye===ee;)e/=Ye,n++;let o=Ye,r=En(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 u=c;if(u.is0(f))return f;if(Vi(u,f)!==1)throw new Error("Cannot find square root");let d=n,h=u.mul(u.ONE,i),l=u.pow(f,e),p=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 m=1,x=u.sqr(l);for(;!u.eql(x,u.ONE);)if(m++,x=u.sqr(x),m===d)throw new Error("Cannot find square root");let w=j<<BigInt(d-m-1),T=u.pow(h,w);d=m,h=u.sqr(T),l=u.mul(l,h),p=u.mul(p,T)}return p}}function Qc(t){return vo(t,"Fp.sqrt"),t%Eo===qi?Ji:t%Wi===Gi?Xc:t%Zi===Wc?Jc(t):Qi(t)}var ef=["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 ef)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 Ao(t,e,n=!1){vt(t),mn(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;vo(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 tf(t,e){if(e!==void 0&&mo(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,xn=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}=tf(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 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&j)===j}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 Yi(e,n,this.ORDER)}div(e,n){return de(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=Qc(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?yo(e,this.BYTES):wn(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?bo(e):He(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 Ao(this,e,!0)}cmov(e,n,o){return Ie(o,"condition"),o?n:e}};function En(t,e={}){return Object.freeze(xn.prototype),new xn(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 Bn(t){let e=es(t);return e+Math.ceil(e/2)}function ko(t,e,n=!1){X(t);let o=t.length,r=es(e),i=Math.max(Bn(e),16);if(o<i||o>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+o);let s=n?bo(t):He(t),a=de(s,e-j)+j;return n?yo(a,r):wn(a,r)}var So=BigInt(0),Nt=BigInt(1),nf=BigInt(4),Io=16,ts=128,of=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=Ao(t.Fp,e.map(o=>o.Z));return e.map((o,r)=>t.fromAffine(o.toAffine(n[r])))}function rf(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 sf(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 Co(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){mn(t,"points"),t.forEach((n,o)=>{if(!(n instanceof e))throw new Error("invalid point at index "+o)})}function af(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 Ho(t){return ss.get(t)||1}function cf(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 ff(t,e){let n=2**e,o=n/2,r=BigInt(n-1),i=[];for(;t>So;){let s=0;t&Nt&&(s=Number(t&r),s>=o&&(s-=n),t-=BigInt(s)),i.push(s),t>>=Nt}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+=Nt),a.push(f)}if(t!==So)throw new Error("invalid wnaf");return a}function df(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 vn=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){At(e),this.randomBytes=Co(n,Io),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 u=0;u<i;u++)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 u=0;u<r;u++){let d=a[u],h=u*s,l=Math.abs(d)-1,p=i[h];for(let x=1;x<s;x++)p=x===l?i[h+x]:p;let m=p.negate();d===0?f=f.add(i[h]):c=c.add(d<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),!wo(n,Nt,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,o,r){let i=Ho(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(Io);if(!xt(i)||i.length!==Io)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=of,i=1<<r,s=Ut(r),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(o/r),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let l=0;l<r;l++)f=f.double();let d=Number(n>>BigInt(u*r)&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===Nt?!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=Ho(e);if(r===1||n>=this.Point.Fn.ORDER)return An(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),rf(n,this.bits);let o=Math.ceil((this.bits+ts)/n)+1;sf(o*2**(n-1),this.Point.Fp.BYTES),ss.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Ho(e)!==1}};function An(t,e,n,o=!1){if(At(t),is(e,t),Ie(o,"allowOversized"),af(n,t.Fn,o?t.Fn.ORDER**nf:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let r=e.map(s=>cf(s,4)),i=n.map(s=>ff(s,4));return df(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 En(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!==So))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 kn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(fn(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 kn(e,n).update(o).digest());return t.create=(e,n)=>new kn(e,n),t})();b();var hf=BigInt(0),To=class extends Error{constructor(e=""){super(e)}},Me={Err:To,_tlv:{encode:(t,e)=>{let{Err:n}=Me;if(Et(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(Oi(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let o=e.length/2,r=Ft(o);if(r.length/2&128)throw new n("tlv.encode: long form length too big");let i=o>127?Ft(r.length/2|128):"";return Ft(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 u of f)s=s<<8|u;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(yn(t),t<hf)throw new e("integer: negative integers are not allowed");let n=Ft(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:u}=o.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}=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)}},$o=(Object.freeze(Me._tlv),Object.freeze(Me._int),Object.freeze(Me));var us=(t,e)=>(t+(t>=0?e:-e)/ds)/e;function lf(t,e,n){xo("scalar",t,Fe,n);let[[o,r],[i,s]]=e,a=us(s*t,n),c=us(-r*t,n),f=t-a*o-c*i,u=-a*r-c*s,d=f<Fe,h=u<Fe;d&&(f=-f),h&&(u=-u);let l=Ut(Math.ceil(Bt(n)/2))+at;if(f<Fe||f>=l||u<Fe||u>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:f,k2neg:h,k2:u}}function Lo(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ro(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&&Lo(n.format),n}var Fe=BigInt(0),at=BigInt(1),ds=BigInt(2),Po=BigInt(3),pf=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,u=e.randomBytes===void 0?bn: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 d=ps(o,r);function h(){if(!o.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(F,E,v){if(f&&E.is0())return Uint8Array.of(0);let{x:H,y:L}=E.toAffine(),A=o.toBytes(H);if(Ie(v,"isCompressed"),v){h();let y=!o.isOdd(L);return De(ls(y),A)}else return De(Uint8Array.of(4),A,o.toBytes(L))}function p(F){X(F,void 0,"Point");let{publicKey:E,publicKeyUncompressed:v}=d,H=F.length,L=F[0],A=F.subarray(1);if(f&&H===1&&L===0)return{x:o.ZERO,y:o.ZERO};if(H===E&&(L===2||L===3)){let y=o.fromBytes(A);if(!o.isValid(y))throw new Error("bad point: is not on curve, wrong x");let I=C(y),S;try{S=o.sqrt(I)}catch(K){let O=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+O)}h();let M=o.isOdd(S);return(L&1)===1!==M&&(S=o.neg(S)),{x:y,y:S}}else if(H===v&&L===4){let y=o.BYTES,I=o.fromBytes(A.subarray(0,y)),S=o.fromBytes(A.subarray(y,y*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,w=o.mul(i.b,Po),T=o.is0(i.a)?F=>o.ZERO:F=>o.mul(i.a,F);function C(F){let E=o.sqr(F),v=o.mul(E,F);return o.add(o.add(v,o.mul(F,i.a)),i.b)}function _(F,E){let v=o.sqr(E),H=C(F);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,Po),pf),$=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(G,$)))throw new Error("bad curve params: a or b");function U(F,E,v=!1){if(!o.isValid(E)||v&&o.is0(E))throw new Error(`bad point coordinate ${F}`);return E}function N(F){if(!(F instanceof D))throw new Error("Weierstrass Point expected")}function Z(F){if(!c||!c.basises)throw new Error("no endo");return lf(F,c.basises,r.ORDER)}function V(F,E,v,H){if(!r.isValid(H))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:L,k1:A,k2neg:y,k2:I}=Z(H),S=new D(o.mul(v.X,c.beta),v.Y,v.Z);F.push(L?v.negate():v,y?S.negate():S),E.push(A,I)}else F.push(v),E.push(H)}let le=new WeakSet;class D{static BASE=new D(i.Gx,i.Gy,o.ONE);static ZERO=new D(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=r;X;Y;Z;constructor(E,v,H){this.X=U("x",E),this.Y=U("y",v,!0),this.Z=U("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 D)throw new Error("projective point not allowed");return o.is0(v)&&o.is0(H)?D.ZERO:new D(v,H,o.ONE)}static fromBytes(E){let v=D.fromAffine(x(X(E,void 0,"point")));return v.assertValidity(),v}static fromHex(E){return D.fromBytes(gn(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(Po),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){N(E);let{X:v,Y:H,Z:L}=this,{X:A,Y:y,Z:I}=E,S=o.eql(o.mul(v,I),o.mul(A,L)),M=o.eql(o.mul(H,I),o.mul(y,L));return S&&M}negate(){return new D(this.X,o.neg(this.Y),this.Z)}double(){let{X:E,Y:v,Z:H}=this,L=o.ZERO,A=o.ZERO,y=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),y=o.mul(E,H),y=o.add(y,y),L=T(y),A=o.mul(w,M),A=o.add(L,A),L=o.sub(S,A),A=o.add(S,A),A=o.mul(L,A),L=o.mul(R,L),y=o.mul(w,y),M=T(M),R=o.sub(I,M),R=T(R),R=o.add(R,y),y=o.add(I,I),I=o.add(y,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),L=o.sub(L,I),y=o.mul(M,S),y=o.add(y,y),y=o.add(y,y),new D(L,A,y)}add(E){N(E);let{X:v,Y:H,Z:L}=this,{X:A,Y:y,Z:I}=E,S=o.ZERO,M=o.ZERO,R=o.ZERO,K=o.mul(v,A),O=o.mul(H,y),W=o.mul(L,I),se=o.add(v,H),z=o.add(A,y);se=o.mul(se,z),z=o.add(K,O),se=o.sub(se,z),z=o.add(v,L);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,L),S=o.add(y,I),te=o.mul(te,S),S=o.add(O,W),te=o.sub(te,S),R=T(z),S=o.mul(w,W),R=o.add(S,R),S=o.sub(O,R),R=o.add(O,R),M=o.mul(S,R),O=o.add(K,K),O=o.add(O,K),W=T(W),z=o.mul(w,z),O=o.add(O,W),W=o.sub(K,W),W=T(W),z=o.add(z,W),K=o.mul(O,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,O),R=o.mul(te,R),R=o.add(R,K),new D(S,M,R)}subtract(E){return N(E),this.add(E.negate())}is0(){return this.equals(D.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===Fe||v.is0())return D.ZERO;if(H===at)return v;if(oe.hasWindowSize(this))return oe.mulUnsafe(v,H,ie);let L=[],A=[];return V(L,A,v,H),An(D,L,A)}mulAddUnsafe(E,v,H){N(v);let L=[],A=[];return V(L,A,this,E),V(L,A,v,H),An(D,L,A)}toAffine(E){let v=this,H=E;if(H!=null&&!o.isValid(H))throw new RangeError('"invertedZ" expected valid field element');let{X:L,Y:A,Z:y}=v;if(o.eql(y,o.ONE))return{x:L,y:A};let I=v.is0();H==null&&(H=I?o.ONE:o.inv(y));let S=o.mul(L,H),M=o.mul(A,H),R=o.mul(y,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(D,this):oe.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:E}=e;return s===at?this:E?E(D,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===at?this.is0():this.clearCofactor().is0()}toBytes(E=!0){return Ie(E,"isCompressed"),this.assertValidity(),m(D,this,E)}toHex(E=!0){return go(this.toBytes(E))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ie=F=>rs(D,F),oe=new vn(D,u);return oe.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}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 mf(t,e={}){At(t);let{Fn:n}=t,o=e.randomBytes===void 0?bn:e.randomBytes,r=Object.assign(ps(t.Fp,n),{seed:Math.max(Bn(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 w=l.length;return p===!0&&w!==m||p===!1&&w!==x?!1:!!t.fromBytes(l)}catch{return!1}}function a(l){return l=l===void 0?o(r.seed):l,ko(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,w=n._lengths;if(!xt(l))return;let T=X(l,void 0,"key").length,C=T===m||T===x,_=T===p||!!w?.includes(T);if(!(C&&_))return C}function u(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 d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=cs(a,c);return Object.freeze(d),Object.freeze(r),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:h,Point:t,utils:d,lengths:r})}function ms(t,e,n={}){At(t);let o=e;fn(o),Ze(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let r=Object.assign({},n),i=r.randomBytes===void 0?bn:r.randomBytes,s=r.hmac===void 0?(A,y)=>fs(o,A,y):r.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:u}=c,d=Bn(f),h=Co(i,d),{keygen:l,getPublicKey:p,getSharedSecret:m,utils:x,lengths:w}=mf(t,r),T={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},C=f*ds+at<a.ORDER;function _(A){let y=f>>at;return A>y}function G(A,y){if(!c.isValidNot0(y))throw new Error(`invalid signature ${A}: out of range 1..Point.Fn.ORDER`);return y}function $(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function U(A,y,I){return $(),(A===I?0:2)|Number(a.isOdd(y))}function N(){if(C)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function Z(A,y){Lo(y);let I=w.signature,S=y==="compact"?I:y==="recovered"?I+1:void 0;return X(A,S)}class V{r;s;recovery;constructor(y,I,S){if(this.r=G("r",y),this.s=G("s",I),S!=null){if(N(),![0,1,2,3].includes(S))throw new Error("invalid recovery id");this.recovery=S}Object.freeze(this)}static fromBytes(y,I=T.format){Z(y,I);let S;if(I==="der"){let{r:O,s:W}=$o.toSig(X(y));return new V(O,W)}I==="recovered"&&(S=y[0],I="compact",y=y.subarray(1));let M=w.signature/2,R=y.subarray(0,M),K=y.subarray(M,M*2);return new V(c.fromBytes(R),c.fromBytes(K),S)}static fromHex(y,I){return this.fromBytes(gn(y),I)}assertRecovery(){let{recovery:y}=this;if(y==null)throw new Error("invalid recovery id: must be present");return y}addRecoveryBit(y){return new V(this.r,this.s,y)}recoverPublicKey(y){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),O=t.fromBytes(De(ls((M&1)===0),K)),W=c.inv(R),se=D(X(y,void 0,"msgHash")),z=c.create(-se*W),te=c.create(S*W),ye=t.BASE.mulAddUnsafe(z,O,te);if(ye.is0())throw new Error("invalid recovery: point at infinify");return ye.assertValidity(),ye}hasHighS(){return _(this.s)}toBytes(y=T.format){if(Lo(y),y==="der")return gn($o.hexFromSig(this));let{r:I,s:S}=this,M=c.toBytes(I),R=c.toBytes(S);return y==="recovered"?(N(),De(Uint8Array.of(this.assertRecovery()),M,R)):De(M,R)}toHex(y){return go(this.toBytes(y))}}Object.freeze(V.prototype),Object.freeze(V);let le=r.bits2int===void 0?function(y){if(y.length>8192)throw new Error("input is too large");let I=He(y),S=y.length*8-u;return S>0?I>>BigInt(S):I}:r.bits2int,D=r.bits2int_modN===void 0?function(y){return c.create(le(y))}:r.bits2int_modN,ie=Ut(u);function oe(A){return xo("num < 2^"+u,A,Fe,ie),c.toBytes(A)}function F(A,y){return X(A,void 0,"message"),y?X(o(A),void 0,"prehashed message"):A}function E(A,y,I){let{lowS:S,prehash:M,extraEntropy:R}=Ro(I,T);A=F(A,M);let K=D(A),O=c.fromBytes(y);if(!c.isValidNot0(O))throw new Error("invalid private key");let W=[oe(O),oe(K)];if(R!=null&&R!==!1){let ye=R===!0?i(w.secretKey):R;W.push(X(ye,void 0,"extraEntropy"))}let se=De(...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===Fe)return;let we;if(h!==void 0){let St=He(ko(h(d),f)),ya=c.inv(c.mul(St,ft)),wa=c.mul(St,z),xa=c.mul(St,O);we=c.create(ya*c.create(wa+xa*_e))}else{let St=Xi(ft,f);we=c.create(St*c.create(z+_e*O))}if(we===Fe)return;let Mn=U(Ht.x,Ht.y,_e),kr=we;return S&&_(we)&&(kr=c.neg(we),Mn^=1),new V(_e,kr,C?void 0:Mn)}return{seed:se,k2sig:te}}function v(A,y,I={}){let{seed:S,k2sig:M}=E(A,y,I);return Ki(o.outputLen,c.BYTES,s)(S,M).toBytes(I.format)}function H(A,y,I,S={}){let{lowS:M,prehash:R,format:K}=Ro(S,T);if(I=X(I,void 0,"publicKey"),y=F(y,R),!xt(A)){let O=A instanceof V?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+O)}Z(A,K);try{let O=V.fromBytes(A,K),W=t.fromBytes(I);if(M&&O.hasHighS())return!1;let{r:se,s:z}=O,te=D(y),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"&&O.recovery!==U(we.x,we.y,se))}catch{return!1}}function L(A,y,I={}){let{prehash:S}=Ro(I,T);return y=F(y,S),V.fromBytes(A,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:l,getPublicKey:p,getSharedSecret:m,utils:x,lengths:w,Point:t,sign:v,verify:H,recoverPublicKey:L,Signature:V,hash:o})}var gf={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var bf=hs(gf),gs=ms(bf,Ui);var Mo=globalThis.crypto,Do=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=q.create();else if(n==="sha512")this.hasher=an.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 Fo(t){return new Do(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(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 o=t[n];typeof o>"u"||(e[n]=No(o))}return e}function In(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 _o(t){let{proof:e,bytes:n,trustAnchors:o}=t,r=await ys(e,n,o);return r===null?{valid:!0}:kf(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=wf(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&&!In(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 u;try{u=await ro(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=Ef(t);if(d!==null)return d}if(t.slotAllocation!==void 0){let d=await Bf(t);if(d!==null)return d}if(t.commit.epochLink!==void 0){let d=Af(t);if(d!==null)return d}if(n!==void 0){let d=xf(t,n);if(d!==null)return d}return null}var yf=new Set(["stub","hw-key","measured-tee"]);function wf(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(!Ot(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(!Ot(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(!Ot(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(!Ot(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!yf.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(!Ot(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 xf(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`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function Ef(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(Fo("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 u=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;u.length%4;)u+="=";if(u!==o.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=Fo("sha256").update(B.Buffer.from(c.clientDataJSON,"utf8")).digest(),p=B.Buffer.concat([d,l]),m=Uo("SHA256");if(m.update(p),!m.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"),u=Uo("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 Bf(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 ro(r,o,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=q(o),u;try{u=kt(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!In(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 Oo=new Map;function vf(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=q(new TextEncoder().encode(e));return B.Buffer.from(n).toString("base64")}function Af(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=vf(e),o=Oo.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 Oo.set(n,e.toEpochId);return null}function It(){Oo.clear()}function kf(t){return{valid:!1,reason:t}}function Ot(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 Hn(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 jo(s)}var ws=["proofHash","ethereum"];function Ko(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 jo(q(o))}function jo(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 Vo(t){return jo(q(Xe(xs(t))))}b();async function*Bs(t,e){let n=new qo(t,e?.maxTotalBytes),o=e?.maxEntryCount??Number.POSITIVE_INFINITY,r=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(u,d)=>{if(u>r)throw new Error(`tar: ${d} metadata entry of ${u} bytes exceeds the ${r}-byte cap`)};for(;;){let u=await n.readExact(512);if(u===null||Cf(u))return;if(++c>o)throw new Error(`tar: archive exceeds the maximum of ${o} entries`);let d=Hf(u),h=d.typeflag;if(h==="x"||h==="g"){f(d.size,"PAX");let C=await Es(n,d.size);await n.skip(Sn(d.size));let _=Tf(C);h==="x"?i=_:s=$f(s,_);continue}if(h==="L"){f(d.size,"GNU long-name");let C=await Es(n,d.size);await n.skip(Sn(d.size)),a=ct(Rf(C));continue}if(h==="K"){await n.skip(d.size+Sn(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 p=d.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",w={remaining:p},T=If(n,w);yield{path:l,size:p,kind:x?"file":"other",typeflag:h,body:T},w.remaining>0&&(await n.skip(w.remaining),w.remaining=0),await n.skip(Sn(p))}}async function*If(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 Hf(t){Sf(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),o=ct(zo(t,0,100));if(ct(zo(t,257,6))==="ustar"){let s=ct(zo(t,345,155));s.length>0&&(o=`${s}/${o}`)}let i=vs(t.subarray(124,136));return{name:o,size:i,typeflag:n}}function zo(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 Sf(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 Cf(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function Tf(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 $f(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 Rf(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var qo=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 Sn(t){return(512-t%512)%512}b();var Rl=new Uint8Array([0]);function As(t){let e=Array.from(t,o=>({pathBytes:Pf(o.path),entryDigest:o.entryDigest}));e.sort((o,r)=>Lf(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 Pf(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Lf(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",Go="bitgraph-bundle/1",Df="bitgraph-anchor-witness/1";var Ts=new WeakMap;async function Wo(t,e){let n=[],o=0,r=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){r++;let u=Rs(f.path);if(u.unsafe){o++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${u.reason}`});continue}let d=await Nf(u.path,void 0,void 0,$s(f.open()));i.push(Of(u.path,d)),s.set(u.path,f)}let c=Ff({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 Mf(t){let e=[],n=0;for await(let o of $s(t.open()))e.push(o),n+=o.length;return Yo(e,n)}function Ff(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 U=$.rawPath,N=$.entryDigestFull;r!==void 0&&(U=$.rawPath.slice(r.length+1),N=$.entryDigestStripped),c.has(U)&&i.push({code:"duplicate-path",path:U,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(U,{path:U,sha256Hex:$.sha256Hex,byteLength:$.byteLength,entryDigest:N,...$.json!==void 0?{json:$.json}:{}})}let f=Array.from(c.values()),u=As(f.filter($=>$.path!==Hs).map($=>({path:$.path,entryDigest:$.entryDigest}))),d=[],h=new Map,l=[],p=[],m=new Map,x,w=0,T=0,C=0;for(let $ of f){if($.path===Hs){x=qf($,u,i);continue}let U=$.json;if(U!==void 0&&Kf(U)){let N=U.version;if(N==="bitgraph/1"){w++;let Z=jf($,U,h,d,i);Z==="exact-duplicate"&&T++,Z==="semantic-duplicate"&&C++;continue}l.push({code:"unsupported-version",path:$.path,version:N,fileSha256Hex:$.sha256Hex}),i.push({code:"unsupported-version",path:$.path,message:`proof-shaped file rejected: version "${N}" is not "bitgraph/1"`,details:{version:N}}),Ss($,m);continue}if(U!==void 0&&U.version===Df){p.push({path:$.path,fileSha256Hex:$.sha256Hex,witness:U});continue}Ss($,m)}for(let $ of d){let U=zf($.proof.artifact);if(U===null)continue;let N=m.get(U);N!==void 0&&N.matchedProofHashes.push($.proofHash)}let _=Array.from(m.values()),G={observed:d.length,proofFiles:w,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:d,unsupportedVersions:l,artifacts:_,witnesses:p,...x!==void 0?{manifest:x}:{},computedContentsHashB64:u,findings:i,counts:G}}async function*Zo(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 u;try{u=await Mf(f)}catch{continue}if(Cn(q(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 Ai(ki(t.bundlePath,...a.split("/"))))}catch{continue}if(Cn(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}=Uf(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 u=[],d=0;for await(let l of s.body)u.push(l.slice()),d+=l.length;let h=Yo(u,d);Cn(q(h))===f.sha256Hex&&(o.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:h})}}finally{i()}}function Uf(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 Nf(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=[],u=0;for await(let d of o)i.update(d),s.update(d),a?.update(d),u+=d.length,c&&(u>ks?(f.length=0,c=!1):f.push(d.slice()));return{sha256Hex:Cn(i.digest()),byteLength:u,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:Yo(f,u)}:{}}}function Of(t,e){let n=e.buffered===void 0?void 0:_f(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 _f(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 Kf(t){return fe(t)?typeof t.version=="string"&&fe(t.artifact)&&fe(t.commit)&&fe(t.signer):!1}function jf(t,e,n,o,r){let i=Hn(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=Vf(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(w=>w.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:{},u=fe(e.signer)?e.signer:{},d=fe(e.environment)?e.environment:{},h=he(f.counter),l=he(f.epochId),p=he(f.chainId),m={proofHash:i,chainHash:Ko(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(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,m),o.push(m),"new"}function Vf(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 zf(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 qf(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!==Go)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(r)} is not "${Go}"; 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=Gf(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:Go,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 Gf(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 Cn(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 u=f.matchedProofHashes.map(d=>o.get(d)).filter(d=>d!==void 0);r.set(f.sha256Hex,u)}for await(let f of Zo(t)){let u=r.get(f.sha256Hex)??[];for(let d of u){if(d.verification!==void 0)continue;let h=await _o({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 _t({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}}b();b();var Ps=new WeakMap;async function Ue(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 ue(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 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=o.get(d);h===void 0?o.set(d,{key:u,members:[f]}):h.members.push(f)}let r=[...o.values()].sort((f,u)=>Wf(f.key,u.key)),i=[],s=new Set,a=new Map;for(let f of r){let u=Zf(f.key,f.members,s);i.push(u);for(let d of u.memberProofHashes)a.set(d,f.key)}let c=await Jf(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function Wf(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 Zf(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),ue(r,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(Yf(h,r,i));u.sort(Xf);let d=[...e].sort(Se).map(h=>h.proofHash);return{key:t,memberProofHashes:d,components:u}}function Yf(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 u,d;for(let h of t)for(let l of[h.counter,h.slotCounter]){let p=Y(l);p!==void 0&&((u===void 0||p<u)&&(u=p),(d===void 0||p>d)&&(d=p))}return{memberProofHashes:c,genesisProofHashes:r.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 Xf(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 Jf(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=Qf(h);l!==null&&s.push(await eu(l,h,i,r,n,o))}let a=nu(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),Jo(f,h.toEpochId,h.fromEpochId),Jo(u,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:[...u.get(h)??[]].sort()})),edges:s,orderedPairs:a}}function Qf(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 eu(t,e,n,o,r,i){let s=await Ue(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"),tu(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await Ue(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:!r.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:u&&s&&f}}function tu(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 nu(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 ou=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(u=>i.get(u));ru(c,f,n),await Ls(c,f,"counter",n,o),await Ls(c,f,"slot",n,o),await iu(c,f,n,o),await su(c,f,s,n,o),au(c,f,s,a,n,r),await fu(c,f,n,o),uu(c,f,n)}return await du(e.epochRelationships.edges,i,n,o),{anomalies:n,divergences:o,boundaryEntryPoints:r}}function ru(t,e,n){let o=new Set;for(let d of e){let h=Y(d.counter);h!==void 0&&o.add(h);let l=Y(d.slotCounter);l!==void 0&&o.add(l)}if(o.size<2)return;let r=[...o].sort((d,h)=>d<h?-1:d>h?1:0),i=[],s=[],a=0n;for(let d=1;d<r.length;d++){let h=r[d-1]+1n,l=r[d]-1n;if(!(h>l)){i.push({start:String(h),end:String(l)}),a+=l-h+1n;for(let p=h;p<=l&&s.length<ou;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]),u=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}, ${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 Ls(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);ue(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 Tn(a);if(c.length<2)continue;let u=s.startsWith("raw:")?s.slice(4):s,d=n==="counter"?"counter-collision":"slot-collision";o.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)}}),r.push({kind:d,partition:t.key,contested:n==="counter"?{counter:u}:{slotCounter:u},parties:c.map(Ce),invalidContext:f.map(Ce),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 iu(t,e,n,o){let r=new Map,i=new Map;for(let a of e){let c=Y(a.counter);c!==void 0&&ue(r,String(c),a);let f=Y(a.slotCounter);f!==void 0&&ue(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),u=[];for(let w of c)await Ue(w)&&u.push(w);let d=[];for(let w of f)await Ue(w)&&d.push(w);if(!u.some(w=>d.some(T=>T.proofHash!==w.proofHash)))continue;let l=new Map;for(let w of[...u,...d])l.set(w.proofHash,w);let p=[...l.values()],m=new Map;for(let w of[...c,...f])m.set(w.proofHash,w);let x=[...m.values()].filter(w=>!l.has(w.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:u.map(w=>w.proofHash),slotParties:d.map(w=>w.proofHash),validParties:p.map(w=>w.proofHash),invalidObserved:x.map(w=>w.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 su(t,e,n,o,r){let i=new Map;for(let s of e)s.prevB64!==void 0&&ue(i,s.prevB64,s);for(let[s,a]of tr(i)){if(a.length<2)continue;let{parties:c,context:f}=await Tn(a);if(c.length<2)continue;let u=n.has(s);o.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)}}),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${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 au(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(!cu(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 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}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 cu(t){if(t.length===0)return!1;let e=B.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function fu(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 Tn(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 uu(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 du(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)ue(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:u}=await Tn(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)&&o.push({kind:"epochlink-fork",contested:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64},parties:f.map(Ce),invalidContext:u.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 hu(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 hu(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 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),p=lu(l);e.set(p.join("|"),p);continue}n.has(d)||c.push(d)}}return[...e.values()].sort((r,i)=>{let s=r.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function lu(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 Tn(t){let e=[],n=[];for(let o of t)await Ue(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(pu),o=new Map;for(let a of t.proofs)a.epochId!==void 0&&ue(o,a.epochId,a);let r=[];for(let[a,c]of[...o.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&&r.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&&r.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:r,sharedSignersAcrossEpochs:s}}function pu(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 mu="Ethereum Anchor",Ds="ethereum-anchor",gu=/^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=bu(r);if(!(i===mu)){s===Ds&&(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===Ds?"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"),u=or(r,"title"),d=u!==void 0?gu.exec(u)?.[1]??void 0:void 0;d===void 0&&o.push({code:"anchor-title-unparseable",...rr(r),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:r.proofHash,...u!==void 0?{title:u}:{}}});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}:{},...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: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 bu(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 yu=BigInt(0),Kt=BigInt(1),wu=BigInt(2),xu=BigInt(7),Eu=BigInt(256),Bu=BigInt(113),Us=[],Ns=[],Os=[];for(let t=0,e=Kt,n=1,o=0;t<24;t++){[n,o]=[o,(2*n+3*o)%5],Us.push(2*(5*o+n)),Ns.push((t+1)*(t+2)/2%64);let r=yu;for(let i=0;i<7;i++)e=(e<<Kt^(e>>xu)*Bu)%Eu,e&wu&&(r^=Kt<<(Kt<<BigInt(i))-Kt);Os.push(r)}var _s=rn(Os,!0),vu=_s[0],Au=_s[1],Ms=(t,e,n)=>n>32?li(t,e,n):di(t,e,n),Fs=(t,e,n)=>n>32?pi(t,e,n):hi(t,e,n);function ku(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],u=n[c+1],d=Ms(f,u,1)^n[a],h=Fs(f,u,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=d,t[s+l+1]^=h}let r=t[2],i=t[3];for(let s=0;s<24;s++){let a=Ns[s],c=Ms(r,i,a),f=Fs(r,i,a),u=Us[s];r=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]^=vu[o],t[1]^=Au[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,io(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(){so(this.state32),ku(this.state32,this.rounds),so(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 io(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(tn(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}},Iu=(t,e,n)=>Rt(()=>new sr(e,t,n));var Ks=Iu(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=$n(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,u=$n(t,f,c);return{item:t.subarray(f,u),next:u}}if(n<=247){let a=n-192,c=$n(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=$n(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 $n(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,Hu=/^0x[0-9a-fA-F]{64}$/,Su=/^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=Cu(i);if(s.failure!==void 0){let u={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(u),o.push(cr(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),o.push(cr(u));continue}for(let u of f){let d=r.get(u.proofHash),h=d!==void 0&&await Ue(d),l=Tu(s,i.path,u.proofHash,d,h);n.push(l),l.verified||o.push(cr(l))}}return{outcomes:n,findings:o}}function Cu(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return Rn("headerRlpHex is missing or not a string");let o=e.blockNumber;if(typeof o!="number"||!Number.isInteger(o)||o<0)return Rn("blockNumber is missing or not a non-negative integer");let r=e.blockHash;if(typeof r!="string"||!Hu.test(r))return Rn("blockHash is missing or not 0x followed by 64 hex characters");let i=Ws(n);if(i===null)return Rn("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 Rn(t){return{failure:{reason:"witness-malformed",detail:t}}}function Tu(t,e,n,o,r){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(w,T,C)=>({...s,verified:!1,reason:w,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=$u(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=Lu(Pu(o));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let u=q(new TextEncoder().encode(c));if(!Du(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[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=Ru(o);if(p!==void 0){let w=Su.exec(p)?.[1];if(w!==void 0&&BigInt(w)!==l)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${w}, 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=d[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 $u(t){return Js(t,"message")}function Ru(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 Pu(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 Lu(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 Du(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 ur(t,e,n,o){let r=new Map(t.proofs.map(u=>[u.proofHash,u])),i=new Map;for(let u of o.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(...Mu(u,r,i));let f=Ku(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function Mu(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||ue(s,l.proofHash,h)}let a=new Map,c=new Map;for(let h of i)a.set(h.proofHash,Uu(h,s)),c.set(h.proofHash,Nu(h,r));let f=o.map(h=>{let l=new Map,p=new Map,m=Y(h.counter);for(let x of i){let w=x.proofHash,T=Y(x.counter);h.proofHash===w||a.get(w).has(h.proofHash)?l.set(w,"chain-link"):m!==void 0&&T!==void 0&&m>T&&(l.has(w)||l.set(w,"counter-order")),c.get(w).has(h.proofHash)?p.set(w,"chain-link"):h.proofHash!==w&&m!==void 0&&T!==void 0&&m<T&&(p.has(w)||p.set(w,"counter-order"))}return{member:h,lower:Qs("not-before",l,n),upper:Qs("not-after",p,n)}}),u=new Map;for(let h of f)ue(u,Fu(h),h);let d=[];for(let h of u.values()){let l=h.map(C=>C.member).sort(Se),p=h[0],m=p.lower,x=p.upper,w=m.length>0&&x.length>0?"bracketed":m.length>0?"lower-bounded":x.length>0?"upper-bounded":"ordered-but-unanchored",T=Ou(l);d.push({partition:t.key,memberProofHashes:l.map(C=>C.proofHash),...T!==void 0?{positionRange:T}:{},status:w,lowerBounds:m,upperBounds:x})}return d.sort(_u),d}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",claim:a}}function Fu(t){let e=n=>n.map(o=>`${o.anchorProofHash}:${o.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function Uu(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 Nu(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 Ou(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 _u(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 Ku(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,u=c.lowerMin.evidence,d=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: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 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-----
|
|
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 Ra(){return Ir.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function Hr(){return new Uint8Array(w.Buffer.from(Ra(),"base64"))}async function $r(t,e){let n=[],o={},r,i,s,a,c,u=()=>({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=La(t);if(d===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),u();let h=re(d,0).value;if(!Array.isArray(h)||h.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),u();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let f=h[0],l=h[2],g=h[3];if(!(f instanceof Uint8Array)||!(l instanceof Uint8Array)||!(g instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),u();let m=re(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"}),u();o=Ka(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 v=m.user_data;c=v instanceof Uint8Array&&v.length>0?w.Buffer.from(v).toString("base64"):void 0;let b=m.cabundle,A=m.certificate;if(!(A instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),u();a=(Array.isArray(b)?b.length:0)+1;let B=Hn(A),S=Fa(f,l),R=await Cn(g,S,B.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:R,detail:R?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!R)return u();if(!Array.isArray(b)||b.length===0||!b.every(_=>_ instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),u();let k=[...b,A].map(Hn),I=!0,H="";for(let _=1;_<k.length;_++){let me=k[_],Kr=k[_-1];if(!await Cn(me.signature,me.tbsCertificate,Kr.publicKey)){I=!1,H=`Certificate ${_} signature invalid (parent: ${_-1})`;break}}if(n.push({name:"Certificate Chain",pass:I,detail:I?`${k.length} certificates, each signed by parent`:H}),!I)return u();let D=e?.trustedRootCaDer===void 0,ke=Hn(e?.trustedRootCaDer??Hr()),Ae=k[0],se=await Cn(Ae.signature,Ae.tbsCertificate,ke.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:se,detail:se?D?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":D?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!se)return u();let ae=!0,Ne=`All ${k.length} certificate validity windows contain the document timestamp`;if(s===void 0)ae=!1,Ne="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let _=0;_<k.length;_++){let me=k[_];if(s<me.notBeforeMs||s>me.notAfterMs){ae=!1,Ne=`Certificate ${_} validity window [${new Date(me.notBeforeMs).toISOString()}, ${new Date(me.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:ae,detail:Ne}),!ae)return u();let ce;e?.expectedPcr0!==void 0&&(ce=r===e.expectedPcr0,n.push({name:"PCR0 Match",pass:ce,detail:ce?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(r??"").slice(0,16)}...`}));let Ue;return e?.expectedUserDataB64!==void 0&&(Ue=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:Ue,detail:Ue?"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}:{},...ce!==void 0?{pcr0Matches:ce}:{},...Ue!==void 0?{userDataMatches:Ue}:{}}}catch(d){return n.push({name:"Verification Error",pass:!1,detail:d instanceof Error?d.message:String(d)}),u()}}async function $n(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=Da(s),u={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 $r(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:s.proofHash,...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});u.documentValidated=d.documentValid,u.checks=d.checks,d.pcr0!==void 0&&(u.attestedPcr0=d.pcr0),u.pcrs=d.pcrs,d.moduleId!==void 0&&(u.moduleId=d.moduleId),d.timestamp!==void 0&&(u.timestamp=d.timestamp),d.certChainLength!==void 0&&(u.certChainLength=d.certChainLength),d.userDataB64!==void 0&&(u.userDataB64=d.userDataB64),d.documentValid?(i.documentsValidated++,d.pcr0Matches!==void 0&&(u.pcr0MatchesDeclared=d.pcr0Matches,d.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,r.push({code:"attestation-measurement-mismatch",...An(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&&(u.userDataBoundToProof=d.userDataMatches,d.userDataMatches?i.userDataBound++:(i.userDataUnbound++,r.push({code:"attestation-user-data-mismatch",...An(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&&(u.validationFailure=d.failure),r.push({code:"attestation-invalid",...An(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(u)}return e!==void 0&&Ma(e,o),{records:o,findings:r,counts:i}}function Ma(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(u=>n.get(u)).filter(u=>u!==void 0&&u.documentPresent);if(r.length===0)continue;let i=r.filter(u=>u.documentValidated),s=r.length-i.length,a=[...new Set(i.map(u=>u.attestedPcr0).filter(u=>u!==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 Da(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 An(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function La(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=w.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function Sn(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 In(t){let e=Sn(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 Na(t){let e=new TextEncoder().encode(t),n=Sn(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 Ua(t){let e=Sn(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 Fa(t,e){return Ua([Na("Signature1"),In(t),In(new Uint8Array(0)),In(e)])}function re(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 u=[];for(;i(e)!==255;){let d=re(t,e);u.push(d.value),e=d.offset}return{value:u,offset:e+1}}let a=s(),c=[];for(let u=0;u<a;u++){let d=re(t,e);c.push(d.value),e=d.offset}return{value:c,offset:e}}case 5:{if(r===31){let u={};for(;i(e)!==255;){let d=re(t,e);e=d.offset;let h=re(t,e);e=h.offset,u[String(d.value)]=h.value}return{value:u,offset:e+1}}let a=s(),c={};for(let u=0;u<a;u++){let d=re(t,e);e=d.offset;let h=re(t,e);e=h.offset,c[String(d.value)]=h.value}return{value:c,offset:e}}case 6:return s(),re(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 Hn(t){let n=Je(t,0).contentStart,o=L(t,n),r=t.slice(n,o.end);n=o.end,n=L(t,n).end;let s=L(t,n),a=t.slice(s.contentStart+1,s.end),c=_a(a,48),{publicKey:u,notBeforeMs:d,notAfterMs:h}=Oa(r);return{tbsCertificate:r,signature:c,publicKey:u,notBeforeMs:d,notAfterMs:h}}function L(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 Je(t,e){let n=L(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function Oa(t){let n=Je(t,0).contentStart;t[n]===160&&(n=L(t,n).end),n=L(t,n).end,n=L(t,n).end,n=L(t,n).end;let o=Je(t,n),r=o.contentStart,i=L(t,r);r=i.end;let s=L(t,r),a=Cr(t,i),c=Cr(t,s);n=o.end,n=L(t,n).end;let d=Je(t,n).contentStart;d=L(t,d).end;let f=L(t,d);return{publicKey:t.slice(f.contentStart+1,f.end),notBeforeMs:a,notAfterMs:c}}function Cr(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),u=Number.parseInt(r.slice(8,10),10);return Date.UTC(o,i-1,s,a,c,u)}function _a(t,e){let o=Je(t,0).contentStart,r=L(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=L(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 Cn(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let o=await Yt.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await Yt.subtle.verify({name:"ECDSA",hash:"SHA-384"},o,t,e)}catch{return!1}}function Ka(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=w.Buffer.from(r).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(o)]=i)}return e}y();var xt="0.2.0";function Sr(){return xt}async function Pn(t,e){let n=e?.startedAt??new Date().toISOString(),o=await hn(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),r=await ln(t),i=await pn(t,r),s=gn(t),a=wn(t),c=await En(t,a),u=kn(t,r,a,c),d=await $n(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:Sr(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:o,reconstruction:r,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:u,attestations:d}}y();y();y();y();y();function vt(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}y();y();var Tn="0.4.0";var qa=[{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"}],Wa=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function Mr(t,e){let n=await Pn(t,{startedAt:""});return Ja(n,e)}function Ja(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 v of m.memberProofHashes)i.set(v,m);let s=new Map;for(let m of t.witnesses.outcomes){if(m.anchorProofHash===void 0)continue;let v=s.get(m.anchorProofHash)??[];v.push(m),s.set(m.anchorProofHash,v)}let a=new Map;for(let m of t.ingest.artifacts)for(let v of m.matchedProofHashes)!a.has(v)&&m.paths[0]!==void 0&&a.set(v,m.paths[0]);let c=[],u=[];for(let m of t.ingest.proofs){let v=o.get(m.proofHash);v!==void 0?u.push(nc(m,v,s.get(m.proofHash)??[])):c.push(Xa(m,r.get(m.proofHash),i.get(m.proofHash),a.get(m.proofHash),n))}Pr(c),Pr(u);let d=oc(t),h=rc(t,c,u),f=ic(u.length>0),l=[...c.map(m=>m.result),...u.map(m=>m.result),...d.map(m=>m.result)],g=l.length===0?"UNDETERMINED":vt(l);return{check:"bitgraph-check/1",result:g,summary:sc(g,c,u,d),recordings:c,anchors:u,contradictions:d,notes:h,notChecked:f,evaluator:{name:"bitgraph-player",version:Tn,audit:xt},network:"none"}}function Pr(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 Xa(t,e,n,o,r){let i=[],s=t.verification,a=t.proof.artifact.digestB64;s?.tier==="full"?i.push({name:"file",result:s.status==="verified"||s.status==="failed"?"TRUE":"UNDETERMINED",detail:s.status==="verified"||s.status==="failed"?`${o??"the matched file"} hashes to the recorded digest ${a}`:`no file in this bundle hashes to the recorded digest ${a}`}):i.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${a}; the recording cannot be bound to bytes in hand`}),s===void 0?i.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):s.status==="failed"?i.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${s.reason??"unspecified failure"}`}):i.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${Mn(t.publicKeyB64)}`});let c=Ya(e,r);i.push(c.line),i.push(Za(c.attestedPcr0,c.line.result));let u=vt(i.map(d=>d.result));return{proofHash:t.proofHash,digestB64:a,...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&&s?.tier==="full"?{filePath:o}:{},lines:i,result:u,bounds:Qa(n)}}function Ya(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 ${Xe(t.attestedPcr0)} is not the measurement the signed body declares ${Xe(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 ${Xe(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"}}}function Za(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=qa.find(o=>o.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${Xe(t)} is not among the BitGraph enclave measurements this verifier knows (player ${Tn}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${Xe(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function Qa(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=Tr(t.lowerBounds,"not-before"),n=Tr(t.upperBounds,"not-after"),o=e===void 0?void 0:Rr(e),r=n===void 0?void 0:Rr(n),i=o!==void 0&&r!==void 0?"bracketed":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 ${ec(i,o,r)}`;return{status:i,...o!==void 0?{notBefore:o}:{},...r!==void 0?{notAfter:r}:{},detail:s}}function ec(t,e,n){switch(t){case"bracketed":return`after Ethereum block ${le(e)} and before block ${le(n)} (both headers verified in this bundle)`+Rn(e.weaker||n.weaker);case"lower-bounded":return`after Ethereum block ${le(e)} (header verified in this bundle); no verified upper bound here`+Rn(e.weaker);case"upper-bounded":return`before Ethereum block ${le(n)} (header verified in this bundle); no verified lower bound here`+Rn(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function Tr(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 Rr(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 tc(t){switch(t.status){case"bracketed":return`between Ethereum blocks ${le(t.notBefore)} and ${le(t.notAfter)}`;case"lower-bounded":return`after Ethereum block ${le(t.notBefore)}`;case"upper-bounded":return`before Ethereum block ${le(t.notAfter)}`;default:return"with no Ethereum bound in this bundle"}}function le(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function Rn(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function nc(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 ${Mn(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:vt(o.map(s=>s.result))}}function oc(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)Wa.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 rc(t,e,n){let o=[],r=0n,i=0;for(let u of t.anomalies.anomalies)if(u.code==="unexplained-counter-positions"){let d=u.details?.count;d!==void 0&&/^[0-9]+$/.test(d)&&(r+=BigInt(d))}else u.code==="chain-break-missing"&&(i+=u.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(u=>u.matchedProofHashes.length===0);if(s.length>0&&e.length>0){let u=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: ${u}${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(u=>u.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 u of t.ingest.unsupportedVersions)o.push(`${u.path} is proof-shaped but its version "${u.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 u of t.ingest.findings)typeof u.code=="string"&&u.code.startsWith("manifest-")&&o.push(`${u.code}: ${u.message}`);return e.length===0&&n.length===0&&o.push("no BitGraph proofs were found in this bundle"),o}function ic(t){let e=[];return t&&e.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e.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"),e.push("whether an epoch key was later quarantined: that is published outside any bundle"),e}function sc(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 ${Mn(a.epochId)}`:""}`:""}, ${tc(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(u=>u.result==="FALSE").map(u=>`${u.name}: ${u.detail}`)),...n.flatMap(c=>c.lines.filter(u=>u.result==="FALSE").map(u=>`${u.name}: ${u.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 Mn(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function Xe(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}st.sha512Async=async(...t)=>ft(st.concatBytes(...t));var Or=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function _r(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 ac(t){return new Promise((e,n)=>t.file(e,n))}async function Nn(t,e,n){if(t.isFile){let o=await ac(t);n.push({path:e+t.name,file:o});return}if(t.isDirectory){let o=t.createReader(),r=await _r(o);for(let i of r)i.name!==".DS_Store"&&await Nn(i,`${e}${t.name}/`,n)}}async function cc(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 _r(r.createReader()))i.name!==".DS_Store"&&await Nn(i,"",o)}else for(let r of n)await Nn(r,"",o);return o.length===0?Array.from(t.files??[]).map(r=>({path:r.name,file:r})):o}function Dr(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 uc(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function E(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 Un(t){return t==="TRUE"?null:E("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function Ye(t,e,n={}){let o=E("div",{class:"field-head"},[E("span",{class:"field-label"},[t])]),r=n.mark!==void 0?Un(n.mark):null;return r!==null&&o.append(r),E("div",{class:"field"},[o,E("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function pe(t,e,n={}){let o=n.open===!0,r=E("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=E("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(o)},[E("span",{},[t]),r]),s=E("div",{class:"opener-body"},e),a=E("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 dc(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function hc(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function fc(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function Bt(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function lc(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 Lr(t){let e=t.bounds,n=i=>E("span",{class:"when-grey"},[i]),o=i=>E("span",{class:"when-dark"},[i]),r=E("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;r.append(E("div",{class:"when-date"},[fc(i.timestamp)]));let s=E("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("between "),o(Bt(e.notBefore.timestamp,!1)),n(" and "),o(Bt(e.notAfter.timestamp,!0))):e.notBefore!==void 0?s.append(n("after "),o(Bt(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("before "),o(Bt(e.notAfter.timestamp,!0))),r.append(s)}else r.append(E("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return r}var pc=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,mc=/\.(mp4|m4v|mov|webm|ogv)$/i,gc=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,yc=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function bc(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 wc(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":pc.test(n)?"image":mc.test(n)?"video":gc.test(n)?"audio":yc.test(n)||bc(e)?"text":"other"}function xc(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 vc(t,e,n){if(n==="image"||n==="video"){let o=URL.createObjectURL(t),r=n==="image"?E("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"}):E("video",{src:o,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return E("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[r])}if(n==="audio"){let o=URL.createObjectURL(t);return E("div",{style:"padding:20px 16px"},[E("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(`
|
|
152
|
+
-----END CERTIFICATE-----`;function ju(){return na.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function oa(){return new Uint8Array(B.Buffer.from(ju(),"base64"))}async function ia(t,e){let n=[],o={},r,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(u=>!u.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 u=qu(t);if(u===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let d=Ne(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],p=d[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=Ne(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=Ju(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 w=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(w)?w.length:0)+1;let C=lr(T),_=Zu(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(w)||w.length===0||!w.every(v=>v instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let $=[...w,T].map(lr),U=!0,N="";for(let v=1;v<$.length;v++){let H=$[v],L=$[v-1];if(!await pr(H.signature,H.tbsCertificate,L.publicKey)){U=!1,N=`Certificate ${v} signature invalid (parent: ${v-1})`;break}}if(n.push({name:"Certificate Chain",pass:U,detail:U?`${$.length} certificates, each signed by parent`:N}),!U)return f();let Z=e?.trustedRootCaDer===void 0,V=lr(e?.trustedRootCaDer??oa()),le=$[0],D=await pr(le.signature,le.tbsCertificate,V.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:D,detail:D?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"}),!D)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 F;e?.expectedPcr0!==void 0&&(F=r===e.expectedPcr0,n.push({name:"PCR0 Match",pass:F,detail:F?"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}:{},...F!==void 0?{pcr0Matches:F}:{},...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 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=zu(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 ia(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:Vo(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++,r.push({code:"attestation-measurement-mismatch",...dr(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++,r.push({code:"attestation-user-data-mismatch",...dr(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),r.push({code:"attestation-invalid",...dr(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}}))}o.push(f)}return e!==void 0&&Vu(e,o),{records:o,findings:r,counts:i}}function Vu(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 zu(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 dr(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function qu(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 Gu(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 Wu(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 Zu(t,e){return Wu([Gu("Signature1"),hr(t),hr(new Uint8Array(0)),hr(e)])}function Ne(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 u=Ne(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=Ne(t,e);c.push(u.value),e=u.offset}return{value:c,offset:e}}case 5:{if(r===31){let f={};for(;i(e)!==255;){let u=Ne(t,e);e=u.offset;let d=Ne(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=Ne(t,e);e=u.offset;let d=Ne(t,e);e=d.offset,c[String(u.value)]=d.value}return{value:c,offset:e}}case 6:return s(),Ne(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=jt(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=Xu(a,48),{publicKey:f,notBeforeMs:u,notAfterMs:d}=Yu(r);return{tbsCertificate:r,signature:c,publicKey:f,notBeforeMs:u,notAfterMs:d}}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 jt(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 Yu(t){let n=jt(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=jt(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 u=jt(t,n).contentStart;u=re(t,u).end;let h=re(t,u);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 u=Number.parseInt(n.slice(0,2),10);o=u<50?2e3+u:1900+u,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 Xu(t,e){let o=jt(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 Mo.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await Mo.subtle.verify({name:"ECDSA",hash:"SHA-384"},o,t,e)}catch{return!1}}function Ju(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 Pn="0.2.0";function sa(){return Pn}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=ur(t,r,a,c),u=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:u}}b();b();b();b();b();function Ln(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.5.1";var od=[{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"}],rd=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function ua(t,e){let n=await br(t,{startedAt:""});return id(n,e)}function id(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(hd(m,x,s.get(m.proofHash)??[])):c.push(sd(m,r.get(m.proofHash),i.get(m.proofHash),a.get(m.proofHash),n))}aa(c),aa(f);let u=ld(t),d=pd(t,c,f),h=md(f.length>0),l=[...c.map(m=>m.result),...f.map(m=>m.result),...u.map(m=>m.result)],p=l.length===0?"UNDETERMINED":Ln(l);return{check:"bitgraph-check/1",result:p,summary:gd(p,c,f,u),recordings:c,anchors:f,contradictions:u,notes:d,notChecked:h,evaluator:{name:"bitgraph-player",version:yr,audit:Pn},network:"none"}}function aa(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 sd(t,e,n,o,r){let i=[],s=t.verification,a=t.proof.artifact.digestB64;s?.tier==="full"?i.push({name:"file",result:s.status==="verified"||s.status==="failed"?"TRUE":"UNDETERMINED",detail:s.status==="verified"||s.status==="failed"?`${o??"the matched file"} hashes to the recorded digest ${a}`:`no file in this bundle hashes to the recorded digest ${a}`}):i.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${a}; the recording cannot be bound to bytes in hand`}),s===void 0?i.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):s.status==="failed"?i.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${s.reason??"unspecified failure"}`}):i.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${xr(t.publicKeyB64)}`});let c=ad(e,r);i.push(c.line),i.push(cd(c.attestedPcr0,c.line.result));let f=Ln(i.map(u=>u.result));return{proofHash:t.proofHash,digestB64:a,...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&&s?.tier==="full"?{filePath:o}:{},lines:i,result:f,bounds:fd(n)}}function ad(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 ${Vt(t.attestedPcr0)} is not the measurement the signed body declares ${Vt(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 ${Vt(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"}}}function cd(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=od.find(o=>o.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${Vt(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 ${Vt(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function fd(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=ca(t.lowerBounds,"not-before"),n=ca(t.upperBounds,"not-after"),o=e===void 0?void 0:fa(e),r=n===void 0?void 0:fa(n),i=o!==void 0&&r!==void 0?"bracketed":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 ${ud(i,o,r)}`;return{status:i,...o!==void 0?{notBefore:o}:{},...r!==void 0?{notAfter:r}:{},detail:s}}function ud(t,e,n){switch(t){case"bracketed":return`after Ethereum block ${Je(e)} and before block ${Je(n)} (both headers verified in this bundle)`+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 ca(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 fa(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 dd(t){switch(t.status){case"bracketed":return`between Ethereum blocks ${Je(t.notBefore)} and ${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 hd(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:Ln(o.map(s=>s.result))}}function ld(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)rd.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 pd(t,e,n){let o=[],r=0n,i=0;for(let f of t.anomalies.anomalies)if(f.code==="unexplained-counter-positions"){let u=f.details?.count;u!==void 0&&/^[0-9]+$/.test(u)&&(r+=BigInt(u))}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(u=>`${u.paths[0]??"(unnamed)"} (sha256:${u.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 md(t){let e=[];return t&&e.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e.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"),e.push("whether an epoch key was later quarantined: that is published outside any bundle"),e}function gd(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)}`:""}`:""}, ${dd(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 Vt(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}en.sha512Async=async(...t)=>an(en.concatBytes(...t));var ga=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function ba(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 bd(t){return new Promise((e,n)=>t.file(e,n))}async function vr(t,e,n){if(t.isFile){let o=await bd(t);n.push({path:e+t.name,file:o});return}if(t.isDirectory){let o=t.createReader(),r=await ba(o);for(let i of r)i.name!==".DS_Store"&&await vr(i,`${e}${t.name}/`,n)}}async function yd(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 ba(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 da(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 wd(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 zt(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 xd(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function Ed(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function Bd(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function Dn(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function vd(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 ha(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"},[Bd(i.timestamp)]));let s=P("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("between "),o(Dn(e.notBefore.timestamp,!1)),n(" and "),o(Dn(e.notAfter.timestamp,!0))):e.notBefore!==void 0?s.append(n("after "),o(Dn(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("before "),o(Dn(e.notAfter.timestamp,!0))),r.append(s)}else r.append(P("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return r}var Ad=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,kd=/\.(mp4|m4v|mov|webm|ogv)$/i,Id=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,Hd=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function Sd(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 Cd(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":Ad.test(n)?"image":kd.test(n)?"video":Id.test(n)?"audio":Hd.test(n)||Sd(e)?"text":"other"}function Td(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 $d(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
153
|
`),i=r.slice(0,24).join(`
|
|
154
|
-
`).slice(0,3e3),s=r.length>24||o.length>i.length||e.byteLength>6e3;return
|
|
155
|
-
\u2026`:"")])}catch{return null}return null}function
|
|
154
|
+
`).slice(0,3e3),s=r.length>24||o.length>i.length||e.byteLength>6e3;return P("pre",{class:"excerpt"},[i+(s?`
|
|
155
|
+
\u2026`:"")])}catch{return null}return null}function la(t,e,n,o){let r=t.lines.find(s=>s.name==="file"),i=P("div",{class:o?"file-row above":"file-row"});if(t.filePath!==void 0){let s=P("span",{class:"file-ident"},[P("span",{class:"file-name"},[t.filePath])]);e!==void 0&&s.append(document.createTextNode(` \xB7 ${Td(e.size)}`)),i.append(s);let a=P("span",{class:"file-right"});e!==void 0&&n!==void 0&&(n==="image"||n==="text"||n==="pdf")&&a.append(P("a",{class:"bg-arrow-link",href:URL.createObjectURL(e),target:"_blank",rel:"noopener"},["Open ",P("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]));let c=r!==void 0?Ar(r.result):null;c!==null&&a.append(c),a.childNodes.length>0&&i.append(a)}else{i.append(P("span",{class:"file-missing"},["file not in this bundle"]));let s=r!==void 0?Ar(r.result):null;s!==null&&i.append(s)}return i}function Oe(t,e,n=!1){return zt(t,e,{mono:n})}function pa(t,e){let n=document.getElementById("title-action");if(n===null)return;let o=P("a",{class:"bg-arrow-link",href:"#"},[t+" ",P("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]);o.addEventListener("click",r=>{r.preventDefault(),e()}),n.replaceChildren(o)}function ma(t){let e={file:"File",signature:"Signature",attestation:"Hardware Enclave attestation",enclave:"Enclave identity",witness:"Block header",contradiction:"Contradiction"};return t.lines.map(n=>zt(e[n.name]??n.name,n.detail,{mark:n.result}))}function Rd(t,e,n,o){let r=e==="before"?"Recorded after this block":e==="after"?"Recorded before this block":`Ethereum anchor ${n+1}`,i=[];if(t.blockNumber!==void 0&&i.push(Oe("Block",Ed(t.blockNumber),!0)),o!==void 0&&i.push(Oe("Block Time",vd(o))),t.blockHash!==void 0&&i.push(Oe("Block Hash",t.blockHash,!0)),t.counter!==void 0&&i.push(Oe("Anchor position",`#${t.counter}`,!0)),t.blockNumber!==void 0){let s=P("a",{class:"field-link",href:`https://etherscan.io/block/${t.blockNumber}`,target:"_blank",rel:"noopener"},[`https://etherscan.io/block/${t.blockNumber}`]);i.push(P("div",{class:"field"},[P("span",{class:"field-label"},["Etherscan"]),s]))}for(let s of t.lines)i.push(zt(s.name==="witness"?"Block header":"Anchor signature",s.detail,{mark:s.result}));return t.witnessPath===void 0&&i.push(zt("Block header","no block-header witness in this bundle, so this anchor's block hash is not verified here and it bounds nothing")),Qe(t.result==="TRUE"?r:`${r} [${t.result}]`,i)}async function Pd(t,e,n,o){e.replaceChildren();let r=()=>location.reload();if(t.recordings.length===0&&t.anchors.length===0){n.textContent="No BitGraph Found",e.append(P("section",{class:"card primary"},[P("div",{class:"notice"},["No BitGraph proof was found in what you chose. In your BitGraph Folder a recording is a folder inside Recordings, under the day it was sealed, named for the file: BitGraph (photo.jpg). It holds proof.json beside the file, and its Ethereum anchors."])])),pa("Choose a recording folder",r),e.append(Qe("Report JSON",[P("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let f=document.getElementById("more");f.replaceChildren(),f.hidden=!0;return}n.textContent=xd(t.result);let i=t.recordings.length===1?t.recordings[0]:void 0,s=P("section",{class:"card primary"});if(t.result!=="TRUE"&&s.append(P("div",{class:`notice ${t.result.toLowerCase()}`},[t.summary])),i!==void 0){s.append(ha(i));let f=i.filePath!==void 0?o.get(i.filePath):void 0,u,d=null;if(f!==void 0){let h=new Uint8Array(await f.arrayBuffer());u=Cd(f.name,h),d=$d(f,h,u)}d!==null&&s.append(d),s.append(la(i,f,u,d!==null)),i.counter!==void 0&&s.append(Oe("Position",`#${i.counter}${i.epochId!==void 0?` \xB7 epoch ${i.epochId}`:""}`,!0)),s.append(Oe("File Hash",i.digestB64,!0))}else if(t.recordings.length>1)for(let f of t.recordings)s.append(la(f,f.filePath!==void 0?o.get(f.filePath):void 0,void 0,!1));else s.append(Oe("Recordings","no recordings in this bundle"));if(e.append(s),pa("Check another BitGraph",r),i!==void 0){let f=i.lines.filter(u=>u.result!=="TRUE").length;e.append(Qe(f===0?"Recording checks":`Recording checks ${f} not verified`,ma(i),{open:t.result!=="TRUE"}))}else t.recordings.forEach((f,u)=>{e.append(Qe(`Recording ${u+1}: ${f.filePath??f.digestB64.slice(0,16)+"\u2026"} [${f.result}]`,[ha(f),...f.counter!==void 0?[Oe("Position",`#${f.counter}${f.epochId!==void 0?` \xB7 epoch ${f.epochId}`:""}`,!0)]:[],Oe("File Hash",f.digestB64,!0),...ma(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(Rd(f,d,u,a.get(f.proofHash)))}),t.contradictions.length>0&&e.append(Qe(`Contradictions ${t.contradictions.length}`,t.contradictions.map(f=>zt("Contradiction",f.detail,{mark:"FALSE"})),{open:!0,tone:"danger"})),t.notes.length>0&&e.append(Qe(`Notes ${t.notes.length}`,[P("ul",{class:"list"},t.notes.map(f=>P("li",{},[f])))])),e.append(Qe("Not checked",[P("ul",{class:"list"},t.notChecked.map(f=>P("li",{},[f])))])),e.append(Qe("Report JSON",[P("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let c=document.getElementById("more");c.replaceChildren(),c.hidden=!0}async function Er(t){let e=document.getElementById("drop"),n=document.getElementById("results"),o=document.getElementById("status");if(t.length===0){o.textContent="Nothing readable was dropped.";return}e.classList.add("busy"),o.textContent=`Checking ${t.length} file${t.length===1?"":"s"}\u2026`;try{let r=await Wo(wd(t),{label:"dropped"}),i=await ua(r,{webCryptoAvailable:ga});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"),o.textContent="",n.hidden=!1;let s=new Map(t.map(a=>[a.path,a.file]));await Pd(i,n,document.getElementById("title"),s),document.title=`${i.result} \xB7 BitGraph verify`}catch(r){o.textContent=`The check could not run: ${r.message}`}finally{e.classList.remove("busy")}}function Br(){let t=document.querySelector(".bitgraph-wrap");t&&t.style.setProperty("--bg-wrap-min",`${Math.round(window.innerHeight)}px`)}function Ld(){let t=document.getElementById("drop"),e=document.getElementById("status"),n=document.getElementById("pick-files"),o=document.getElementById("pick-folder");Br(),window.addEventListener("resize",Br),window.addEventListener("orientationchange",Br),ga||(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 r=!1,i=!1,s=!1,a=()=>{t.classList.toggle("hot",r||i||s),t.classList.toggle("over",s)};t.addEventListener("mouseenter",()=>{r=!0,a()}),t.addEventListener("mouseleave",()=>{r=!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",yd(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 Er(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",()=>o.click()),t.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),o.click())}),n.addEventListener("change",()=>void Er(da(n))),o.addEventListener("change",()=>void Er(da(o)))}document.addEventListener("DOMContentLoaded",Ld);})();
|
|
156
156
|
|
|
157
157
|
</script>
|
|
158
158
|
</body>
|