@blockcerts/blockcerts-verifier 1.64.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +1 -1
- package/dist/{EcdsaSd2023-C-1LsSqc-ObXBX61N.js → EcdsaSd2023-CFEOfg7w-mH0iTn_o.js} +5 -5
- package/dist/{EcdsaSecp256k1Signature2019-9eEnZ1FG-BmfqA6PL.js → EcdsaSecp256k1Signature2019-ubMolKKG--XgmQozH.js} +1 -1
- package/dist/{Ed25519Signature2020-BMcgU5hX-x_NYJtpB.js → Ed25519Signature2020-BZ-qRxuK-BYYEQJGi.js} +5 -5
- package/dist/{MerkleProof2017-CYhvkyFU-Dl5-uCC8.js → MerkleProof2017-8DlLs_7g-DQaM2JIJ.js} +1 -1
- package/dist/{MerkleProof2019-DvKX1MAC-ZkVAsaEc.js → MerkleProof2019-Cv-l9BBE-DWMqt_64.js} +1 -1
- package/dist/{checkCredentialSchemaConformity-BKqGaA0B-BD_kUjvp.js → checkCredentialSchemaConformity-jTrYEW-3-Dd-TT_aS.js} +1 -1
- package/dist/{controlVerificationMethod-CxlzFjkZ-PQqX7CMl.js → controlVerificationMethod-CXY1HfP3-B24OCl2R.js} +1 -1
- package/dist/{did-key-common.esm-BFTxB53c-CbGeVC_r.js → did-key-common.esm-B-c4r5DX-DkFupqKN.js} +3 -3
- package/dist/{did-key-ed25519.esm-De8G8Ym_-DucypQMo.js → did-key-ed25519.esm-BcBjidXA-DBqZ-FkQ.js} +1 -1
- package/dist/{did-key-secp256k1.esm-Bq_BYfMd-CQBo4Q3q.js → did-key-secp256k1.esm-6buyKG_l-BMESYfmC.js} +1 -1
- package/dist/{index-DJ38G5vv-CIHAiYCe.js → index-CUYLWUzw-Bvbn47Hw.js} +7 -7
- package/dist/{index-CXMZ9dwW-lR6I8M8V.js → index-D-CbTXp7-DPOLY-Lt.js} +1 -1
- package/dist/{index-SE5hL_nS--rUcmgx9.js → index-hjoL_SpB-ntvlvLOE.js} +5 -5
- package/dist/main.js +104 -104
- package/dist/{retrieveVerificationMethodPublicKey-8w3WQciA-sHmGZCdE.js → retrieveVerificationMethodPublicKey-DVFc1aT7-B_qGml2q.js} +1 -1
- package/package.json +2 -2
- /package/dist/{HashlinkVerifier-BtvQtMxp-dg5WNZnc.js → HashlinkVerifier-_iTrfpkJ-dg5WNZnc.js} +0 -0
- /package/dist/{checkRevocationStatusList2021-BUqNLYXm-XCu3zkCJ.js → checkRevocationStatusList2021-BnjtBDNQ-XCu3zkCJ.js} +0 -0
- /package/dist/{elliptic-ChFQ9Ngs-BRLTdj5Y.js → elliptic-C4nnFoxE-BRLTdj5Y.js} +0 -0
- /package/dist/{ensureNotRevoked-JuH4UdyO-DvMIgM4L.js → ensureNotRevoked-DWOMZyzg-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-CVj5gBFJ-wu9SdYxL.js → ensureValidIssuingKey-CCMYu_4t-wu9SdYxL.js} +0 -0
- /package/dist/{index-BcM1LBSs-Dgus2xdV.js → index-DGqgobGj-Dgus2xdV.js} +0 -0
- /package/dist/{index-CZmdZxVn-C0eXpZGn.js → index-DO31KEg9-C0eXpZGn.js} +0 -0
- /package/dist/{jsonld-DSQP4wXm-C61cS9xX.js → jsonld-B5Vzncdv-C61cS9xX.js} +0 -0
- /package/dist/{sha256-4DF0Q3E2-C1PUWFZm.js → sha256-D1k1uYHq-C1PUWFZm.js} +0 -0
- /package/dist/{webcrypto.es-SQMaF2SJ-B87Lqr9a.js → webcrypto.es-DlDhx8-u-B87Lqr9a.js} +0 -0
- /package/dist/{x25519-KjRyLrTf-NSl6svWQ.js → x25519-BTjd7-6X-NSl6svWQ.js} +0 -0
package/dist/{Ed25519Signature2020-BMcgU5hX-x_NYJtpB.js → Ed25519Signature2020-BZ-qRxuK-BYYEQJGi.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{d as t,f as e,e as r,V as n,q as i,B as o,i as a}from"./main.js";import{j as c,d as s,e as u}from"./index-
|
|
1
|
+
import{d as t,f as e,e as r,V as n,q as i,B as o,i as a}from"./main.js";import{j as c,d as s,e as u}from"./index-hjoL_SpB-ntvlvLOE.js";import{j as f}from"./jsonld-B5Vzncdv-C61cS9xX.js";import{d as p,e as l}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{_ as y}from"./tslib.es6-CNEFicEt-CmLYFWVC.js";import{x as h,e as d}from"./x25519-BTjd7-6X-NSl6svWQ.js";import{S as w}from"./Suite-B7Vy9AuU-D1ucdMDB.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
4
4
|
*/function v({bytes:t,expectedLength:e=32,code:r}){if(!(t instanceof Uint8Array))throw new TypeError('"bytes" must be a Uint8Array.');if(t.length!==e){const t=new Error(`"bytes" must be a ${e}-byte Uint8Array.`);throw t.name="DataError",r&&(t.code=r),t}}
|
|
5
|
-
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const g=BigInt(0),m=BigInt(1),b=BigInt(2),E=BigInt(8),x=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),K=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:x,n:x,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),T=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),A=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const k=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),S=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),L=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class P{constructor(t,e,r,n){this.x=t,this.y=e,this.z=r,this.t=n}static fromAffine(t){if(!(t instanceof R))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(R.ZERO)?P.ZERO:new P(t.x,t.y,m,Z(t.x*t.y))}static toAffineBatch(t){const e=function(t,e=K.P){const r=new Array(t.length),n=H(t.reduce(((t,n,i)=>n===g?t:(r[i]=t,Z(t*n,e))),m),e);return t.reduceRight(((t,n,i)=>n===g?t:(r[i]=Z(t*r[i],e),Z(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return this.toAffineBatch(t).map(this.fromAffine)}equals(t){_(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,c=Z(e*a),s=Z(i*n),u=Z(r*a),f=Z(o*n);return c===s&&u===f}negate(){return new P(Z(-this.x),this.y,this.z,Z(-this.t))}double(){const{x:t,y:e,z:r}=this,{a:n}=K,i=Z(t*t),o=Z(e*e),a=Z(b*Z(r*r)),c=Z(n*i),s=t+e,u=Z(Z(s*s)-i-o),f=c+o,p=f-a,l=c-o,y=Z(u*p),h=Z(f*l),d=Z(u*l),w=Z(p*f);return new P(y,h,w,d)}add(t){_(t);const{x:e,y:r,z:n,t:i}=this,{x:o,y:a,z:c,t:s}=t,u=Z((r-e)*(a+o)),f=Z((r+e)*(a-o)),p=Z(f-u);if(p===g)return this.double();const l=Z(n*b*s),y=Z(i*b*c),h=y+l,d=f+u,w=y-l,v=Z(h*p),m=Z(d*w),E=Z(h*w),x=Z(p*d);return new P(v,m,x,E)}subtract(t){return this.add(t.negate())}precomputeWindow(t){const e=1+256/t,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(P.BASE)&&(e=R.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&I.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=P.normalizeZ(n),I.set(e,n)));let i=P.ZERO,o=P.BASE;const a=1+256/r,c=2**(r-1),s=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*c;let a=Number(t&s);t>>=f,a>c&&(a-=u,t+=m);const p=r,l=r+Math.abs(a)-1,y=e%2!=0,h=a<0;0===a?o=o.add(B(y,n[p])):i=i.add(B(h,n[l]))}return P.normalizeZ([i,o])[0]}multiply(t,e){return this.wNAF(rt(t,K.l),e)}multiplyUnsafe(t){let e=rt(t,K.l,!1);const r=P.BASE,n=P.ZERO;if(e===g)return n;if(this.equals(n)||e===m)return this;if(this.equals(r))return this.wNAF(e);let i=n,o=this;for(;e>g;)e&m&&(i=i.add(o)),o=o.double(),e>>=m;return i}isSmallOrder(){return this.multiplyUnsafe(K.h).equals(P.ZERO)}isTorsionFree(){let t=this.multiplyUnsafe(K.l/b).double();return K.l%b&&(t=t.add(this)),t.equals(P.ZERO)}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(P.ZERO);null==t&&(t=i?E:H(n));const o=Z(e*t),a=Z(r*t),c=Z(n*t);if(i)return R.ZERO;if(c!==m)throw new Error("invZ was invalid");return new R(o,a)}fromRistrettoBytes(){U()}toRistrettoBytes(){U()}fromRistrettoHash(){U()}}function B(t,e){const r=e.negate();return t?r:e}function _(t){if(!(t instanceof P))throw new TypeError("ExtendedPoint expected")}function M(t){if(!(t instanceof N))throw new TypeError("RistrettoPoint expected")}function U(){throw new Error("Legacy method: switch to RistrettoPoint")}P.BASE=new P(K.Gx,K.Gy,m,Z(K.Gx*K.Gy)),P.ZERO=new P(g,m,m,g);class N{constructor(t){this.ep=t}static calcElligatorRistrettoMap(t){const{d:e}=K,r=Z(A*t*t),n=Z((r+m)*S);let i=BigInt(-1);const o=Z((i-e*r)*Z(r+e));let{isValid:a,value:c}=Y(n,o),s=Z(c*t);z(s)||(s=Z(-s)),a||(c=s),a||(i=r);const u=Z(i*(r-m)*L-o),f=c*c,p=Z((c+c)*o),l=Z(u*k),y=Z(m-f),h=Z(m+f);return new P(Z(p*h),Z(y*l),Z(l*h),Z(p*y))}static hashToCurve(t){const e=q((t=et(t,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(e),n=q(t.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new N(r.add(i))}static fromHex(t){t=et(t,32);const{a:e,d:r}=K,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=q(t);if(!function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(F(i),t)||z(i))throw new Error(n);const o=Z(i*i),a=Z(m+e*o),c=Z(m-e*o),s=Z(a*a),u=Z(c*c),f=Z(e*r*s-u),{isValid:p,value:l}=Q(Z(f*u)),y=Z(l*c),h=Z(l*y*f);let d=Z((i+i)*y);z(d)&&(d=Z(-d));const w=Z(a*h),v=Z(d*w);if(!p||z(v)||w===g)throw new Error(n);return new N(new P(d,w,m,v))}toRawBytes(){let{x:t,y:e,z:r,t:n}=this.ep;const i=Z(Z(r+e)*Z(r-e)),o=Z(t*e),a=Z(o*o),{value:c}=Q(Z(i*a)),s=Z(c*i),u=Z(c*o),f=Z(s*u*n);let p;if(z(n*f)){let r=Z(e*A),n=Z(t*A);t=r,e=n,p=Z(s*O)}else p=u;z(t*f)&&(e=Z(-e));let l=Z((r-e)*p);return z(l)&&(l=Z(-l)),F(l)}toHex(){return X(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const e=this.ep,r=t.ep,n=Z(e.x*r.y)===Z(e.y*r.x),i=Z(e.y*r.y)===Z(e.x*r.x);return n||i}add(t){return M(t),new N(this.ep.add(t.ep))}subtract(t){return M(t),new N(this.ep.subtract(t.ep))}multiply(t){return new N(this.ep.multiply(t))}multiplyUnsafe(t){return new N(this.ep.multiplyUnsafe(t))}}N.BASE=new N(P.BASE),N.ZERO=new N(P.ZERO);const I=new WeakMap;class R{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,I.delete(this)}static fromHex(t,e=!0){const{d:r,P:n}=K,i=(t=et(t,32)).slice();i[31]=-129&t[31];const o=W(i);if(e&&o>=n)throw new Error("Expected 0 < hex < P");if(!e&&o>=T)throw new Error("Expected 0 < hex < 2**256");const a=Z(o*o),c=Z(a-m),s=Z(r*a+m);let{isValid:u,value:f}=Y(c,s);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&m)===m;return!!(128&t[31])!==p&&(f=Z(-f)),new R(f,o)}static async fromPrivateKey(t){return(await it(t)).point}toRawBytes(){const t=F(this.y);return t[31]|=this.x&m?128:0,t}toHex(){return X(this.toRawBytes())}toX25519(){const{y:t}=this;return F(Z((m+t)*H(m-t)))}isTorsionFree(){return P.fromAffine(this).isTorsionFree()}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new R(Z(-this.x),this.y)}add(t){return P.fromAffine(this).add(P.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return P.fromAffine(this).multiply(t,this).toAffine()}}R.BASE=new R(K.Gx,K.Gy),R.ZERO=new R(g,m);class j{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=et(t,64),r=R.fromHex(e.slice(0,32),!1),n=W(e.slice(32,64));return new j(r,n)}assertValidity(){const{r:t,s:e}=this;if(!(t instanceof R))throw new Error("Expected Point instance");return rt(e,K.l,!1),this}toRawBytes(){const t=new Uint8Array(64);return t.set(this.r.toRawBytes()),t.set(F(this.s),32),t}toHex(){return X(this.toRawBytes())}}function C(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const V=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function X(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=V[t[r]];return e}function D(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function J(t){return D(t.toString(16).padStart(64,"0"))}function F(t){return J(t).reverse()}function z(t){return(Z(t)&m)===m}function W(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+X(Uint8Array.from(t).reverse()))}const G=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function q(t){return Z(W(t)&G)}function Z(t,e=K.P){const r=t%e;return r>=g?r:e+r}function H(t,e=K.P){if(t===g||e<=g)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Z(t,e),n=e,i=g,o=m;for(;r!==g;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==m)throw new Error("invert: does not exist");return Z(i,e)}function $(t,e){const{P:r}=K;let n=t;for(;e-- >g;)n*=n,n%=r;return n}function Y(t,e){const r=Z(e*e*e),n=function(t){const{P:e}=K,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),c=t*t%e*t%e,s=$(c,b)*c%e,u=$(s,m)*t%e,f=$(u,r)*u%e,p=$(f,n)*f%e,l=$(p,i)*p%e,y=$(l,o)*l%e,h=$(y,a)*y%e,d=$(h,a)*y%e,w=$(d,n)*f%e;return{pow_p_5_8:$(w,b)*t%e,b2:c}}(t*Z(r*r*e)).pow_p_5_8;let i=Z(t*r*n);const o=Z(e*i*i),a=i,c=Z(i*A),s=o===t,u=o===Z(-t),f=o===Z(-t*A);return s&&(i=a),(u||f)&&(i=c),z(i)&&(i=Z(-i)),{isValid:s||u,value:i}}function Q(t){return Y(m,t)}function tt(t){return Z(W(t),K.l)}function et(t,e){const r=t instanceof Uint8Array?Uint8Array.from(t):D(t);if("number"==typeof e&&r.length!==e)throw new Error(`Expected ${e} bytes`);return r}function rt(t,e,r=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof t&&Number.isSafeInteger(t)&&(t=BigInt(t)),"bigint"==typeof t&&t<e)if(r){if(g<t)return t}else if(g<=t)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let nt;async function it(t){return function(t){const e=((r=t.slice(0,32))[0]&=248,r[31]&=127,r[31]|=64,r);var r;const n=t.slice(32,64),i=tt(e),o=R.BASE.multiply(i),a=o.toRawBytes();return{head:e,prefix:n,scalar:i,point:o,pointBytes:a}}(await ct.sha512(function(t){if(32!==(t="bigint"==typeof t||"number"==typeof t?J(rt(t,T)):et(t)).length)throw new Error("Expected 32 bytes");return t}(t)))}async function ot(t,e,r){const{r:n,SB:i,msg:o,pub:a}=function(t,e,r){e=et(e),r instanceof R||(r=R.fromHex(r,!1));const{r:n,s:i}=t instanceof j?t.assertValidity():j.fromHex(t);return{r:n,s:i,SB:P.BASE.multiplyUnsafe(i),pub:r,msg:e}}(t,e,r),c=await ct.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(t,e,r,n){const i=tt(n),o=P.fromAffine(t).multiplyUnsafe(i);return P.fromAffine(e).add(o).subtract(r).multiplyUnsafe(K.h).equals(P.ZERO)}(a,n,i,c)}R.BASE._setWindowSize(8);const at={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={bytesToHex:X,hexToBytes:D,concatBytes:C,getExtendedPublicKey:it,mod:Z,invert:H,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if((t=et(t)).length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(W(t),K.l-m)+m},randomBytes:(t=32)=>{if(at.web)return at.web.getRandomValues(new Uint8Array(t));if(at.node){const{randomBytes:e}=at.node;return new Uint8Array(e(t).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ct.randomBytes(32),sha512:async(...t)=>{const e=C(...t);if(at.web){const t=await at.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(at.node)return Uint8Array.from(at.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(t=8,e=R.BASE){const r=e.equals(R.BASE)?e:new R(e.x,e.y);return r._setWindowSize(t),r.multiply(b),r},sha512Sync:void 0};Object.defineProperties(ct,{sha512Sync:{configurable:!1,get:()=>nt,set(t){nt||(nt=t)}}});
|
|
5
|
+
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const g=BigInt(0),m=BigInt(1),b=BigInt(2),x=BigInt(8),E=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),K=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:E,n:E,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),T=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),A=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const k=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),L=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),S=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class B{constructor(t,e,r,n){this.x=t,this.y=e,this.z=r,this.t=n}static fromAffine(t){if(!(t instanceof R))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(R.ZERO)?B.ZERO:new B(t.x,t.y,m,Z(t.x*t.y))}static toAffineBatch(t){const e=function(t,e=K.P){const r=new Array(t.length),n=H(t.reduce(((t,n,i)=>n===g?t:(r[i]=t,Z(t*n,e))),m),e);return t.reduceRight(((t,n,i)=>n===g?t:(r[i]=Z(t*r[i],e),Z(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return this.toAffineBatch(t).map(this.fromAffine)}equals(t){_(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,c=Z(e*a),s=Z(i*n),u=Z(r*a),f=Z(o*n);return c===s&&u===f}negate(){return new B(Z(-this.x),this.y,this.z,Z(-this.t))}double(){const{x:t,y:e,z:r}=this,{a:n}=K,i=Z(t*t),o=Z(e*e),a=Z(b*Z(r*r)),c=Z(n*i),s=t+e,u=Z(Z(s*s)-i-o),f=c+o,p=f-a,l=c-o,y=Z(u*p),h=Z(f*l),d=Z(u*l),w=Z(p*f);return new B(y,h,w,d)}add(t){_(t);const{x:e,y:r,z:n,t:i}=this,{x:o,y:a,z:c,t:s}=t,u=Z((r-e)*(a+o)),f=Z((r+e)*(a-o)),p=Z(f-u);if(p===g)return this.double();const l=Z(n*b*s),y=Z(i*b*c),h=y+l,d=f+u,w=y-l,v=Z(h*p),m=Z(d*w),x=Z(h*w),E=Z(p*d);return new B(v,m,E,x)}subtract(t){return this.add(t.negate())}precomputeWindow(t){const e=1+256/t,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(B.BASE)&&(e=R.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&I.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=B.normalizeZ(n),I.set(e,n)));let i=B.ZERO,o=B.BASE;const a=1+256/r,c=2**(r-1),s=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*c;let a=Number(t&s);t>>=f,a>c&&(a-=u,t+=m);const p=r,l=r+Math.abs(a)-1,y=e%2!=0,h=a<0;0===a?o=o.add(P(y,n[p])):i=i.add(P(h,n[l]))}return B.normalizeZ([i,o])[0]}multiply(t,e){return this.wNAF(rt(t,K.l),e)}multiplyUnsafe(t){let e=rt(t,K.l,!1);const r=B.BASE,n=B.ZERO;if(e===g)return n;if(this.equals(n)||e===m)return this;if(this.equals(r))return this.wNAF(e);let i=n,o=this;for(;e>g;)e&m&&(i=i.add(o)),o=o.double(),e>>=m;return i}isSmallOrder(){return this.multiplyUnsafe(K.h).equals(B.ZERO)}isTorsionFree(){let t=this.multiplyUnsafe(K.l/b).double();return K.l%b&&(t=t.add(this)),t.equals(B.ZERO)}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(B.ZERO);null==t&&(t=i?x:H(n));const o=Z(e*t),a=Z(r*t),c=Z(n*t);if(i)return R.ZERO;if(c!==m)throw new Error("invZ was invalid");return new R(o,a)}fromRistrettoBytes(){U()}toRistrettoBytes(){U()}fromRistrettoHash(){U()}}function P(t,e){const r=e.negate();return t?r:e}function _(t){if(!(t instanceof B))throw new TypeError("ExtendedPoint expected")}function M(t){if(!(t instanceof N))throw new TypeError("RistrettoPoint expected")}function U(){throw new Error("Legacy method: switch to RistrettoPoint")}B.BASE=new B(K.Gx,K.Gy,m,Z(K.Gx*K.Gy)),B.ZERO=new B(g,m,m,g);class N{constructor(t){this.ep=t}static calcElligatorRistrettoMap(t){const{d:e}=K,r=Z(A*t*t),n=Z((r+m)*L);let i=BigInt(-1);const o=Z((i-e*r)*Z(r+e));let{isValid:a,value:c}=Y(n,o),s=Z(c*t);F(s)||(s=Z(-s)),a||(c=s),a||(i=r);const u=Z(i*(r-m)*S-o),f=c*c,p=Z((c+c)*o),l=Z(u*k),y=Z(m-f),h=Z(m+f);return new B(Z(p*h),Z(y*l),Z(l*h),Z(p*y))}static hashToCurve(t){const e=q((t=et(t,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(e),n=q(t.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new N(r.add(i))}static fromHex(t){t=et(t,32);const{a:e,d:r}=K,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=q(t);if(!function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(z(i),t)||F(i))throw new Error(n);const o=Z(i*i),a=Z(m+e*o),c=Z(m-e*o),s=Z(a*a),u=Z(c*c),f=Z(e*r*s-u),{isValid:p,value:l}=Q(Z(f*u)),y=Z(l*c),h=Z(l*y*f);let d=Z((i+i)*y);F(d)&&(d=Z(-d));const w=Z(a*h),v=Z(d*w);if(!p||F(v)||w===g)throw new Error(n);return new N(new B(d,w,m,v))}toRawBytes(){let{x:t,y:e,z:r,t:n}=this.ep;const i=Z(Z(r+e)*Z(r-e)),o=Z(t*e),a=Z(o*o),{value:c}=Q(Z(i*a)),s=Z(c*i),u=Z(c*o),f=Z(s*u*n);let p;if(F(n*f)){let r=Z(e*A),n=Z(t*A);t=r,e=n,p=Z(s*O)}else p=u;F(t*f)&&(e=Z(-e));let l=Z((r-e)*p);return F(l)&&(l=Z(-l)),z(l)}toHex(){return X(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const e=this.ep,r=t.ep,n=Z(e.x*r.y)===Z(e.y*r.x),i=Z(e.y*r.y)===Z(e.x*r.x);return n||i}add(t){return M(t),new N(this.ep.add(t.ep))}subtract(t){return M(t),new N(this.ep.subtract(t.ep))}multiply(t){return new N(this.ep.multiply(t))}multiplyUnsafe(t){return new N(this.ep.multiplyUnsafe(t))}}N.BASE=new N(B.BASE),N.ZERO=new N(B.ZERO);const I=new WeakMap;class R{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,I.delete(this)}static fromHex(t,e=!0){const{d:r,P:n}=K,i=(t=et(t,32)).slice();i[31]=-129&t[31];const o=W(i);if(e&&o>=n)throw new Error("Expected 0 < hex < P");if(!e&&o>=T)throw new Error("Expected 0 < hex < 2**256");const a=Z(o*o),c=Z(a-m),s=Z(r*a+m);let{isValid:u,value:f}=Y(c,s);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&m)===m;return!!(128&t[31])!==p&&(f=Z(-f)),new R(f,o)}static async fromPrivateKey(t){return(await it(t)).point}toRawBytes(){const t=z(this.y);return t[31]|=this.x&m?128:0,t}toHex(){return X(this.toRawBytes())}toX25519(){const{y:t}=this;return z(Z((m+t)*H(m-t)))}isTorsionFree(){return B.fromAffine(this).isTorsionFree()}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new R(Z(-this.x),this.y)}add(t){return B.fromAffine(this).add(B.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return B.fromAffine(this).multiply(t,this).toAffine()}}R.BASE=new R(K.Gx,K.Gy),R.ZERO=new R(g,m);class j{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=et(t,64),r=R.fromHex(e.slice(0,32),!1),n=W(e.slice(32,64));return new j(r,n)}assertValidity(){const{r:t,s:e}=this;if(!(t instanceof R))throw new Error("Expected Point instance");return rt(e,K.l,!1),this}toRawBytes(){const t=new Uint8Array(64);return t.set(this.r.toRawBytes()),t.set(z(this.s),32),t}toHex(){return X(this.toRawBytes())}}function C(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const V=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function X(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=V[t[r]];return e}function J(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function D(t){return J(t.toString(16).padStart(64,"0"))}function z(t){return D(t).reverse()}function F(t){return(Z(t)&m)===m}function W(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+X(Uint8Array.from(t).reverse()))}const G=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function q(t){return Z(W(t)&G)}function Z(t,e=K.P){const r=t%e;return r>=g?r:e+r}function H(t,e=K.P){if(t===g||e<=g)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Z(t,e),n=e,i=g,o=m;for(;r!==g;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==m)throw new Error("invert: does not exist");return Z(i,e)}function $(t,e){const{P:r}=K;let n=t;for(;e-- >g;)n*=n,n%=r;return n}function Y(t,e){const r=Z(e*e*e),n=function(t){const{P:e}=K,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),c=t*t%e*t%e,s=$(c,b)*c%e,u=$(s,m)*t%e,f=$(u,r)*u%e,p=$(f,n)*f%e,l=$(p,i)*p%e,y=$(l,o)*l%e,h=$(y,a)*y%e,d=$(h,a)*y%e,w=$(d,n)*f%e;return{pow_p_5_8:$(w,b)*t%e,b2:c}}(t*Z(r*r*e)).pow_p_5_8;let i=Z(t*r*n);const o=Z(e*i*i),a=i,c=Z(i*A),s=o===t,u=o===Z(-t),f=o===Z(-t*A);return s&&(i=a),(u||f)&&(i=c),F(i)&&(i=Z(-i)),{isValid:s||u,value:i}}function Q(t){return Y(m,t)}function tt(t){return Z(W(t),K.l)}function et(t,e){const r=t instanceof Uint8Array?Uint8Array.from(t):J(t);if("number"==typeof e&&r.length!==e)throw new Error(`Expected ${e} bytes`);return r}function rt(t,e,r=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof t&&Number.isSafeInteger(t)&&(t=BigInt(t)),"bigint"==typeof t&&t<e)if(r){if(g<t)return t}else if(g<=t)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let nt;async function it(t){return function(t){const e=((r=t.slice(0,32))[0]&=248,r[31]&=127,r[31]|=64,r);var r;const n=t.slice(32,64),i=tt(e),o=R.BASE.multiply(i),a=o.toRawBytes();return{head:e,prefix:n,scalar:i,point:o,pointBytes:a}}(await ct.sha512(function(t){if(32!==(t="bigint"==typeof t||"number"==typeof t?D(rt(t,T)):et(t)).length)throw new Error("Expected 32 bytes");return t}(t)))}async function ot(t,e,r){const{r:n,SB:i,msg:o,pub:a}=function(t,e,r){e=et(e),r instanceof R||(r=R.fromHex(r,!1));const{r:n,s:i}=t instanceof j?t.assertValidity():j.fromHex(t);return{r:n,s:i,SB:B.BASE.multiplyUnsafe(i),pub:r,msg:e}}(t,e,r),c=await ct.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(t,e,r,n){const i=tt(n),o=B.fromAffine(t).multiplyUnsafe(i);return B.fromAffine(e).add(o).subtract(r).multiplyUnsafe(K.h).equals(B.ZERO)}(a,n,i,c)}R.BASE._setWindowSize(8);const at={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={bytesToHex:X,hexToBytes:J,concatBytes:C,getExtendedPublicKey:it,mod:Z,invert:H,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if((t=et(t)).length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(W(t),K.l-m)+m},randomBytes:(t=32)=>{if(at.web)return at.web.getRandomValues(new Uint8Array(t));if(at.node){const{randomBytes:e}=at.node;return new Uint8Array(e(t).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ct.randomBytes(32),sha512:async(...t)=>{const e=C(...t);if(at.web){const t=await at.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(at.node)return Uint8Array.from(at.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(t=8,e=R.BASE){const r=e.equals(R.BASE)?e:new R(e.x,e.y);return r._setWindowSize(t),r.multiply(b),r},sha512Sync:void 0};Object.defineProperties(ct,{sha512Sync:{configurable:!1,get:()=>nt,set(t){nt||(nt=t)}}});
|
|
6
6
|
/*!
|
|
7
7
|
* Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
|
|
8
8
|
*/
|
|
@@ -13,7 +13,7 @@ const st=globalThis.crypto;if(!st.getRandomValues)throw new Error('Browser does
|
|
|
13
13
|
/*!
|
|
14
14
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
15
15
|
*/
|
|
16
|
-
const lt="Ed25519VerificationKey2020",yt=new Uint8Array([237,1]),ht=new Uint8Array([128,38]);class dt extends pt{constructor(t={}){super(t),this.type=lt;const{publicKeyMultibase:e,privateKeyMultibase:r}=t;if(!e)throw new TypeError('The "publicKeyMultibase" property is required.');if(!e||!wt(e,yt))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${e}".`);if(r&&!wt(r,ht))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=e,this.privateKeyMultibase=r,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),v({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(t){return"Ed25519VerificationKey2018"===t.type?dt.fromEd25519VerificationKey2018(t):"JsonWebKey2020"===t.type?dt.fromJsonWebKey2020(t):new dt(t)}static fromEd25519VerificationKey2018({keyPair:t}={}){const e=vt(yt,s(t.publicKeyBase58)),r=new dt({id:t.id,controller:t.controller,publicKeyMultibase:e});return t.privateKeyBase58&&(r.privateKeyMultibase=vt(ht,s(t.privateKeyBase58))),r}static fromJsonWebKey2020({id:t,type:e,controller:r,publicKeyJwk:n}={}){if("JsonWebKey2020"!==e)throw new TypeError(`Invalid key type: "${e}".`);if(!n)throw new TypeError('"publicKeyJwk" property is required.');const{kty:i,crv:o}=n;if("OKP"!==i)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==o)throw new TypeError('"crv" is required to be "Ed25519".');const{x:a}=n,c=vt(yt,p(a));return dt.from({id:t,controller:r,publicKeyMultibase:c})}static async generate({seed:t,...e}={}){let r;r=t?await ut.generateKeyPairFromSeed(t):await ut.generateKeyPair();const n=vt(yt,r.publicKey),i=vt(ht,r.secretKey);return new dt({publicKeyMultibase:n,privateKeyMultibase:i,...e})}static fromFingerprint({fingerprint:t}={}){return new dt({publicKeyMultibase:t})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return s(this.publicKeyMultibase.substr(1)).slice(yt.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return s(this.privateKeyMultibase.substr(1)).slice(ht.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:t=!1,privateKey:e=!1,includeContext:r=!1}={}){if(!t&&!e)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const n={id:this.id,type:this.type};return r&&(n["@context"]=dt.SUITE_CONTEXT),this.controller&&(n.controller=this.controller),t&&(n.publicKeyMultibase=this.publicKeyMultibase),e&&(n.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(n.revoked=this.revoked),n}toJwk({publicKey:t=!0,privateKey:e=!1}={}){if(!t&&!e)throw TypeError('Either a "publicKey" or a "privateKey" is required.');const r={crv:"Ed25519",kty:"OKP"};return t&&(r.x=l(this._publicKeyBuffer)),e&&(r.d=l(this._privateKeyBuffer)),r}async jwkThumbprint(){const t=`{"crv":"Ed25519","kty":"OKP","x":"${l(this._publicKeyBuffer)}"}`,e=(new TextEncoder).encode(t);return l(new Uint8Array(await ut.sha256digest({data:e})))}async toJsonWebKey2020(){return{"@context":"https://w3id.org/security/jws/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey2020",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}verifyFingerprint({fingerprint:t}={}){if("string"!=typeof t||"z"!==t[0])return{error:new Error('"fingerprint" must be a multibase encoded string.'),valid:!1};let e;try{if(e=s(t.substr(1)),!e)throw new TypeError("Invalid encoding of fingerprint.")}catch(t){return{error:t,valid:!1}}const r=function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(this._publicKeyBuffer,e.slice(2)),n=e[0]===yt[0]&&e[1]===yt[1]&&r;return n?{valid:n}:{error:new Error("The fingerprint does not match the public key."),valid:!1}}signer(){const t=this._privateKeyBuffer;return{async sign({data:e}){if(!t)throw new Error("A private key is not available for signing.");return ut.sign(t,e)},id:this.id}}verifier(){const t=this._publicKeyBuffer;return{async verify({data:e,signature:r}){if(!t)throw new Error("A public key is not available for verifying.");return ut.verify(t,e,r)},id:this.id}}}function wt(t,e){if("string"!=typeof t||"z"!==t[0])return!1;const r=s(t.slice(1));return e.every(((t,e)=>r[e]===t))}function vt(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),"z"+u(r)}dt.suite=lt,dt.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var gt,mt,bt,
|
|
16
|
+
const lt="Ed25519VerificationKey2020",yt=new Uint8Array([237,1]),ht=new Uint8Array([128,38]);class dt extends pt{constructor(t={}){super(t),this.type=lt;const{publicKeyMultibase:e,privateKeyMultibase:r}=t;if(!e)throw new TypeError('The "publicKeyMultibase" property is required.');if(!e||!wt(e,yt))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${e}".`);if(r&&!wt(r,ht))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=e,this.privateKeyMultibase=r,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),v({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(t){return"Ed25519VerificationKey2018"===t.type?dt.fromEd25519VerificationKey2018(t):"JsonWebKey2020"===t.type?dt.fromJsonWebKey2020(t):new dt(t)}static fromEd25519VerificationKey2018({keyPair:t}={}){const e=vt(yt,s(t.publicKeyBase58)),r=new dt({id:t.id,controller:t.controller,publicKeyMultibase:e});return t.privateKeyBase58&&(r.privateKeyMultibase=vt(ht,s(t.privateKeyBase58))),r}static fromJsonWebKey2020({id:t,type:e,controller:r,publicKeyJwk:n}={}){if("JsonWebKey2020"!==e)throw new TypeError(`Invalid key type: "${e}".`);if(!n)throw new TypeError('"publicKeyJwk" property is required.');const{kty:i,crv:o}=n;if("OKP"!==i)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==o)throw new TypeError('"crv" is required to be "Ed25519".');const{x:a}=n,c=vt(yt,p(a));return dt.from({id:t,controller:r,publicKeyMultibase:c})}static async generate({seed:t,...e}={}){let r;r=t?await ut.generateKeyPairFromSeed(t):await ut.generateKeyPair();const n=vt(yt,r.publicKey),i=vt(ht,r.secretKey);return new dt({publicKeyMultibase:n,privateKeyMultibase:i,...e})}static fromFingerprint({fingerprint:t}={}){return new dt({publicKeyMultibase:t})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return s(this.publicKeyMultibase.substr(1)).slice(yt.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return s(this.privateKeyMultibase.substr(1)).slice(ht.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:t=!1,privateKey:e=!1,includeContext:r=!1}={}){if(!t&&!e)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const n={id:this.id,type:this.type};return r&&(n["@context"]=dt.SUITE_CONTEXT),this.controller&&(n.controller=this.controller),t&&(n.publicKeyMultibase=this.publicKeyMultibase),e&&(n.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(n.revoked=this.revoked),n}toJwk({publicKey:t=!0,privateKey:e=!1}={}){if(!t&&!e)throw TypeError('Either a "publicKey" or a "privateKey" is required.');const r={crv:"Ed25519",kty:"OKP"};return t&&(r.x=l(this._publicKeyBuffer)),e&&(r.d=l(this._privateKeyBuffer)),r}async jwkThumbprint(){const t=`{"crv":"Ed25519","kty":"OKP","x":"${l(this._publicKeyBuffer)}"}`,e=(new TextEncoder).encode(t);return l(new Uint8Array(await ut.sha256digest({data:e})))}async toJsonWebKey2020(){return{"@context":"https://w3id.org/security/jws/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey2020",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}verifyFingerprint({fingerprint:t}={}){if("string"!=typeof t||"z"!==t[0])return{error:new Error('"fingerprint" must be a multibase encoded string.'),valid:!1};let e;try{if(e=s(t.substr(1)),!e)throw new TypeError("Invalid encoding of fingerprint.")}catch(t){return{error:t,valid:!1}}const r=function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(this._publicKeyBuffer,e.slice(2)),n=e[0]===yt[0]&&e[1]===yt[1]&&r;return n?{valid:n}:{error:new Error("The fingerprint does not match the public key."),valid:!1}}signer(){const t=this._privateKeyBuffer;return{async sign({data:e}){if(!t)throw new Error("A private key is not available for signing.");return ut.sign(t,e)},id:this.id}}verifier(){const t=this._publicKeyBuffer;return{async verify({data:e,signature:r}){if(!t)throw new Error("A public key is not available for verifying.");return ut.verify(t,e,r)},id:this.id}}}function wt(t,e){if("string"!=typeof t||"z"!==t[0])return!1;const r=s(t.slice(1));return e.every(((t,e)=>r[e]===t))}function vt(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),"z"+u(r)}dt.suite=lt,dt.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var gt,mt,bt,xt=(gt=function(t,e){!function(t,e){for(var r in e)t[r]=e[r]}(e,function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){
|
|
17
17
|
/*!
|
|
18
18
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
19
19
|
*/
|
|
@@ -29,7 +29,7 @@ const n=r(0),i=r(1),{documentLoader:o}=r(3),{CONTEXT_URL:a,CBORLD_CODEC_VALUE:c}
|
|
|
29
29
|
/*!
|
|
30
30
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
31
31
|
*/
|
|
32
|
-
const{CONTEXT_URL:n}=r(1),i=r(0);t.exports={documentLoader(t){if(t!==n)throw new Error(`Loading document "${t}" is not allowed.`);return{contextUrl:null,document:i,documentUrl:t}}}}]))},gt(mt={exports:{}},mt.exports),mt.exports),
|
|
32
|
+
const{CONTEXT_URL:n}=r(1),i=r(0);t.exports={documentLoader(t){if(t!==n)throw new Error(`Loading document "${t}" is not allowed.`);return{contextUrl:null,document:i,documentUrl:t}}}}]))},gt(mt={exports:{}},mt.exports),mt.exports),Et=(bt=xt)&&bt.__esModule&&Object.prototype.hasOwnProperty.call(bt,"default")?bt.default:bt;xt.contexts,xt.constants,xt.CONTEXT,xt.CONTEXT_URL,xt.appContextMap,xt.documentLoader;var Kt=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){!function(t,e){for(var r in e)t[r]=e[r]}(e,function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){
|
|
33
33
|
/*!
|
|
34
34
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
35
35
|
*/
|
|
@@ -49,4 +49,4 @@ const{CONTEXT_URL:n}=r(1),i=r(0);t.exports={documentLoader(t){if(t!==n)throw new
|
|
|
49
49
|
/*!
|
|
50
50
|
* Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
|
|
51
51
|
*/
|
|
52
|
-
const{suites:{LinkedDataSignature:At}}=c,kt=xt.constants.CONTEXT_URL,Ot=Tt.constants.CONTEXT_URL;let St=class extends At{constructor({key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:dt,contextUrl:kt,key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:t,proof:e}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const r=await this.signer.sign({data:t});return e.proofValue="z"+u(r),e}async verifySignature({verifyData:t,verificationMethod:e,proof:r}){const{proofValue:n}=r;if(!n||"string"!=typeof n)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==n[0])throw new Error("Only base58btc multibase encoding is supported.");const i=s(n.substr(1));let{verifier:o}=this;if(!o){o=(await this.LDKeyClass.from(e)).verifier()}return o.verify({data:t,signature:i})}async assertVerificationMethod({verificationMethod:t}){let e;if("Ed25519VerificationKey2020"===t.type)e=kt;else{if("Ed25519VerificationKey2018"!==t.type)throw new Error(`Unsupported key type "${t.type}".`);e=Ot}if(!Lt({document:t,contextUrl:e}))throw new TypeError(`The verification method (key) must contain "${e}" context.`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const{document:n}=await e(r);return r="string"==typeof n?JSON.parse(n):n,await this.assertVerificationMethod({verificationMethod:r}),"Ed25519VerificationKey2018"===r.type&&(r=(await dt.fromEd25519VerificationKey2018({keyPair:r})).export({publicKey:!0,includeContext:!0})),r}async matchProof({proof:t,document:e,purpose:r,documentLoader:n}){if(!Lt({document:e,contextUrl:kt}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:r,documentLoader:n}))return!1;if(!this.key)return!0;const{verificationMethod:i}=t;return"object"==typeof i?i.id===this.key.id:i===this.key.id}};function Lt({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}St.CONTEXT_URL=kt,St.CONTEXT=xt.contexts.get(kt);var Pt,Bt,_t={exports:{}},Mt={};var Ut,Nt,It,Rt=(Bt||(Bt=1,_t.exports=(Pt||(Pt=1,Ut=Mt,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.staticImplements=function(){return function(t){}}),Mt)),_t.exports),jt={exports:{}},Ct={};var Vt=(It||(It=1,jt.exports=(Nt||(Nt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.staticImplements=function(){return function(t){}}}(Ct)),Ct)),jt.exports);function Xt(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Xt(o,n,i,a,c,"next",t)}function c(t){Xt(o,n,i,a,c,"throw",t)}a(void 0)}))}}function Jt(){return Jt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Jt.apply(this,arguments)}var Ft=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,E=b&&b(b(L([])));E&&E!==r&&n.call(E,o)&&(m=E);var x=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=x.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(x),s(x,c,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function zt(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var Wt,Gt=zt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),qt=function(t){return o.from(t||"").toString("base64")},Zt=function(t){return qt(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},Ht=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=236,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+Gt.encode(r);if("base64url"===e)return"u"+Zt(r);throw new Error("Unsupported encoding: "+e)},$t=function(t){return Uint8Array.from(o.from(t.x,"base64"))},Yt={JsonWebKey2020:function(t){var e,r=$t(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:$t(e),privateKey:Uint8Array.from(o.from(e.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(t){var e=Gt.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(Gt.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},Qt={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"X25519",x:Zt(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=Jt({},i,{d:Zt(n)})),o},X25519KeyAgreementKey2019:function(t,e,r,n){var i={id:t,type:"X25519KeyAgreementKey2019",controller:e,publicKeyBase58:Gt.encode(r)};return n&&(i.privateKeyBase58=Gt.encode(n)),i}},te=Wt=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=Dt(Ft.mark((function t(e){var r,n;return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Wt.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",Ht(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=Dt(Ft.mark((function t(e){var r,n,i,o;return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,236!==(n=Gt.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,Wt.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:Gt.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=Dt(Ft.mark((function t(){return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Ht(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=Dt(Ft.mark((function t(e){return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!Qt[e.type]){t.next=3;break}return t.abrupt("return",Qt[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.deriveSecret=function(){var t=Dt(Ft.mark((function t(e){var r,n,i;return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.publicKey,t.next=3,Wt.from(r);case 3:if(n=t.sent,this.privateKey){t.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return i=h.sharedKey(this.privateKey,n.publicKey,!0),t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();function ee(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function re(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ee(o,n,i,a,c,"next",t)}function c(t){ee(o,n,i,a,c,"throw",t)}a(void 0)}))}}function ne(){return ne=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ne.apply(this,arguments)}te.generate=function(){var t=Dt(Ft.mark((function t(e){var r,n,i,o,a;return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=h.generateKeyPair({isAvailable:!0,randomBytes:r}),i=Ht(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new Wt({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),te.from=function(){var t=Dt(Ft.mark((function t(e){var r,n,i;return Ft.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Yt[e.type](e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new Wt({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),te=Wt=y([Vt.staticImplements()],te);var ie=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,E=b&&b(b(L([])));E&&E!==r&&n.call(E,o)&&(m=E);var x=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=x.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(x),s(x,c,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function oe(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var ae,ce=oe("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),se=function(t){return o.from(t||"").toString("base64")},ue=function(t){return se(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},fe=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=237,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+ce.encode(r);if("base64url"===e)return"u"+ue(r);throw new Error("Unsupported encoding: "+e)},pe=function(t){return Uint8Array.from(o.from(t.x,"base64"))},le={JsonWebKey2020:function(t){var e,r=pe(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:pe(e),privateKey:Uint8Array.from(o.concat([o.from(e.d,"base64"),o.from(e.x,"base64")]))}).privateKey);return{publicKey:r,privateKey:n}},Ed25519VerificationKey2018:function(t){var e=ce.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(ce.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},ye=function(t){if(!le[t.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(t,null,2));return le[t.type](t)},he={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"Ed25519",x:ue(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=ne({},i,{d:ue(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(t,e,r,n){var i={id:t,type:"Ed25519VerificationKey2018",controller:e,publicKeyBase58:ce.encode(r)};return n&&(i.privateKeyBase58=ce.encode(n)),i}},de={EdDsa:{__proto__:null,signer:function(t){return{sign:function(e){return re(ie.mark((function r(){var n;return ie.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.data,r.abrupt("return",d.sign(t,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(t){return{verify:function(e){return re(ie.mark((function r(){var n,i,o;return ie.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.data,i=e.signature,o=!1;try{o=d.verify(t,n,i)}catch(t){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},we=ae=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=re(ie.mark((function t(e){var r,n;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",fe(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.toX25519KeyPair=function(){var t=re(ie.mark((function t(e){var r,n,i;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=d.convertPublicKeyToX25519(e.publicKey),n=void 0,e.privateKey&&(n=d.convertSecretKeyToX25519(e.privateKey)),i=new te({id:"",type:"X25519KeyAgreementKey2019",controller:e.controller,publicKey:r,privateKey:n}),t.t0=e.controller+"#",t.next=7,i.fingerprint();case 7:return t.t1=t.sent,i.id=t.t0+t.t1,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=re(ie.mark((function t(e){var r,n,i,o;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,237!==(n=ce.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,ae.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:ce.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=re(ie.mark((function t(){return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fe(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=re(ie.mark((function t(e){return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!he[e.type]){t.next=3;break}return t.abrupt("return",he[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.signer=function(t){if(void 0===t&&(t="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(de[t])return de[t].signer(this.privateKey);throw new Error("Unsupported suite type "+t)},e.verifier=function(t){if(void 0===t&&(t="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(de[t])return de[t].verifier(this.publicKey);throw new Error("Unsupported suite type "+t)},e.getDerivedKeyPairs=function(){var t=re(ie.mark((function t(){return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,ae.toX25519KeyPair(this);case 3:return t.t1=t.sent,t.abrupt("return",[t.t0,t.t1]);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();we.generate=function(){var t=re(ie.mark((function t(e){var r,n,i,o,a;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=d.generateKeyPair({isAvailable:!0,randomBytes:r}),i=fe(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new ae({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),we.from=function(){var t=re(ie.mark((function t(e){var r,n,i;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ye(e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new ae({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),we=ae=y([Rt.staticImplements()],we);const{purposes:{AssertionProofPurpose:ve}}=c;var ge;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.checkDocumentSignature="checkDocumentSignature"}(ge||(ge={}));class me extends w{verificationProcess=[ge.retrieveVerificationMethodPublicKey,ge.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;publicKey;constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType()}async init(){}async verifyProof(){for(const t of this.verificationProcess){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(t){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(t,e,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(t){return await we.fingerprintFromPublicKey(t)}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){e[this.documentToVerify.issuer]=this.issuer.didDocument;return function(t){return t in e?{contextUrl:null,document:e[t],documentUrl:t}:f.documentLoader(t)}}retrieveInitialDocument(){const t=r(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(ge.retrieveVerificationMethodPublicKey,(async()=>{const t=this.issuer.didDocument.verificationMethod.find((t=>t.id===this.proof.verificationMethod));if(!t)throw new n(ge.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=t.publicKeyMultibase??await this.publicKeyJwkToString(t)}catch(t){console.error("ERROR retrieving Ed25519Signature2020 public key",t)}const e=await dt.from({...t});if(!e)throw new n(ge.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new n(ge.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e}),this.type)}async checkDocumentSignature(){await this.executeStep(ge.checkDocumentSignature,(async()=>{const t=new St({key:this.verificationKey});t.date=new Date(Date.now()).toISOString();const e=await c.verify(this.retrieveInitialDocument(),{suite:t,purpose:new ve,documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new n(ge.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{me as default};
|
|
52
|
+
const{suites:{LinkedDataSignature:At}}=c,kt=Et.constants.CONTEXT_URL,Ot=Tt.constants.CONTEXT_URL;let Lt=class extends At{constructor({key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:dt,contextUrl:kt,key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:t,proof:e}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const r=await this.signer.sign({data:t});return e.proofValue="z"+u(r),e}async verifySignature({verifyData:t,verificationMethod:e,proof:r}){const{proofValue:n}=r;if(!n||"string"!=typeof n)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==n[0])throw new Error("Only base58btc multibase encoding is supported.");const i=s(n.substr(1));let{verifier:o}=this;if(!o){o=(await this.LDKeyClass.from(e)).verifier()}return o.verify({data:t,signature:i})}async assertVerificationMethod({verificationMethod:t}){let e;if("Ed25519VerificationKey2020"===t.type)e=kt;else{if("Ed25519VerificationKey2018"!==t.type)throw new Error(`Unsupported key type "${t.type}".`);e=Ot}if(!St({document:t,contextUrl:e}))throw new TypeError(`The verification method (key) must contain "${e}" context.`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const{document:n}=await e(r);return r="string"==typeof n?JSON.parse(n):n,await this.assertVerificationMethod({verificationMethod:r}),"Ed25519VerificationKey2018"===r.type&&(r=(await dt.fromEd25519VerificationKey2018({keyPair:r})).export({publicKey:!0,includeContext:!0})),r}async matchProof({proof:t,document:e,purpose:r,documentLoader:n}){if(!St({document:e,contextUrl:kt}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:r,documentLoader:n}))return!1;if(!this.key)return!0;const{verificationMethod:i}=t;return"object"==typeof i?i.id===this.key.id:i===this.key.id}};function St({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}Lt.CONTEXT_URL=kt,Lt.CONTEXT=Et.contexts.get(kt);var Bt,Pt,_t={exports:{}},Mt={};var Ut,Nt,It,Rt=(Pt||(Pt=1,_t.exports=(Bt||(Bt=1,Ut=Mt,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.staticImplements=function(){return function(t){}}),Mt)),_t.exports),jt={exports:{}},Ct={};var Vt=(It||(It=1,jt.exports=(Nt||(Nt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.staticImplements=function(){return function(t){}}}(Ct)),Ct)),jt.exports);function Xt(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Jt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Xt(o,n,i,a,c,"next",t)}function c(t){Xt(o,n,i,a,c,"throw",t)}a(void 0)}))}}function Dt(){return Dt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Dt.apply(this,arguments)}var zt=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new L(n||[]);return o._invoke=function(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return B()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(S([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:B}}function B(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:S(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function Ft(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var Wt,Gt=Ft("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),qt=function(t){return o.from(t||"").toString("base64")},Zt=function(t){return qt(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},Ht=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=236,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+Gt.encode(r);if("base64url"===e)return"u"+Zt(r);throw new Error("Unsupported encoding: "+e)},$t=function(t){return Uint8Array.from(o.from(t.x,"base64"))},Yt={JsonWebKey2020:function(t){var e,r=$t(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:$t(e),privateKey:Uint8Array.from(o.from(e.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(t){var e=Gt.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(Gt.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},Qt={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"X25519",x:Zt(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=Dt({},i,{d:Zt(n)})),o},X25519KeyAgreementKey2019:function(t,e,r,n){var i={id:t,type:"X25519KeyAgreementKey2019",controller:e,publicKeyBase58:Gt.encode(r)};return n&&(i.privateKeyBase58=Gt.encode(n)),i}},te=Wt=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=Jt(zt.mark((function t(e){var r,n;return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Wt.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",Ht(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=Jt(zt.mark((function t(e){var r,n,i,o;return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,236!==(n=Gt.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,Wt.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:Gt.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=Jt(zt.mark((function t(){return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Ht(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=Jt(zt.mark((function t(e){return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!Qt[e.type]){t.next=3;break}return t.abrupt("return",Qt[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.deriveSecret=function(){var t=Jt(zt.mark((function t(e){var r,n,i;return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.publicKey,t.next=3,Wt.from(r);case 3:if(n=t.sent,this.privateKey){t.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return i=h.sharedKey(this.privateKey,n.publicKey,!0),t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();function ee(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function re(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ee(o,n,i,a,c,"next",t)}function c(t){ee(o,n,i,a,c,"throw",t)}a(void 0)}))}}function ne(){return ne=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ne.apply(this,arguments)}te.generate=function(){var t=Jt(zt.mark((function t(e){var r,n,i,o,a;return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=h.generateKeyPair({isAvailable:!0,randomBytes:r}),i=Ht(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new Wt({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),te.from=function(){var t=Jt(zt.mark((function t(e){var r,n,i;return zt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Yt[e.type](e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new Wt({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),te=Wt=y([Vt.staticImplements()],te);var ie=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new L(n||[]);return o._invoke=function(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return B()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(S([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:B}}function B(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:S(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function oe(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var ae,ce=oe("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),se=function(t){return o.from(t||"").toString("base64")},ue=function(t){return se(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},fe=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=237,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+ce.encode(r);if("base64url"===e)return"u"+ue(r);throw new Error("Unsupported encoding: "+e)},pe=function(t){return Uint8Array.from(o.from(t.x,"base64"))},le={JsonWebKey2020:function(t){var e,r=pe(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:pe(e),privateKey:Uint8Array.from(o.concat([o.from(e.d,"base64"),o.from(e.x,"base64")]))}).privateKey);return{publicKey:r,privateKey:n}},Ed25519VerificationKey2018:function(t){var e=ce.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(ce.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},ye=function(t){if(!le[t.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(t,null,2));return le[t.type](t)},he={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"Ed25519",x:ue(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=ne({},i,{d:ue(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(t,e,r,n){var i={id:t,type:"Ed25519VerificationKey2018",controller:e,publicKeyBase58:ce.encode(r)};return n&&(i.privateKeyBase58=ce.encode(n)),i}},de={EdDsa:{__proto__:null,signer:function(t){return{sign:function(e){return re(ie.mark((function r(){var n;return ie.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.data,r.abrupt("return",d.sign(t,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(t){return{verify:function(e){return re(ie.mark((function r(){var n,i,o;return ie.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.data,i=e.signature,o=!1;try{o=d.verify(t,n,i)}catch(t){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},we=ae=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=re(ie.mark((function t(e){var r,n;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ae.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",fe(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.toX25519KeyPair=function(){var t=re(ie.mark((function t(e){var r,n,i;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=d.convertPublicKeyToX25519(e.publicKey),n=void 0,e.privateKey&&(n=d.convertSecretKeyToX25519(e.privateKey)),i=new te({id:"",type:"X25519KeyAgreementKey2019",controller:e.controller,publicKey:r,privateKey:n}),t.t0=e.controller+"#",t.next=7,i.fingerprint();case 7:return t.t1=t.sent,i.id=t.t0+t.t1,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=re(ie.mark((function t(e){var r,n,i,o;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,237!==(n=ce.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,ae.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:ce.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=re(ie.mark((function t(){return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fe(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=re(ie.mark((function t(e){return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!he[e.type]){t.next=3;break}return t.abrupt("return",he[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.signer=function(t){if(void 0===t&&(t="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(de[t])return de[t].signer(this.privateKey);throw new Error("Unsupported suite type "+t)},e.verifier=function(t){if(void 0===t&&(t="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(de[t])return de[t].verifier(this.publicKey);throw new Error("Unsupported suite type "+t)},e.getDerivedKeyPairs=function(){var t=re(ie.mark((function t(){return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,ae.toX25519KeyPair(this);case 3:return t.t1=t.sent,t.abrupt("return",[t.t0,t.t1]);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();we.generate=function(){var t=re(ie.mark((function t(e){var r,n,i,o,a;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=d.generateKeyPair({isAvailable:!0,randomBytes:r}),i=fe(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new ae({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),we.from=function(){var t=re(ie.mark((function t(e){var r,n,i;return ie.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ye(e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new ae({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),we=ae=y([Rt.staticImplements()],we);const{purposes:{AssertionProofPurpose:ve}}=c;var ge;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.checkDocumentSignature="checkDocumentSignature"}(ge||(ge={}));class me extends w{verificationProcess=[ge.retrieveVerificationMethodPublicKey,ge.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;publicKey;constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType()}async init(){}async verifyProof(){for(const t of this.verificationProcess){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(t){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(t,e,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(t){return await we.fingerprintFromPublicKey(t)}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){e[this.documentToVerify.issuer]=this.issuer.didDocument;return function(t){return t in e?{contextUrl:null,document:e[t],documentUrl:t}:f.documentLoader(t)}}retrieveInitialDocument(){const t=r(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(ge.retrieveVerificationMethodPublicKey,(async()=>{const t=this.issuer.didDocument.verificationMethod.find((t=>t.id===this.proof.verificationMethod));if(!t)throw new n(ge.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=t.publicKeyMultibase??await this.publicKeyJwkToString(t)}catch(t){console.error("ERROR retrieving Ed25519Signature2020 public key",t)}const e=await dt.from({...t});if(!e)throw new n(ge.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new n(ge.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e}),this.type)}async checkDocumentSignature(){await this.executeStep(ge.checkDocumentSignature,(async()=>{const t=new Lt({key:this.verificationKey});t.date=new Date(Date.now()).toISOString();const e=await c.verify(this.retrieveInitialDocument(),{suite:t,purpose:new ve,documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new n(ge.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,r as t,a as i,V as s,b as r,e as o,f as a}from"./main.js";import"./pako.esm-DnD5dZGi-Bw1vqMku.js";import{j as n}from"./jsonld-
|
|
1
|
+
import{d as e,r as t,a as i,V as s,b as r,e as o,f as a}from"./main.js";import"./pako.esm-DnD5dZGi-Bw1vqMku.js";import{j as n}from"./jsonld-B5Vzncdv-C61cS9xX.js";import{s as c}from"./sha256-D1k1uYHq-C1PUWFZm.js";import{e as h}from"./ensureValidIssuingKey-CCMYu_4t-wu9SdYxL.js";import"./index-DGqgobGj-Dgus2xdV.js";import{S as u}from"./Suite-B7Vy9AuU-D1ucdMDB.js";function p(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 f(e){const t=o(e);return"proof"in t?function(e){const t=o(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 l(e){e["@context"].find((e=>i(e)&&"@vocab"in e))||e["@context"].push({"@vocab":"http://fallback.org/"});const t=f(e),o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in a?{contextUrl:null,document:a[e],documentUrl:e}:n.documentLoader(e)}};let h;try{h=await n.normalize(t,o)}catch(e){throw console.error(e),new s("computeLocalHash",r("errors","failedJsonLdNormalization"))}const u=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}(h);if(u)throw new s("computeLocalHash",`${r("errors","foundUnmappedFields")}: ${u.join(", ")}`);return c(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}(h))}var d;!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"}(d||(d={}));class y extends u{verificationProcess=[d.getTransactionId,d.computeLocalHash,d.fetchRemoteHash,d.compareHashes,d.checkMerkleRoot,d.checkReceipt,d.parseIssuerKeys,d.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,d.getTransactionId),t(this.verificationProcess,d.fetchRemoteHash),t(this.verificationProcess,d.parseIssuerKeys),t(this.verificationProcess,d.checkMerkleRoot),t(this.verificationProcess,d.checkAuthenticity))}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(d.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new s("getTransactionId",r("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(d.computeLocalHash,(async()=>await l(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(d.fetchRemoteHash,(async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(d.compareHashes,(()=>function(e,t){if(e!==t)throw new s("compareHashes",r("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(d.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new s("checkMerkleRoot",r("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(d.checkReceipt,(()=>{!function(e){let t=e.targetHash;const i=e.merkleRoot;try{const i=e.proof??e.path;if(i)for(const e in i){const r=i[e];let o;if(void 0!==r.left)o=p(`${r.left}${t}`),t=c(o);else{if(void 0===r.right)throw new s("checkReceipt","Trigger catch error.");o=p(`${t}${r.right}`),t=c(o)}}}catch(e){throw new s("checkReceipt",r("errors","ensureValidReceipt"))}if(t!==i)throw new s("checkReceipt",r("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(d.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(d.checkAuthenticity,(()=>{h(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{y as default};
|