PageSourceSearch

https://www.blockcerts.org/node_modules/@blockcerts/blockcerts-verifier/dist/Bbs2023-Bp5cEh1R-CyaAsSfy.js

js blockcerts.org collected 2026-10-02 18:14:57 UTC 100,889 bytes, 64 lines download raw bytes

1import{d as e,p as t,V as r,P as n,u as i,w as o,f as c,v as s}from"./main.js";import{j as a}from"./jsonld-signatures-B0DqrrUT-B4B7KZ3F.js";import{j as f}from"./jsonld-BHLXlZBJ-dtl20tiV.js";import{c as u,m as d,b as l,a as p,d as h,f as b,v as m,n as y,i as g,g as w,h as E,j as _,k as v,r as B,l as x,F as S,w as O,o as I,q as F,s as T,t as A,u as N,x as R,y as j,z as U,A as k,B as P,C as K}from"./weierstrass-qx_4bPUU-BwaVz9Sr.js";import{s as $,c as M,a as D,b as q,d as z,u as L,e as V,f as G,g as C,h as H,i as Z,j as X,o as Y}from"./sha2-CJXzPerd-BVhQN7q7.js";import{D as W}from"./DataIntegrityProof-C6eNcfZD-DxdoQnVI.js";import{h as J,c as Q,l as ee,a as te,d as re,s as ne}from"./decode-BvGwOAqu-BaxzowN_.js";import{S as ie}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./index-DLhZKDC_-Dgus2xdV.js";import{r as oe}from"./retrieveVerificationMethodPublicKey-B-kSksW4-OGh7Cdla.js";const ce=BigInt(0),se=BigInt(1),ae=BigInt(2),fe=BigInt(3),ue=BigInt(4),de=l;function le(e,t){if(h(e),h(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function pe(e,t){const r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function he(e){if(!g(e)&&"string"!=typeof e)throw new Error("DST must be Uint8Array or ascii string");const t="string"==typeof e?b(e):e;if(0===t.length)throw new Error("DST must be non-empty");return t}function be(e,t,r,n){if(p(e),h(r),"function"!=typeof n)throw new Error("expand_message_xmd: expected hash function");h(n.outputLen,"hash.outputLen"),h(n.blockLen,"hash.blockLen"),(t=he(t)).length>255&&(t=n(u(b("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=n,c=Math.ceil(r/i);if(r>65535||c>255)throw new Error("expand_message_xmd: invalid lenInBytes");const s=u(t,le(t.length,1)),a=new Uint8Array(o),f=le(r,2),d=new Array(c),l=n(u(a,e,f,le(0,1),s));d[0]=n(u(l,le(1,1),s));for(let e=1;e<c;e++){const t=[pe(l,d[e-1]),le(e+1,1),s];d[e]=n(u(...t))}return u(...d).slice(0,r)}function me(e,t,r,n,i){if(p(e),h(r),h(n,"k"),n<0)throw new Error("expand_message_xof: invalid k");if("function"!=typeof i)throw new Error("expand_message_xof: expected XOF function");if("function"!=typeof i.create)throw new Error("expand_message_xof: expected XOF create");if(t=he(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update(b("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return i.create({dkLen:r}).update(e).update(le(r,2)).update(t).update(le(t.length,1)).digest()}function ye(e,t,r){m(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:n,k:i,m:o,hash:c,expand:s,DST:a}=r;if(h(c.outputLen,"valid hash"),p(e),h(t),h(o,"m"),h(i,"k"),n<=BigInt(1))throw new Error("hash_to_field: expected valid field characteristic");if(t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");if(i<0)throw new Error("hash_to_field: invalid k");const f=n.toString(2).length,u=Math.ceil((f+i)/8),l=t*o*u;let b;if("xmd"===s)b=be(e,a,l,c);else if("xof"===s)b=me(e,a,l,i,c);else{if("_internal_pass"!==s)throw new Error('expand must be "xmd" or "xof"');b=e}const y=new Array(t);for(let e=0;e<t;e++){const t=new Array(o);for(let r=0;r<o;r++){const i=u*(r+e*o),c=b.subarray(i,i+u);t[r]=d(de(c),n)}y[e]=t}return y}function ge(e,t){T(e),v(t,"map");const r=t.map((e,t)=>{if(v(e,"map["+t+"]"),e.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(e).reverse()});return(t,n)=>{const[i,o,c,s]=r.map(r=>r.reduce((r,n)=>e.add(e.mul(r,t),n))),a=e.is0(o)||e.is0(s),[f,u]=A(e,[o,s],!0);return t=e.mul(i,f),n=e.mul(n,e.mul(c,u)),a?{x:e.ZERO,y:e.ZERO}:{x:t,y:n}}}function we(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");m(r);const n=e=>Object.freeze({...e,DST:g(e.DST)?E(e.DST):e.DST,...void 0===e.encodeDST?{}:{encodeDST:g(e.encodeDST)?E(e.encodeDST):e.encodeDST}}),i=n(r),o=e=>e&&void 0!==e.DST?{DST:e.DST}:void 0;function c(r){return e.fromAffine(t(r))}function s(t){const r=t.clearCofactor();return r.equals(e.ZERO)?e.ZERO:(r.assertValidity(),r)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(e,t){const r=ye(e,2,Object.assign({},i,o(t))),n=c(r[0]),a=c(r[1]);return s(n.add(a))},encodeToCurve(e,t){const r=void 0===i.encodeDST?{}:{DST:i.encodeDST};return s(c(ye(e,1,Object.assign({},i,r,o(t)))[0]))},mapToCurve(e){if(1===i.m){if("bigint"!=typeof e)throw new Error("expected bigint (m=1)");return s(c([e]))}if(!Array.isArray(e))throw new Error("expected array of bigints");if(e.length!==i.m)throw new Error(`expected array of ${i.m} bigints`);for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return s(c(e))},hashToScalar(t,r){const n=e.Fn.ORDER;return ye(t,1,Object.assign({},i,{DST:"HashToScalar-"},o(r),{p:n,m:1}))[0][0]}})}function Ee(e,t){const r=T(e);m(t,{},{},"opts");const{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invali
1d opts");if(r.eql(o,r.neg(r.ONE))||P(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");const c=r.mul(i,r.inv(r.mul(o,n))),s=r.add(r.add(r.mul(r.sqr(c),c),r.mul(n,c)),i);if(!P(r,s))throw new Error("mapToCurveSimpleSWU: invalid opts");const a=function(e,t){const r=T(e),n=r.ORDER;let i=ce;for(let e=n-se;e%ae===ce;e/=ae)i+=se;const o=i,c=ae<<o-se-se,s=c*ae,a=(n-se)/s,f=(a-se)/ae,u=s-se,d=c,l=r.pow(t,a),p=r.pow(t,(a+se)/ae);let h=(e,t)=>{let n=l,i=r.pow(t,u),c=r.sqr(i);c=r.mul(c,t);let s=r.mul(e,c);s=r.pow(s,f),s=r.mul(s,i),i=r.mul(s,t),c=r.mul(s,e);let a=r.mul(c,i);s=r.pow(a,d);let h=r.eql(s,r.ONE);i=r.mul(c,p),s=r.mul(a,n),c=r.cmov(i,c,h),a=r.cmov(s,a,h);for(let e=o;e>se;e--){let t=e-ae;t=ae<<t-se;let o=r.pow(a,t);const s=r.eql(o,r.ONE);i=r.mul(c,n),n=r.mul(n,n),o=r.mul(a,n),c=r.cmov(i,c,s),a=r.cmov(o,a,s)}return{isValid:!r.is0(t)&&(h||r.is0(e)),value:c}};if(r.ORDER%ue===fe){const e=(r.ORDER-fe)/ue,n=r.sqrt(r.neg(t));h=(t,i)=>{let o=r.sqr(i);const c=r.mul(t,i);o=r.mul(o,c);let s=r.pow(o,e);s=r.mul(s,c);const a=r.mul(s,n),f=r.mul(r.sqr(s),i),u=r.eql(f,t);let d=r.cmov(a,s,u);return{isValid:!r.is0(i)&&u,value:d}}}return h}(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return e=>{let t,c,s,f,u,d,l,p;t=r.sqr(e),t=r.mul(t,o),c=r.sqr(t),c=r.add(c,t),s=r.add(c,r.ONE),s=r.mul(s,i),f=r.cmov(o,r.neg(c),!r.eql(c,r.ZERO)),f=r.mul(f,n),c=r.sqr(s),d=r.sqr(f),u=r.mul(d,n),c=r.add(c,u),c=r.mul(c,s),d=r.mul(d,f),u=r.mul(d,i),c=r.add(c,u),l=r.mul(t,s);const{isValid:h,value:b}=a(c,d);p=r.mul(t,e),p=r.mul(p,b),l=r.cmov(l,s,h),p=r.cmov(p,b,h);const m=r.isOdd(e)===r.isOdd(p);p=r.cmov(r.neg(p),p,m);const y=A(r,[f],!0)[0];return l=r.mul(l,y),{x:l,y:p}}}
2/*!
3 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
4 */function _e(e,t){if(!Array.isArray(e))throw new TypeError(`"${t}" must be an array.`)}function ve(e,t,r){if(!(t instanceof e))throw new TypeError(`"${r}" must be a ${e.name}.`)}function Be(e,t,r){if(typeof t!==e){throw new TypeError(`"${r}" must be ${"object"===e?"an":"a"} ${e}.`)}}
5/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xe=BigInt(0),Se=BigInt(1),Oe=BigInt(2),Ie=BigInt(3);function Fe(e){if(!Array.isArray(e)||0===e.length)throw new Error("expected non-empty array")}function Te(e,t,r,n){if(m(e,{Fp:"object",Fr:"object",Fp2:"object",Fp12:"object"},{Fp6:"object"},"fields"),"function"!=typeof t)throw new TypeError('"G1_Point" expected point constructor, got type='+typeof t);if("function"!=typeof r)throw new TypeError('"G2_Point" expected point constructor, got type='+typeof r);m(n,{ateLoopSize:"bigint",xNegative:"boolean",twistType:"string"},{randomBytes:"function",postPrecompute:"function"},"params");const{Fp:i,Fr:o,Fp2:c,Fp12:s}=e,{twistType:a,ateLoopSize:f,xNegative:u,postPrecompute:d}=n,l=(e,t)=>({c0:e,c1:t}),h=({c0:e,c1:t})=>Object.freeze({c0:e,c1:t}),b=(e,t)=>l(i.add(e.c0,t.c0),i.add(e.c1,t.c1)),y=(e,t)=>l(i.sub(e.c0,t.c0),i.sub(e.c1,t.c1)),g=(e,t)=>{const r=i.mul(e.c0,t.c0),n=i.mul(e.c1,t.c1);return l(i.sub(r,n),i.sub(i.mul(i.add(e.c0,e.c1),i.add(t.c0,t.c1)),i.add(r,n)))},E=(e,t)=>l(i.mul(e.c0,t),i.mul(e.c1,t)),x=e=>c.mulByNonresidue(e);let S;if("multiplicative"===a)S=(e,t,r,n,i,o)=>(({c0:e,c1:t},r,n,i,o,c)=>{const s=E(n,o),a=E(i,c),{c0:f,c1:u,c2:d}=e,{c0:l,c1:p,c2:m}=t,w=g(f,r),_=g(u,s),v=b(x(y(g(b(u,d),s),_)),w),B=y(y(g(b(r,s),b(f,u)),w),_),S=b(y(g(b(f,d),r),w),_),O=x(g(m,a)),I=g(l,a),F=g(p,a),T=b(f,l),A=b(u,p),N=b(d,m),R=b(s,a),j=g(T,r),U=g(A,R),k=b(x(y(g(b(A,N),R),U)),j),P=y(y(g(b(r,R),b(T,A)),j),U),K=b(y(g(b(T,N),r),j),U);return Object.freeze({c0:Object.freeze({c0:h(b(x(F),v)),c1:h(b(O,B)),c2:h(b(I,S))}),c1:Object.freeze({c0:h(y(y(k,v),O)),c1:h(y(y(P,B),I)),c2:h(y(y(K,S),F))})})})(n,e,t,r,i,o);else{if("divisive"!==a)throw new Error("bls: unknown twist type");S=(e,t,r,n,i,o)=>(({c0:e,c1:t},r,n,i,o,c)=>{const s=E(r,c),a=E(n,o),{c0:f,c1:u,c2:d}=e,{c0:l,c1:p,c2:m}=t,w=g(f,s),_=g(u,s),v=g(d,s),B=g(l,a),S=g(p,i),O=b(x(y(g(b(p,m),i),S)),B),I=y(y(g(b(a,i),b(l,p)),B),S),F=b(y(g(b(l,m),a),B),S),T=b(f,l),A=b(u,p),N=b(d,m),R=b(s,a),j=g(T,R),U=g(A,i),k=b(x(y(g(b(A,N),i),U)),j),P=y(y(g(b(R,i),b(T,A)),j),U),K=b(y(g(b(T,N),R),j),U);return Object.freeze({c0:Object.freeze({c0:h(b(x(F),w)),c1:h(b(O,_)),c2:h(b(I,v))}),c1:Object.freeze({c0:h(y(y(k,w),O)),c1:h(y(y(P,_),I)),c2:h(y(y(K,v),F))})})})(n,r,t,e,i,o)}const O=c.div(c.ONE,c.mul(c.ONE,Oe));function I(e,t,r,n){const i=c.sqr(r),o=c.sqr(n),s=c.mulByB(c.mul(o,Ie)),a=c.mul(s,Ie),f=c.sub(c.sub(c.sqr(c.add(r,n)),o),i),u=c.sub(s,i),d=c.mul(c.sqr(t),Ie),l=c.neg(f);return e.push([u,d,l]),{Rx:t=c.mul(c.mul(c.mul(c.sub(i,a),t),r),O),Ry:r=c.sub(c.sqr(c.mul(c.add(i,a),O)),c.mul(c.sqr(s),Ie)),Rz:n=c.mul(i,f)}}function F(e,t,r,n,i,o){const s=c.sub(r,c.mul(o,n)),a=c.sub(t,c.mul(i,n)),f=c.sub(c.mul(s,i),c.mul(a,o)),u=c.neg(s),d=a;e.push([f,u,d]);const l=c.sqr(a),p=c.mul(l,a),h=c.mul(l,t),b=c.add(c.sub(p,c.mul(h,Oe)),c.mul(c.sqr(s),n));return{Rx:t=c.mul(a,b),Ry:r=c.sub(c.mul(c.sub(h,b),s),c.mul(p,r)),Rz:n=c.mul(n,p)}}const T=function(e){const t=[];for(;e>Se;e>>=Se)(e&Se)===xe?t.unshift(0):(e&Ie)===Ie?(t.unshift(-1),e+=Se):t.unshift(1);return t}(f),A=e=>{if(!(e instanceof r))throw new TypeError('"point" expected G2 point, got type='+typeof e);const t=e,{x:n,y:i}=t.toAffine(),o=n,s=i,a=c.neg(i);let f=o,u=s,l=c.ONE;const p=[];for(const e of T){const t=[];({Rx:f,Ry:u,Rz:l}=I(t,f,u,l)),e&&({Rx:f,Ry:u,Rz:l}=F(t,f,u,l,o,-1===e?a:s)),p.push(t)}if(d){const e=p[p.length-1];d(f,u,l,o,s,F.bind(null,e))}return p};function N(e,t=!1){v(e,"pairs",(e,t)=>{if(v(e,t),3!==e.length)throw new TypeError(`"${t}" expected precompute tuple`);v(e[0],t+"[0]")});let r=s.ONE;if(e.length){const t=e[0][0].length;for(let n=0;n<t;n++){0!==n&&(r=s.sqr(r));for(const[t,i,o]of e)for(const[e,c,s]of t[n])r=S(e,c,s,r,i,o)}}return u&&(r=s.conjugate(r)),t?s.finalExponentiate(r):r}function R(e,n=!0){v(e,"pairs");const i=[];for(let n=0;n<e.length;n++){const o=e[n];m(o,{g1:"object",g2:"object"},{},"pairs["+n+"]");
5const{g1:c,g2:s}=o;if(!(c instanceof t))throw new TypeError('"pairs['+n+'].g1" expected G1 point, got type='+typeof c);if(!(s instanceof r))throw new TypeError('"pairs['+n+'].g2" expected G2 point, got type='+typeof s);if(c.is0()||s.is0())throw new Error("pairing is not available for ZERO point");c.assertValidity(),s.assertValidity();const a=c.toAffine();i.push([A(s),a.x,a.y])}return N(i,n)}const j={seed:w(o.ORDER)},U=void 0===n.randomBytes?B:n.randomBytes;return Object.freeze(j),{lengths:j,Fr:o,Fp12:s,millerLoopBatch:N,pairing:function(e,n,i=!0){if(!(e instanceof t))throw new TypeError('"Q" expected G1 point, got type='+typeof e);if(!(n instanceof r))throw new TypeError('"P" expected G2 point, got type='+typeof n);return R([{g1:e,g2:n}],i)},pairingBatch:R,calcPairingPrecomputes:A,randomSecretKey:e=>(e=void 0===e?U(j.seed):e,p(e,j.seed,"seed"),_(e,o.ORDER))}}function Ae(e,t,r,n,i,o){const{Fr:c,Fp12:s,pairingBatch:a,randomSecretKey:f,lengths:u}=e;o||(o={fromBytes:y,fromHex:y,toBytes:y,toHex:y});const d=Object.freeze({...o});function l(e){return e instanceof t?e:t.fromBytes(e)}function h(e){return e instanceof r?e:d.fromBytes(e)}function b(e){if(!(e instanceof r))throw new Error(`expected valid message hashed to ${n?"G1":"G2"} curve`);return e}const m=n?(e,t)=>({g1:t,g2:e}):(e,t)=>({g1:e,g2:t});return Object.freeze({lengths:Object.freeze({...u,secretKey:c.BYTES}),keygen(e){const t=f(e);return{secretKey:t,publicKey:this.getPublicKey(t)}},getPublicKey(e){let r;try{r=t.Fn.fromBytes(e)}catch(t){throw new Error("invalid private key: "+typeof e,{cause:t})}return t.BASE.multiply(r)},sign(e,r,n){if(null!=n)throw new Error("sign() expects 2 arguments");const i=t.Fn.fromBytes(r);return b(e).assertValidity(),e.multiply(i)},verify(e,r,n,i){if(null!=i)throw new Error("verify() expects 3 arguments");e=h(e);const o=(n=l(n)).negate(),c=t.BASE,f=b(r),u=e;try{const e=a([m(o,f),m(c,u)]);return s.eql(e,s.ONE)}catch{return!1}},verifyBatch(e,r){Fe(r);const n=h(e),i=r.map(e=>b(e.message)),o=r.map(e=>l(e.publicKey)),c=new Map;for(let e=0;e<o.length;e++){const t=o[e],r=i[e];let n=c.get(r);void 0===n&&(n=[],c.set(r,n)),n.push(t)}const f=[],u=t.BASE;try{for(const[e,t]of c){const r=t.reduce((e,t)=>e.add(t));f.push(m(r,e))}return f.push(m(u.negate(),n)),s.eql(a(f),s.ONE)}catch{return!1}},aggregatePublicKeys(e){Fe(e);const r=(e=e.map(e=>l(e))).reduce((e,t)=>e.add(t),t.ZERO);return r.assertValidity(),r},aggregateSignatures(e){Fe(e);const t=(e=e.map(e=>h(e))).reduce((e,t)=>e.add(t),r.ZERO);return t.assertValidity(),t},hash(e,t){p(e);return i(e,void 0===t?void 0:{DST:t})},Signature:Object.freeze({...d})})}function Ne(e,t,r,n,i){const o=function(e,t,r,n){const{Fp:i,Fr:o,Fp2:c,Fp6:s,Fp12:a}=e,f={Point:t},u={Point:r},d=Te(e,t,r,n),{millerLoopBatch:l,pairing:p,pairingBatch:h,calcPairingPrecomputes:b,randomSecretKey:m,lengths:y}=d;return f.Point.BASE.precompute(4),Object.freeze(f),Object.freeze(u),Object.freeze({lengths:Object.freeze(y),millerLoopBatch:l,pairing:p,pairingBatch:h,G1:f,G2:u,fields:Object.freeze({Fr:o,Fp:i,Fp2:c,Fp6:s,Fp12:a}),params:Object.freeze({ateLoopSize:n.ateLoopSize,xNegative:n.xNegative,twistType:n.twistType,postPrecompute:n.postPrecompute}),utils:Object.freeze({randomSecretKey:m,calcPairingPrecomputes:b})})}(e,t,r,n);m(i,{hasherOpts:"object",hasherOptsG1:"object",hasherOptsG2:"object"},{mapToG1:"function",mapToG2:"function"},"hasherParams");const c=we(t,void 0===i.mapToG1?y:i.mapToG1,{...i.hasherOpts,...i.hasherOptsG1}),s=we(r,void 0===i.mapToG2?y:i.mapToG2,{...i.hasherOpts,...i.hasherOptsG2});return Object.freeze({...o,G1:c,G2:s})}
6/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7const Re=BigInt(0),je=BigInt(1),Ue=BigInt(2),ke=BigInt(3),Pe=BigInt(6),Ke=BigInt(12),$e=e=>!!e&&"object"==typeof e;function Me(e,t,r,n,i=1,o){h(i,"num"),h(n,"degree");const c=void 0===o?n:o;h(c,"divisor");const s=e;if("bigint"!=typeof r||r<=je)throw new Error("calcFrobeniusCoefficients: expected valid modulus, got "+r);if(n<=0)throw new Error("calcFrobeniusCoefficients: expected positive degree, got "+n);if(i<=0)throw new Error("calcFrobeniusCoefficients: expected positive row count, got "+i);if(c<=0)throw new Error("calcFrobeniusCoefficients: expected positive divisor, got "+c);const a=BigInt(c),f=r**BigInt(n),u=[];for(let e=0;e<i;e++){const i=BigInt(e+1),o=[];for(let e=0,c=je;e<n;e++){const e=i*c-i;if(e%a)throw new Error("calcFrobeniusCoefficients: inexact tower exponent");const n=e/a%f;o.push(s.pow(t,n)),c*=r}u.push(o)}return u}class De{ORDER;BITS;BYTES;isLE;ZERO;ONE;Fp;NONRESIDUE;mulByB;
7Fp_NONRESIDUE;Fp_div2;constructor(e,t={}){const{NONRESIDUE:r=BigInt(-1),FP2_NONRESIDUE:n,Fp2mulByB:i}=t,o=e.ORDER,c=o*o;this.Fp=e,this.ORDER=c,this.BITS=x(c),this.BYTES=Math.ceil(x(c)/8),this.isLE=e.isLE,this.ZERO=this.create({c0:e.ZERO,c1:e.ZERO}),this.ONE=this.create({c0:e.ONE,c1:e.ZERO}),this.Fp_NONRESIDUE=e.create(r),this.Fp_div2=e.div(e.ONE,Ue),this.NONRESIDUE=this.create({c0:n[0],c1:n[1]}),this.mulByB=e=>{const{c0:t,c1:r}=i(e);return Object.freeze({c0:t,c1:r})},Object.freeze(this)}fromBigTuple(e){if(!Array.isArray(e)||2!==e.length)throw new Error("invalid Fp2.fromBigTuple");const[t,r]=e;if("bigint"!=typeof t||"bigint"!=typeof r)throw new Error("invalid Fp2.fromBigTuple");return this.create({c0:t,c1:r})}create(e){const{Fp:t}=this,r=t.create(e.c0),n=t.create(e.c1);return Object.freeze({c0:r,c1:n})}isValid(e){if(!$e(e))throw new TypeError("invalid field element: expected object, got "+typeof e);const{c0:t,c1:r}=e,{Fp:n}=this;return n.isValid(t)&&n.isValid(r)}is0(e){if(!$e(e))return!1;const{c0:t,c1:r}=e,{Fp:n}=this;return n.is0(t)&&n.is0(r)}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}eql({c0:e,c1:t},{c0:r,c1:n}){const{Fp:i}=this;return i.eql(e,r)&&i.eql(t,n)}neg({c0:e,c1:t}){const{Fp:r}=this;return Object.freeze({c0:r.neg(e),c1:r.neg(t)})}pow(e,t){return N(this,e,t)}invertBatch(e){return A(this,e,!0)}add(e,t){const{Fp:r}=this,{c0:n,c1:i}=e,{c0:o,c1:c}=t;return Object.freeze({c0:r.add(n,o),c1:r.add(i,c)})}sub({c0:e,c1:t},{c0:r,c1:n}){const{Fp:i}=this;return Object.freeze({c0:i.sub(e,r),c1:i.sub(t,n)})}mul({c0:e,c1:t},r){const{Fp:n}=this;if("bigint"==typeof r)return Object.freeze({c0:n.mul(e,r),c1:n.mul(t,r)});const{c0:i,c1:o}=r;let c=n.mul(e,i),s=n.mul(t,o);const a=n.sub(c,s),f=n.sub(n.mul(n.add(e,t),n.add(i,o)),n.add(c,s));return Object.freeze({c0:a,c1:f})}sqr({c0:e,c1:t}){const{Fp:r}=this,n=r.add(e,t),i=r.sub(e,t),o=r.add(e,e);return Object.freeze({c0:r.mul(n,i),c1:r.mul(o,t)})}addN(e,t){return this.add(e,t)}subN(e,t){return this.sub(e,t)}mulN(e,t){return this.mul(e,t)}sqrN(e){return this.sqr(e)}div(e,t){const{Fp:r}=this;return this.mul(e,"bigint"==typeof t?r.inv(r.create(t)):this.inv(t))}inv({c0:e,c1:t}){const{Fp:r}=this,n=r.inv(r.create(e*e+t*t));return Object.freeze({c0:r.mul(n,r.create(e)),c1:r.mul(n,r.create(-t))})}sqrt(e){const{Fp:t}=this,r=this,{c0:n,c1:i}=e;if(t.is0(i))return 1===R(t,n)?r.create({c0:t.sqrt(n),c1:t.ZERO}):r.create({c0:t.ZERO,c1:t.sqrt(t.div(n,this.Fp_NONRESIDUE))});const o=t.sqrt(t.sub(t.sqr(n),t.mul(t.sqr(i),this.Fp_NONRESIDUE)));let c=t.mul(t.add(o,n),this.Fp_div2);-1===R(t,c)&&(c=t.sub(c,o));const s=t.sqrt(c),a=r.create({c0:s,c1:t.div(t.mul(i,this.Fp_div2),s)});if(!r.eql(r.sqr(a),e))throw new Error("Cannot find square root");const f=a,u=r.neg(f),{re:d,im:l}=r.reim(f),{re:p,im:h}=r.reim(u);return l>h||l===h&&d>p?f:u}isOdd(e){const{re:t,im:r}=this.reim(e);return BigInt(t%Ue||t===Re&&r%Ue)==je}fromBytes(e){const{Fp:t}=this;if(p(e),e.length!==this.BYTES)throw new Error("fromBytes invalid length="+e.length);return this.create({c0:t.fromBytes(e.subarray(0,t.BYTES)),c1:t.fromBytes(e.subarray(t.BYTES))})}toBytes({c0:e,c1:t}){return u(this.Fp.toBytes(e),this.Fp.toBytes(t))}cmov({c0:e,c1:t},{c0:r,c1:n},i){const{Fp:o}=this;return this.create({c0:o.cmov(e,r,i),c1:o.cmov(t,n,i)})}reim({c0:e,c1:t}){return{re:e,im:t}}Fp4Square(e,t){const r=this,n=r.sqr(e),i=r.sqr(t);return{first:r.add(r.mulByNonresidue(i),n),second:r.sub(r.sub(r.sqr(r.add(e,t)),n),i)}}mulByNonresidue({c0:e,c1:t}){const{Fp:r,NONRESIDUE:n}=this;return n.c0===r.ONE&&n.c1===r.ONE?Object.freeze({c0:r.sub(e,t),c1:r.add(e,t)}):n.c1===r.ONE?Object.freeze({c0:r.sub(r.mul(e,n.c0),t),c1:r.add(e,r.mul(t,n.c0))}):this.mul({c0:e,c1:t},n)}frobeniusMap(e,t){const{c0:r,c1:n}=e,{Fp:i}=this;return Object.freeze({c0:r,c1:t%2==0?n:i.neg(n)})}}class qe{ORDER;BITS;BYTES;isLE;ZERO;ONE;Fp2;constructor(e){this.Fp2=e,this.ORDER=e.Fp.ORDER**Pe,this.BITS=3*e.BITS,this.BYTES=3*e.BYTES,this.isLE=e.isLE,this.ZERO=this.create({c0:e.ZERO,c1:e.ZERO,c2:e.ZERO}),this.ONE=this.create({c0:e.ONE,c1:e.ZERO,c2:e.ZERO}),Object.freeze(this)}get FROBENIUS_COEFFICIENTS_1(){const e=ze.get(this);if(e)return e[0];const{Fp2:t}=this,{Fp:r}
7=t,n=Me(t,t.NONRESIDUE,r.ORDER,6,2,3),i=[Object.freeze(n[0]),Object.freeze(n[1])];return ze.set(this,i),i[0]}get FROBENIUS_COEFFICIENTS_2(){const e=ze.get(this);return e?e[1]:(this.FROBENIUS_COEFFICIENTS_1,ze.get(this)[1])}add({c0:e,c1:t,c2:r},{c0:n,c1:i,c2:o}){const{Fp2:c}=this;return Object.freeze({c0:c.add(e,n),c1:c.add(t,i),c2:c.add(r,o)})}sub({c0:e,c1:t,c2:r},{c0:n,c1:i,c2:o}){const{Fp2:c}=this;return Object.freeze({c0:c.sub(e,n),c1:c.sub(t,i),c2:c.sub(r,o)})}mul({c0:e,c1:t,c2:r},n){const{Fp2:i}=this;if("bigint"==typeof n)return Object.freeze({c0:i.mul(e,n),c1:i.mul(t,n),c2:i.mul(r,n)});const{c0:o,c1:c,c2:s}=n,a=i.mul(e,o),f=i.mul(t,c),u=i.mul(r,s);return Object.freeze({c0:i.add(a,i.mulByNonresidue(i.sub(i.mul(i.add(t,r),i.add(c,s)),i.add(f,u)))),c1:i.add(i.sub(i.mul(i.add(e,t),i.add(o,c)),i.add(a,f)),i.mulByNonresidue(u)),c2:i.sub(i.add(f,i.mul(i.add(e,r),i.add(o,s))),i.add(a,u))})}sqr({c0:e,c1:t,c2:r}){const{Fp2:n}=this;let i=n.sqr(e),o=n.mul(n.mul(e,t),Ue),c=n.mul(n.mul(t,r),Ue),s=n.sqr(r);return Object.freeze({c0:n.add(n.mulByNonresidue(c),i),c1:n.add(n.mulByNonresidue(s),o),c2:n.sub(n.sub(n.add(n.add(o,n.sqr(n.add(n.sub(e,t),r))),c),i),s)})}addN(e,t){return this.add(e,t)}subN(e,t){return this.sub(e,t)}mulN(e,t){return this.mul(e,t)}sqrN(e){return this.sqr(e)}create(e){const{Fp2:t}=this,r=t.create(e.c0),n=t.create(e.c1),i=t.create(e.c2);return Object.freeze({c0:r,c1:n,c2:i})}isValid(e){if(!$e(e))throw new TypeError("invalid field element: expected object, got "+typeof e);const{c0:t,c1:r,c2:n}=e,{Fp2:i}=this;return i.isValid(t)&&i.isValid(r)&&i.isValid(n)}is0(e){if(!$e(e))return!1;const{c0:t,c1:r,c2:n}=e,{Fp2:i}=this;return i.is0(t)&&i.is0(r)&&i.is0(n)}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}neg({c0:e,c1:t,c2:r}){const{Fp2:n}=this;return Object.freeze({c0:n.neg(e),c1:n.neg(t),c2:n.neg(r)})}eql({c0:e,c1:t,c2:r},{c0:n,c1:i,c2:o}){const{Fp2:c}=this;return c.eql(e,n)&&c.eql(t,i)&&c.eql(r,o)}sqrt(e){return y()}div(e,t){const{Fp2:r}=this,{Fp:n}=r;return this.mul(e,"bigint"==typeof t?n.inv(n.create(t)):this.inv(t))}pow(e,t){return N(this,e,t)}invertBatch(e){return A(this,e,!0)}inv({c0:e,c1:t,c2:r}){const{Fp2:n}=this;let i=n.sub(n.sqr(e),n.mulByNonresidue(n.mul(r,t))),o=n.sub(n.mulByNonresidue(n.sqr(r)),n.mul(e,t)),c=n.sub(n.sqr(t),n.mul(e,r)),s=n.inv(n.add(n.mulByNonresidue(n.add(n.mul(r,o),n.mul(t,c))),n.mul(e,i)));return Object.freeze({c0:n.mul(s,i),c1:n.mul(s,o),c2:n.mul(s,c)})}fromBytes(e){const{Fp2:t}=this;if(p(e),e.length!==this.BYTES)throw new Error("fromBytes invalid length="+e.length);const r=t.BYTES;return this.create({c0:t.fromBytes(e.subarray(0,r)),c1:t.fromBytes(e.subarray(r,2*r)),c2:t.fromBytes(e.subarray(2*r))})}toBytes({c0:e,c1:t,c2:r}){const{Fp2:n}=this;return u(n.toBytes(e),n.toBytes(t),n.toBytes(r))}cmov({c0:e,c1:t,c2:r},{c0:n,c1:i,c2:o},c){const{Fp2:s}=this;return this.create({c0:s.cmov(e,n,c),c1:s.cmov(t,i,c),c2:s.cmov(r,o,c)})}fromBigSix(e){const{Fp2:t}=this;if(!Array.isArray(e)||6!==e.length)throw new Error("invalid Fp6.fromBigSix");for(let t=0;t<6;t++)if("bigint"!=typeof e[t])throw new Error("invalid Fp6.fromBigSix");const r=e;return this.create({c0:t.fromBigTuple(r.slice(0,2)),c1:t.fromBigTuple(r.slice(2,4)),c2:t.fromBigTuple(r.slice(4,6))})}frobeniusMap(e,t){const{c0:r,c1:n,c2:i}=e;if(t%6==0)return Object.freeze({c0:r,c1:n,c2:i});const{Fp2:o}=this;return Object.freeze({c0:o.frobeniusMap(r,t),c1:o.mul(o.frobeniusMap(n,t),this.FROBENIUS_COEFFICIENTS_1[t%6]),c2:o.mul(o.frobeniusMap(i,t),this.FROBENIUS_COEFFICIENTS_2[t%6])})}mulByFp2({c0:e,c1:t,c2:r},n){const{Fp2:i}=this;return Object.freeze({c0:i.mul(e,n),c1:i.mul(t,n),c2:i.mul(r,n)})}mulByNonresidue({c0:e,c1:t,c2:r}){const{Fp2:n}=this;return Object.freeze({c0:n.mulByNonresidue(r),c1:e,c2:t})}mul1({c0:e,c1:t,c2:r},n){const{Fp2:i}=this;return Object.freeze({c0:i.mulByNonresidue(i.mul(r,n)),c1:i.mul(e,n),c2:i.mul(t,n)})}mul01({c0:e,c1:t,c2:r},n,i){const{Fp2:o}=this;let c=o.mul(e,n),s=o.mul(t,i);return Object.freeze({c0:o.add(o.mulByNonresidue(o.sub(o.mul(o.add(t,r),i),s)),c),c1:o.sub(o.sub(o.mul(o.add(n,i),o.add(e,t)),c),s),c2:o.add(o.sub(o.mul(o.add(e,r),n),c),s)})}}const ze=new WeakMap;class Le{ORDER;BITS;BYTES;isLE;ZERO;ONE;Fp6;X_LEN;finalExponentiate;constructor(e,t){const{X_LEN:r,Fp12finalExponentiate:n}=t,{Fp2:i}=e,{Fp:o}=i;this.Fp6=e,this.ORDER=o.ORDER**Ke,this.BITS=2*e.BITS,this.BYTES=2*e.BYTES,this.isLE=e.isLE,this.ZERO=this.create({c0:e.ZERO,c1:e.ZERO}),this.ONE=this.create({c0:e.ONE,c1:e.ZERO}),this.X_LEN=r,this.finalExponentiate=e=>{const t=({c0:e,c1:t})=>Object.freeze({c0:e,c1:t}),r=({c0:e,c1:r,c2:n})=>Object.freeze({c0:t(e),c1:t(r),c2:t(n)}),i=n(e);return Object.freeze({c0:r(i.c0),c1:r(i.c1)})}
7,Object.freeze(this)}get FROBENIUS_COEFFICIENTS(){const e=Ve.get(this);if(e)return e;const{Fp2:t}=this.Fp6,{Fp:r}=t,n=Object.freeze(Me(t,t.NONRESIDUE,r.ORDER,12,1,6)[0]);return Ve.set(this,n),n}create(e){const{Fp6:t}=this,r=t.create(e.c0),n=t.create(e.c1);return Object.freeze({c0:r,c1:n})}isValid(e){if(!$e(e))throw new TypeError("invalid field element: expected object, got "+typeof e);const{c0:t,c1:r}=e,{Fp6:n}=this;return n.isValid(t)&&n.isValid(r)}is0(e){if(!$e(e))return!1;const{c0:t,c1:r}=e,{Fp6:n}=this;return n.is0(t)&&n.is0(r)}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}neg({c0:e,c1:t}){const{Fp6:r}=this;return Object.freeze({c0:r.neg(e),c1:r.neg(t)})}eql({c0:e,c1:t},{c0:r,c1:n}){const{Fp6:i}=this;return i.eql(e,r)&&i.eql(t,n)}sqrt(e){return y()}inv({c0:e,c1:t}){const{Fp6:r}=this;let n=r.inv(r.sub(r.sqr(e),r.mulByNonresidue(r.sqr(t))));return Object.freeze({c0:r.mul(e,n),c1:r.neg(r.mul(t,n))})}div(e,t){const{Fp6:r}=this,{Fp2:n}=r,{Fp:i}=n;return this.mul(e,"bigint"==typeof t?i.inv(i.create(t)):this.inv(t))}pow(e,t){return N(this,e,t)}invertBatch(e){return A(this,e,!0)}add({c0:e,c1:t},{c0:r,c1:n}){const{Fp6:i}=this;return Object.freeze({c0:i.add(e,r),c1:i.add(t,n)})}sub({c0:e,c1:t},{c0:r,c1:n}){const{Fp6:i}=this;return Object.freeze({c0:i.sub(e,r),c1:i.sub(t,n)})}mul({c0:e,c1:t},r){const{Fp6:n}=this;if("bigint"==typeof r)return Object.freeze({c0:n.mul(e,r),c1:n.mul(t,r)});let{c0:i,c1:o}=r,c=n.mul(e,i),s=n.mul(t,o);return Object.freeze({c0:n.add(c,n.mulByNonresidue(s)),c1:n.sub(n.mul(n.add(e,t),n.add(i,o)),n.add(c,s))})}sqr({c0:e,c1:t}){const{Fp6:r}=this;let n=r.mul(e,t);return Object.freeze({c0:r.sub(r.sub(r.mul(r.add(r.mulByNonresidue(t),e),r.add(e,t)),n),r.mulByNonresidue(n)),c1:r.add(n,n)})}addN(e,t){return this.add(e,t)}subN(e,t){return this.sub(e,t)}mulN(e,t){return this.mul(e,t)}sqrN(e){return this.sqr(e)}fromBytes(e){const{Fp6:t}=this;if(p(e),e.length!==this.BYTES)throw new Error("fromBytes invalid length="+e.length);return this.create({c0:t.fromBytes(e.subarray(0,t.BYTES)),c1:t.fromBytes(e.subarray(t.BYTES))})}toBytes({c0:e,c1:t}){const{Fp6:r}=this;return u(r.toBytes(e),r.toBytes(t))}cmov({c0:e,c1:t},{c0:r,c1:n},i){const{Fp6:o}=this;return this.create({c0:o.cmov(e,r,i),c1:o.cmov(t,n,i)})}fromBigTwelve(e){const{Fp6:t}=this;if(!Array.isArray(e)||12!==e.length)throw new Error("invalid Fp12.fromBigTwelve");for(let t=0;t<12;t++)if("bigint"!=typeof e[t])throw new Error("invalid Fp12.fromBigTwelve");const r=e;return this.create({c0:t.fromBigSix(r.slice(0,6)),c1:t.fromBigSix(r.slice(6,12))})}frobeniusMap(e,t){const r=t%12;if(0===r)return Object.freeze({c0:e.c0,c1:e.c1});if(6===r)return this.conjugate(e);const{Fp6:n}=this,{Fp2:i}=n,{c0:o,c1:c,c2:s}=n.frobeniusMap(e.c1,t),a=this.FROBENIUS_COEFFICIENTS[r];return Object.freeze({c0:n.frobeniusMap(e.c0,t),c1:Object.freeze({c0:i.mul(o,a),c1:i.mul(c,a),c2:i.mul(s,a)})})}mulByFp2({c0:e,c1:t},r){const{Fp6:n}=this;return Object.freeze({c0:n.mulByFp2(e,r),c1:n.mulByFp2(t,r)})}conjugate({c0:e,c1:t}){return Object.freeze({c0:e,c1:this.Fp6.neg(t)})}_cyclotomicSquare({c0:e,c1:t}){const{Fp6:r}=this,{Fp2:n}=r,{c0:i,c1:o,c2:c}=e,{c0:s,c1:a,c2:f}=t,{first:u,second:d}=n.Fp4Square(i,a),{first:l,second:p}=n.Fp4Square(s,c),{first:h,second:b}=n.Fp4Square(o,f),m=n.mulByNonresidue(b);return Object.freeze({c0:Object.freeze({c0:n.add(n.mul(n.sub(u,i),Ue),u),c1:n.add(n.mul(n.sub(l,o),Ue),l),c2:n.add(n.mul(n.sub(h,c),Ue),h)}),c1:Object.freeze({c0:n.add(n.mul(n.add(m,s),Ue),m),c1:n.add(n.mul(n.add(d,a),Ue),d),c2:n.add(n.mul(n.add(p,f),Ue),p)})})}_cyclotomicExp(e,t){if(j("cyclotomic exponent",t,Re,je<<BigInt(this.X_LEN)),t===Re)return this.ONE;let r=e;for(let n=x(t)-2;n>=0;n--)r=this._cyclotomicSquare(r),U(t,n)&&(r=this.mul(r,e));return r}}const Ve=new WeakMap;
8/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
9const Ge=BigInt(0),Ce=BigInt(1),He=BigInt(2),Ze=BigInt(3),Xe=BigInt(4),Ye=BigInt("0xd201000000010000"),We=x(Ye),Je={p:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),n:BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"),h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),a:Ge,b:Xe,Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db
918cb2c04b3edd03cc744a2888ae40caa232946c5e7e1")},Qe=S(Je.n,{modFromBytes:!0});function et({g2:e,g3:t,g4:r,g5:n}){const{first:i,second:o}=it.Fp4Square(r,n),{first:c,second:s}=it.Fp4Square(e,t),a=it.add(e,e),f=it.add(t,t),u=it.add(r,r),d=it.add(n,n);return{g2:it.add(it.mul(it.mulByNonresidue(o),Ze),a),g3:it.sub(it.mul(i,Ze),f),g4:it.sub(it.mul(c,Ze),u),g5:it.add(it.mul(s,Ze),d)}}function tt({g2:e,g3:t,g4:r,g5:n}){return it.is0(e)?{num:it.mul(it.mul(r,n),He),den:t}:{num:it.add(it.sub(it.mul(it.sqr(r),Ze),it.mul(t,He)),it.mulByNonresidue(it.sqr(n))),den:it.mul(e,Xe)}}function rt(e,t){const r=[];let n=function({c0:e,c1:t}){return{g2:t.c0,g3:e.c2,g4:e.c1,g5:t.c2}}(e);for(const e of t){for(let t=0;t<e;t++)n=et(n);r.push(n)}const i=r.map(({g2:e,g3:t})=>it.is0(e)&&it.is0(t)),o=r.map(tt),c=it.invertBatch(o.map(({den:e})=>e)),s=r.map((e,t)=>{if(i[t])return ct.ONE;const r=it.mul(o[t].num,c[t]);return function(e,t,{g2:r,g3:n,g4:i,g5:o}){return{c0:{c0:e,c1:i,c2:n},c1:{c0:r,c1:t,c2:o}}}(function(e,{g2:t,g3:r,g4:n,g5:i}){const o=it.mul(r,n),c=it.add(it.sub(it.mul(it.sub(it.sqr(e),o),He),o),it.mul(t,i));return it.add(it.mulByNonresidue(c),it.ONE)}(r,e),r,e)});return{result:ct.mul(ct.mul(s[0],s[1]),s[2]),last:s[2]}}const{Fp:nt,Fp2:it,Fp6:ot,Fp12:ct}=function(e){if(m(e,{ORDER:"bigint",X_LEN:"number",FP2_NONRESIDUE:"object",Fp2mulByB:"function",Fp12finalExponentiate:"function"},{NONRESIDUE:"bigint"}),h(e.X_LEN,"X_LEN"),e.X_LEN<1)throw new Error("invalid X_LEN");const t=e.FP2_NONRESIDUE;if(!Array.isArray(t)||2!==t.length)throw new Error("invalid FP2_NONRESIDUE");if("bigint"!=typeof t[0]||"bigint"!=typeof t[1])throw new Error("invalid FP2_NONRESIDUE");const r=S(e.ORDER),n=new De(r,e),i=new qe(n);return{Fp:r,Fp2:n,Fp6:i,Fp12:new Le(i,e)}}({ORDER:Je.p,X_LEN:We,FP2_NONRESIDUE:[Ce,Ce],Fp2mulByB:({c0:e,c1:t})=>{const r=nt.mul(e,Xe),n=nt.mul(t,Xe);return{c0:nt.sub(r,n),c1:nt.add(r,n)}},Fp12finalExponentiate:e=>{const t=e=>ct.conjugate(function(e){const{result:t,last:r}=rt(e,[16,32,9]);let n=t,i=r;for(let e=0;e<3;e++)i=ct._cyclotomicSquare(i);n=ct.mul(n,i);for(let e=0;e<2;e++)i=ct._cyclotomicSquare(i);return n=ct.mul(n,i),i=ct._cyclotomicSquare(i),ct.mul(n,i)}(e)),r=ct.div(ct.frobeniusMap(e,6),e),n=ct.mul(ct.frobeniusMap(r,2),r),i=t(n),o=ct.mul(ct.conjugate(ct._cyclotomicSquare(n)),i),c=t(o),s=t(c),a=ct.mul(t(s),ct._cyclotomicSquare(i)),f=t(a),u=ct.frobeniusMap(ct.mul(i,s),2),d=ct.frobeniusMap(ct.mul(c,n),3),l=ct.frobeniusMap(ct.mul(a,ct.conjugate(n)),1),p=ct.mul(ct.mul(f,ct.conjugate(o)),n);return ct.mul(ct.mul(ct.mul(u,d),l),p)}});let st;const at=()=>st||(st=function(e,t,r){if(T(e),T(t),m(t,{Fp:"object",frobeniusMap:"function",fromBigTuple:"function",mulByB:"function",mulByNonresidue:"function",reim:"function",Fp4Square:"function",NONRESIDUE:"object"},{}),!$e(r)||Array.isArray(r))throw new TypeError('"base" expected Fp2 element, got type='+typeof r);if(!t.isValid(r))throw new RangeError('"base" expected valid Fp2 element');const n=t.pow(r,(e.ORDER-je)/ke),i=t.pow(r,(e.ORDER-je)/Ue);function o(e,r){return[t.mul(t.frobeniusMap(e,1),n),t.mul(t.frobeniusMap(r,1),i)]}const c=t.pow(r,(e.ORDER**Ue-je)/ke),s=t.pow(r,(e.ORDER**Ue-je)/Ue);if(!t.eql(s,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function a(e,r){return[t.mul(e,c),t.neg(r)]}const f=e=>(t,r)=>{if("function"!=typeof t)throw new TypeError('"c" expected point constructor, got type='+typeof t);if(K(t),!(r instanceof t))throw new TypeError('"P" expected Point instance, got type='+typeof r);const n=r.toAffine(),i=e(n.x,n.y);return t.fromAffine({x:i[0],y:i[1]})};return{psi:o,psi2:a,G2psi:f(o),G2psi2:f(a),PSI_X:n,PSI_Y:i,PSI2_X:c,PSI2_Y:s}}(nt,it,it.div(it.ONE,it.NONRESIDUE)));let ft=(e,t)=>{const r=at().G2psi;return ft=r,r(e,t)},ut=(e,t)=>{const r=at().G2psi2;return ut=r,r(e,t)};const dt=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:nt.ORDER,m:2,k:128,expand:"xmd",hash:$}),lt={p:it.ORDER,n:Je.n,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),a:it.ZERO,b:it.fromBigTuple([Xe,Xe]),Gx:it.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:it.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")])},pt=(e,t)=>
9{for(const r of e)if(r!==Ge)return Boolean(r*He/t);return!1},ht={encode({c0:e,c1:t}){const{BYTES:r}=nt;return u(k(t,r),k(e,r))},decode(e){const{BYTES:t}=nt;return it.create({c0:mt(e.subarray(t)),c1:mt(e.subarray(0,t))})}},bt=nt;function mt(e){return nt.fromBytes(e)}const yt=(e,t,r,n,i,o)=>{const c=t,s=n,a=i,f=c.BYTES;return t=>({encode(e,r=!0){if(!r&&!t)throw new Error("invalid signature: expected compressed encoding");const n=e.is0(),{x:i,y:c}=e.toAffine(),a=r?s(i):u(s(i),s(c));let f;return r&&!n&&(f=pt(o(c),bt.ORDER)),function(e,t){if(224&e[0])throw new Error("setMask: non-empty mask");gt({compressed:!!t.compressed,infinity:!!t.infinity,sort:!!t.sort}),t.compressed&&(e[0]|=128);t.infinity&&(e[0]|=64);t.sort&&(e[0]|=32);return e}(a,{compressed:r,infinity:n,sort:f})},decode(n){const i=t?p(n,void 0,"point"):p(n,f,"signature"),{compressed:s,infinity:u,sort:d,value:l}=function(e){e=E(e);const t=224&e[0],r=!!(t>>7&1),n=!!(t>>6&1),i=!!(t>>5&1);return gt({compressed:r,infinity:n,sort:i}),e[0]&=31,{compressed:r,infinity:n,sort:i,value:e}}(i);if(!t&&!s)throw new Error("invalid signature: expected compressed encoding");const h=s?f:2*f;if(l.length!==h)throw new Error(`invalid ${e} point: expected ${h} bytes`);if(u){for(const t of l)if(t)throw new Error(`invalid ${e} point: non-canonical zero`);return{x:c.ZERO,y:c.ZERO}}const b=a(s?l:l.subarray(0,f));let m;if(s){if(m=c.sqrt(c.add(c.pow(b,Ze),r)),!m)throw new Error(`invalid ${e} point: compressed`);pt(o(m),bt.ORDER)!==d&&(m=c.neg(m))}else m=a(l.subarray(f));if(!s&&c.is0(b)&&c.is0(m))throw new Error(`invalid ${e} point: uncompressed`);return{x:b,y:m}}})};function gt({compressed:e,infinity:t,sort:r}){if(!e&&!t&&r||!e&&t&&r||e&&t&&r)throw new Error("invalid encoding flag")}const wt=yt("G1",nt,nt.create(Je.b),e=>k(e,nt.BYTES),mt,e=>[e]),Et={point:wt(!0),sig:wt(!1)},_t=e=>(e.assertValidity(),Et.sig.encode(e));function vt(e){const t=Rt.G1.Point.fromAffine(Et.sig.decode(e));return t.assertValidity(),t}const Bt=yt("G2",it,lt.b,ht.encode,ht.decode,e=>[e.c1,e.c0]),xt={point:Bt(!0),sig:Bt(!1)},St=e=>(e.assertValidity(),xt.sig.encode(e));function Ot(e){const t=Rt.G2.Point.fromAffine(xt.sig.decode(e));return t.assertValidity(),t}const It={ShortSignature:{fromBytes:e=>vt(p(e)),fromHex:e=>vt(F(e)),toBytes:e=>_t(e),toRawBytes:e=>_t(e),toHex:e=>I(_t(e))},LongSignature:{fromBytes:e=>Ot(p(e)),fromHex:e=>Ot(F(e)),toBytes:e=>St(e),toRawBytes:e=>St(e),toHex:e=>I(St(e))}},Ft={Fp:nt,Fp2:it,Fp6:ot,Fp12:ct,Fr:Qe},Tt=O(Je,{allowInfinityPoint:!0,Fn:Qe,fromBytes:Et.point.decode,toBytes:(e,t,r)=>Et.point.encode(t,r),isTorsionFree:(e,t)=>{const r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(nt.mul(t.X,r),t.Y,t.Z);return t.multiplyUnsafe(Ye).negate().multiplyUnsafe(Ye).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Ye).add(t)}),At=O(lt,{Fp:it,allowInfinityPoint:!0,Fn:Qe,fromBytes:xt.point.decode,toBytes:(e,t,r)=>xt.point.encode(t,r),isTorsionFree:(e,t)=>t.multiplyUnsafe(Ye).negate().equals(ft(e,t)),clearCofactor:(e,t)=>{const r=Ye;let n=t.multiplyUnsafe(r).negate(),i=ft(e,t),o=t.double();o=ut(e,o),o=o.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),o=o.add(i),o=o.subtract(n);return o.subtract(t)}}),Nt={mapToG1:function(e){const{x:t,y:r}=Kt()(nt.create(e[0]));return Ut(t,r)},mapToG2:function(e){const{x:t,y:r}=$t()(it.fromBigTuple(e));return jt(t,r)}
10/*!
11 * Copyright (c) 2019-2023 Digital Bazaar, Inc. All rights reserved.
12 */,hasherOpts:dt,hasherOptsG1:{...dt,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},hasherOptsG2:{...dt}},Rt=function(e,t,r,n,i,o){const c=Ne(e,t,r,n,i),s={...c,Fr:c.fields.Fr,Fp12:c.fields.Fp12,calcPairingPrecomputes:c.utils.calcPairingPrecomputes,randomSecretKey:c.utils.randomSecretKey},a=Ae(s,t,r,!1,c.G2.hashToCurve,o?.LongSignature),f=Ae(s,r,t,!0,c.G1.hashToCurve,o?.ShortSignature);return Object.freeze({...c,longSignatures:a,shortSignatures:f})}(Ft,Tt,At,{ateLoopSize:Ye,xNegative:!0,twistType:"multiplicative",randomBytes:B},Nt,It),jt=ge(it,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0
12761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(e=>it.fromBigTuple(e.map(BigInt))))),Ut=ge(nt,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0
12x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e))));let kt,Pt;const Kt=()=>kt||(kt=Ee(nt,{A:nt.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:nt.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:nt.create(BigInt(11))})),$t=()=>Pt||(Pt=Ee(it,{A:it.create({c0:nt.create(Ge),c1:nt.create(BigInt(240))}),B:it.create({c0:nt.create(BigInt(1012)),c1:nt.create(BigInt(1012))}),Z:it.create({c0:nt.create(BigInt(-2)),c1:nt.create(BigInt(-1))})}));const Mt=globalThis.crypto,Dt=new TextEncoder;
13/*!
14 * Copyright (c) 2023-2026 Digital Bazaar, Inc.
15 */function qt({PK:e,generators:t,header:r,messages:n,api_id:i,ciphersuite:o}={}){const{P1:c}=o,{Q_1:s,H:a}=t,f=zt({PK:e,generators:t,header:r,api_id:i,ciphersuite:o});let u=c.add(s.multiply(f)),d=0;for(const e of n)0n!==e&&(u=u.add(a[d++].multiply(e)));return{B:u,domain:f}}function zt({PK:e,generators:t,header:r=new Uint8Array,api_id:n=new Uint8Array,ciphersuite:i}={}){const o=u(n,Dt.encode("H2S_")),{Q_1:c,H:s}=t;let a=Xt({input_array:[s.length,c,...s],ciphersuite:i});n.length>0&&(a=u(a,n));return Ct({msg_octets:u(e,a,Ht(r.length,8),r),dst:o,ciphersuite:i})}function Lt(e,t){return Dt.encode(e+t)}function Vt({count:e,api_id:t=new Uint8Array,ciphersuite:r,compress:n=!1}={}){if(!(Number.isSafeInteger(e)&&e>0))throw new Error('"count" must be a safe integer >= 1.');const i=u(t,Dt.encode("SIG_GENERATOR_SEED_")),o=u(t,Dt.encode("SIG_GENERATOR_DST_")),c=u(t,Dt.encode("MESSAGE_GENERATOR_SEED")),s=new Array(e);let a=r.expand_message(c,i);for(let t=1;t<=e;++t){a=r.expand_message(u(a,Ht(t,8)),i);let e=r.hash_to_curve_g1(a,o);n&&(e=r.octets_to_point_E1(r.point_to_octets_E1(e))),s[t-1]=e}return s.Q_1=s[0],s.H=s.slice(1),s}async function Gt(e){const t=await async function(e){return Mt.getRandomValues(new Uint8Array(e))}(e.expand_len);return d(l(t),e.r)}function Ct({msg_octets:e,dst:t,ciphersuite:r}={}){const n=r.expand_message(e,t);return d(l(n),r.r)}function Ht(e,t){if(e=BigInt(e),!(t>0&&Number.isSafeInteger(t)))throw new Error(`"length" (${t}) must be a positive safe integer.`);if(e<0||e>=1n<<8n*BigInt(t))throw new Error(`"value" (${e}) not in byte range (0, ${t}).`);const r=new Uint8Array(t);for(let n=t-1;n>=0;--n)r[n]=Number(0xffn&e),e>>=8n;return r}function Zt({messages:e,api_id:t=new Uint8Array,ciphersuite:r}={}){const n=u(t,Dt.encode("MAP_MSG_TO_SCALAR_AS_HASH_"));if(!Number.isSafeInteger(e.length))throw new Error('"messages.length" must be a safe integer.');return e.map(e=>Ct({msg_octets:e,dst:n,ciphersuite:r}))}function Xt({input_array:e,ciphersuite:t}={}){const{G1:r,G2:n}=Rt;let i=0;const o=new Array(e.length);for(const c of e){let e;if(c instanceof r.Point)e=t.point_to_octets_E1(c);else if(c instanceof n.Point)e=t.point_to_octets_E2(c);else if("bigint"==typeof c)e=Ht(c,t.octet_scalar_length);else if("number"==typeof c)e=Ht(c,8);else{if(!(c instanceof Uint8Array))throw new Error(`Unknown element "${c}" detected during "serialize()".`);e=c}o[i++]=e}return u(...o)}const Yt=BigInt(0),Wt=BigInt(1),Jt=BigInt(2),Qt=BigInt(7),er=BigInt(256),tr=BigInt(113),rr=[],nr=[],ir=[];for(let e=0,t=Wt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],rr.push(2*(5*n+r)),nr.push((e+1)*(e+2)/2%64);let i=Yt;for(let e=0;e<7;e++)t=(t<<Wt^(t>>Qt)*tr)%er,t&Jt&&(i^=Wt<<(Wt<<BigInt(e))-Wt);ir.push(i)}const or=X(ir,!0),cr=or[0],sr=or[1],ar=(e,t,r)=>r>32?((e,t,r)=>t<<r-32|e>>>64-r)(e,t,r):((e,t,r)=>e<<r|t>>>32-r)(e,t,r),fr=(e,t,r)=>r>32?((e,t,r)=>e<<r-32|t>>>64-r)(e,t,r):((e,t,r)=>t<<r|e>>>
1532-r)(e,t,r),ur=new Uint32Array(10);class dr{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,r,n=!1,i=24){if(q(e,"blockLen"),q(t,"suffix"),q(i,"rounds"),z(n,"enableXOF"),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.canXOF=n,this.rounds=i,q(r,"outputLen"),!(0<e&&e<200))throw new Error('"blockLen" must be 1..199');this.state=new Uint8Array(200),this.state32=L(this.state)}clone(){return this._cloneInto()}keccak(){V(this.state32),function(e,t=24){if(!(e instanceof Uint32Array))throw new TypeError('"s" expected Uint32Array(50), got type='+typeof e);if(50!==e.length)throw new RangeError('"s" expected Uint32Array(50), got length='+e.length);if(q(t,"rounds"),t<1||t>24)throw new Error('"rounds" expected integer 1..24');for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)ur[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,n=(t+2)%10,i=ur[n],o=ur[n+1],c=ar(i,o,1)^ur[r],s=fr(i,o,1)^ur[r+1];for(let r=0;r<50;r+=10)e[t+r]^=c,e[t+r+1]^=s}let t=e[2],n=e[3];for(let r=0;r<24;r++){const i=nr[r],o=ar(t,n,i),c=fr(t,n,i),s=rr[r];t=e[s],n=e[s+1],e[s]=o,e[s+1]=c}for(let t=0;t<50;t+=10){const r=e[t],n=e[t+1],i=e[t+2],o=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&r,e[t+7]^=~e[t+9]&n,e[t+8]^=~r&i,e[t+9]^=~n&o}e[0]^=cr[r],e[1]^=sr[r]}Z(ur)}(this.state32,this.rounds),V(this.state32),this.posOut=0,this.pos=0}update(e){G(this),C(e);const{blockLen:t,state:r,state32:n}=this,i=e.length,o=t/4,c=t%4==0&&e.byteOffset%4==0&&i>=t?L(e):void 0;for(let s=0;s<i;){if(void 0!==c&&0===this.pos&&s%4==0&&i-s>=t){for(let e=0,t=s/4;e<o;e++)n[e]^=c[t+e];s+=t,this.pos=t,this.keccak();continue}const a=Math.min(t-this.pos,i-s);for(let t=0;t<a;t++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,128&t&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){G(this,!1),C(e),this.finish();const t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not enabled");return this.writeInto(e)}xof(e){return q(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(H(e,this),this.finished)throw new Error("digest() was already called");this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){const e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,Z(this.state)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||=new dr(t,r,n,o,i),e.blockLen=t,e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.canXOF=this.canXOF,e.destroyed=this.destroyed,e}}const lr=((e,t,r,n={})=>M((n={})=>(n=D({},n),new dr(t,e,void 0===n.dkLen?r:n.dkLen,!0)),n))(31,136,32,Y(12)),pr={BLS12381_SHAKE256:{ciphersuite_id:"BBS_BLS12381G1_XOF:SHAKE-256_SSWU_RO_",name:"BLS12-381-SHAKE-256",expand_len:48,hash:"SHAKE-256",octet_scalar_length:32,octet_point_length:48,BP1:Rt.G1.Point.BASE,BP2:Rt.G2.Point.BASE,E1:Rt.fields.Fp,E2:Rt.fields.Fp2,Identity_E1:Rt.G1.Point.ZERO,Identity_E2:Rt.G2.Point.ZERO,P1:Rt.G1.Point.fromHex("8929dfbc7e6642c4ed9cba0856e493f8b9d7d5fcb0c31ef8fdcd34d50648a56c795e106e9eada6e0bda386b414150755"),Fr:Rt.fields.Fr,r:Rt.fields.Fr.ORDER,hash_to_curve_g1(e,t){if(t.length>255)throw new Error('"dst.length" must be <= 255.');return Rt.G1.hashToCurve(e,{DST:t,expand:"xof",k:128,hash:lr})},expand_message(e,t,r){if(t.length>255)throw new Error('"dst.length" must be <= 255.');return me(e,t,r??pr.BLS12381_SHAKE256.expand_len,128,lr)},pairingCompare:wr,octets_to_point_E1:yr,octets_to_point_E2:gr,point_to_octets_E1:mr,point_to_octets_E2:mr},BLS12381_SHA256:{ciphersuite_id:"BBS_BLS12381G1_XMD:SHA-256_SSWU_RO_",name:"BLS12-381-SHA-256",expand_len:48,hash:"SHA-256",octet_scalar_length:32,octet_point_length:48,Fr:Rt.fields.Fr,r:Rt.fields.Fr.ORDER,BP1:Rt.G1.Point.BASE,BP2:Rt.G2.Point.BASE,E1:Rt.fields.Fp,E2:Rt.fields.Fp2,Identity_E1:Rt.G1.Point.ZERO,Identity_E2:Rt.G2.Point.ZERO,P1:Rt.G1.Point.fromHex("a8ce256102840821a3e94ea9025e4662b205762f9776b3a766c872b948f1fd225e7c59698588e70d11406d161b4e28c9"),hash_to_curve_g1(e,t){if(t.length>255)throw new Error('"dst.length" must be <= 255.');return Rt.G1.hashToCurve(e,{DST:t,expand:"xmd",hash:$})},expand_message(e,t,r){if(t.length>255)throw new Error('"dst.length" must be <= 255.');return be(e,t,r??pr.BLS12381_SHA256.expand_len,$)},pairingCompare:wr,octets_to_point_E1:yr,octets_to_point_E2:gr,point_to_octets_E1:mr,point_to_octets_E2:mr}},hr=[...Object.values(pr)];function br(e){if("object"==typeof e){if(!hr.includes(e))throw new TypeError(`Unknown ciphersuite "${e?.name}".`);return e}Be("string",e,"ciphersuite");const t=pr[e];if(t)return t;for(const[,t]of Object.entries(pr))if(t.name===e||t.ciphersuite_id===e)return t;throw new Error(`Unknown ciphersuite "${e}".`)}function mr(e){return e.toBytes()}function yr(e){return Rt.G1.Point.fromBytes(e)}function gr(e){return Rt.G2.Point.fromBytes(e)}function wr({pair1:e,pair2:t,performNegation:r=!0}={}){r&&(t=[t[0],t[1].negate()]);const n=Rt.pairing(...e,!1),i=Rt.pairing(...t,!1),{fields:{Fp12:o}}=Rt,c=o.ONE,s=o.finalExponentiate(o.mul(n,i));return o.eql(s,c)}
16/*!
17 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
18 */function Er({SK:e,ciphersuite:t}={}){Be("bigint",e,"SK"),t=br(t);const{BP2:r}=t,n=r.multiply(e);return t.point_to_octets_E2(n)}
19/*!
20 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
21 */function _r({init_res:e,disclosed_indexes:t=[],disclosed_messages:r=[],ph:n=new Uint8Array,api_id:i=new Uint8Array,ciphersuite:o}={}){const c=u(i,Dt.encode("H2S_")),s=t.length,[a,f,d,l,p,h]=e;if(!Number.isSafeInteger(s))throw new Error(`"disclosed_indexes.length" (${s}) must be a safe integer.`);if(!Number.isSafeInteger(n.length))throw new Error(`"ph.length" (${n.length}) must be a safe integer.`);const b=[s,...t.map((e,t)=>[e,r[t]]).flat(),a,f,d,l,p,h];return Ct({msg_octets:u(Xt({input_array:b,ciphersuite:o}),Ht(n.length,8),n),dst:c,ciphersuite:o})}function vr({init_res:e,challenge:t,e_value:r,random_scalars:n,undisclosed_messages:i=[],ciphersuite:o}={}){const c=i.length;if(n.length!==c+5)throw new Error(`"random_scalars.length" (${n.length}) must equal "undisclosed_messages.length + 5" (${c+5}).`);const[s,a,f,u,d,...l]=n,[p,h,b]=e,{Fr:m}=o,y=m.inv(a);return function({proof:e,ciphersuite:t}={}){return Xt({input_array:e,ciphersuite:t})}({proof:[p,h,b,m.add(f,m.mul(r,t)),m.sub(u,m.mul(s,t)),m.sub(d,m.mul(y,t)),...i.map((e,r)=>m.add(l[r],m.mul(e,t))),t],ciphersuite:o})}
22/*!
23 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
24 */
25async function Br({PK:e,signature:t,generators:r,header:n=new Uint8Array,ph:i=new Uint8Array,messages:o=[],disclosed_indexes:c=[],api_id:s=new Uint8Array,ciphersuite:a,mocked_random_scalars_options:f}={}){const u=function({signature_octets:e,ciphersuite:t}={}){const{octet_point_length:r,octet_scalar_length:n}=t,i=r+n;if(e.length!==i)throw new Error(`"signature_octets.length" (${e.length}) must be ${i}.`);const o=e.subarray(0,r),c=t.octets_to_point_E1(o);if(c.equals(t.Identity_E1))throw new Error("Invalid signature.");const s=l(e.subarray(r));if(s<0n||s>=t.Fr.ORDER)throw new Error(`signature "e" value must be >= 0 and < (${t.Fr.ORDER}).`);return[c,s]}({signature_octets:t,ciphersuite:a}),p=o.length,h=c.length;if(h>p)throw new Error(`"disclosed_indexes.length" (${c.length}) must be less than or equal to "messages.length" (${o.length}).`);const b=p-h;if(c.some(e=>isNaN(e)||e<0||e>=p))throw new Error(`Every index in "disclosed_indexes" (${c}) must be a number in the range [0, ${p}).`);const m=[],y=[],g=[],w=new Set(c);for(const[e,t]of o.entries())w.has(e)?y.push(t):(m.push(e),g.push(t));const E=void 0===f?await async function({count:e,ciphersuite:t}={}){if(!(Number.isSafeInteger(e)&&e>=0))throw new Error('"count" must be a non-negative safe integer.');const r=new Array(e);for(let n=0;n<e;++n)r[n]=Gt(t);return Promise.all(r)}({count:5+b,ciphersuite:a}):function({count:e,seed:t,dst:r,ciphersuite:n}={}){if(!(Number.isSafeInteger(e)&&e>=0))throw new Error('"count" must be a non-negative safe integer.');const{expand_len:i,r:o}=n,c=i*e,s=n.expand_message(t,r,c),a=new Array(e);let f=0;for(let t=0;t<e;++t){const e=f+i,r=s.subarray(f,e);f=e,a[t]=d(l(r),o)}return a}({count:5+b,...f,ciphersuite:a}),_=function({PK:e,signature_result:t,generators:r,random_scalars:n,header:i=new Uint8Array,messages:o=[],undisclosed_indexes:c=[],api_id:s=new Uint8Array,ciphersuite:a}={}){const[f,u]=t,{H:d}=r,l=o.length,p=c.length;if(n.length!==p+5)throw new Error(`"random_scalars.length" (${n.length}) must equal "undisclosed_indexes.length + 5" (${p+5}).`);if(r.length!==l+1)throw new Error(`"generators.length" (${r.length}) must equal the total number of messages + 1 (${l+1}).`);const{B:h,domain:b}=qt({PK:e,generators:r,header:i,messages:o,api_id:s,ciphersuite:a}),[m,y,g,w,E,..._]=n,v=h.multiply(y),B=f.multiply(a.Fr.mul(m,y)),x=v.multiply(m).subtract(B.multiply(u)),S=B.multiply(g).add(v.multiply(w));let O=v.multiply(E);for(const[e,t]of c.entries())O=O.add(d[t].multiply(_[e]));return[B,x,v,S,O,b]}({PK:e,signature_result:u,generators:r,random_scalars:E,header:n,messages:o,undisclosed_indexes:m,api_id:s,ciphersuite:a}),v=_r({init_res:_,disclosed_indexes:c,disclosed_messages:y,ph:i,api_id:s,ciphersuite:a}),[,B]=u;return vr({init_res:_,challenge:v,e_value:B,random_scalars:E,undisclosed_messages:g,ciphersuite:a})}function xr({PK:e,proof:t,generators:r,header:n=new Uint8Array,ph:i=new Uint8Array,disclosed_messages:o=[],disclosed_indexes:c=[],api_id:s=new Uint8Array,ciphersuite:a}={}){const f=function({proof_octets:e,ciphersuite:t}={}){const{r:r,octet_point_length:n,octet_scalar_length:i}=t,o=3*n+4*i;if(e.length<o)throw new Error(`"proof_octets.length" (${e.length}) must be at least ${o}.`);if((e.length-o)%i!==0)throw new Error("Invalid proof size.");let c=0;const s=new Array(3);for(let r=0;r<=2;++r){if(s[r]=t.octets_to_point_E1(e.subarray(c,c+n)),s[r].equals(t.Identity_E1))throw new Error("Invalid point in proof.");c+=n}const a=[];for(;c<e.length;){const t=l(e.subarray(c,c+i));if(0===t||t>=r)throw new Error("Invalid scalar in proof.");a.push(t),c+=i}return[...s,...a]}({proof_octets:t,ciphersuite:a}),[u,d]=f,p=f.at(-1),h=function({PK:e,ciphersuite:t}={}){const r=t.octets_to_point_E2(e);
25if(r.equals(t.Identity_E2))throw new Error("Invalid public key.");return r}({PK:e,ciphersuite:a}),b=function({PK:e,proof:t,generators:r,header:n=new Uint8Array,disclosed_messages:i=[],disclosed_indexes:o=[],api_id:c=new Uint8Array,ciphersuite:s}={}){const[a,f,u,d,l,p,...h]=t,b=h.pop(),m=h.length,y=o.length+m;if(o.some(e=>isNaN(e)||e<0||e>y-1))throw new Error(`Every index in "disclosed_indexes" must be a number >= 0 and <= ${y}.`);if(r.length!==y+1)throw new Error(`"generators.length" (${r.length}) must equal the total number of commitments and disclosed indexes + 1 (${y+1}).`);const{Q_1:g,H:w}=r,E=new Set(o),_=[...w.keys()].filter(e=>!E.has(e)),v=zt({PK:e,generators:r,header:n,api_id:c,ciphersuite:s}),B=f.multiply(b).add(a.multiply(d)).add(u.multiply(l)),{P1:x}=s;let S=x.add(g.multiply(v));for(const[e,t]of i.entries())S=S.add(w[o[e]].multiply(t));let O=S.multiply(b).add(u.multiply(p));for(const[e,t]of h.entries())O=O.add(w[_[e]].multiply(t));return[a,f,u,B,O,v]}({PK:e,proof:f,generators:r,header:n,disclosed_messages:o,disclosed_indexes:c,api_id:s,ciphersuite:a});if(p!==_r({init_res:b,disclosed_indexes:c,disclosed_messages:o,ph:i,api_id:s,ciphersuite:a}))return!1;const{BP2:m}=a,y=[u,h],g=[d,m];return a.pairingCompare({pair1:y,pair2:g})}function Sr({SK:e,PK:t,generators:r,header:n=new Uint8Array,messages:i=[],api_id:o=new Uint8Array,ciphersuite:c}={}){const s=u(o,Dt.encode("H2S_")),a=i.length;if(r.length!==a+1)throw new Error(`"generators.length" (${r.length}) must equal "messages.length" (${i.length}) + 1.`);const{B:f,domain:d}=qt({PK:t,generators:r,header:n,messages:i,api_id:o,ciphersuite:c}),l=Ct({msg_octets:Xt({input_array:[e,...i,d],ciphersuite:c}),dst:s,ciphersuite:c}),{Fr:p}=c,h=f.multiply(p.inv(p.add(e,l)));if(h.equals(c.Identity_E1))throw new Error("Invalid signature.");return function({signature:e,ciphersuite:t}={}){return Xt({input_array:e,ciphersuite:t})}({signature:[h,l],ciphersuite:c})}
26/*!
27 * Copyright (c) 2024-2025 Digital Bazaar, Inc. All rights reserved.
28 */const Or="H2G_HM2S_";
29/*!
30 * Copyright (c) 2023-2025 Digital Bazaar, Inc. All rights reserved.
31 */async function Ir({secretKey:e,publicKey:t,header:r,messages:n,ciphersuite:i}={}){ve(Uint8Array,e,"secretKey"),i=br(i),ve(Uint8Array,r,"header"),_e(n,"messages"),n.forEach((e,t)=>ve(Uint8Array,e,`messages[${t}]`));const o=Ar({secretKey:e,ciphersuite:i});return void 0!==t?ve(Uint8Array,t,"publicKey"):t=Er({SK:o,ciphersuite:i}),async function({SK:e,PK:t,header:r=new Uint8Array,messages:n=[],ciphersuite:i}={}){Be("bigint",e,"SK"),ve(Uint8Array,t,"PK"),ve(Uint8Array,r,"header"),_e(n,"messages");const o=Lt((i=br(i)).ciphersuite_id,Or),c=Zt({messages:n,api_id:o,ciphersuite:i});return Sr({SK:e,PK:t,generators:Vt({count:n.length+1,api_id:o,ciphersuite:i}),header:r,messages:c,api_id:o,ciphersuite:i})}
32/*!
33 * Copyright (c) 2022-2026 Digital Bazaar, Inc.
34 */({SK:o,PK:t,header:r,messages:n,ciphersuite:i})}async function Fr({publicKey:e,signature:t,header:r,messages:n,presentationHeader:i,disclosedMessageIndexes:o,ciphersuite:c}={}){return ve(Uint8Array,e,"publicKey"),ve(Uint8Array,t,"signature"),ve(Uint8Array,r,"header"),_e(n,"messages"),n.forEach((e,t)=>ve(Uint8Array,e,`messages[${t}]`)),ve(Uint8Array,i,"presentationHeader"),_e(o,"disclosedMessageIndexes"),o.forEach((e,t)=>Be("number",e,`disclosedMessageIndexes[${t}]`)),async function({PK:e,signature:t,header:r=new Uint8Array,ph:n=new Uint8Array,messages:i=[],disclosed_indexes:o=[],ciphersuite:c,mocked_random_scalars_options:s}={}){ve(Uint8Array,e,"PK"),ve(Uint8Array,t,"signature"),ve(Uint8Array,r,"header"),ve(Uint8Array,n,"ph"),_e(i,"messages"),_e(o,"disclosed_indexes");const a=Lt((c=br(c)).ciphersuite_id,Or),f=Zt({messages:i,api_id:a,ciphersuite:c}),u=Vt({count:i.length+1,api_id:a,ciphersuite:c});return await Br({PK:e,signature:t,generators:u,header:r,ph:n,messages:f,disclosed_indexes:o,api_id:a,ciphersuite:c,mocked_random_scalars_options:s})}({PK:e,signature:t,header:r,ph:i,messages:n,disclosed_indexes:o,ciphersuite:c})}async function Tr({publicKey:e,proof:t,header:r,presentationHeader:n,disclosedMessages:i,disclosedMessageIndexes:o,ciphersuite:c}={}){return ve(Uint8Array,e,"publicKey"),ve(Uint8Array,t,"proof"),ve(Uint8Array,r,"header"),ve(Uint8Array,n,"presentationHeader"),_e(i,"disclosedMessages"),i.forEac
34h((e,t)=>ve(Uint8Array,e,`disclosedMessages[${t}]`)),_e(o,"disclosedMessageIndexes"),o.forEach((e,t)=>Be("number",e,`disclosedMessageIndexes[${t}]`)),async function({PK:e,proof:t,header:r,ph:n,disclosed_messages:i,disclosed_indexes:o,ciphersuite:c}={}){if(ve(Uint8Array,e,"PK"),ve(Uint8Array,t,"proof"),ve(Uint8Array,r,"header"),ve(Uint8Array,n,"ph"),_e(i,"disclosed_messages"),_e(o,"disclosed_indexes"),i.length!==o.length)throw new Error(`"disclosed_messages.length" (${i.length}) must equal "disclosed_indexes.length" (${o.length}).`);const s=Lt((c=br(c)).ciphersuite_id,Or),{octet_point_length:a,octet_scalar_length:f}=c,u=3*a+4*f;if(t.length<u)throw new Error(`"proof.length" (${t.length}) must be at least ${u}.`);const d=t.length-u;if(d%f!==0)throw new Error("Invalid proof size.");const l=d/f,p=o.length,h=Zt({messages:i,api_id:s,ciphersuite:c});return xr({PK:e,proof:t,generators:Vt({count:l+p+1,api_id:s,ciphersuite:c}),header:r,ph:n,disclosed_messages:h,disclosed_indexes:o,api_id:s,ciphersuite:c})}({PK:e,proof:t,header:r,ph:n,disclosed_messages:i,disclosed_indexes:o,ciphersuite:c})}function Ar({secretKey:e,ciphersuite:t}={}){const{octet_scalar_length:r,r:n}=t,i=d(l(e),n);if(0n===i)throw new Error('Invalid secret key scalar value of "0".');return i}
35/*!
36 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
37 */const Nr={BBS_BLS12381_SHAKE256:"BBS-BLS12-381-SHAKE-256",BBS_BLS12381_SHA256:"BBS-BLS12-381-SHA-256"},Rr="https://w3id.org/security/multikey/v1",jr="z",Ur=new Uint8Array([234,1]),kr=new Uint8Array([235,1]),Pr=new Uint8Array([137,38]),Kr=new Uint8Array([138,38]),$r="Bls12381G1",Mr="Bls12381G2",Dr=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function qr(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if("string"===t||"number"===t||"bigint"===t||"symbol"===t)return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";const r=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(Dr.includes(t))return t;return}(e);return r||"Object"}
37class zr{constructor(e,t,r){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,t){return e===t||e.major===t.major&&e.name===t.name}}zr.uint=new zr(0,"uint",!0),zr.negint=new zr(1,"negint",!0),zr.bytes=new zr(2,"bytes",!0),zr.string=new zr(3,"string",!0),zr.array=new zr(4,"array",!1),zr.map=new zr(5,"map",!1),zr.tag=new zr(6,"tag",!1),zr.float=new zr(7,"float",!0),zr.false=new zr(7,"false",!0),zr.true=new zr(7,"true",!0),zr.null=new zr(7,"null",!0),zr.undefined=new zr(7,"undefined",!0),zr.break=new zr(7,"break",!0);class Lr{constructor(e,t,r){this.type=e,this.value=t,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}}const Vr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,Gr=new TextEncoder;function Cr(e){return Vr&&globalThis.Buffer.isBuffer(e)}const Hr=Vr?e=>e.length>=24?globalThis.Buffer.from(e):Zr(e):e=>e.length>=200?Gr.encode(e):Zr(e);function Zr(e){const t=[];let r=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296==(64512&i)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++n)),t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(i>=55296&&i<=57343&&(i=65533),t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128)}return t}const Xr="CBOR decode error:",Yr="CBOR encode error:";function Wr(e,t,r){if(e.length-t<r)throw new Error(`${Xr} not enough data for type`)}const Jr=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Qr(e,t,r){Wr(e,t,1);const n=e[t];if(!0===r.strict&&n<Jr[0])throw new Error(`${Xr} integer encoded in more bytes than necessary (strict decode)`);return n}function en(e,t,r){Wr(e,t,2);const n=e[t]<<8|e[t+1];if(!0===r.strict&&n<Jr[1])throw new Error(`${Xr} integer encoded in more bytes than necessary (strict decode)`);return n}function tn(e,t,r){Wr(e,t,4);const n=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===r.strict&&n<Jr[2])throw new Error(`${Xr} integer encoded in more bytes than necessary (strict decode)`);return n}function rn(e,t,r){Wr(e,t,8);const n=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=16777216*e[t+4]+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(!0===r.strict&&o<Jr[3])throw new Error(`${Xr} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(!0===r.allowBigInt)return o;throw new Error(`${Xr} integers outside of the safe integer range are not supported`)}function nn(e,t){return on(e,0,t.value)}function on(e,t,r){if(r<Jr[0]){const n=Number(r);e.push([t|n])}else if(r<Jr[1]){const n=Number(r);e.push([24|t,n])}else if(r<Jr[2]){const n=Number(r);e.push([25|t,n>>>8,255&n])}else if(r<Jr[3]){const n=Number(r);e.push([26|t,n>>>24&255,n>>>16&255,n>>>8&255,255&n])}else{const n=BigInt(r);if(!(n<Jr[4]))throw new Error(`${Xr} encountered BigInt larger than allowable range`);{const r=[27|t,0,0,0,0,0,0,0];let i=Number(n&BigInt(4294967295)),o=Number(n>>BigInt(32)&BigInt(4294967295));r[8]=255&i,i>>=8,r[7]=255&i,i>>=8,r[6]=255&i,i>>=8,r[5]=255&i,r[4]=255&o,o>>=8,r[3]=255&o,o>>=8,r[2]=255&o,o>>=8,r[1]=255&o,e.push(r)}}}nn.encodedSize=function(e){return on.encodedSize(e.value)},on.encodedSize=function(e){return e<Jr[0]?1:e<Jr[1]?2:e<Jr[2]?3:e<Jr[3]?5:9},nn.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const cn=BigInt(-1),sn=BigInt(1);function an(e,t){const r=t.value,n="bigint"==typeof r?r*cn-sn:-1*r-1;on(e,t.type.majorEncoded,n)}function fn(e,t,r,n){Wr(e,t,r+n);const i=e.slice(t+r,t+r+n);return new Lr(zr.bytes,i,r+n)}function un(e,t,r,n){return fn(e,t,1,r)}function dn(e){return void 0===e.encodedBytes&&(e.encodedBytes=zr.equals(e.type,zr.string)?Hr(e.value):e.value),e.encodedBytes}function ln(e,t){const r=dn(t);on(e,t.type.majorEncoded,r.length),e.push(r)}an.encodedSize=function(e){const t=e.value,r="bigint"==typeof t?t*cn-sn:-1*t-1;return r<Jr[0]?1:r<Jr[1]?2:r<Jr[2]?3:r<Jr[3]?5:9},an.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},ln.encodedSize=function(e){const t=dn(e);return on.encodedSize(t.length)+t.length},ln.compareTokens=function(e,t){return r=dn(e),n=dn(t),r.length<n.length?-1:r.length>n.length?1:function(e,t){if(Cr(e)&&Cr(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}(r,n);var r,n};const pn=new TextDecoder;function hn(e,t,r,n,i){const o=r+n;Wr(e,t,o);const c=new Lr(zr.string,function(e,t,r){if(r-t<32){let n="";for(let i=t;i<r;i++){const o=e[i];if(128&o)return pn.decode(e.subarray(t,r));n+=String.fromCharCode(o)}return n}return pn.decode(e.subarray(t,r))}(e,t+r,t+o),o);return!0===i.retainStringBytes&&(c.byteValue=e.slice(t+r,t+o)),c}function bn(e,t,r,n){return hn(e,t,1,r,n)}const mn=ln;function yn(e,t,r,n){return new Lr(zr.array,n,r)}function gn(e,t,r,n){return yn(0,0,1,r)}function wn(e,t){on(e,zr.array.majorEncoded,t.value)}function En(e,t,r,n){return new Lr(zr.map,n,r)}function _n(e,t,r,n){return En(0,0,1,r)}function vn(e,t){on(e,zr.map.majorEncoded,t.value)}function Bn(e,t,r,n){return new Lr(zr.tag,r,1)}function xn(e,t){on(e,zr.tag.majorEncoded,t.value)}wn.compareTokens=nn.compareTokens,wn.encodedSize=function(e){return on.encodedSize(e.value)},vn.compareTokens=nn.compareTokens,vn.encodedSize=function(e){return on.encodedSize(e.value)},xn.compareTokens=nn.compareTokens,xn.encodedSize=function(e){return on.encodedSize(e.value)};function Sn(e,t,r){if(r){if(!1===r.allowNaN&&Number.isNaN(e))throw new Error(`${Xr} NaN values are not supported`);if(!1===r.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${Xr} Infinity values are not supported`)}return new Lr(zr.float,e,t)}function On(e,t,r){const n=t.value;if(!1===n)e.push([20|zr.float.majorEncoded]);else if(!0===n)e.push([21|zr.float.majorEncoded]);else if(null===n)e.push([22|zr.float.majorEncoded]);else if(void 0===n)e.push([23|zr.float.majorEncoded]);else{let t,o=!1;r&&!0===r.float64||(An(n),t=Nn(Tn,1),n===t||Number.isNaN(n)?(Tn[0]=249,e.push(Tn.slice(0,3)),o=!0):(Rn(n),t=jn(Tn,1),n===t&&(Tn[0]=250,e.push(Tn.slice(0,5)),o=!0))),o||(i=n,Fn.setFloat64(0,i,!1),t=Un(Tn,1),Tn[0]=251,e.push(Tn.slice(0,9)))}var i}On.encodedSize=function(e,t){const r=e.value;if(!1===r||!0===r||null==r)return 1;if(!t||!0!==t.float64){An(r);let e=Nn(Tn,1);if(r===e||Number.isNaN(r))return 3;if(Rn(r),e=jn(Tn,1),r===e)return 5}return 9};
37const In=new ArrayBuffer(9),Fn=new DataView(In,1),Tn=new Uint8Array(In,0);function An(e){if(e===1/0)Fn.setUint16(0,31744,!1);else if(e===-1/0)Fn.setUint16(0,64512,!1);else if(Number.isNaN(e))Fn.setUint16(0,32256,!1);else{Fn.setFloat32(0,e);const t=Fn.getUint32(0),r=(2139095040&t)>>23,n=8388607&t;if(255===r)Fn.setUint16(0,31744,!1);else if(0===r)Fn.setUint16(0,(2147483648&t)>>16|n>>13,!1);else{const e=r-127;e<-24?Fn.setUint16(0,0):e<-14?Fn.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):Fn.setUint16(0,(2147483648&t)>>16|e+15<<10|n>>13,!1)}}}function Nn(e,t){if(e.length-t<2)throw new Error(`${Xr} not enough data for float16`);const r=(e[t]<<8)+e[t+1];if(31744===r)return 1/0;if(64512===r)return-1/0;if(32256===r)return NaN;const n=r>>10&31,i=1023&r;let o;return o=0===n?i*2**-24:31!==n?(i+1024)*2**(n-25):0===i?1/0:NaN,32768&r?-o:o}function Rn(e){Fn.setFloat32(0,e,!1)}function jn(e,t){if(e.length-t<4)throw new Error(`${Xr} not enough data for float32`);const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Un(e,t){if(e.length-t<8)throw new Error(`${Xr} not enough data for float64`);const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}function kn(e,t,r){throw new Error(`${Xr} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Pn(e){return()=>{throw new Error(`${Xr} ${e}`)}}On.compareTokens=nn.compareTokens;const Kn=[];for(let e=0;e<=23;e++)Kn[e]=kn;Kn[24]=function(e,t,r,n){return new Lr(zr.uint,Qr(e,t+1,n),2)},Kn[25]=function(e,t,r,n){return new Lr(zr.uint,en(e,t+1,n),3)},Kn[26]=function(e,t,r,n){return new Lr(zr.uint,tn(e,t+1,n),5)},Kn[27]=function(e,t,r,n){return new Lr(zr.uint,rn(e,t+1,n),9)},Kn[28]=kn,Kn[29]=kn,Kn[30]=kn,Kn[31]=kn;for(let e=32;e<=55;e++)Kn[e]=kn;Kn[56]=function(e,t,r,n){return new Lr(zr.negint,-1-Qr(e,t+1,n),2)},Kn[57]=function(e,t,r,n){return new Lr(zr.negint,-1-en(e,t+1,n),3)},Kn[58]=function(e,t,r,n){return new Lr(zr.negint,-1-tn(e,t+1,n),5)},Kn[59]=function(e,t,r,n){const i=rn(e,t+1,n);if("bigint"!=typeof i){const e=-1-i;if(e>=Number.MIN_SAFE_INTEGER)return new Lr(zr.negint,e,9)}if(!0!==n.allowBigInt)throw new Error(`${Xr} integers outside of the safe integer range are not supported`);return new Lr(zr.negint,cn-BigInt(i),9)},Kn[60]=kn,Kn[61]=kn,Kn[62]=kn,Kn[63]=kn;for(let e=64;e<=87;e++)Kn[e]=un;Kn[88]=function(e,t,r,n){return fn(e,t,2,Qr(e,t+1,n))},Kn[89]=function(e,t,r,n){return fn(e,t,3,en(e,t+1,n))},Kn[90]=function(e,t,r,n){return fn(e,t,5,tn(e,t+1,n))},Kn[91]=function(e,t,r,n){const i=rn(e,t+1,n);if("bigint"==typeof i)throw new Error(`${Xr} 64-bit integer bytes lengths not supported`);return fn(e,t,9,i)},Kn[92]=kn,Kn[93]=kn,Kn[94]=kn,Kn[95]=Pn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Kn[e]=bn;Kn[120]=function(e,t,r,n){return hn(e,t,2,Qr(e,t+1,n),n)},Kn[121]=function(e,t,r,n){return hn(e,t,3,en(e,t+1,n),n)},Kn[122]=function(e,t,r,n){return hn(e,t,5,tn(e,t+1,n),n)},Kn[123]=function(e,t,r,n){const i=rn(e,t+1,n);if("bigint"==typeof i)throw new Error(`${Xr} 64-bit integer string lengths not supported`);return hn(e,t,9,i,n)},Kn[124]=kn,Kn[125]=kn,Kn[126]=kn,Kn[127]=Pn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Kn[e]=gn;Kn[152]=function(e,t,r,n){return yn(0,0,2,Qr(e,t+1,n))},Kn[153]=function(e,t,r,n){return yn(0,0,3,en(e,t+1,n))},Kn[154]=function(e,t,r,n){return yn(0,0,5,tn(e,t+1,n))},Kn[155]=function(e,t,r,n){const i=rn(e,t+1,n);if("bigint"==typeof i)throw new Error(`${Xr} 64-bit integer array lengths not supported`);return yn(0,0,9,i)},Kn[156]=kn,Kn[157]=kn,Kn[158]=kn,Kn[159]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(`${Xr} indefinite length items not allowed`);return yn(0,0,1,1/0)};for(let e=160;e<=183;e++)Kn[e]=_n;Kn[184]=function(e,t,r,n){return En(0,0,2,Qr(e,t+1,n))},Kn[185]=function(e,t,r,n){return En(0,0,3,en(e,t+1,n))},Kn[186]=function(e,t,r,n){return En(0,0,5,tn(e,t+1,n))},Kn[187]=function(e,t,r,n){const i=rn(e,t+1,n);if("bigint"==typeof i)throw new Error(`${Xr} 64-bit integer map lengths not supported`);return En(0,0,9,i)},Kn[188]=kn,Kn[189]=kn,Kn[190]=kn,Kn[191]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(`${Xr} indefinite length items not allowed`);return En(0,0,1,1/0)};for(let e=192;e<=215;e++)Kn[e]=Bn;Kn[216]=function(e,t,r,n){return new Lr(zr.tag,Qr(e,t+1,n),2)},Kn[217]=function(e,t,r,n){return new Lr(zr.tag,en(e,t+1,n),3)},Kn[218]=function(e,t,r,n){return new Lr(zr.tag,tn(e,t+1,n),5)},Kn[219]=function(e,t,r,n){return new Lr(zr.tag,rn(e,t+1,n),9)},Kn[220]=kn,Kn[221]=kn,Kn[222]=kn,Kn[223]=kn;for(let e=224;e<=243;e++)Kn[e]=Pn("simple values are not supported");Kn[244]=kn,Kn[245]=kn,Kn[246]=kn,Kn[247]=function(e,t,r,n){if(!1===n.allowUndefined)throw new Error(`${Xr} undefined values are not supported`);return!0===n.coerceUndefinedToNull?new Lr(zr.null,null,1):new Lr(zr.undefined,void 0,1)},Kn[248]=Pn("simple values are not supported"),Kn[249]=function(e,t,r,n){return Sn(Nn(e,t+1),3,n)},Kn[250]=function(e,t,r,n){return Sn(jn(e,t+1),5,n)},Kn[251]=function(e,t,r,n){return Sn(Un(e,t+1),9,n)},Kn[252]=kn,Kn[253]=kn,Kn[254]=kn,Kn[255]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(`${Xr} indefinite length items not allowed`);return new Lr(zr.break,void 0,1)};const $n=[];for(let e=0;e<24;e++)$n[e]=new Lr(zr.uint,e,1);for(let e=-1;e>=-24;e--)$n[31-e]=new Lr(zr.negint,e,1);$n[64]=new Lr(zr.bytes,new Uint8Array(0),1),$n[96]=new Lr(zr.string,"",1),$n[
37128]=new Lr(zr.array,0,1),$n[160]=new Lr(zr.map,0,1),$n[244]=new Lr(zr.false,!1,1),$n[245]=new Lr(zr.true,!0,1),$n[246]=new Lr(zr.null,null,1),function(){const e=[];e[zr.uint.major]=nn,e[zr.negint.major]=an,e[zr.bytes.major]=ln,e[zr.string.major]=mn,e[zr.array.major]=wn,e[zr.map.major]=vn,e[zr.tag.major]=xn,e[zr.float.major]=On}();class Mn{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Yr} object contains circular references`);return new Mn(t,e)}}const Dn={null:new Lr(zr.null,null),undefined:new Lr(zr.undefined,void 0),true:new Lr(zr.true,!0),false:new Lr(zr.false,!1),emptyArray:new Lr(zr.array,0),emptyMap:new Lr(zr.map,0)},qn={number:(e,t,r,n)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new Lr(e>=0?zr.uint:zr.negint,e):new Lr(zr.float,e),bigint:(e,t,r,n)=>e>=BigInt(0)?new Lr(zr.uint,e):new Lr(zr.negint,e),Uint8Array:(e,t,r,n)=>new Lr(zr.bytes,e),string:(e,t,r,n)=>new Lr(zr.string,e),boolean:(e,t,r,n)=>e?Dn.true:Dn.false,null:(e,t,r,n)=>Dn.null,undefined:(e,t,r,n)=>Dn.undefined,ArrayBuffer:(e,t,r,n)=>new Lr(zr.bytes,new Uint8Array(e)),DataView:(e,t,r,n)=>new Lr(zr.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,r,n){if(!e.length)return!0===r.addBreakTokens?[Dn.emptyArray,new Lr(zr.break)]:Dn.emptyArray;n=Mn.createCheck(n,e);const i=[];let o=0;for(const t of e)i[o++]=zn(t,r,n);return r.addBreakTokens?[new Lr(zr.array,e.length),i,new Lr(zr.break)]:[new Lr(zr.array,e.length),i]},Object(e,t,r,n){const i="Object"!==t,o=i?e.keys():Object.keys(e),c=i?e.size:o.length;let s;if(c){s=new Array(c),n=Mn.createCheck(n,e);const t=!i&&r.ignoreUndefinedProperties;let a=0;for(const c of o){const o=i?e.get(c):e[c];t&&void 0===o||(s[a++]=[zn(c,r,n),zn(o,r,n)])}a<c&&(s.length=a)}return s?.length?(function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(s,r),r.addBreakTokens?[new Lr(zr.map,s.length),s,new Lr(zr.break)]:[new Lr(zr.map,s.length),s]):!0===r.addBreakTokens?[Dn.emptyMap,new Lr(zr.break)]:Dn.emptyMap},Tagged:(e,t,r,n)=>[new Lr(zr.tag,e.tag),zn(e.value,r,n)]};qn.Map=qn.Object,qn.Buffer=qn.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))qn[`${e}Array`]=qn.DataView;function zn(e,t={},r){const n=qr(e),i=t&&t.typeEncoders&&t.typeEncoders[n]||qn[n];if("function"==typeof i){const o=i(e,n,t,r);if(null!=o)return o}const o=qn[n];if(!o)throw new Error(`${Yr} unsupported type: ${n}`);return o(e,n,t,r)}zr.uint.majorEncoded,zr.negint.majorEncoded,zr.bytes.majorEncoded,zr.string.majorEncoded,zr.array.majorEncoded,zr.float.majorEncoded,zr.float.majorEncoded,zr.float.majorEncoded,zr.float.majorEncoded,BigInt(-1),BigInt(1);const Ln={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class Vn{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){const e=this.data[this._pos];let t=$n[e];if(void 0===t){const r=Kn[e];if(!r)throw new Error(`${Xr} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const n=31&e;t=r(this.data,this._pos,n,this.options)}return this._pos+=t.encodedLength,t}}const Gn=Symbol.for("DONE"),Cn=Symbol.for("BREAK");function Hn(e,t){let r=!1;const n=function(){if(r)throw new Error(`${Xr} tag decode() may only be called once`);r=!0;const n=Zn(e,t);if(n===Gn)throw new Error(`${Xr} tag content missing`);if(n===Cn)throw new Error(`${Xr} got unexpected break in tag content`);return n};return n.entries=function(){if(r)throw new Error(`${Xr} tag decode() may only be called once`);r=!0;const n=e.next();if(!zr.equals(n.type,zr.map))throw new Error(`${Xr} entries() requires map content, got ${n.type.name}`);const i=[];for(const r of function*(e,t,r){for(let n=0;n<e.value;n++){const i=Zn(t,r);if(i===Cn){if(e.value===1/0)break;throw new Error(`${Xr} got unexpected break to lengthed map`)}if(i===Gn)throw new Error(`${Xr} found map but not enough entries (got ${n} [no key], expected ${e.value})`);const o=Zn(t,r);if(o===Gn)throw new Error(`${Xr}
37 found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[i,o]}}(n,e,t))i.push(r);return i},Object.defineProperty(n,"_called",{get:()=>r,enumerable:!1}),n}function Zn(e,t){if(e.done())return Gn;const r=e.next();if(zr.equals(r.type,zr.break))return Cn;if(r.type.terminal)return r.value;if(zr.equals(r.type,zr.array))return function(e,t,r){const n=[];for(let i=0;i<e.value;i++){const o=Zn(t,r);if(o===Cn){if(e.value===1/0)break;throw new Error(`${Xr} got unexpected break to lengthed array`)}if(o===Gn)throw new Error(`${Xr} found array but not enough entries (got ${i}, expected ${e.value})`);n[i]=o}return n}(r,e,t);if(zr.equals(r.type,zr.map))return function(e,t,r){const n=!0===r.useMaps,i=!0===r.rejectDuplicateMapKeys,o=n?void 0:{},c=n?new Map:void 0;for(let s=0;s<e.value;s++){const a=Zn(t,r);if(a===Cn){if(e.value===1/0)break;throw new Error(`${Xr} got unexpected break to lengthed map`)}if(a===Gn)throw new Error(`${Xr} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(!n&&"string"!=typeof a)throw new Error(`${Xr} non-string keys not supported (got ${typeof a})`);if(i&&(n&&c.has(a)||!n&&Object.hasOwn(o,a)))throw new Error(`${Xr} found repeat map key "${a}"`);const f=Zn(t,r);if(f===Gn)throw new Error(`${Xr} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?c.set(a,f):o[a]=f}return n?c:o}(r,e,t);if(zr.equals(r.type,zr.tag)){if(t.tags&&"function"==typeof t.tags[r.value]){const n=Hn(e,t),i=t.tags[r.value](n);if(!n._called)throw new Error(`${Xr} tag decoder must call decode() or entries()`);return i}throw new Error(`${Xr} tag not supported (${r.value})`)}throw new Error("unsupported")}function Xn(e,t){if(!(e instanceof Uint8Array))throw new Error(`${Xr} data to decode must be a Uint8Array`);t=Object.assign({},Ln,t);const r=(n=e)instanceof Uint8Array?Cr(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n:Uint8Array.from(n);var n;const i=t.tokenizer||new Vn(r,t),o=Zn(i,t);if(o===Gn)throw new Error(`${Xr} did not find any content to decode`);if(o===Cn)throw new Error(`${Xr} got unexpected break`);return[o,e.subarray(i.pos())]}
38/*!
39 * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
40 */
41function Yn({id:e,secretKey:t,publicKey:r,algorithm:n}){if(!t)throw new Error('"secretKey" is required for signing.');const i=n.slice(4),o=async function({header:e,messages:n}={}){return Ir({secretKey:t,publicKey:r,header:e,messages:n,ciphersuite:i})};return{algorithm:n,id:e,publicKey:r,multisign:o,async sign({data:e}={}){const t=function(e,t){const[r,n]=Xn(e,t);if(n.length>0)throw new Error(`${Xr} too many terminals, data makes no sense`);return r}(e);if(2!==t.length)throw new Error('Sign "data" must be a CBOR-encoded array with two parameters: the BBS "header" and BBS "messages".');const[r,n]=t;return o({header:r,messages:n})}}}
42/*!
43 * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
44 */
45function Wn({publicMultikey:e}){if(e[0]===Ur[0]&&e[1]===Ur[1])return $r;if(e[0]===kr[0]&&e[1]===kr[1])return Mr;throw new TypeError("Unsupported public multikey header.")}function Jn({secretMultikey:e}){if(e[0]===Pr[0]&&e[1]===Pr[1])return $r;if(e[0]===Kr[0]&&e[1]===Kr[1])return Mr;throw new TypeError("Unsupported secret multikey header.")}function Qn({curve:e}){if(e===$r)return 48;if(e===Mr)return 96;throw new TypeError(`Unsupported curve "${e}".`)}function ei({curve:e}){if(e===$r||e===Mr)return 32;throw new TypeError(`Unsupported curve "${e}".`)}function ti({curve:e,buffer:t}){if(e===$r)t[0]=Pr[0],t[1]=Pr[1];else{if(e!==Mr)throw new TypeError(`Unsupported curve "${e}".`);t[0]=Kr[0],t[1]=Kr[1]}}function ri({curve:e,buffer:t}){if(e===$r)t[0]=Ur[0],t[1]=Ur[1];else{if(e!==Mr)throw new TypeError(`Unsupported curve "${e}".`);t[0]=kr[0],t[1]=kr[1]}}
46/*!
47 * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
48 */const ni=Rt.G1.Point,ii=Rt.G2.Point;async function oi({keyPair:e,secretKey:t,publicKey:r,includeContext:n}={}){if(!r&&!t)throw new TypeError('Export requires specifying either "publicKey" or "secretKey".');const i=t&&!!e.secretKey,c={};return n&&(c["@context"]=Rr),c.id=e.id,c.type="Multikey",c.controller=e.controller,r&&(c.publicKeyMultibase=function({curve:e,publicKey:t}={}){const r=Qn({curve:e});if(t.length!==r)throw new Error(`Invalid public key size (${t.length}); expected ${r}.`);const n=new Uint8Array(2+r);ri({curve:e,buffer:n}
48),n.set(t,2);return jr+o(n)}(e)),i&&(c.secretKeyMultibase=function({curve:e,secretKey:t}={}){const r=ei({curve:e});if(t.length!==r)throw new Error(`Invalid secret key size (${t.length}); expected ${r}.`);const n=new Uint8Array(2+r);ti({curve:e,buffer:n}),n.set(t,2);return jr+o(n)}(e)),c}async function ci({id:e,controller:t,secretKeyMultibase:r,publicKeyMultibase:n},{algorithm:i}){if(!n&&!r)throw new TypeError('Either "publicKeyMultibase" or "secretKeyMultibase" are required.');const o={id:e,controller:t,algorithm:i,curve:void 0,publicKey:void 0};let s;if(r){if("string"!=typeof r||r[0]!==jr)throw new TypeError('"secretKeyMultibase" must be a multibase, base58-encoded string.');s=c(r.slice(1)),o.curve=Jn({secretMultikey:s}),o.secretKey=s.slice(2)}if(n){if("string"!=typeof n||n[0]!==jr)throw new TypeError('"publicKeyMultibase" must be a multibase, base58-encoded string.');{const e=c(n.slice(1));o.curve=Wn({publicMultikey:e}),o.publicKey=e.slice(2),s&&function({secretMultikey:e,publicMultikey:t}){const r=Wn({publicMultikey:t}),n=Jn({secretMultikey:e});if(r!==n)throw new Error(`Public key curve ('${r}') does not match secret key curve ('${n}').`)}
49/*!
50 * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
51 */({secretMultikey:s,publicMultikey:e})}}else{const e=i.slice(4),{secretKey:t}=o,r=await async function({secretKey:e,ciphersuite:t}={}){return ve(Uint8Array,e,"secretKey"),Er({SK:Ar({secretKey:e,ciphersuite:t=br(t)}),ciphersuite:t})}({secretKey:t,ciphersuite:e});o.publicKey=r}return o}function si({jwk:e}={}){if("OKP"!==e?.kty)throw new TypeError('"jwk.kty" must be "OKP".');const{crv:t}=e,r=Qn({curve:t});let n;const o=i(e.x);if(e.y){n=function({curve:e,x:t,y:r}){const n=u(t,r);if(e===$r)return ni.fromBytes(n).toBytes(!0);if(e===Mr)return ii.fromBytes(n).toBytes(!0);throw new TypeError(`Unsupported curve "${e}".`)}({curve:t,x:o,y:i(e.y)})}else n=Uint8Array.from(o);if(n.length!==r)throw new Error(`Invalid public key size (${n.length}); expected ${r}.`);return n}function ai({jwk:e}={}){const{crv:t}=e,r=si({jwk:e}),n=new Uint8Array(2+r.length);ri({curve:t,buffer:n}),n.set(r,2);return jr+o(n)}function fi({jwk:e}={}){if("OKP"!==e?.kty)throw new TypeError('"jwk.kty" must be "OKP".');const{crv:t}=e,r=ei({curve:t}),n=Uint8Array.from(i(e.d));if(e.y&&n.reverse(),n.length!==r)throw new Error(`Invalid secret key size (${n.length}); expected ${r}.`);return n}const ui=new Set([...Object.values(Nr)]);async function di(e,t={algorithm:Nr.BBS_BLS12381_SHA256}){const r={...e};if("Multikey"!==r.type&&r.publicKeyJwk){let e,t;return"JsonWebKey"!==r.type&&"JsonWebKey2020"!==r.type||({id:e,controller:t}=r),async function({jwk:e,secretKey:t=!1,id:r,controller:n}={}){const i={"@context":Rr,type:"Multikey",publicKeyMultibase:ai({jwk:e})};"string"==typeof r&&(i.id=r);"string"==typeof n&&(i.controller=n);t&&e.d&&(i.secretKeyMultibase=function({jwk:e}={}){const t=fi({jwk:e}
51),r=new Uint8Array(2+t.length);return ti({curve:e.crv,buffer:r}),r.set(t,2),jr+o(r)}({jwk:e}));const c={algorithm:!e.alg||e.alg.startsWith("BBS-DRAFT-")?Nr.BBS_BLS12381_SHA256:e.alg};return di(i,c)}({jwk:r.publicKeyJwk,secretKey:!1,id:e,controller:t})}return r.type||(r.type="Multikey"),r["@context"]||(r["@context"]=Rr),r.controller&&!r.id&&(r.id=`${e.controller}#${e.publicKeyMultibase}`),function(e){if(!e||"object"!=typeof e)throw new TypeError('"key" must be an object.');if("Multikey"!==e.type)throw new TypeError('"key" must be a Multikey with type "Multikey".');if(!(e["@context"]===Rr||Array.isArray(e["@context"])&&e["@context"].includes(Rr)))throw new TypeError(`"key" must be a Multikey with context "${Rr}".`)}
52/*!
53 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
54 */(r),async function({keyPair:e,options:t={}}){if("string"!=typeof t?.algorithm)throw new TypeError('"options.algorithm" must be a string.');const{algorithm:r}=t;if(!ui.has(r))throw new Error(`Unknown algorithm "${r}".`);e.curve&&e.publicKey&&e.secretKey||(e=await ci(e,{algorithm:r}));const n=async({publicKey:t=!0,secretKey:r=!1,includeContext:n=!0,raw:i=!1}={})=>{if(i){const n=await async function({keyPair:e,secretKey:t=!1}={}){const r={kty:"OKP",alg:e.algorithm,crv:e.curve,x:s(e.publicKey)},n=t&&!!e.secretKey;n&&(r.d=s(e.secretKey));return r}({keyPair:e,secretKey:r}),i={curve:e.curve};return t&&(i.publicKey=si({jwk:n})),r&&(i.secretKey=fi({jwk:n})),i}return oi({keyPair:e,publicKey:t,secretKey:r,includeContext:n})},{publicKeyMultibase:i,secretKeyMultibase:o}=await n({publicKey:!0,secretKey:!0,includeContext:!0});return e={...e,algorithm:r,publicKeyMultibase:i,secretKeyMultibase:o,export:n,signer(){const{id:t,secretKey:n,publicKey:i}=e;return Yn({id:t,secretKey:n,publicKey:i,algorithm:r})},async deriveProof({signature:t,header:r,messages:n,presentationHeader:i,disclosedMessageIndexes:o}){const{algorithm:c,publicKey:s}=e;return Fr({publicKey:s,signature:t,header:r,messages:n,presentationHeader:i,disclosedMessageIndexes:o,ciphersuite:c.slice(4)})},verifier(){const{id:t,publicKey:n}=e;return function({id:e,publicKey:t,algorithm:r}){if(!t)throw new Error('"publicKey" is required for verifying.');const n=r.slice(4);return{algorithm:r,id:e,async multiverify({proof:e,header:r,presentationHeader:i,messages:o}={}){const c=o.map((e,t)=>e?t:void 0).filter(e=>void 0!==e),s=o.filter(e=>e);return Tr({publicKey:t,proof:e,header:r,presentationHeader:i,disclosedMessages:s,disclosedMessageIndexes:c,ciphersuite:n})},async verify(){throw new Error('"verify()" not implemented; use "multiverify()".')}}}({id:t,publicKey:n,algorithm:r})}}}({keyPair:r,options:t})}const li=new Uint8Array([217,93,3]),pi=[];function hi({proof:e}={}){try{if("string"!=typeof e?.proofValue)throw new TypeError('"proof.proofValue" must be a string.');if("u"!==e.proofValue[0])throw new Error("Only base64url multibase encoding is supported.");const t=i(e.proofValue.slice(1));if(!function(e,t){for(let r=0;r<t.length;++r)if(e[r]!==t[r])return!1;return!0}(t,li))throw new TypeError('"proof.proofValue" must be a derived proof.');const r=t.subarray(li.length),[n,o,c,s,a]=re(r,{useMaps:!0,tags:pi}),f=function(e){const t=new Map;for(const[r,n]of e.entries())t.set(`c14n${r}`,`b${n}`);return t}(o),u={bbsProof:n,labelMap:f,mandatoryIndexes:c,selectiveIndexes:s,presentationHeader:a};return function({bbsProof:e,labelMap:t,mandatoryIndexes:r,selectiveIndexes:n,presentationHeader:i}){if(!(e instanceof Uint8Array))throw new TypeError('"bbsProof" must be a Uint8Array.');if(!(t instanceof Map&&[...t.entries()].every(([e,t])=>"string"==typeof e&&"string"==typeof t)))throw new TypeError('"labelMap" must be a Map of strings to strings.');if(!Array.isArray(r)||!r.every(Number.isInteger))throw new TypeError('"mandatoryIndexes" must be an array of integers.');if(!Array.isArray(n)||!n.every(Number.isInteger))throw new TypeError('"selectiveIndexes" must be an array of integers.');if(!(i instanceof Uint8Array))throw new TypeError('"presentationHeader" must be a Uint8Array.')}(u),u}catch(e){const t=new TypeError('The proof does not include a valid "proofValue" property.');throw t.cause=e,t}}pi[64]=function(e){return e}
55/*!
56 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
57 */;const bi="bbs-2023",mi=[Nr.BBS_BLS12381_SHA256,"Bls12381G2"];
58/*!
59 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
60 */
61/*!
62 * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
63 */
64function yi({expectedPresentationHeader:e}={}){return{name:bi,requiredAlgorithm:mi,createVerifier:gi,createVerifyData:wi,options:{expectedPresentationHeader:e},results:{lastParsedProof:null}}}async function gi({verificationMethod:e}){const t=(await di(e)).verifier();return{algorithm:t.algorithm,id:t.id,verify:async({data:e})=>async function({verifier:e,data:t}={}){const{bbsProof:r,proofHash:n,nonMandatory:i,mandatoryHash:o,selectiveIndexes:c,presentationHeader:s}=t,a=function(e){const t=new Uint8Array(e.reduce((e,t)=>
64e+t.length,0));let r=0;for(const n of e)t.set(n,r),r+=n.length;return t}([n,o]),f=i.map(ne);if(f.length!==c.length)throw new Error(`Number of disclosed messages (${f.length}) does not equal number of "selectiveIndexes" (${c.length}).`);const u=[];for(const[e,t]of f.entries())u[c[e]]=t;return e.multiverify({proof:r,header:a,presentationHeader:s,messages:u})}({verifier:t,data:e})}}async function wi({cryptosuite:e,document:t,proof:r,documentLoader:n}){if(e?.name!==bi)throw new TypeError(`"cryptosuite.name" must be "${bi}".`);const{expectedPresentationHeader:i}=e.options;if(i&&!(i instanceof Uint8Array))throw new TypeError('"cryptosuite.options.expectedPresentationHeader" must be a Uint8Array.');const o={documentLoader:n},c=J({document:t,proof:r,options:o}).catch(e=>e),{bbsProof:s,labelMap:a,mandatoryIndexes:f,selectiveIndexes:u,presentationHeader:d}=await hi({proof:r});if(i){if(d.length!==i.length||!d.every((e,t)=>e===i[t]))return!1}else e.results.lastParsedProof={presentationHeader:d};const l=await Q({labelMap:a}),p=await ee({document:t,labelMapFactoryFunction:l,options:o}),h=[],b=[];for(const[e,t]of p.entries())f.includes(e)?h.push(t):b.push(t);const{mandatoryHash:m}=await te({mandatory:h}),y=await c;if(y instanceof Error)throw y;return{bbsProof:s,proofHash:y,nonMandatory:b,mandatoryHash:m,selectiveIndexes:u,presentationHeader:d}}const{purposes:{AssertionProofPurpose:Ei,AuthenticationProofPurpose:_i}}=a;var vi;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(vi||(vi={}));class Bi extends ie{verificationProcess=[vi.retrieveVerificationMethodPublicKey,vi.ensureVerificationMethodValidity,vi.checkDocumentSignature];documentToVerify;issuer;proof;type="Bbs2023";cryptosuite="bbs-2023";publicKey;verificationKey;verificationMethod;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:_i,assertionMethod:Ei},this.validateProofType()}
64async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map(r=>e.verifier.convertToVerificationSubsteps(t,r))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const e=this.proof.type;if("DataIntegrityProof"===e){const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`);return}if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}generateDocumentLoader(e=[]){e.forEach(e=>{t[e.url]=e.value}),t[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:f.documentLoader(e)}}getErrorMessage(e){return e.error.errors[0].message}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find(e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod)??null}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(vi.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=oe(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new r(vi.retrieveVerificationMethodPublicKey,"Could not derive the verification key",n.CRYPTOGRAPHIC_SECURITY_ERROR);if(this.verificationMethod.revoked)throw new r(vi.retrieveVerificationMethodPublicKey,"The verification key has been revoked",n.CRYPTOGRAPHIC_SECURITY_ERROR);return this.publicKey=this.verificationMethod.publicKeyMultibase,this.verificationMethod},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(vi.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new r(vi.ensureVerificationMethodValidity,"The verification key has expired",n.CRYPTOGRAPHIC_SECURITY_ERROR)}if(this.verificationMethod.revoked)throw new r(vi.ensureVerificationMethodValidity,"The verification key has been revoked",n.CRYPTOGRAPHIC_SECURITY_ERROR)},this.type)}async checkDocumentSignature(){await this.executeStep(vi.checkDocumentSignature,async()=>{const e=new W({cryptosuite:yi()}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const i=await a.verify(this.documentToVerify,{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader([{url:t,value:this.verificationKey}])});if(!i.verified)throw console.error(JSON.stringify(i,null,2)),new r(vi.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(i)}`,n.PROOF_VERIFICATION_ERROR);console.log(`Credential ${this.type} signature successfully verified`)},this.type)}}export{Bi as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.