@blockcerts/blockcerts-verifier 1.74.0 → 1.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/bundle-stats.html +1 -1
  2. package/coverage/lcov.info +102 -102
  3. package/dist/Bbs2023-Bp5cEh1R-CyaAsSfy.js +64 -0
  4. package/dist/{DataIntegrityProof-DRK-bLb_-CItV0ZXY.js → DataIntegrityProof-C6eNcfZD-DxdoQnVI.js} +1 -1
  5. package/dist/EcdsaSd2023-DZZuYYEc-CWUg-wCj.js +14 -0
  6. package/dist/{EcdsaSecp256k1Signature2019-rfxWS2XE-C73WHAtH.js → EcdsaSecp256k1Signature2019-DhXTmkRz-BDI0F5k3.js} +1 -1
  7. package/dist/{Ed25519Signature2020-CDbX0d2Z-Dc1L-exZ.js → Ed25519Signature2020-DQ74b0xi-mZPb25zD.js} +1 -1
  8. package/dist/{EddsaRdfc2022-Do0HFpDb-BcV_n8Fk.js → EddsaRdfc2022-DoIsbQDP-CdTbCYWu.js} +4 -4
  9. package/dist/MerkleProof2017-DjEiaTFN-DYmuOUac.js +1 -0
  10. package/dist/MerkleProof2019-eet_uSL0-DMgMKE-N.js +5 -0
  11. package/dist/{checkBitStringStatusList-CKk6xxUL-D99R7EXK.js → checkBitStringStatusList-imqRJLbC-BxFzQ5zP.js} +1 -1
  12. package/dist/checkCredentialSchemaConformity-drHrI5ZX-D8a64oBH.js +1 -0
  13. package/dist/{controlVerificationMethod-Blm4pE1t-BYBRLxNP.js → controlVerificationMethod-yDdxMt7K-CmPWOLBp.js} +1 -1
  14. package/dist/decode-BvGwOAqu-BaxzowN_.js +13 -0
  15. package/dist/ensureValidIssuingKey-BBsblYif-DXO_G6MC.js +1 -0
  16. package/dist/{index-C4ZZHHRx-BOdwDnYa.js → index-B5gC_Ed--DC3Wd_3X.js} +4 -4
  17. package/dist/{index-BNsIYV4r-BnYxKy2f.js → index-BALRZPPb-BXRdR9Sh.js} +2 -2
  18. package/dist/{index-CVS5Gn9h-DNgvq6Wk.js → index-D8xF_f-v-BlsVgJYJ.js} +1 -1
  19. package/dist/{index-D2bS6rRi-D_ppNIsb.js → index-Dab3X91f-dKXR6RU7.js} +4 -4
  20. package/dist/index-cqs5icUJ-DWIE-ahU.js +23 -0
  21. package/dist/{jsonld-signatures-BJXipuab-CB799Kkm.js → jsonld-signatures-B0DqrrUT-B4B7KZ3F.js} +2 -2
  22. package/dist/main.js +114 -114
  23. package/dist/{retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js → retrieveVerificationMethodPublicKey-B-kSksW4-OGh7Cdla.js} +1 -1
  24. package/dist/sha2-CJXzPerd-BVhQN7q7.js +1 -0
  25. package/dist/verifyIssuerProfile-Bn2qjtLO-CctriaZ1.js +1 -0
  26. package/dist/weierstrass-qx_4bPUU-BwaVz9Sr.js +5 -0
  27. package/package.json +2 -2
  28. package/dist/EcdsaSd2023-CdilbQE4-BlaeM9K_.js +0 -26
  29. package/dist/MerkleProof2017-5uQFQKSe-dtmePIpg.js +0 -1
  30. package/dist/MerkleProof2019-DraC60XD-B9XV8wNx.js +0 -5
  31. package/dist/checkCredentialSchemaConformity-U2NlIuJZ-swOY09NS.js +0 -1
  32. package/dist/ensureValidIssuingKey-D7OT4D35--HN0afRq.js +0 -1
  33. package/dist/index-Dr7MpiEc-D5LHgMik.js +0 -30
  34. package/dist/verifyIssuerProfile-BG-odQrl-0JjZhiiC.js +0 -1
  35. /package/dist/{HashlinkVerifier-Cdnza1Dw-A9htzw7A.js → HashlinkVerifier-CLOBeWTC-A9htzw7A.js} +0 -0
  36. /package/dist/{ensureNotRevoked-DrQAPfcJ-BheL-ZKZ.js → ensureNotRevoked-DkeMWyFL-BheL-ZKZ.js} +0 -0
  37. /package/dist/{index-uKBVup0_-Dh4-8Ruv.js → index-DBwScGKb-Dh4-8Ruv.js} +0 -0
  38. /package/dist/{index-yOIIz7AL-Dgus2xdV.js → index-DLhZKDC_-Dgus2xdV.js} +0 -0
  39. /package/dist/{jsonld-DOUjwF6J-dtl20tiV.js → jsonld-BHLXlZBJ-dtl20tiV.js} +0 -0
  40. /package/dist/{webcrypto.es-FKUHCUj--gGk5JRJH.js → webcrypto.es-D4KX-5fg-gGk5JRJH.js} +0 -0
@@ -1 +1 @@
1
- import{V as e,d as i,P as r}from"./main.js";import{b as t}from"./index-yOIIz7AL-Dgus2xdV.js";function o(o,n){if(!o.verificationMethod)return void console.warn("No verification method found in the issuer document. This will likely become a requirement in the near future");const a=n.split("#")[1],s=o.verificationMethod.find(e=>e.id===`#${a}`||e.id===n);if(!s)throw new e("retrieveVerificationMethodPublicKey",`${t} - ${i.i18n.getText("errors","retrieveVerificationMethodPublicKey")}`,r.CRYPTOGRAPHIC_SECURITY_ERROR);return{...s}}export{o as r};
1
+ import{V as e,d as i,P as r}from"./main.js";import{b as t}from"./index-DLhZKDC_-Dgus2xdV.js";function o(o,n){if(!o.verificationMethod)return void console.warn("No verification method found in the issuer document. This will likely become a requirement in the near future");const a=n.split("#")[1],s=o.verificationMethod.find(e=>e.id===`#${a}`||e.id===n);if(!s)throw new e("retrieveVerificationMethodPublicKey",`${t} - ${i.i18n.getText("errors","retrieveVerificationMethodPublicKey")}`,r.CRYPTOGRAPHIC_SECURITY_ERROR);return{...s}}export{o as r};
@@ -0,0 +1 @@
1
+ const t=(()=>BigInt(2**32-1))(),e=BigInt(32);function n(n,r=!1){return r?{h:Number(n&t),l:Number(n>>e&t)}:{h:0|Number(n>>e&t),l:0|Number(n&t)}}function r(t,e=!1){const r=t.length;let o=new Uint32Array(r),s=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:h}=n(t[i],e);[o[i],s[i]]=[r,h]}return[o,s]}function o(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}const s=t=>t?`"${t}" `:"";function i(t,e=""){if("number"!=typeof t)throw new TypeError(s(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(s(e)+"expected integer >= 0, got "+t);return t}function h(t,e=""){if("boolean"!=typeof t)throw new TypeError(s(e)+"expected boolean, got type="+typeof t);return t}function f(t,e,n=""){if(o(t)&&(void 0===e||t.length===e))return t;void 0!==e&&i(e,"length");const r=o(t),h=void 0!==e?` of length ${e}`:"",f=r?`length=${t.length}`:"type="+typeof t,c=s(n)+"expected Uint8Array"+h+", got "+f;if(!r)throw new TypeError(c);throw new RangeError(c)}function c(t){if("function"!=typeof t||"function"!=typeof t.create)throw new TypeError("expected hash wrapped by utils.createHasher");if(i(t.outputLen),i(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}const u=(t,e)=>{((t,e)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(("object"===e?"":`"${e}" `)+"expected object, got type="+typeof t)})(t,e);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&null!==n)throw new TypeError(`"${e}" expected plain object`);if(Object.hasOwn(t,"__proto__"))throw new TypeError(`"${e}.__proto__" is not allowed`)};function a(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function l(t,e){f(t,void 0,"output");const n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function p(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function d(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function y(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function g(t,e){return t<<32-e|t>>>e}function w(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const b=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=w(t[e]);return t},E=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),A=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function L(t){if(f(t),E)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=A[t[n]];return e}function x(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function m(t){if("string"!=typeof t)throw new TypeError("hex string expected, got "+typeof t);if(E)try{return Uint8Array.fromHex(t)}catch(t){if(t instanceof SyntaxError)throw new RangeError(t.message);throw t}const e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,o=0;e<n;e++,o+=2){const n=x(t.charCodeAt(o)),s=x(t.charCodeAt(o+1));if(void 0===n||void 0===s){const e=t[o]+t[o+1];throw new RangeError('hex string expected, got non-hex character "'+e+'" at index '+o)}r[e]=16*n+s}return r}function U(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];f(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const o=t[e];n.set(o,r),r+=o.length}return n}function O(t,e,n="opts"){u(t,"defaults"),void 0!==e&&u(e,n);return Object.assign(Object.create(null),t,e)}function _(t,e={}){if("function"!=typeof t)throw new TypeError('"hashCons" expected function, got type='+typeof t);e=O({},e,"info");const n=(e,n)=>t(n).update(e).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=e=>t(e),Object.assign(n,e),Object.freeze(n)}function T(t=32){i(t,"bytesLength");const e="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof e?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}const v=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function j(t,e,n){return t&e^~t&n}function C(t,e,n){return t&e^t&n^e&n}class R{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,r){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=y(this.buffer)}update(t){a(this),f(t);const{view:e,buffer:n,blockLen:r}=this,o=t.length;let s=!1;for(let i=0;i<o;){const h=Math.min(r-this.pos,o-i);if(h===r){const e=y(t);for(;r<=o-i;i+=r)this.process(e,i);s=!0;continue}n.set(0===i&&h===o?t:t.subarray(i,i+h),this.pos),this.pos+=h,i+=h,this.pos===r&&(this.process(e,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){a(this),l(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;e[s++]=128,e.fill(0,s),this.padOffset>r-s&&(this.process(n,0),e.fill(0)),function(t,e,n,r){const o=(t=>t/2**32|0)(n),s=(t=>t>>>0)(n);t.setUint32(e,r?s:o,r),t.setUint32(e+4,r?o:s,r)}(n,r-8,8*this.length,o),this.process(n,0),this.roundClean();const i=t===e?n:y(t),h=this.outputLen,f=h/4,c=this.get();if(h%4||f>c.length)throw new Error("invalid outputLen");for(let t=0;t<f;t++)i.setUint32(4*t,c[t],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneIntoMeta(t){const{buffer:e,length:n,finished:r,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=r,t.length=n,t.pos=s,s&&t.buffer.set(e),t}clone(){return this._cloneInto()}}const B=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),H=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),k=new Uint32Array(64);class F extends R{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,e){super(64,t,8,!1),this.A=0|e[0],this.B=0|e[1],this.C=0|e[2],this.D=0|e[3],this.E=0|e[4],this.F=0|e[5],this.G=0|e[6],this.H=0|e[7]}get(){const{A:t,B:e,C:n,D:r,E:o,F:s,G:i,H:h}=this;return[t,e,n,r,o,s,i,h]}set(t,e,n,r,o,s,i,h){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|h}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,e){for(let n=0;n<16;n++,e+=4)k[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=k[t-15],n=k[t-2],r=g(e,7)^g(e,18)^e>>>3,o=g(n,17)^g(n,19)^n>>>10;k[t]=o+k[t-7]+r+k[t-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:h,G:f,H:c}=this;for(let t=0;t<64;t++){const e=c+(g(i,6)^g(i,11)^g(i,25))+j(i,h,f)+H[t]+k[t]|0,u=(g(n,2)^g(n,13)^g(n,22))+C(n,r,o)|0;c=f,f=h,h=i,i=s+e|0,s=o,o=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,h=h+this.F|0,f=f+this.G|0,c=c+this.H|0,this.set(n,r,o,s,i,h,f,c)}roundClean(){d(k)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),d(this.buffer)}}class I extends F{constructor(){super(32,B)}}const D=_(()=>new I,v(1));export{O as a,i as b,_ as c,h as d,b as e,a as f,f as g,l as h,d as i,r as j,U as k,L as l,c as m,o as n,v as o,m as p,T as r,D as s,p as u};
@@ -0,0 +1 @@
1
+ import{H as t,I as r}from"./main.js";async function e(e){if(!e.proof)return void console.warn("No proof found in the issuer profile.");let o=e.proof.type;"DataIntegrityProof"===o&&(o=t(e.proof.cryptosuite));const i=await async function(t){if(t===r.MerkleProof2019){const{default:t}=await import("./MerkleProof2019-eet_uSL0-DMgMKE-N.js");return t}if(t===r.Ed25519Signature2020){const{default:t}=await import("./Ed25519Signature2020-DQ74b0xi-mZPb25zD.js");return t}if(t===r.EcdsaSecp256k1Signature2019){const{default:t}=await import("./EcdsaSecp256k1Signature2019-DhXTmkRz-BDI0F5k3.js");return t}if(t===r.EcdsaSd2023){const{default:t}=await import("./EcdsaSd2023-DZZuYYEc-CWUg-wCj.js");return t}if(t===r.Bbs2023){const{default:t}=await import("./Bbs2023-Bp5cEh1R-CyaAsSfy.js");return t}}(o),a=new i({document:e,proof:e.proof,issuer:e.issuer?e.issuer:e,executeStep:async(t,r,e)=>r()});await a.init();try{await a.verifyProof()}catch(t){throw new Error(`Issuer profile verification failed: ${t.message}`)}}export{e as default};
@@ -0,0 +1,5 @@
1
+ import{k as t,l as e,m as r,g as n,r as o,n as i,p as s,b as a,i as c,f as u,h as d}from"./sha2-CJXzPerd-BVhQN7q7.js";
2
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function f(t,e,r=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let n=0;n<t.length;n++)r(t[n],`${e}[${n}]`);return t}const l=(t,e,r)=>n(t,e,r),h=a;function w(t,e="object"){if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError("object"===e?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function p(t,e){if("function"!=typeof t)throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}const g=e,y=(...e)=>t(...e),m=t=>s(t),E=i,b=t=>o(t),v=BigInt(0),B=BigInt(1);function R(t,e=""){if("boolean"!=typeof t)throw new TypeError((t=>t?`"${t}" `:"")(e)+"expected boolean, got type="+typeof t);return t}function O(t){if("bigint"==typeof t){if(!N(t))throw new RangeError("positive bigint expected, got "+t)}else h(t);return t}function x(t,e=""){if("number"!=typeof t){throw new TypeError((e&&`"${e}" `)+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){throw new RangeError((e&&`"${e}" `)+"expected safe integer, got "+t)}}function S(t){const e=O(t).toString(16);return 1&e.length?"0"+e:e}function T(t){if("string"!=typeof t)throw new TypeError("hex string expected, got "+typeof t);return""===t?v:BigInt("0x"+t)}function I(t){return T(e(t))}function A(t){return T(e(P(n(t)).reverse()))}function q(t,e){if(a(e),0===e)throw new Error("zero output length is invalid");const r=2*e,n=(t=O(t)).toString(16);if(n.length>r)throw new RangeError("number is too large");return s(n.padStart(r,"0"))}function F(t,e){return q(t,e).reverse()}function P(t){return Uint8Array.from(l(t))}function Z(t){if("string"!=typeof t)throw new TypeError("ascii string expected, got "+typeof t);return Uint8Array.from(t,(e,r)=>{const n=e.charCodeAt(0);if(1!==e.length||n>127)throw new RangeError(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})}function N(t){return"bigint"==typeof t&&v<=t}function C(t,e,r){return N(t)&&N(e)&&N(r)&&e<=t&&t<r}function D(t,e,r,n){if(!C(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function j(t){if(t<v)throw new Error("expected non-negative bigint, got "+t);return t===v?0:t.toString(2).length}function V(t,e){if("bigint"!=typeof t)throw new TypeError('"n" expected bigint, got type='+typeof t);return x(e,"pos"),t>>BigInt(e)&B}const k=t=>(x(t,"n"),(B<<BigInt(t))-B);function H(t,e={},r={},n="object"){w(t,n),w(e,"fields"),w(r,"optFields");const o=(e,r)=>Object.entries(e).forEach(([e,o])=>function(e,r,o){const i="object"===n?`param "${String(e)}"`:`"${n}.${String(e)}"`,s=t[e];if(!Object.hasOwn(t,e)&&(o?void 0!==s:"function"!==r))throw new TypeError(`${i} is invalid: expected own property`);if(o&&void 0===s)return;const a=typeof s;if(a!==r||null===s)throw new TypeError(`${i} is invalid: expected ${r}, got ${a}`)}(e,o,r));o(e,!1),o(r,!0)}const L=()=>{throw new Error("not implemented")},U=BigInt(0),$=BigInt(1),z=BigInt(2),Y=BigInt(3),K=BigInt(4),_=BigInt(5),M=BigInt(7),W=BigInt(8),X=BigInt(9),G=BigInt(15),J=BigInt(16),Q=BigInt("0x10000000000000000");
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function tt(t,e){if(e<=U)throw new Error("mod: expected positive modulus, got "+e);const r=t%e;return r>=U?r:e+r}function et(t,e,r){if(r<=$)throw new Error("pow: expected modulus > 1, got "+r);if("bigint"!=typeof e)throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<U)throw new Error("invalid exponent, negatives unsupported");if(e===U)return $;if(e===$)return t;let n=t%r;if(n<U&&(n+=r),e<Q){let t=$;for(;e>U;)e&$&&(t=t*n%r),n=n*n%r,e>>=$;return t}const o=[];for(;e>U;)o.push(Number(e&G)),e>>=K;const i=new Array(16);i[0]=$,i[1]=n;for(let t=2;t<16;t++)i[t]=i[t-1]*n%r;let s=i[o[o.length-1]];for(let t=o.length-2;t>=0;t--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;const e=o[t];0!==e&&(s=s*i[e]%r)}return s}function rt(t,e,r){if(r<=$)throw new Error("pow2: expected modulus > 1, got "+r);if(e<U)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >U;)n*=n,n%=r;return n}function nt(t,e){if(t===U)throw new Error("invert: expected non-zero number");if(e<=$)throw new Error("invert: expected modulus > 1, got "+e);let r=tt(t,e),n=e,o=U,i=$;for(;r!==U;){const t=n/r,e=n-r*t,s=o-i*t;n=r,r=e,o=i,i=s}if(n!==$)throw new Error("invert: does not exist");return tt(o,e)}function ot(t,e,r){const n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function it(t,e){if((t&$)===U)throw new Error(e+": expected odd modulus, got "+t)}function st(t,e){const r=t,n=(r.ORDER+$)/K,o=r.pow(e,n);return ot(r,o,e),o}function at(t,e){const r=t,n=(r.ORDER-_)/W,o=r.mul(e,z),i=r.pow(o,n),s=r.mul(e,i),a=r.mul(r.mul(s,z),i),c=r.mul(s,r.sub(a,r.ONE));return ot(r,c,e),c}function ct(t){if(t<Y)throw new Error("sqrt is not defined for small field");it(t,"tonelliShanks");let e=t-$,r=0;for(;e%z===U;)e/=z,r++;let n=z;const o=mt(t);for(;1===wt(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return st;let i=o.pow(n,e);const s=(e+$)/z;return function(t,n){const o=t;if(o.is0(n))return n;if(1!==wt(o,n))throw new Error("Cannot find square root");let a=r,c=o.mul(o.ONE,i),u=o.pow(n,e),d=o.pow(n,s);for(;!o.eql(u,o.ONE);){if(o.is0(u))throw new Error("Cannot find square root: probably non-prime P");let t=1,e=o.sqr(u);for(;!o.eql(e,o.ONE);)if(t++,e=o.sqr(e),t===a)throw new Error("Cannot find square root");const r=$<<BigInt(a-t-1),n=o.pow(c,r);a=t,c=o.sqr(n),u=o.mul(u,c),d=o.mul(d,n)}return d}}function ut(t){return it(t,"Fp.sqrt"),t%K===Y?st:t%W===_?at:t%J===X?function(t){const e=mt(t),r=ct(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+M)/J;return(t,e)=>{const r=t;let a=r.pow(e,s),c=r.mul(a,n);const u=r.mul(a,o),d=r.mul(a,i),f=r.eql(r.sqr(c),e),l=r.eql(r.sqr(u),e);a=r.cmov(a,c,f),c=r.cmov(d,u,l);const h=r.eql(r.sqr(c),e),w=r.cmov(a,c,h);return ot(r,w,e),w}}(t):ct(t)}const dt=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ft(t){if(w(t,"field"),"bigint"!=typeof t.ORDER)throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);x(t.BYTES,"BYTES"),x(t.BITS,"BITS");for(const e of dt)p(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=$)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function lt(t,e,r){ft(t);const n=t;if("bigint"!=typeof r)throw new TypeError("invalid exponent: expected bigint, got "+typeof r);if(r<U)throw new Error("invalid exponent, negatives unsupported");if(r===U)return n.ONE;if(r===$)return e;if(r<Q){let t=n.ONE,o=e;for(;r>U;)r&$&&(t=n.mul(t,o)),o=n.sqr(o),r>>=$;return t}const o=[];for(;r>U;)o.push(Number(r&G)),r>>=K;const i=new Array(16);i[0]=n.ONE,i[1]=e;for(let t=2;t<16;t++)i[t]=n.mul(i[t-1],e);let s=i[o[o.length-1]];for(let t=o.length-2;t>=0;t--){s=n.sqr(n.sqr(n.sqr(n.sqr(s))));const e=o[t];0!==e&&(s=n.mul(s,i[e]))}return s}function ht(t,e,r=!1){ft(t),f(e,"nums"),R(r,"passZero");const n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),i=e.reduce((t,e,r)=>n.is0(e)?t:(o[r]=t,n.mul(t,e)),n.ONE),s=n.inv(i);return e.reduceRight((t,e,r)=>n.is0(e)?t:(o[r]=n.mul(t,o[r]),n.mul(t,e)),s),o}function wt(t,e){ft(t);const r=t;it(r.ORDER,"FpLegendre");const n=(r.ORDER-$)/z,o=r.pow(e,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function pt(t,e){return-1!==wt(t,e)}const gt=new WeakMap;class yt{ORDER;BITS;BYTES;isLE;ZERO=U;ONE=$;_lengths;_mod;constructor(t,e={}){if(t<=$)throw new Error("invalid field: expected ORDER > 1, got "+t);let r;this.isLE=!1,null!=e&&"object"==typeof e&&("number"==typeof e.BITS&&(r=e.BITS),"function"==typeof e.sqrt&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),"boolean"==typeof e.isLE&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),"boolean"==typeof e.modFromBytes&&(this._mod=e.modFromBytes));const{nBitLength:n,nByteLength:o}=function(t,e){if(void 0!==e&&h(e),t<=U)throw new Error("invalid n length: expected positive n, got "+t);if(void 0!==e&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);const r=j(t);if(void 0!==e&&e<r)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${r})`);const n=void 0!==e?e:r;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}(t,r);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=o,Object.freeze(this)}create(t){return tt(t,this.ORDER)}isValid(t){if("bigint"!=typeof t)throw new TypeError("invalid field element: expected bigint, got "+typeof t);return U<=t&&t<this.ORDER}is0(t){return t===U}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&$)===$}neg(t){return tt(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return tt(t*t,this.ORDER)}add(t,e){return tt(t+e,this.ORDER)}sub(t,e){return tt(t-e,this.ORDER)}mul(t,e){return tt(t*e,this.ORDER)}pow(t,e){return et(t,e,this.ORDER)}div(t,e){return tt(t*nt(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return nt(t,this.ORDER)}sqrt(t){let e=gt.get(this);return e||gt.set(this,e=ut(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?F(t,this.BYTES):q(t,this.BYTES)}fromBytes(t,e=!1){l(t);const{_lengths:r,BYTES:n,isLE:o,ORDER:i,_mod:s}=this;if(r){if(t.length<1||!r.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);const e=new Uint8Array(n);e.set(t,o?0:e.length-t.length),t=e}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let a=o?A(t):I(t);if(s&&(a=tt(a,i)),!e&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return ht(this,t,!0)}cmov(t,e,r){return R(r,"condition"),r?e:t}}function mt(t,e={}){return Object.freeze(yt.prototype),new yt(t,e)}function Et(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");if(t<=$)throw new Error("field order must be greater than 1");const e=j(t-$);return Math.ceil(e/8)}function bt(t){const e=Et(t);return e+Math.ceil(e/2)}function vt(t,e,r=!1){l(t);const n=t.length,o=Et(e),i=Math.max(bt(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const s=tt(r?A(t):I(t),e-$)+$;return r?F(s,o):q(s,o)}
4
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bt=BigInt(0),Rt=BigInt(1),Ot=BigInt(4),xt=(()=>2**31)();function St(t){const e=t;if("function"!=typeof e)throw new TypeError('"Point" expected constructor, got type='+typeof t);p(e.fromAffine,"Point.fromAffine"),p(e.fromBytes,"Point.fromBytes"),p(e.fromHex,"Point.fromHex"),w(e.BASE,"Point.BASE"),w(e.ZERO,"Point.ZERO"),ft(e.Fp),ft(e.Fn)}function Tt(t,e){if(void 0!==t){p(t,"randomBytes");try{const r=t(e);if(!E(r)||r.length!==e)return}catch{return}return t}}function It(t,e){f(t,"points"),t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}const At=new WeakMap;function qt(t){return At.get(t)||1}class Ft{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,e){St(t),this.randomBytes=Tt(e,16),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,e,r){const n=Math.ceil(r/e)+1,o=2**(e-1),i=[];let s=t;for(let t=0;t<n;t++){let t=s;for(let e=0;e<o;e++)i.push(t),t=t.add(s);s=i[i.length-1].double()}return{W:e,bits:r,windows:n,comp:i}}wnafCachedCT(t,e){const{W:r,windows:n,comp:o}=t,i=2**(r-1),s=function(t,e,r){const n=2**e,o=n/2,i=BigInt(n-1),s=BigInt(e),a=[];for(let e=0;e<r;e++){let e=Number(t&i);t>>=s,e>o&&(e-=n,t+=Rt),a.push(e)}if(t!==Bt)throw new Error("invalid wnaf");return a}(e,r,n);let a=this.ZERO,c=this.BASE;for(let t=0;t<n;t++){const e=s[t],r=t*i,n=Math.abs(e)-1;let u=o[r];for(let t=1;t<i;t++)u=t===n?o[r+t]:u;const d=u.negate();0===e?c=c.add(o[r]):a=a.add(e<0?d:u)}return{p:a,f:c}}getWnafPrecomputes(t,e,r,n){let o=this.wnafPrecomputes.get(e),i=o?.find(e=>e.W===t&&e.bits===r);return i||(i=this.buildWnafTable(e,t,r),"function"==typeof n&&(i={...i,comp:n(i.comp)}),o||(o=[],this.wnafPrecomputes.set(e,o)),o.push(i)),i}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,e){if(this.assertPoint(t),!C(e,Rt,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,e,r,n){const o=qt(t);return 1===o?this.fixedWindowCT(t,e,r):this.wnafCachedCT(this.getWnafPrecomputes(o,t,r,n),e)}mulCT(t,e,r){return this.validateMulInput(t,e),this.runCT(t,e,this.bits,r)}mulCTBlinded(t,e,r){if(this.validateMulInput(t,e),void 0===this.randomBytes)throw new Error("randomBytes is required for scalar blinding");const n=this.Point.Fn.BITS+128,o=this.randomBytes(16);if(!E(o)||16!==o.length)throw new Error("randomBytes returned invalid byte array");o[0]=63&o[0]|128;const i=e+I(o)*this.Point.Fn.ORDER;return this.runCT(t,i,n,r)}fixedWindowCT(t,e,r){const n=k(5),o=new Array(32);o[0]=this.ZERO;for(let e=1;e<32;e++)o[e]=o[e-1].add(t);const i=Math.ceil(r/5);let s=this.ZERO;for(let t=i-1;t>=0;t--){if(t!==i-1)for(let t=0;t<5;t++)s=s.double();const r=Number(e>>BigInt(5*t)&n);let a=o[0];for(let t=1;t<32;t++)a=t===r?o[t]:a;s=s.add(a)}return{p:s,f:s}}shouldBlind(t,e){return void 0!==this.randomBytes&&(e===Rt||t===this.BASE&&(void 0===this.baseCanBeBlinded&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded))}mulSecret(t,e,r,n){return this.shouldBlind(t,r)?this.mulCTBlinded(t,e,n):this.mulCT(t,e,n)}mulUnsafe(t,e,r){if(this.assertPoint(t),!N(e))throw new Error("invalid scalar");const n=qt(t);if(1===n||e>=this.Point.Fn.ORDER)return Pt(this.Point,[t],[e],!0);const o=this.getWnafPrecomputes(n,t,this.bits,r);return this.wnafCachedCT(o,e).p}setWindowSize(t,e){this.assertPoint(t),function(t,e,r=1){if(!Number.isSafeInteger(t)||t<r||t>e)throw new Error("invalid window size, expected ["+r+".."+e+"], got W="+t)}(e,this.bits);!function(t,e){const r=t*(4*e+128);if(r>xt)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+xt/2**20+" MiB")}((Math.ceil((this.bits+128)/e)+1)*2**(e-1),this.Point.Fp.BYTES),At.set(t,e),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return 1!==qt(t)}}function Pt(t,e,r,n=!1){if(St(t),It(e,t),R(n,"allowOversized"),function(t,e,r){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,n)=>{if(!(void 0===r?e.isValid(t):N(t)&&t<r))throw new Error("invalid scalar at index "+n)})}(r,t.Fn,n?t.Fn.ORDER**Ot:void 0),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=e.map(t=>function(t,e){const r=t.double(),n=[t];for(let t=1;t<e;t++)n.push(n[t-1].add(r));return n}(t,4)),i=r.map(t=>function(t,e){const r=2**e,n=r/2,o=BigInt(r-1),i=[];for(;t>Bt;){let e=0;t&Rt&&(e=Number(t&o),e>=n&&(e-=r),t-=BigInt(e)),i.push(e),t>>=Rt}return i}(t,4));return function(t,e,r){let n=0;for(const t of r)n=Math.max(n,t.length);let o=t;for(let t=n-1;t>=0;t--){t!==n-1&&(o=o.double());for(let n=0;n<r.length;n++){const i=r[n][t];if(i){const t=e[n][Math.abs(i)-1>>1];o=o.add(i<0?t.negate():t)}}}return o}(t.ZERO,o,i)}function Zt(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ft(e),e}return mt(t,{isLE:r})}class Nt{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(r(t),n(e,void 0,"key"),this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(e.length>o?t.create().update(e).digest():e);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),c(i)}update(t){return u(this),this.iHash.update(t),this}digestInto(t){u(this),d(t,this),this.finished=!0;const e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});const{oHash:e,iHash:r,finished:n,destroyed:o,blockLen:i,outputLen:s,canXOF:a}=this;return t.finished=n,t.destroyed=o,t.blockLen=i,t.outputLen=s,t.canXOF=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ct=(()=>{const t=(t,e,r)=>new Nt(t,e).update(r).digest();return t.create=(t,e)=>new Nt(t,e),t})(),Dt=BigInt(0);
5
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */class jt extends Error{constructor(t=""){super(t)}}const Vt={Err:jt,_tlv:{encode:(t,e)=>{const{Err:r}=Vt;if(x(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(function(t,e=""){if("string"!=typeof t)throw new TypeError((e&&`"${e}" `)+"expected string, got type="+typeof t)}(e,"data"),1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,o=S(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");const i=n>127?S(o.length/2|128):"";return S(t)+i+o+e},decode(t,e){const{Err:r}=Vt;e=l(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.decode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const o=e[n++];let i=0;if(!!(128&o)){const t=127&o;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const s=e.subarray(n,n+t);if(s.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===s[0])throw new r("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(n+=t,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=o;const s=e.subarray(n,n+i);if(s.length!==i)throw new r("tlv.decode: wrong value length");return{v:s,l:e.subarray(n+i)}}},_int:{encode(t){const{Err:e}=Vt;if(O(t),t<Dt)throw new e("integer: negative integers are not allowed");let r=S(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Vt;if(t.length<1)throw new e("invalid signature integer: empty");if(128&t[0])throw new e("invalid signature integer: negative");if(t.length>1&&0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return I(t)}},toSig(t,e){const{Err:r,_int:n,_tlv:o}=Vt;if(void 0!==e&&(x(e,"maxScalarBytes"),e<1))throw new r("invalid signature: maxScalarBytes must be positive");const i=l(t,void 0,"signature"),{v:s,l:a}=o.decode(48,i);if(a.length)throw new r("invalid signature: left bytes after parsing");const{v:c,l:u}=o.decode(2,s),{v:d,l:f}=o.decode(2,u);if(f.length)throw new r("invalid signature: left bytes after parsing");if(void 0!==e&&(c.length>e||d.length>e))throw new r("invalid signature: integer too large");return{r:n.decode(c),s:n.decode(d)}},hexFromSig(t){const{_tlv:e,_int:r}=Vt;H(t,{r:"bigint",s:"bigint"},{},"sig");const n=e.encode(2,r.encode(t.r))+e.encode(2,r.encode(t.s));return e.encode(48,n)}},kt=(()=>(Object.freeze(Vt._tlv),Object.freeze(Vt._int),Object.freeze(Vt)))(),Ht=(t,e)=>(t+(t>=0?e:-e)/Yt)/e;function Lt(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ut(t,e){H(t);const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return R(r.lowS,"lowS"),R(r.prehash,"prehash"),void 0!==r.format&&Lt(r.format),r}const $t=BigInt(0),zt=BigInt(1),Yt=BigInt(2),Kt=BigInt(3),_t=BigInt(4);function Mt(t,e={}){const r=function(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);H(r);for(const t of["p","n","h"]){const r=e[t];if(!N(r)||r===Bt)throw new Error(`CURVE.${t} must be positive bigint`)}const o=Zt(e.p,r.Fp,n),i=Zt(e.n,r.Fn,n),s=["Gx","Gy","a","b"];for(const t of s)if(!o.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:o,Fn:i}}("weierstrass",t,e),n=r.Fp,o=r.Fn;let i=r.CURVE;const{h:s,n:a}=i;H(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});const{endo:c,allowInfinityPoint:u,clearCofactor:d,isTorsionFree:f,fromBytes:h,toBytes:w}=e,p=void 0===e.randomBytes?b:e.randomBytes;if(c&&(!n.is0(i.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const E=c?{beta:c.beta,basises:c.basises.map(t=>[...t])}:void 0,v=Xt(n,o);function B(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const O=void 0===w?function(t,e,r){if(e.is0()){if(!u)throw new Error("bad point: ZERO");return Uint8Array.of(0)}const{x:o,y:i}=e.toAffine(),s=n.toBytes(o);if(R(r,"isCompressed"),r){B();const t=!n.isOdd(i);return y(Wt(t),s)}return y(Uint8Array.of(4),s,n.toBytes(i))}:w,x=void 0===h?function(t){l(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=v,o=t.length,i=t[0],s=t.subarray(1);if(u&&1===o&&0===i)return{x:n.ZERO,y:n.ZERO};if(o!==e||2!==i&&3!==i){if(o===r&&4===i){const t=n.BYTES,e=n.fromBytes(s.subarray(0,t)),r=n.fromBytes(s.subarray(t,2*t));if(!A(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${o}, expected compressed=${e} or uncompressed=${r}`)}{const t=n.fromBytes(s);if(!n.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=I(t);let r;try{r=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}B();return!(1&~i)!==n.isOdd(r)&&(r=n.neg(r)),{x:t,y:r}}}:h,S=n.mul(i.b,Kt),T=n.is0(i.a)?t=>n.ZERO:t=>n.mul(i.a,t);function I(t){const e=n.sqr(t),r=n.mul(e,t);return n.add(n.add(r,n.mul(t,i.a)),i.b)}function A(t,e){const r=n.sqr(e),o=I(t);return n.eql(r,o)}if(!A(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const q=n.mul(n.pow(i.a,Kt),_t),F=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(q,F)))throw new Error("bad curve params: a or b");function P(t,e,r=!1){if(!n.isValid(e)||r&&n.is0(e))throw new Error(`bad point coordinate ${t}`);return"object"==typeof e&&null!==e?n.create(e):e}function Z(t){if(!(t instanceof U))throw new Error("Weierstrass Point expected")}function C(t){if(!E||!E.basises)throw new Error("no endo");return function(t,e,r){D("scalar",t,$t,r);const[[n,o],[i,s]]=e,a=Ht(s*t,r),c=Ht(-o*t,r);let u=t-a*n-c*i,d=-a*o-c*s;const f=u<$t,l=d<$t;f&&(u=-u),l&&(d=-d);const h=k(Math.ceil(j(r)/2))+zt;if(u<$t||u>=h||d<$t||d>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:l,k2:d}}(t,E.basises,o.ORDER)}function V(t,e,r,i){if(!o.isValid(i))throw new RangeError("invalid scalar: out of range");if(E){const{k1neg:o,k1:s,k2neg:a,k2:c}=C(i),u=new U(n.mul(r.X,E.beta),r.Y,r.Z);t.push(o?r.negate():r,a?u.negate():u),e.push(s,c)}else t.push(r),e.push(i)}const L=new WeakSet;class U{static BASE=new U(i.Gx,i.Gy,n.ONE);static ZERO=new U(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(t,e,r){this.X=P("x",t),this.Y=P("y",e,!0),this.Z=P("z",r),Object.freeze(this)}static CURVE(){return i}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof U)throw new Error("projective point not allowed");return n.is0(e)&&n.is0(r)?U.ZERO:new U(e,r,n.ONE)}static fromBytes(t){const e=U.fromAffine(x(l(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return U.fromBytes(m(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=6,e=!0){return z.setWindowSize(this,t),e||this.multiply(Kt),this}assertValidity(){const t=this;if(t.is0()){if(u&&n.is0(t.X)&&n.eql(t.Y,n.ONE)&&n.is0(t.Z))return;throw new Error("bad point: ZERO")}if(L.has(t))return;const{x:e,y:r}=t.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not field elements");if(!A(e,r))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");L.add(t)}hasEvenY(){const{y:t}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(t)}equals(t){Z(t);const{X:e,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=t,c=n.eql(n.mul(e,a),n.mul(i,o)),u=n.eql(n.mul(r,a),n.mul(s,o));return c&&u}negate(){return new U(this.X,n.neg(this.Y),this.Z)}double(){const{X:t,Y:e,Z:r}=this;let o=n.ZERO,i=n.ZERO,s=n.ZERO,a=n.mul(t,t),c=n.mul(e,e),u=n.mul(r,r),d=n.mul(t,e);return d=n.add(d,d),s=n.mul(t,r),s=n.add(s,s),o=T(s),i=n.mul(S,u),i=n.add(o,i),o=n.sub(c,i),i=n.add(c,i),i=n.mul(o,i),o=n.mul(d,o),s=n.mul(S,s),u=T(u),d=n.sub(a,u),d=T(d),d=n.add(d,s),s=n.add(a,a),a=n.add(s,a),a=n.add(a,u),a=n.mul(a,d),i=n.add(i,a),u=n.mul(e,r),u=n.add(u,u),a=n.mul(u,d),o=n.sub(o,a),s=n.mul(u,c),s=n.add(s,s),s=n.add(s,s),new U(o,i,s)}add(t){Z(t);const{X:e,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=t;let c=n.ZERO,u=n.ZERO,d=n.ZERO,f=n.mul(e,i),l=n.mul(r,s),h=n.mul(o,a),w=n.add(e,r),p=n.add(i,s);w=n.mul(w,p),p=n.add(f,l),w=n.sub(w,p),p=n.add(e,o);let g=n.add(i,a);return p=n.mul(p,g),g=n.add(f,h),p=n.sub(p,g),g=n.add(r,o),c=n.add(s,a),g=n.mul(g,c),c=n.add(l,h),g=n.sub(g,c),d=T(p),c=n.mul(S,h),d=n.add(c,d),c=n.sub(l,d),d=n.add(l,d),u=n.mul(c,d),l=n.add(f,f),l=n.add(l,f),h=T(h),p=n.mul(S,p),l=n.add(l,h),h=n.sub(f,h),h=T(h),p=n.add(p,h),f=n.mul(l,p),u=n.add(u,f),f=n.mul(g,p),c=n.mul(w,c),c=n.sub(c,f),f=n.mul(w,l),d=n.mul(g,d),d=n.add(d,f),new U(c,u,d)}subtract(t){return Z(t),this.add(t.negate())}is0(){return this.equals(U.ZERO)}multiply(t){if(!o.isValidNot0(t))throw new RangeError("invalid scalar: out of range");const{p:e,f:r}=z.mulSecret(this,t,s,$);return $([e,r])[0]}multiplyUnsafe(t){const e=this,r=t;if(!o.isValid(r))throw new RangeError("invalid scalar: out of range");if(r===$t||e.is0())return U.ZERO;if(r===zt)return e;if(z.hasWindowSize(this))return z.mulUnsafe(e,r,$);const n=[],i=[];return V(n,i,e,r),Pt(U,n,i)}mulAddUnsafe(t,e,r){Z(e);const n=[],o=[];return V(n,o,this,t),V(n,o,e,r),Pt(U,n,o)}toAffine(t){let e=t;if(null!=e&&!n.isValid(e))throw new RangeError('"invertedZ" expected valid field element');const{X:r,Y:o,Z:i}=this;if(n.eql(i,n.ONE))return{x:r,y:o};const s=this.is0();null==e&&(e=s?n.ONE:n.inv(i));const a=n.mul(r,e),c=n.mul(o,e),u=n.mul(i,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}isTorsionFree(){return s===zt||(f?f(U,this):z.mulUnsafe(this,a).is0())}clearCofactor(){return s===zt?this:d?d(U,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===zt?this.is0():this.clearCofactor().is0()}toBytes(t=!0){return R(t,"isCompressed"),this.assertValidity(),O(U,this,t)}toHex(t=!0){return g(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const $=t=>function(t,e){St(t),It(e,t);const r=ht(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}(U,t),z=new Ft(U,p);return z.bits>=6&&U.BASE.precompute(6),Object.freeze(U.prototype),Object.freeze(U),U}function Wt(t){return Uint8Array.of(t?2:3)}function Xt(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Gt(t,e,n={}){St(t);const o=e;r(o),H(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const i=Object.assign({},n),s=void 0===i.randomBytes?b:i.randomBytes,c=void 0===i.hmac?(t,e)=>Ct(o,t,e):i.hmac,{Fp:u,Fn:d}=t,{ORDER:f,BITS:h}=d,w=bt(f),p=Tt(s,w),{keygen:v,getPublicKey:B,getSharedSecret:R,utils:O,lengths:x}=function(t,e={}){St(t);const{Fn:r}=t,n=void 0===e.randomBytes?b:e.randomBytes,o=Object.assign(Xt(t.Fp,r),{seed:Math.max(bt(r.ORDER),16)});function i(t){return t=void 0===t?n(o.seed):t,vt(l(t,o.seed,"seed"),r.ORDER)}function s(e,n=!0){return t.BASE.multiply(r.fromBytes(e)).toBytes(n)}function a(t){const{secretKey:e,publicKey:n,publicKeyUncompressed:i}=o,s=r._lengths;if(!E(t))return;const a=l(t,void 0,"key").length,c=a===n||a===i,u=a===e||!!s?.includes(a);return c&&u?void 0:c}const c={isValidSecretKey:function(t){try{const e=r.fromBytes(t);return r.isValidNot0(e)}catch(t){return!1}},isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:i}=o;try{const o=e.length;return!(!0===r&&o!==n||!1===r&&o!==i||t.fromBytes(e).is0())}catch(t){return!1}},randomSecretKey:i},u=function(t,e){return function(r){const n=t(r);return{secretKey:n,publicKey:e(n)}}}(i,s);return Object.freeze(c),Object.freeze(o),Object.freeze({getPublicKey:s,getSharedSecret:function(e,n,o=!0){if(!0===a(e))throw new Error("first arg must be private key");if(!1===a(n))throw new Error("second arg must be public key");const i=r.fromBytes(e),s=t.fromBytes(n);if(s.is0())throw new Error("invalid public key: point at infinity");return s.multiply(i).toBytes(o)},keygen:u,Point:t,utils:c,lengths:o})}(t,i),S={prehash:!0,lowS:"boolean"!=typeof i.lowS||i.lowS,format:"compact",extraEntropy:!1},T=f*Yt+zt<u.ORDER;function A(t){return t>f>>zt}function q(t,e){if(!d.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}function F(t,e,r){return function(){if(!u.isOdd)throw new Error("Field doesn't support isOdd")}(),(t===r?0:2)|Number(u.isOdd(e))}function P(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function Z(t,e){Lt(e);const r=x.signature;return l(t,"compact"===e?r:"recovered"===e?r+1:void 0)}class N{r;s;recovery;constructor(t,e,r){if(this.r=q("r",t),this.s=q("s",e),null!=r){if(P(),![0,1,2,3].includes(r))throw new Error("invalid recovery id");this.recovery=r}Object.freeze(this)}static fromBytes(t,e=S.format){let r;if(Z(t,e),"der"===e){if(t.length>2*d.BYTES+16)throw new kt.Err("invalid signature: DER signature too long");const{r:e,s:r}=kt.toSig(l(t),d.BYTES+1);return new N(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=x.signature/2,o=t.subarray(0,n),i=t.subarray(n,2*n);return new N(d.fromBytes(o),d.fromBytes(i),r)}static fromHex(t,e){return this.fromBytes(m(t),e)}assertRecovery(){const{recovery:t}=this;if(null==t)throw new Error("invalid recovery id: must be present");return t}addRecoveryBit(t){return new N(this.r,this.s,t)}recoverPublicKey(e){const{r:r,s:n}=this,o=this.assertRecovery(),i=2===o||3===o?r+f:r;if(!u.isValid(i))throw new Error("invalid recovery id: sig.r+curve.n != R.x");const s=u.toBytes(i),a=t.fromBytes(y(Wt(!(1&o)),s)),c=d.inv(i),h=j(l(e,void 0,"msgHash")),w=d.create(-h*c),p=d.create(n*c),g=t.BASE.mulAddUnsafe(w,a,p);if(g.is0())throw new Error("invalid recovery: point at infinify");return g.assertValidity(),g}hasHighS(){return A(this.s)}toBytes(t=S.format){if(Lt(t),"der"===t)return m(kt.hexFromSig(this));const{r:e,s:r}=this,n=d.toBytes(e),o=d.toBytes(r);return"recovered"===t?(P(),y(Uint8Array.of(this.assertRecovery()),n,o)):y(n,o)}toHex(t){return g(this.toBytes(t))}}Object.freeze(N.prototype),Object.freeze(N);const C=void 0===i.bits2int?function(t){if(t.length>8192)throw new Error("input is too large");const e=I(t),r=8*t.length-h;return r>0?e>>BigInt(r):e}:i.bits2int,j=void 0===i.bits2int_modN?function(t){return d.create(C(t))}:i.bits2int_modN,V=k(h);function L(t){return D("num < 2^"+h,t,$t,V),d.toBytes(t)}function Y(t,e){return l(t,void 0,"message"),e?l(o(t),void 0,"prehashed message"):t}function K(e,r,n){const{lowS:o,prehash:i,extraEntropy:a}=Ut(n,S);e=Y(e,i);const c=j(e),u=d.fromBytes(r);if(!d.isValidNot0(u))throw new Error("invalid private key");const h=[L(u),L(c)];if(null!=a&&!1!==a){const t=!0===a?s(x.secretKey):a;h.push(l(t,void 0,"extraEntropy"))}const g=y(...h),m=c;return{seed:g,k2sig:function(e){const r=C(e);if(!d.isValidNot0(r))return;const n=t.BASE.multiply(r).toAffine(),i=d.create(n.x);if(i===$t)return;let s;if(void 0!==p){const t=I(vt(p(w),f)),e=d.inv(d.mul(t,r)),n=d.mul(t,m),o=d.mul(t,u);s=d.create(e*d.create(n+o*i))}else{const t=function(t,e){if(e<=$)throw new Error("invertCt: expected prime modulus > 1, got "+e);const r=tt(t,e);if(r===U)throw new Error("invertCt: expected non-zero number");const n=et(r,e-z,e);if(tt(r*n,e)!==$)throw new Error("invertCt: does not exist");return n}(r,f);s=d.create(t*d.create(m+i*u))}if(s===$t)return;let a=F(n.x,n.y,i),c=s;return o&&A(s)&&(c=d.neg(s),a^=1),new N(i,c,T?void 0:a)}}}return Object.freeze({keygen:v,getPublicKey:B,getSharedSecret:R,utils:O,lengths:x,Point:t,sign:function(t,e,r={}){const{seed:n,k2sig:i}=K(t,e,r);return function(t,e,r){if(a(t,"hashLen"),a(e,"qByteLen"),"function"!=typeof r)throw new TypeError("hmacFn must be a function");const n=t=>new Uint8Array(t),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1);let c=n(t),u=n(t),d=0;const f=()=>{c.fill(1),u.fill(0),d=0},l=(...t)=>r(u,y(c,...t)),h=(t=o)=>{u=l(i,t),c=l(),0!==t.length&&(u=l(s,t),c=l())},w=()=>{if(d++>=1e3)throw new Error("drbg: tried max amount of iterations");let t=0;const r=[];for(;t<e;){c=l();const e=c.slice();r.push(e),t+=c.length}return y(...r)};return(t,e)=>{let r;for(f(),h(t);void 0===(r=e(w()));)h();return f(),r}}(o.outputLen,d.BYTES,c)(n,i).toBytes(r.format)},verify:function(e,r,n,o={}){const{lowS:i,prehash:s,format:a}=Ut(o,S);if(n=l(n,void 0,"publicKey"),r=Y(r,s),!E(e)){throw new Error("verify expects Uint8Array signature"+(e instanceof N?", use sig.toBytes()":""))}Z(e,a);try{const o=N.fromBytes(e,a),s=t.fromBytes(n);if(s.is0())return!1;if(i&&o.hasHighS())return!1;const{r:c,s:u}=o,f=j(r),l=d.inv(u),h=d.create(f*l),w=d.create(c*l),p=t.BASE.mulAddUnsafe(h,s,w);if(p.is0())return!1;const g=p.toAffine();return d.create(g.x)===c&&("recovered"!==a||o.recovery===F(g.x,g.y,c))}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=Ut(r,S);return e=Y(e,n),N.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:N,hash:o})}export{q as A,pt as B,St as C,mt as F,l as a,I as b,y as c,x as d,Gt as e,Z as f,bt as g,P as h,E as i,vt as j,f as k,j as l,tt as m,L as n,g as o,rt as p,m as q,b as r,ft as s,ht as t,lt as u,H as v,Mt as w,wt as x,D as y,V as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockcerts/blockcerts-verifier",
3
- "version": "1.74.0",
3
+ "version": "1.75.0",
4
4
  "description": "A standalone universal viewer and verifier for blockcerts credentials",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "node": ">=20.0.0"
12
12
  },
13
13
  "dependencies": {
14
- "@blockcerts/cert-verifier-js": "^6.37.2",
14
+ "@blockcerts/cert-verifier-js": "^6.38.0",
15
15
  "@blockcerts/cert-verifier-js-v1-legacy": "^4.0.2",
16
16
  "@polymer/lit-element": "0.5.1",
17
17
  "@polymer/polymer": "3.5.2",
@@ -1,26 +0,0 @@
1
- import{d as e,p as t,V as n,P as r,u as o,w as i,v as a}from"./main.js";import{j as s}from"./jsonld-signatures-BJXipuab-CB799Kkm.js";import{j as u}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{D as c,r as f}from"./DataIntegrityProof-DRK-bLb_-CItV0ZXY.js";import{f as l}from"./index-Dr7MpiEc-D5LHgMik.js";import{S as d}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./index-yOIIz7AL-Dgus2xdV.js";import{r as h}from"./retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js";
2
- /*!
3
- * Copyright (c) 2023-2026 Digital Bazaar, Inc.
4
- */const p=globalThis.crypto;function y({algorithm:e="sha256"}={}){if("sha256"!==e)throw new Error(`Unsupported algorithm "${e}".`);return{hash:async e=>new Uint8Array(await p.subtle.digest("SHA-256",e))}}
5
- /*!
6
- * Copyright (c) 2023-2026 Digital Bazaar, Inc.
7
- */const w=new TextEncoder;function g(e){return w.encode(e)}
8
- /*!
9
- * Copyright (c) 2023-2026 Digital Bazaar, Inc.
10
- */async function m({document:e,labelMapFactoryFunction:t,options:n}={}){const{nquads:r}=await async function({document:e,nquads:t,labelMapFactoryFunction:n,options:r}={}){let o,i=new Map;o=e?await b(e,{...r,canonicalIdMap:i}):await b(t.join(""),{...r,inputFormat:"application/n-quads",canonicalIdMap:i});i=function(e){let t=!1,n=!1,r=!1;const o=new Map;for(const[i,a]of e){if(!t&&(t=!0,n=i.startsWith("_:"),r=a.startsWith("_:"),!n&&!r))return e;o.set(n?i.slice(2):i,r?a.slice(2):a)}return o}(i);const a=await n({canonicalIdMap:i}),s=new Map;for(const[e,t]of a)s.set(i.get(e),t);const u=(e,t,n)=>"_:"+s.get(n);return{nquads:o.split("\n").slice(0,-1).map(e=>e.replace(/(_:([^\s]+))/g,u)+"\n").sort(),labelMap:a}}
11
- /*!
12
- * Copyright (c) 2023-2026 Digital Bazaar, Inc.
13
- */({document:e,labelMapFactoryFunction:t,options:n});return r}async function b(e,t){if(!t||"object"!=typeof t)throw new TypeError('"options" must be an object.');if(t={algorithm:"RDFC-1.0",format:"application/n-quads",base:null,safe:!0,...t},"string"!=typeof e){const n={rdfDirection:"i18n-datatype",...t,produceGeneralizedRdf:!1};delete n.format,e=await u.toRDF(e,n)}return f.canonize(e,t)}async function v({document:e,proof:t,options:n,hasher:r}={}){r||(r=y());const o=await async function({document:e,proof:t,options:n}={}){return delete(t={"@context":e["@context"],...t}).proofValue,b(t,n)}({document:e,proof:t,options:n});return r.hash(g(o))}const E=["string","number","bigint","symbol"],M=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function A(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(E.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const n=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(M.includes(t))return t;return}(e);return n||"Object"}class T{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}}T.uint=new T(0,"uint",!0),T.negint=new T(1,"negint",!0),T.bytes=new T(2,"bytes",!0),T.string=new T(3,"string",!0),T.array=new T(4,"array",!1),T.map=new T(5,"map",!1),T.tag=new T(6,"tag",!1),T.float=new T(7,"float",!0),T.false=new T(7,"false",!0),T.true=new T(7,"true",!0),T.null=new T(7,"null",!0),T.undefined=new T(7,"undefined",!0),T.break=new T(7,"break",!0);class ${constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}}const I=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,S=new TextDecoder,k=new TextEncoder;function U(e){return I&&globalThis.Buffer.isBuffer(e)}const j=I?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString("utf8"):R(e,t,n):(e,t,n)=>n-t>64?S.decode(e.subarray(t,n)):R(e,t,n),V=I?e=>e.length>64?globalThis.Buffer.from(e):P(e):e=>e.length>64?k.encode(e):P(e),B=I?(e,t,n)=>U(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n);function P(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t}function R(e,t,n){const r=[];for(;t<n;){const o=e[t];let i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=n){let n,r,s,u;switch(a){case 1:o<128&&(i=o);break;case 2:n=e[t+1],128==(192&n)&&(u=(31&o)<<6|63&n,u>127&&(i=u));break;case 3:n=e[t+1],r=e[t+2],128==(192&n)&&128==(192&r)&&(u=(15&o)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:n=e[t+1],r=e[t+2],s=e[t+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(u=(15&o)<<18|(63&n)<<12|(63&r)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),t+=a}return function(e){const t=e.length;if(t<=N)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=N));return n}(r)}const N=4096;const D="CBOR decode error:",x="CBOR encode error:";function C(e,t,n){if(e.length-t<n)throw new Error(`${D} not enough data for type`)}const O=[24,256,65536,4294967296,BigInt("18446744073709551616")];function F(e,t,n){C(e,t,1);const r=e[t];if(!0===n.strict&&r<O[0])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return r}function K(e,t,n){C(e,t,2);const r=e[t]<<8|e[t+1];if(!0===n.strict&&r<O[1])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return r}function _(e,t,n){C(e,t,4);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===n.strict&&r<O[2])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return r}function H(e,t,n){C(e,t,8);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=16777216*e[t+4]+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(!0===n.strict&&i<O[3])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(!0===n.allowBigInt)return i;throw new Error(`${D} integers outside of the safe integer range are not supported`)}function z(e,t){return L(e,0,t.value)}function L(e,t,n){if(n<O[0]){const r=Number(n);e.push([t|r])}else if(n<O[1]){const r=Number(n);e.push([24|t,r])}else if(n<O[2]){const r=Number(n);e.push([25|t,r>>>8,255&r])}else if(n<O[3]){const r=Number(n);e.push([26|t,r>>>24&255,r>>>16&255,r>>>8&255,255&r])}else{const r=BigInt(n);if(!(r<O[4]))throw new Error(`${D} encountered BigInt larger than allowable range`);{const n=[27|t,0,0,0,0,0,0,0];let o=Number(r&BigInt(4294967295)),i=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=255&o,o>>=8,n[7]=255&o,o>>=8,n[6]=255&o,o>>=8,n[5]=255&o,n[4]=255&i,i>>=8,n[3]=255&i,i>>=8,n[2]=255&i,i>>=8,n[1]=255&i,e.push(n)}}}z.encodedSize=function(e){return L.encodedSize(e.value)},L.encodedSize=function(e){return e<O[0]?1:e<O[1]?2:e<O[2]?3:e<O[3]?5:9},z.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const G=BigInt(-1),Y=BigInt(1);function q(e,t){const n=t.value,r="bigint"==typeof n?n*G-Y:-1*n-1;L(e,t.type.majorEncoded,r)}function W(e,t,n,r){C(e,t,n+r);const o=B(e,t+n,t+n+r);return new $(T.bytes,o,n+r)}function J(e,t,n,r){return W(e,t,1,n)}function X(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===T.string?V(e.value):e.value),e.encodedBytes}function Q(e,t){const n=X(t);L(e,t.type.majorEncoded,n.length),e.push(n)}function Z(e,t,n,r,o){const i=n+r;C(e,t,i);const a=new $(T.string,j(e,t+n,t+i),i);return!0===o.retainStringBytes&&(a.byteValue=B(e,t+n,t+i)),a}function ee(e,t,n,r){return Z(e,t,1,n,r)}q.encodedSize=function(e){const t=e.value,n="bigint"==typeof t?t*G-Y:-1*t-1;return n<O[0]?1:n<O[1]?2:n<O[2]?3:n<O[3]?5:9},q.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},Q.encodedSize=function(e){const t=X(e);return L.encodedSize(t.length)+t.length},Q.compareTokens=function(e,t){return n=X(e),r=X(t),n.length<r.length?-1:n.length>r.length?1:function(e,t){if(U(e)&&U(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}(n,r);var n,r};const te=Q;function ne(e,t,n,r){return new $(T.array,r,n)}function re(e,t,n,r){return ne(0,0,1,n)}function oe(e,t){L(e,T.array.majorEncoded,t.value)}function ie(e,t,n,r){return new $(T.map,r,n)}function ae(e,t,n,r){return ie(0,0,1,n)}function se(e,t){L(e,T.map.majorEncoded,t.value)}function ue(e,t,n,r){return new $(T.tag,n,1)}function ce(e,t){L(e,T.tag.majorEncoded,t.value)}oe.compareTokens=z.compareTokens,oe.encodedSize=function(e){return L.encodedSize(e.value)},se.compareTokens=z.compareTokens,se.encodedSize=function(e){return L.encodedSize(e.value)},ce.compareTokens=z.compareTokens,ce.encodedSize=function(e){return L.encodedSize(e.value)};function fe(e,t,n){if(n){if(!1===n.allowNaN&&Number.isNaN(e))throw new Error(`${D} NaN values are not supported`);if(!1===n.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${D} Infinity values are not supported`)}return new $(T.float,e,t)}function le(e,t,n){const r=t.value;if(!1===r)e.push([20|T.float.majorEncoded]);else if(!0===r)e.push([21|T.float.majorEncoded]);else if(null===r)e.push([22|T.float.majorEncoded]);else if(void 0===r)e.push([23|T.float.majorEncoded]);else{let t,i=!1;n&&!0===n.float64||(ye(r),t=we(pe,1),r===t||Number.isNaN(r)?(pe[0]=249,e.push(pe.slice(0,3)),i=!0):(ge(r),t=me(pe,1),r===t&&(pe[0]=250,e.push(pe.slice(0,5)),i=!0))),i||(o=r,he.setFloat64(0,o,!1),t=be(pe,1),pe[0]=251,e.push(pe.slice(0,9)))}var o}le.encodedSize=function(e,t){const n=e.value;if(!1===n||!0===n||null==n)return 1;if(!t||!0!==t.float64){ye(n);let e=we(pe,1);if(n===e||Number.isNaN(n))return 3;if(ge(n),e=me(pe,1),n===e)return 5}return 9};const de=new ArrayBuffer(9),he=new DataView(de,1),pe=new Uint8Array(de,0);function ye(e){if(e===1/0)he.setUint16(0,31744,!1);else if(e===-1/0)he.setUint16(0,64512,!1);else if(Number.isNaN(e))he.setUint16(0,32256,!1);else{he.setFloat32(0,e);const t=he.getUint32(0),n=(2139095040&t)>>23,r=8388607&t;if(255===n)he.setUint16(0,31744,!1);else if(0===n)he.setUint16(0,(2147483648&e)>>16|r>>13,!1);else{const e=n-127;e<-24?he.setUint16(0,0):e<-14?he.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):he.setUint16(0,(2147483648&t)>>16|e+15<<10|r>>13,!1)}}}function we(e,t){if(e.length-t<2)throw new Error(`${D} not enough data for float16`);const n=(e[t]<<8)+e[t+1];if(31744===n)return 1/0;if(64512===n)return-1/0;if(32256===n)return NaN;const r=n>>10&31,o=1023&n;let i;return i=0===r?o*2**-24:31!==r?(o+1024)*2**(r-25):0===o?1/0:NaN,32768&n?-i:i}function ge(e){he.setFloat32(0,e,!1)}function me(e,t){if(e.length-t<4)throw new Error(`${D} not enough data for float32`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function be(e,t){if(e.length-t<8)throw new Error(`${D} not enough data for float64`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function ve(e,t,n){throw new Error(`${D} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function Ee(e){return()=>{throw new Error(`${D} ${e}`)}}le.compareTokens=z.compareTokens;const Me=[];for(let e=0;e<=23;e++)Me[e]=ve;Me[24]=function(e,t,n,r){return new $(T.uint,F(e,t+1,r),2)},Me[25]=function(e,t,n,r){return new $(T.uint,K(e,t+1,r),3)},Me[26]=function(e,t,n,r){return new $(T.uint,_(e,t+1,r),5)},Me[27]=function(e,t,n,r){return new $(T.uint,H(e,t+1,r),9)},Me[28]=ve,Me[29]=ve,Me[30]=ve,Me[31]=ve;for(let e=32;e<=55;e++)Me[e]=ve;Me[56]=function(e,t,n,r){return new $(T.negint,-1-F(e,t+1,r),2)},Me[57]=function(e,t,n,r){return new $(T.negint,-1-K(e,t+1,r),3)},Me[58]=function(e,t,n,r){return new $(T.negint,-1-_(e,t+1,r),5)},Me[59]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new $(T.negint,e,9)}if(!0!==r.allowBigInt)throw new Error(`${D} integers outside of the safe integer range are not supported`);return new $(T.negint,G-BigInt(o),9)},Me[60]=ve,Me[61]=ve,Me[62]=ve,Me[63]=ve;for(let e=64;e<=87;e++)Me[e]=J;Me[88]=function(e,t,n,r){return W(e,t,2,F(e,t+1,r))},Me[89]=function(e,t,n,r){return W(e,t,3,K(e,t+1,r))},Me[90]=function(e,t,n,r){return W(e,t,5,_(e,t+1,r))},Me[91]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer bytes lengths not supported`);return W(e,t,9,o)},Me[92]=ve,Me[93]=ve,Me[94]=ve,Me[95]=Ee("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Me[e]=ee;Me[120]=function(e,t,n,r){return Z(e,t,2,F(e,t+1,r),r)},Me[121]=function(e,t,n,r){return Z(e,t,3,K(e,t+1,r),r)},Me[122]=function(e,t,n,r){return Z(e,t,5,_(e,t+1,r),r)},Me[123]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer string lengths not supported`);return Z(e,t,9,o,r)},Me[124]=ve,Me[125]=ve,Me[126]=ve,Me[127]=Ee("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Me[e]=re;Me[152]=function(e,t,n,r){return ne(0,0,2,F(e,t+1,r))},Me[153]=function(e,t,n,r){return ne(0,0,3,K(e,t+1,r))},Me[154]=function(e,t,n,r){return ne(0,0,5,_(e,t+1,r))},Me[155]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer array lengths not supported`);return ne(0,0,9,o)},Me[156]=ve,Me[157]=ve,Me[158]=ve,Me[159]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${D} indefinite length items not allowed`);return ne(0,0,1,1/0)};for(let e=160;e<=183;e++)Me[e]=ae;Me[184]=function(e,t,n,r){return ie(0,0,2,F(e,t+1,r))},Me[185]=function(e,t,n,r){return ie(0,0,3,K(e,t+1,r))},Me[186]=function(e,t,n,r){return ie(0,0,5,_(e,t+1,r))},Me[187]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer map lengths not supported`);return ie(0,0,9,o)},Me[188]=ve,Me[189]=ve,Me[190]=ve,Me[191]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${D} indefinite length items not allowed`);return ie(0,0,1,1/0)};for(let e=192;e<=215;e++)Me[e]=ue;Me[216]=function(e,t,n,r){return new $(T.tag,F(e,t+1,r),2)},Me[217]=function(e,t,n,r){return new $(T.tag,K(e,t+1,r),3)},Me[218]=function(e,t,n,r){return new $(T.tag,_(e,t+1,r),5)},Me[219]=function(e,t,n,r){return new $(T.tag,H(e,t+1,r),9)},Me[220]=ve,Me[221]=ve,Me[222]=ve,Me[223]=ve;for(let e=224;e<=243;e++)Me[e]=Ee("simple values are not supported");Me[244]=ve,Me[245]=ve,Me[246]=ve,Me[247]=function(e,t,n,r){if(!1===r.allowUndefined)throw new Error(`${D} undefined values are not supported`);return!0===r.coerceUndefinedToNull?new $(T.null,null,1):new $(T.undefined,void 0,1)},Me[248]=Ee("simple values are not supported"),Me[249]=function(e,t,n,r){return fe(we(e,t+1),3,r)},Me[250]=function(e,t,n,r){return fe(me(e,t+1),5,r)},Me[251]=function(e,t,n,r){return fe(be(e,t+1),9,r)},Me[252]=ve,Me[253]=ve,Me[254]=ve,Me[255]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${D} indefinite length items not allowed`);return new $(T.break,void 0,1)};const Ae=[];for(let e=0;e<24;e++)Ae[e]=new $(T.uint,e,1);for(let e=-1;e>=-24;e--)Ae[31-e]=new $(T.negint,e,1);Ae[64]=new $(T.bytes,new Uint8Array(0),1),Ae[96]=new $(T.string,"",1),Ae[128]=new $(T.array,0,1),Ae[160]=new $(T.map,0,1),Ae[244]=new $(T.false,!1,1),Ae[245]=new $(T.true,!0,1),Ae[246]=new $(T.null,null,1),function(){const e=[];e[T.uint.major]=z,e[T.negint.major]=q,e[T.bytes.major]=Q,e[T.string.major]=te,e[T.array.major]=oe,e[T.map.major]=se,e[T.tag.major]=ce,e[T.float.major]=le}();class Te{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(`${x} object contains circular references`);return new Te(t,e)}}const $e={null:new $(T.null,null),undefined:new $(T.undefined,void 0),true:new $(T.true,!0),false:new $(T.false,!1),emptyArray:new $(T.array,0),emptyMap:new $(T.map,0)},Ie={number:(e,t,n,r)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new $(e>=0?T.uint:T.negint,e):new $(T.float,e),bigint:(e,t,n,r)=>e>=BigInt(0)?new $(T.uint,e):new $(T.negint,e),Uint8Array:(e,t,n,r)=>new $(T.bytes,e),string:(e,t,n,r)=>new $(T.string,e),boolean:(e,t,n,r)=>e?$e.true:$e.false,null:(e,t,n,r)=>$e.null,undefined:(e,t,n,r)=>$e.undefined,ArrayBuffer:(e,t,n,r)=>new $(T.bytes,new Uint8Array(e)),DataView:(e,t,n,r)=>new $(T.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,n,r){if(!e.length)return!0===n.addBreakTokens?[$e.emptyArray,new $(T.break)]:$e.emptyArray;r=Te.createCheck(r,e);const o=[];let i=0;for(const t of e)o[i++]=Se(t,n,r);return n.addBreakTokens?[new $(T.array,e.length),o,new $(T.break)]:[new $(T.array,e.length),o]},Object(e,t,n,r){const o="Object"!==t,i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return!0===n.addBreakTokens?[$e.emptyMap,new $(T.break)]:$e.emptyMap;r=Te.createCheck(r,e);const s=[];let u=0;for(const t of i)s[u++]=[Se(t,n,r),Se(o?e.get(t):e[t],n,r)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(s,n),n.addBreakTokens?[new $(T.map,a),s,new $(T.break)]:[new $(T.map,a),s]}};Ie.Map=Ie.Object,Ie.Buffer=Ie.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ie[`${e}Array`]=Ie.DataView;function Se(e,t={},n){const r=A(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Ie[r];if("function"==typeof o){const i=o(e,r,t,n);if(null!=i)return i}const i=Ie[r];if(!i)throw new Error(`${x} unsupported type: ${r}`);return i(e,r,t,n)}const ke={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class Ue{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=Ae[e];if(void 0===t){const n=Me[e];if(!n)throw new Error(`${D} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const r=31&e;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}}const je=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function Be(e,t){if(e.done())return je;const n=e.next();if(n.type===T.break)return Ve;if(n.type.terminal)return n.value;if(n.type===T.array)return function(e,t,n){const r=[];for(let o=0;o<e.value;o++){const i=Be(t,n);if(i===Ve){if(e.value===1/0)break;throw new Error(`${D} got unexpected break to lengthed array`)}if(i===je)throw new Error(`${D} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}(n,e,t);if(n.type===T.map)return function(e,t,n){const r=!0===n.useMaps,o=r?void 0:{},i=r?new Map:void 0;for(let a=0;a<e.value;a++){const s=Be(t,n);if(s===Ve){if(e.value===1/0)break;throw new Error(`${D} got unexpected break to lengthed map`)}if(s===je)throw new Error(`${D} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!0!==r&&"string"!=typeof s)throw new Error(`${D} non-string keys not supported (got ${typeof s})`);if(!0===n.rejectDuplicateMapKeys&&(r&&i.has(s)||!r&&s in o))throw new Error(`${D} found repeat map key "${s}"`);const u=Be(t,n);if(u===je)throw new Error(`${D} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?i.set(s,u):o[s]=u}return r?i:o}(n,e,t);if(n.type===T.tag){if(t.tags&&"function"==typeof t.tags[n.value]){const r=Be(e,t);return t.tags[n.value](r)}throw new Error(`${D} tag not supported (${n.value})`)}throw new Error("unsupported")}function Pe(e,t){const[n,r]=function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${D} data to decode must be a Uint8Array`);const n=(t=Object.assign({},ke,t)).tokenizer||new Ue(e,t),r=Be(n,t);if(r===je)throw new Error(`${D} did not find any content to decode`);if(r===Ve)throw new Error(`${D} got unexpected break`);return[r,e.subarray(n.pos())]}(e,t);if(r.length>0)throw new Error(`${D} too many terminals, data makes no sense`);return n}
14
- /*!
15
- * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
16
- */const Re=new Uint8Array([217,93,1]),Ne=[];function De({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=o(e.proofValue.slice(1));if(!function(e,t){for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}(t,Re))throw new TypeError('"proof.proofValue" must be a derived proof.');const n=t.subarray(Re.length),[r,i,s,u,c]=Pe(n,{useMaps:!0,tags:Ne}),f=function(e){const t=new Map;for(const[n,r]of e.entries())t.set(`c14n${n}`,`u${a(r)}`);return t}(u),l={baseSignature:r,publicKey:i,signatures:s,labelMap:f,mandatoryIndexes:c};return function({baseSignature:e,publicKey:t,signatures:n,labelMap:r,mandatoryIndexes:o}){if(!(e instanceof Uint8Array&&64===e.length))throw new TypeError('"baseSignature" must be a Uint8Array of length 64.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!Array.isArray(n)||!n.every(e=>e instanceof Uint8Array))throw new TypeError('"signatures" must be an array of Uint8Arrays.');if(!(r instanceof Map&&[...r.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(o)||!o.every(Number.isInteger))throw new TypeError('"mandatoryIndexes" must be an array of integers.')}(l),l}catch(e){const t=new TypeError('The proof does not include a valid "proofValue" property.');throw t.cause=e,t}}function xe({proofHash:e,publicKey:t,mandatoryHash:n}={}){!function({proofHash:e,publicKey:t,mandatoryHash:n}){if(!(e instanceof Uint8Array&&32===e.length))throw new TypeError('"proofHash" must be a Uint8Array of length 32.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!(n instanceof Uint8Array&&32===n.length))throw new TypeError('"mandatoryHash" must be a Uint8Array of length 32.')}({proofHash:e,publicKey:t,mandatoryHash:n});return function(e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}([e,t,n])}Ne[64]=function(e){return e}
17
- /*!
18
- * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
19
- */;const Ce="ecdsa-sd-2023";
20
- /*!
21
- * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
22
- */
23
- /*!
24
- * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
25
- */
26
- function Oe({requiredAlgorithm:e="P-256"}={}){return{name:Ce,requiredAlgorithm:e,createVerifier:Fe,createVerifyData:Ke}}async function Fe({verificationMethod:e}){const t=(await l(e)).verifier();return{algorithm:t.algorithm,id:t.id,verify:async({data:e})=>async function({verifier:e,data:t}={}){const{baseSignature:n,proofHash:r,publicKey:o,signatures:a,nonMandatory:s,mandatoryHash:u}=t,c="z"+i(o),f=await l({publicKeyMultibase:c});if(a.length!==s.length)throw new Error(`Signature count (${a.length}) does not match non-mandatory message count (${s.length}).`);const{verify:d}=f.verifier();if((await Promise.all(a.map((e,t)=>d({data:g(s[t]),signature:e})))).some(e=>!e))return!1;const h=await xe({proofHash:r,publicKey:o,mandatoryHash:u});return e.verify({data:h,signature:n})}({verifier:t,data:e})}}async function Ke({cryptosuite:e,document:t,proof:n,documentLoader:r}){if(e?.name!==Ce)throw new TypeError(`"cryptosuite.name" must be "${Ce}".`);const o={documentLoader:r},i=v({document:t,proof:n,options:o}).catch(e=>e),{baseSignature:a,publicKey:s,signatures:u,labelMap:c,mandatoryIndexes:f}=await De({proof:n}),l=await function({labelMap:e}={}){return async({canonicalIdMap:t})=>{const n=new Map;for(const[r,o]of t)n.set(r,e.get(o));return n}}({labelMap:c}),d=await m({document:t,labelMapFactoryFunction:l,options:o}),h=[],p=[];for(const[e,t]of d.entries())f.includes(e)?h.push(t):p.push(t);const{mandatoryHash:w}=await async function({mandatory:e,hasher:t}={}){return t||(t=y()),{mandatoryHash:await t.hash(g(e.join("")))}}({mandatory:h}),b=await i;if(b instanceof Error)throw b;return{baseSignature:a,proofHash:b,publicKey:s,signatures:u,nonMandatory:p,mandatoryHash:w}}const{purposes:{AssertionProofPurpose:_e,AuthenticationProofPurpose:He}}=s;var ze;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(ze||(ze={}));class Le extends d{verificationProcess=[ze.retrieveVerificationMethodPublicKey,ze.ensureVerificationMethodValidity,ze.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSd2023";cryptosuite="ecdsa-sd-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:He,assertionMethod:_e},this.validateProofType()}async 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(n=>e.verifier.convertToVerificationSubsteps(t,n))}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,n){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}:u.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(ze.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=h(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new n(ze.retrieveVerificationMethodPublicKey,"Could not derive the verification key",r.CRYPTOGRAPHIC_SECURITY_ERROR);if(this.verificationMethod.revoked)throw new n(ze.retrieveVerificationMethodPublicKey,"The verification key has been revoked",r.CRYPTOGRAPHIC_SECURITY_ERROR);return this.verificationMethod},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(ze.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(ze.ensureVerificationMethodValidity,"The verification key has expired",r.CRYPTOGRAPHIC_SECURITY_ERROR)}if(this.verificationMethod.revoked)throw new n(ze.ensureVerificationMethodValidity,"The verification key has been revoked",r.CRYPTOGRAPHIC_SECURITY_ERROR)},this.type)}async checkDocumentSignature(){await this.executeStep(ze.checkDocumentSignature,async()=>{const e=new c({cryptosuite:Oe({requiredAlgorithm:"K-256"})}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const o=await s.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(!o.verified)throw console.error(JSON.stringify(o,null,2)),new n(ze.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(o)}`,r.PROOF_VERIFICATION_ERROR);console.log(`Credential ${this.type} signature successfully verified`)},this.type)}}export{Le as default};
@@ -1 +0,0 @@
1
- import{d as e,r as t,V as i,g as s,P as r,i as o,B as a,a as n,p as c}from"./main.js";import{j as h}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{e as u,s as p}from"./ensureValidIssuingKey-D7OT4D35--HN0afRq.js";import"./index-yOIIz7AL-Dgus2xdV.js";import{S as f}from"./Suite-BmP2Qu19-D1ucdMDB.js";function l(e){e=e.trim();const t=[];for(let i=0;i<e.length;i+=2)t.push(parseInt(e.substring(i,i+2),16));return t}function d(e){const t=n(e);return"proof"in t?function(e){const t=n(e);if(!Array.isArray(e.proof))return delete t.proof,t;const i=e.proof.find(e=>"ChainedProof2021"!==e.type);return t.proof=i,t}(t):("signature"in t&&delete t.signature,t)}async function y(e){e["@context"].find(e=>o(e)&&"@vocab"in e)||e["@context"].push({"@vocab":"http://fallback.org/"});const t=d(e),n={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in c?{contextUrl:null,document:c[e],documentUrl:e}:h.documentLoader(e)}};let u;try{u=await h.normalize(t,n)}catch(e){throw console.error(e),new i("computeLocalHash",s("errors","failedJsonLdNormalization"),r.PROOF_TRANSFORMATION_ERROR)}const f=function(e){const t=e.split("\n"),i=/<http:\/\/fallback\.org\/(.*)>/,s=t.map(e=>i.exec(e)).filter(e=>null!=e);if(s.length>0){const e=s.map(e=>e[1]).sort();return Array.from(new Set(e))}return null}(u);if(f)throw new i("computeLocalHash",`${s("errors","foundUnmappedFields")}: ${f.join(", ")}`,r.MALFORMED_VALUE_ERROR);return a.from(p(Uint8Array.from(function(e){const t=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);s<128?t.push(s):s<2048?t.push(192|s>>6,128|63&s):s<55296||s>=57344?t.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&e.charCodeAt(i)),t.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return t}(u)))).toString("hex")}var m;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(m||(m={}));class R extends f{verificationProcess=[m.getTransactionId,m.computeLocalHash,m.fetchRemoteHash,m.compareHashes,m.checkMerkleRoot,m.checkReceipt,m.parseIssuerKeys,m.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature,this.chain=e.certificates.getChain("",this.receipt),this.transactionId=e.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async 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(i=>e.verifier.convertToVerificationSubsteps(t,i))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return e.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.documentToVerify.issuedOn}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){if(this.proof.type[0]!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(t(this.verificationProcess,m.getTransactionId),t(this.verificationProcess,m.fetchRemoteHash),t(this.verificationProcess,m.parseIssuerKeys),t(this.verificationProcess,m.checkMerkleRoot),t(this.verificationProcess,m.checkAuthenticity))}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(m.getTransactionId,()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new i("getTransactionId",s("errors","isTransactionIdValid"),r.MALFORMED_VALUE_ERROR)}(this.transactionId),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(m.computeLocalHash,async()=>await y(this.documentToVerify),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(m.fetchRemoteHash,async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs}),this.type)}async compareHashes(){await this.executeStep(m.compareHashes,()=>function(e,t){if(e!==t)throw new i("compareHashes",s("errors","ensureHashesEqual"),r.CRYPTOGRAPHIC_SECURITY_ERROR);return!0}(this.localHash,this.receipt.targetHash),this.type)}async checkMerkleRoot(){await this.executeStep(m.checkMerkleRoot,()=>function(e,t){if(e!==t)throw new i("checkMerkleRoot",s("errors","ensureMerkleRootEqual"),r.CRYPTOGRAPHIC_SECURITY_ERROR);return!0}(this.receipt.merkleRoot,this.txData.remoteHash),this.type)}async checkReceipt(){await this.executeStep(m.checkReceipt,()=>{!function(e){let t=e.targetHash;const o=e.merkleRoot;try{const s=e.proof??e.path;if(s)for(const e in s){const r=s[e];let o;if(void 0!==r.left)o=l(`${r.left}${t}`),t=a.from(p(Uint8Array.from(o))).toString("hex");else{if(void 0===r.right)throw new i("checkReceipt","Trigger catch error.");o=l(`${t}${r.right}`),t=a.from(p(Uint8Array.from(o))).toString("hex")}}}catch(e){throw new i("checkReceipt",s("errors","ensureValidReceipt"),r.CRYPTOGRAPHIC_SECURITY_ERROR)}if(t!==o)throw new i("checkReceipt",s("errors","invalidMerkleReceipt"),r.CRYPTOGRAPHIC_SECURITY_ERROR)}(this.receipt)},this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(m.parseIssuerKeys,()=>e.verifier.parseIssuerKeys(this.issuer),this.type)}async checkAuthenticity(){await this.executeStep(m.checkAuthenticity,()=>{u(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)},this.type)}}export{R as default};