nostr-crypto-utils 0.4.12 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +52 -2
  2. package/dist/browser/343.nostr-crypto-utils.min.js +1 -0
  3. package/dist/browser/419.nostr-crypto-utils.min.js +1 -0
  4. package/dist/browser/657.nostr-crypto-utils.min.js +1 -1
  5. package/dist/browser/705.nostr-crypto-utils.min.js +1 -1
  6. package/dist/browser/761.nostr-crypto-utils.min.js +1 -1
  7. package/dist/browser/774.nostr-crypto-utils.min.js +1 -1
  8. package/dist/browser/crypto.nostr-crypto-utils.min.js +1 -1
  9. package/dist/browser/main.nostr-crypto-utils.min.js +1 -0
  10. package/dist/browser/protocol.nostr-crypto-utils.min.js +1 -1
  11. package/dist/cjs/event/index.d.ts +7 -0
  12. package/dist/cjs/event/index.d.ts.map +1 -0
  13. package/dist/cjs/event/index.js +15 -0
  14. package/dist/cjs/event/index.js.map +1 -0
  15. package/dist/cjs/event/signing.d.ts +12 -0
  16. package/dist/cjs/event/signing.d.ts.map +1 -1
  17. package/dist/cjs/event/signing.js +29 -0
  18. package/dist/cjs/event/signing.js.map +1 -1
  19. package/dist/cjs/index.d.ts +11 -8
  20. package/dist/cjs/index.d.ts.map +1 -1
  21. package/dist/cjs/index.js +58 -56
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/nips/nip-04.d.ts +1 -1
  24. package/dist/cjs/nips/nip-04.d.ts.map +1 -1
  25. package/dist/cjs/nips/nip-04.js +6 -5
  26. package/dist/cjs/nips/nip-04.js.map +1 -1
  27. package/dist/cjs/protocol/index.d.ts +9 -9
  28. package/dist/cjs/protocol/index.d.ts.map +1 -1
  29. package/dist/cjs/protocol/index.js +8 -9
  30. package/dist/cjs/protocol/index.js.map +1 -1
  31. package/dist/cjs/types/base.d.ts +45 -121
  32. package/dist/cjs/types/base.d.ts.map +1 -1
  33. package/dist/cjs/types/base.js +10 -28
  34. package/dist/cjs/types/base.js.map +1 -1
  35. package/dist/cjs/utils/encoding.d.ts +12 -0
  36. package/dist/cjs/utils/encoding.d.ts.map +1 -1
  37. package/dist/cjs/utils/encoding.js +18 -0
  38. package/dist/cjs/utils/encoding.js.map +1 -1
  39. package/dist/cjs/utils/integration.d.ts +14 -15
  40. package/dist/cjs/utils/integration.d.ts.map +1 -1
  41. package/dist/cjs/utils/integration.js +145 -98
  42. package/dist/cjs/utils/integration.js.map +1 -1
  43. package/dist/cjs/utils/logger.d.ts +17 -2
  44. package/dist/cjs/utils/logger.d.ts.map +1 -1
  45. package/dist/cjs/utils/logger.js +40 -3
  46. package/dist/cjs/utils/logger.js.map +1 -1
  47. package/dist/cjs/utils/validation.d.ts +6 -0
  48. package/dist/cjs/utils/validation.d.ts.map +1 -1
  49. package/dist/cjs/utils/validation.js +37 -0
  50. package/dist/cjs/utils/validation.js.map +1 -1
  51. package/dist/cjs/validation/keys.d.ts +7 -0
  52. package/dist/cjs/validation/keys.d.ts.map +1 -0
  53. package/dist/cjs/validation/keys.js +23 -0
  54. package/dist/cjs/validation/keys.js.map +1 -0
  55. package/dist/esm/event/index.d.ts +7 -0
  56. package/dist/esm/event/index.d.ts.map +1 -0
  57. package/dist/esm/event/index.js +7 -0
  58. package/dist/esm/event/index.js.map +1 -0
  59. package/dist/esm/event/signing.d.ts +12 -0
  60. package/dist/esm/event/signing.d.ts.map +1 -1
  61. package/dist/esm/event/signing.js +27 -0
  62. package/dist/esm/event/signing.js.map +1 -1
  63. package/dist/esm/index.d.ts +11 -8
  64. package/dist/esm/index.d.ts.map +1 -1
  65. package/dist/esm/index.js +16 -14
  66. package/dist/esm/index.js.map +1 -1
  67. package/dist/esm/nips/nip-04.d.ts +1 -1
  68. package/dist/esm/nips/nip-04.d.ts.map +1 -1
  69. package/dist/esm/nips/nip-04.js +3 -2
  70. package/dist/esm/nips/nip-04.js.map +1 -1
  71. package/dist/esm/protocol/index.d.ts +9 -9
  72. package/dist/esm/protocol/index.d.ts.map +1 -1
  73. package/dist/esm/protocol/index.js +8 -9
  74. package/dist/esm/protocol/index.js.map +1 -1
  75. package/dist/esm/types/base.d.ts +45 -121
  76. package/dist/esm/types/base.d.ts.map +1 -1
  77. package/dist/esm/types/base.js +10 -28
  78. package/dist/esm/types/base.js.map +1 -1
  79. package/dist/esm/utils/encoding.d.ts +12 -0
  80. package/dist/esm/utils/encoding.d.ts.map +1 -1
  81. package/dist/esm/utils/encoding.js +16 -0
  82. package/dist/esm/utils/encoding.js.map +1 -1
  83. package/dist/esm/utils/integration.d.ts +14 -15
  84. package/dist/esm/utils/integration.d.ts.map +1 -1
  85. package/dist/esm/utils/integration.js +136 -89
  86. package/dist/esm/utils/integration.js.map +1 -1
  87. package/dist/esm/utils/logger.d.ts +17 -2
  88. package/dist/esm/utils/logger.d.ts.map +1 -1
  89. package/dist/esm/utils/logger.js +38 -2
  90. package/dist/esm/utils/logger.js.map +1 -1
  91. package/dist/esm/utils/validation.d.ts +6 -0
  92. package/dist/esm/utils/validation.d.ts.map +1 -1
  93. package/dist/esm/utils/validation.js +36 -0
  94. package/dist/esm/utils/validation.js.map +1 -1
  95. package/dist/esm/validation/keys.d.ts +7 -0
  96. package/dist/esm/validation/keys.d.ts.map +1 -0
  97. package/dist/esm/validation/keys.js +20 -0
  98. package/dist/esm/validation/keys.js.map +1 -0
  99. package/package.json +2 -3
  100. package/src/__tests__/integration.test.ts +1 -1
  101. package/src/__tests__/types.test.ts +36 -242
  102. package/src/event/index.ts +7 -0
  103. package/src/event/signing.ts +29 -0
  104. package/src/index.ts +39 -47
  105. package/src/nips/nip-04.ts +4 -2
  106. package/src/protocol/index.ts +23 -14
  107. package/src/types/base.ts +58 -122
  108. package/src/utils/encoding.ts +18 -0
  109. package/src/utils/integration.ts +159 -107
  110. package/src/utils/logger.ts +46 -2
  111. package/src/utils/validation.ts +37 -0
  112. package/src/validation/keys.ts +19 -0
  113. package/dist/browser/551.nostr-crypto-utils.min.js +0 -1
  114. package/dist/browser/565.nostr-crypto-utils.min.js +0 -1
  115. package/dist/browser/69.nostr-crypto-utils.min.js +0 -1
  116. package/dist/browser/main-43dd7041.nostr-crypto-utils.min.js +0 -1
  117. package/dist/browser/main-7bd12dde.nostr-crypto-utils.min.js +0 -1
  118. package/dist/browser/main-d277ceb9.nostr-crypto-utils.min.js +0 -1
package/README.md CHANGED
@@ -12,6 +12,7 @@ This library provides essential cryptographic operations and utilities required
12
12
  - Encrypted direct messages (NIP-04)
13
13
  - Bech32-encoded entities (NIP-19)
14
14
  - Delegated event signing (NIP-26)
15
+ - Authentication protocol (NIP-42)
15
16
 
16
17
  ## Core Features
17
18
 
@@ -21,6 +22,7 @@ This library provides essential cryptographic operations and utilities required
21
22
  - NIP-04 encryption/decryption
22
23
  - Shared secret computation
23
24
  - Delegation token handling (NIP-26)
25
+ - Authentication protocol (NIP-42)
24
26
 
25
27
  ### Encoding Utilities
26
28
  - Hex encoding/decoding
@@ -34,6 +36,7 @@ This library provides essential cryptographic operations and utilities required
34
36
  - NIP-04: Encrypted Direct Messages
35
37
  - NIP-19: Bech32-Encoded Entities
36
38
  - NIP-26: Delegated Event Signing
39
+ - NIP-42: Authentication Protocol
37
40
 
38
41
  ## Project Structure
39
42
 
@@ -104,6 +107,7 @@ This library implements the following Nostr Implementation Possibilities (NIPs):
104
107
  | [NIP-04](https://github.com/nostr-protocol/nips/blob/master/04.md) | Encrypted Direct Messages | Secure, end-to-end encrypted direct messaging between users | ✅ Complete |
105
108
  | [NIP-19](https://github.com/nostr-protocol/nips/blob/master/19.md) | bech32-encoded Entities | Human-readable encoding for keys, events, and other entities | ✅ Complete |
106
109
  | [NIP-26](https://github.com/nostr-protocol/nips/blob/master/26.md) | Delegated Event Signing | Create and verify delegated event signing capabilities | ✅ Complete |
110
+ | [NIP-42](https://github.com/nostr-protocol/nips/blob/master/42.md) | Authentication | Client-relay authentication protocol | ✅ Complete |
107
111
 
108
112
  ### NIP-01 Features
109
113
  - Event creation and serialization
@@ -199,6 +203,52 @@ try {
199
203
  console.error(error); // Error: Invalid hex string
200
204
  }
201
205
 
206
+ ### Type System
207
+
208
+ #### Event Types
209
+ The library provides a comprehensive type system for Nostr events:
210
+
211
+ ```typescript
212
+ // Create an unsigned event
213
+ const unsignedEvent: UnsignedNostrEvent = {
214
+ kind: NostrEventKind.TEXT_NOTE,
215
+ content: "Hello Nostr!",
216
+ tags: [],
217
+ created_at: Math.floor(Date.now() / 1000)
218
+ };
219
+
220
+ // Sign the event
221
+ const signedEvent = await signEvent(unsignedEvent, privateKey);
222
+ ```
223
+
224
+ #### Authentication (NIP-42)
225
+ Support for NIP-42 authentication:
226
+
227
+ ```typescript
228
+ // Create an auth event
229
+ const authEvent: UnsignedNostrEvent = {
230
+ kind: NostrEventKind.AUTH,
231
+ content: "challenge-response",
232
+ tags: [["challenge", challenge]],
233
+ created_at: Math.floor(Date.now() / 1000)
234
+ };
235
+
236
+ // Sign and send the auth event
237
+ const signedAuthEvent = await signEvent(authEvent, privateKey);
238
+ ```
239
+
240
+ #### Custom Tags (NIP-12)
241
+ Support for arbitrary tags:
242
+
243
+ ```typescript
244
+ // Create a filter with custom tags
245
+ const filter: NostrFilter = {
246
+ kinds: [NostrEventKind.TEXT_NOTE],
247
+ "#t": ["nostr", "crypto"], // Filter by custom tag
248
+ limit: 10
249
+ };
250
+ ```
251
+
202
252
  ### Quick Start
203
253
 
204
254
  ### Installation
@@ -659,8 +709,8 @@ import { NostrEvent, NostrFilter, ValidationResult } from '@humanjavaenterprises
659
709
 
660
710
  // All types are properly defined
661
711
  const filter: NostrFilter = {
662
- kinds: [1],
663
- authors: ['pubkey1', 'pubkey2'],
712
+ kinds: [NostrEventKind.TEXT_NOTE],
713
+ "#t": ["nostr", "crypto"], // Filter by custom tag
664
714
  limit: 10
665
715
  };
666
716
 
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[343],{2343:(t,r)=>{const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const r=e.charAt(t);n[r]=t}function o(t){const r=t>>25;return(33554431&t)<<5^996825010&-(1&r)^642813549&-(r>>1&1)^513874426&-(r>>2&1)^1027748829&-(r>>3&1)^705979059&-(r>>4&1)}function i(t){let r=1;for(let e=0;e<t.length;++e){const n=t.charCodeAt(e);if(n<33||n>126)return"Invalid prefix ("+t+")";r=o(r)^n>>5}r=o(r);for(let e=0;e<t.length;++e){const n=t.charCodeAt(e);r=o(r)^31&n}return r}function s(t,r,e,n){let o=0,i=0;const s=(1<<e)-1,c=[];for(let n=0;n<t.length;++n)for(o=o<<r|t[n],i+=r;i>=e;)i-=e,c.push(o>>i&s);if(n)i>0&&c.push(o<<e-i&s);else{if(i>=r)return"Excess padding";if(o<<e-i&s)return"Non-zero padding"}return c}function c(t){return s(t,8,5,!0)}function f(t){const r=s(t,5,8,!1);if(Array.isArray(r))return r}function u(t){const r=s(t,5,8,!1);if(Array.isArray(r))return r;throw new Error(r)}function h(t){let r;function s(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";const s=t.toLowerCase(),c=t.toUpperCase();if(t!==s&&t!==c)return"Mixed-case string "+t;const f=(t=s).lastIndexOf("1");if(-1===f)return"No separator character for "+t;if(0===f)return"Missing prefix for "+t;const u=t.slice(0,f),h=t.slice(f+1);if(h.length<6)return"Data too short";let l=i(u);if("string"==typeof l)return l;const a=[];for(let t=0;t<h.length;++t){const r=h.charAt(t),e=n[r];if(void 0===e)return"Unknown character "+r;l=o(l)^e,t+6>=h.length||a.push(e)}return l!==r?"Invalid checksum for "+t:{prefix:u,words:a}}return r="bech32"===t?1:734539939,{decodeUnsafe:function(t,r){const e=s(t,r);if("object"==typeof e)return e},decode:function(t,r){const e=s(t,r);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError("Exceeds length limit");let c=i(t=t.toLowerCase());if("string"==typeof c)throw new Error(c);let f=t+"1";for(let t=0;t<n.length;++t){const r=n[t];if(r>>5)throw new Error("Non 5-bit word");c=o(c)^r,f+=e.charAt(r)}for(let t=0;t<6;++t)c=o(c);c^=r;for(let t=0;t<6;++t)f+=e.charAt(c>>5*(5-t)&31);return f},toWords:c,fromWordsUnsafe:f,fromWords:u}}h("bech32"),h("bech32m")}}]);
@@ -0,0 +1 @@
1
+ (this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[419],{295:(t,e,r)=>{var i=r(8287).Buffer;t.exports=function(t,e){for(var r=Math.min(t.length,e.length),n=new i(r),o=0;o<r;++o)n[o]=t[o]^e[o];return n}},6168:(t,e,r)=>{"use strict";var i=r(2861).Buffer,n=r(8310).Transform,o=r(3141).I;function s(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(s,n);var f="undefined"!=typeof Uint8Array,a="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(i.prototype instanceof Uint8Array||i.TYPED_ARRAY_SUPPORT);s.prototype.update=function(t,e,r){var n=function(t,e){if(t instanceof i)return t;if("string"==typeof t)return i.from(t,e);if(a&&ArrayBuffer.isView(t)){if(0===t.byteLength)return i.alloc(0);var r=i.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(f&&t instanceof Uint8Array)return i.from(t);if(i.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return i.from(t);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e),o=this._update(n);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){i=t}finally{r(i)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||i.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i},t.exports=s},5622:(t,e,r)=>{function i(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===i(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===i(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===i(t)},e.isError=function(t){return"[object Error]"===i(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(8287).Buffer.isBuffer},1324:(t,e,r)=>{var i=r(8287).Buffer,n=r(6729),o=r(2801);t.exports=function(t){return new f(t)};var s={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function f(t){this.curveType=s[t],this.curveType||(this.curveType={name:t}),this.curve=new n.ec(this.curveType.name),this.keys=void 0}function a(t,e,r){Array.isArray(t)||(t=t.toArray());var n=new i(t);if(r&&n.length<r){var o=new i(r-n.length);o.fill(0),n=i.concat([o,n])}return e?n.toString(e):n}s.p224=s.secp224r1,s.p256=s.secp256r1=s.prime256v1,s.p192=s.secp192r1=s.prime192v1,s.p384=s.secp384r1,s.p521=s.secp521r1,f.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},f.prototype.computeSecret=function(t,e,r){return e=e||"utf8",i.isBuffer(t)||(t=new i(t,e)),a(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},f.prototype.getPublicKey=function(t,e){var r=this.keys.getPublic("compressed"===e,!0);return"hybrid"===e&&(r[r.length-1]%2?r[0]=7:r[0]=6),a(r,t)},f.prototype.getPrivateKey=function(t){return a(this.keys.getPrivate(),t)},f.prototype.setPublicKey=function(t,e){return e=e||"utf8",i.isBuffer(t)||(t=new i(t,e)),this.keys._importPublic(t),this},f.prototype.setPrivateKey=function(t,e){e=e||"utf8",i.isBuffer(t)||(t=new i(t,e));var r=new o(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}},7108:(t,e,r)=>{"use strict";var i=r(6698),n=r(8276),o=r(6011),s=r(2802),f=r(6168);function a(t){f.call(this,"digest"),this._hash=t}i(a,f),a.prototype._update=function(t){this._hash.update(t)},a.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new n:"rmd160"===t||"ripemd160"===t?new o:new a(s(t))}},320:(t,e,r)=>{var i=r(8276);t.exports=function(t){return(new i).update(t).digest()}},3507:(t,e,r)=>{"use strict";var i=r(6698),n=r(1800),o=r(6168),s=r(2861).Buffer,f=r(320),a=r(6011),p=r(2802),u=s.alloc(128);function c(t,e){o.call(this,"digest"),"string"==typeof e&&(e=s.from(e));var r="sha512"===t||"sha384"===t?128:64;this._alg=t,this._key=e,e.length>r?e=("rmd160"===t?new a:p(t)).update(e).digest():e.length<r&&(e=s.concat([e,u],r));for(var i=this._ipad=s.allocUnsafe(r),n=this._opad=s.allocUnsafe(r),f=0;f<r;f++)i[f]=54^e[f],n[f]=92^e[f];this._hash="rmd160"===t?new a:p(t),this._hash.update(i)}i(c,o),c.prototype._update=function(t){this._hash.update(t)},c.prototype._final=function(){var t=this._hash.digest();return("rmd160"===this._alg?new a:p(this._alg)).update(this._opad).update(t).digest()},t.exports=function(t,e){return"rmd160"===(t=t.toLowerCase())||"ripemd160"===t?new c("rmd160",e):"md5"===t?new n(f,e):new c(t,e)}},1800:(t,e,r)=>{"use strict";var i=r(6698),n=r(2861).Buffer,o=r(6168),s=n.alloc(128),f=64;function a(t,e){o.call(this,"digest"),"string"==typeof e&&(e=n.from(e)),this._alg=t,this._key=e,e.length>f?e=t(e):e.length<f&&(e=n.concat([e,s],f));for(var r=this._ipad=n.allocUnsafe(f),i=this._opad=n.allocUnsafe(f),a=0;a<f;a++)r[a]=54^e[a],i[a]=92^e[a];this._hash=[r]}i(a,o),a.prototype._update=function(t){this._hash.push(t)},a.prototype._final=function(){var t=this._alg(n.concat(this._hash));return this._alg(n.concat([this._opad,t]))},t.exports=a},1565:(t,e,r)=>{"use strict";e.randomBytes=e.rng=e.pseudoRandomBytes=e.prng=r(3209),e.createHash=e.Hash=r(7108),e.createHmac=e.Hmac=r(3507);var i=r(5715),n=Object.keys(i),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);e.getHashes=function(){return o};var s=r(8396);e.pbkdf2=s.pbkdf2,e.pbkdf2Sync=s.pbkdf2Sync;var f=r(125);e.Cipher=f.Cipher,e.createCipher=f.createCipher,e.Cipheriv=f.Cipheriv,e.createCipheriv=f.createCipheriv,e.Decipher=f.Decipher,e.createDecipher=f.createDecipher,e.Decipheriv=f.Decipheriv,e.createDecipheriv=f.createDecipheriv,e.getCiphers=f.getCiphers,e.listCiphers=f.listCiphers;var a=r(5380);e.DiffieHellmanGroup=a.DiffieHellmanGroup,e.createDiffieHellmanGroup=a.createDiffieHellmanGroup,e.getDiffieHellman=a.getDiffieHellman,e.createDiffieHellman=a.createDiffieHellman,e.DiffieHellman=a.DiffieHellman;var p=r(20);e.createSign=p.createSign,e.Sign=p.Sign,e.createVerify=p.createVerify,e.Verify=p.Verify,e.createECDH=r(1324);var u=r(7168);e.publicEncrypt=u.publicEncrypt,e.privateEncrypt=u.privateEncrypt,e.publicDecrypt=u.publicDecrypt,e.privateDecrypt=u.privateDecrypt;var c=r(6983);e.randomFill=c.randomFill,e.randomFillSync=c.randomFillSync,e.createCredentials=function(){throw new Error("sorry, createCredentials is not implemented yet\nwe accept pull requests\nhttps://github.com/browserify/crypto-browserify")},e.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},9560:(t,e,r)=>{"use strict";e.utils=r(7626),e.Cipher=r(2808),e.DES=r(2211),e.CBC=r(3389),e.EDE=r(5279)},3389:(t,e,r)=>{"use strict";var i=r(3349),n=r(6698),o={};function s(t){i.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;e<this.iv.length;e++)this.iv[e]=t[e]}e.instantiate=function(t){function e(e){t.call(this,e),this._cbcInit()}n(e,t);for(var r=Object.keys(o),i=0;i<r.length;i++){var s=r[i];e.prototype[s]=o[s]}return e.create=function(t){return new e(t)},e},o._cbcInit=function(){var t=new s(this.options.iv);this._cbcState=t},o._update=function(t,e,r,i){var n=this._cbcState,o=this.constructor.super_.prototype,s=n.iv;if("encrypt"===this.type){for(var f=0;f<this.blockSize;f++)s[f]^=t[e+f];for(o._update.call(this,s,0,r,i),f=0;f<this.blockSize;f++)s[f]=r[i+f]}else{for(o._update.call(this,t,e,r,i),f=0;f<this.blockSize;f++)r[i+f]^=s[f];for(f=0;f<this.blockSize;f++)s[f]=t[e+f]}}},2808:(t,e,r)=>{"use strict";var i=r(3349);function n(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=!1!==t.padding}t.exports=n,n.prototype._init=function(){},n.prototype.update=function(t){return 0===t.length?[]:"decrypt"===this.type?this._updateDecrypt(t):this._updateEncrypt(t)},n.prototype._buffer=function(t,e){for(var r=Math.min(this.buffer.length-this.bufferOff,t.length-e),i=0;i<r;i++)this.buffer[this.bufferOff+i]=t[e+i];return this.bufferOff+=r,r},n.prototype._flushBuffer=function(t,e){return this._update(this.buffer,0,t,e),this.bufferOff=0,this.blockSize},n.prototype._updateEncrypt=function(t){var e=0,r=0,i=(this.bufferOff+t.length)/this.blockSize|0,n=new Array(i*this.blockSize);0!==this.bufferOff&&(e+=this._buffer(t,e),this.bufferOff===this.buffer.length&&(r+=this._flushBuffer(n,r)));for(var o=t.length-(t.length-e)%this.blockSize;e<o;e+=this.blockSize)this._update(t,e,n,r),r+=this.blockSize;for(;e<t.length;e++,this.bufferOff++)this.buffer[this.bufferOff]=t[e];return n},n.prototype._updateDecrypt=function(t){for(var e=0,r=0,i=Math.ceil((this.bufferOff+t.length)/this.blockSize)-1,n=new Array(i*this.blockSize);i>0;i--)e+=this._buffer(t,e),r+=this._flushBuffer(n,r);return e+=this._buffer(t,e),n},n.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},n.prototype._pad=function(t,e){if(0===e)return!1;for(;e<t.length;)t[e++]=0;return!0},n.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var t=new Array(this.blockSize);return this._update(this.buffer,0,t,0),t},n.prototype._unpad=function(t){return t},n.prototype._finalDecrypt=function(){i.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var t=new Array(this.blockSize);return this._flushBuffer(t,0),this._unpad(t)}},2211:(t,e,r)=>{"use strict";var i=r(3349),n=r(6698),o=r(7626),s=r(2808);function f(){this.tmp=new Array(2),this.keys=null}function a(t){s.call(this,t);var e=new f;this._desState=e,this.deriveKeys(e,t.key)}n(a,s),t.exports=a,a.create=function(t){return new a(t)};var p=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];a.prototype.deriveKeys=function(t,e){t.keys=new Array(32),i.equal(e.length,this.blockSize,"Invalid key length");var r=o.readUInt32BE(e,0),n=o.readUInt32BE(e,4);o.pc1(r,n,t.tmp,0),r=t.tmp[0],n=t.tmp[1];for(var s=0;s<t.keys.length;s+=2){var f=p[s>>>1];r=o.r28shl(r,f),n=o.r28shl(n,f),o.pc2(r,n,t.keys,s)}},a.prototype._update=function(t,e,r,i){var n=this._desState,s=o.readUInt32BE(t,e),f=o.readUInt32BE(t,e+4);o.ip(s,f,n.tmp,0),s=n.tmp[0],f=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,f,n.tmp,0):this._decrypt(n,s,f,n.tmp,0),s=n.tmp[0],f=n.tmp[1],o.writeUInt32BE(r,s,i),o.writeUInt32BE(r,f,i+4)},a.prototype._pad=function(t,e){if(!1===this.padding)return!1;for(var r=t.length-e,i=e;i<t.length;i++)t[i]=r;return!0},a.prototype._unpad=function(t){if(!1===this.padding)return t;for(var e=t[t.length-1],r=t.length-e;r<t.length;r++)i.equal(t[r],e);return t.slice(0,t.length-e)},a.prototype._encrypt=function(t,e,r,i,n){for(var s=e,f=r,a=0;a<t.keys.length;a+=2){var p=t.keys[a],u=t.keys[a+1];o.expand(f,t.tmp,0),p^=t.tmp[0],u^=t.tmp[1];var c=o.substitute(p,u),h=f;f=(s^o.permute(c))>>>0,s=h}o.rip(f,s,i,n)},a.prototype._decrypt=function(t,e,r,i,n){for(var s=r,f=e,a=t.keys.length-2;a>=0;a-=2){var p=t.keys[a],u=t.keys[a+1];o.expand(s,t.tmp,0),p^=t.tmp[0],u^=t.tmp[1];var c=o.substitute(p,u),h=s;s=(f^o.permute(c))>>>0,f=h}o.rip(s,f,i,n)}},5279:(t,e,r)=>{"use strict";var i=r(3349),n=r(6698),o=r(2808),s=r(2211);function f(t,e){i.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),n=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:n}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:n}),s.create({type:"decrypt",key:r})]}function a(t){o.call(this,t);var e=new f(this.type,this.options.key);this._edeState=e}n(a,o),t.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,i){var n=this._edeState;n.ciphers[0]._update(t,e,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},7626:(t,e)=>{"use strict";e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},e.ip=function(t,e,r,i){for(var n=0,o=0,s=6;s>=0;s-=2){for(var f=0;f<=24;f+=8)n<<=1,n|=e>>>f+s&1;for(f=0;f<=24;f+=8)n<<=1,n|=t>>>f+s&1}for(s=6;s>=0;s-=2){for(f=1;f<=25;f+=8)o<<=1,o|=e>>>f+s&1;for(f=1;f<=25;f+=8)o<<=1,o|=t>>>f+s&1}r[i+0]=n>>>0,r[i+1]=o>>>0},e.rip=function(t,e,r,i){for(var n=0,o=0,s=0;s<4;s++)for(var f=24;f>=0;f-=8)n<<=1,n|=e>>>f+s&1,n<<=1,n|=t>>>f+s&1;for(s=4;s<8;s++)for(f=24;f>=0;f-=8)o<<=1,o|=e>>>f+s&1,o<<=1,o|=t>>>f+s&1;r[i+0]=n>>>0,r[i+1]=o>>>0},e.pc1=function(t,e,r,i){for(var n=0,o=0,s=7;s>=5;s--){for(var f=0;f<=24;f+=8)n<<=1,n|=e>>f+s&1;for(f=0;f<=24;f+=8)n<<=1,n|=t>>f+s&1}for(f=0;f<=24;f+=8)n<<=1,n|=e>>f+s&1;for(s=1;s<=3;s++){for(f=0;f<=24;f+=8)o<<=1,o|=e>>f+s&1;for(f=0;f<=24;f+=8)o<<=1,o|=t>>f+s&1}for(f=0;f<=24;f+=8)o<<=1,o|=t>>f+s&1;r[i+0]=n>>>0,r[i+1]=o>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,i,n){for(var o=0,s=0,f=r.length>>>1,a=0;a<f;a++)o<<=1,o|=t>>>r[a]&1;for(a=f;a<r.length;a++)s<<=1,s|=e>>>r[a]&1;i[n+0]=o>>>0,i[n+1]=s>>>0},e.expand=function(t,e,r){var i=0,n=0;i=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)i<<=6,i|=t>>>o&63;for(o=11;o>=3;o-=4)n|=t>>>o&63,n<<=6;n|=(31&t)<<1|t>>>31,e[r+0]=i>>>0,e[r+1]=n>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var r=0,n=0;n<4;n++)r<<=4,r|=i[64*n+(t>>>18-6*n&63)];for(n=0;n<4;n++)r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)];return r>>>0};var n=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,r=0;r<n.length;r++)e<<=1,e|=t>>>n[r]&1;return e>>>0},e.padSplit=function(t,e,r){for(var i=t.toString(2);i.length<e;)i="0"+i;for(var n=[],o=0;o<e;o+=r)n.push(i.slice(o,o+r));return n.join(" ")}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 657.nostr-crypto-utils.min.js.LICENSE.txt */
2
- (this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[657],{3562:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getHash=s,e.createCurve=function(t,e){const r=e=>(0,o.weierstrass)({...t,...s(e)});return Object.freeze({...r(e),create:r})};const n=r(9615),i=r(9175),o=r(1705);function s(t){return{hash:t,hmac:(e,...r)=>(0,n.hmac)(t,e,(0,i.concatBytes)(...r)),randomBytes:i.randomBytes}}},2422:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.wNAF=function(t,e){return{constTimeNegate:a,hasPrecomputes:t=>1!==w(t),unsafeLadder(e,r,n=t.ZERO){let i=e;for(;r>o;)r&s&&(n=n.add(i)),i=i.double(),r>>=s;return n},precomputeWindow(t,r){const{windows:n,windowSize:i}=f(r,e),o=[];let s=t,a=s;for(let t=0;t<n;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(r,n,i){const{windows:o,windowSize:c}=f(r,e);let u=t.ZERO,h=t.BASE;const d=BigInt(2**r-1),l=2**r,w=BigInt(r);for(let t=0;t<o;t++){const e=t*c;let r=Number(i&d);i>>=w,r>c&&(r-=l,i+=s);const o=e,f=e+Math.abs(r)-1,p=t%2!=0,g=r<0;0===r?h=h.add(a(p,n[o])):u=u.add(a(g,n[f]))}return{p:u,f:h}},wNAFUnsafe(r,n,i,a=t.ZERO){const{windows:c,windowSize:u}=f(r,e),h=BigInt(2**r-1),d=2**r,l=BigInt(r);for(let t=0;t<c;t++){const e=t*u;if(i===o)break;let r=Number(i&h);if(i>>=l,r>u&&(r-=d,i+=s),0===r)continue;let c=n[e+Math.abs(r)-1];r<0&&(c=c.negate()),a=a.add(c)}return a},getPrecomputes(t,e,r){let n=d.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&d.set(e,r(n))),n},wNAFCached(t,e,r){const n=w(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)},wNAFCachedUnsafe(t,e,r,n){const i=w(t);return 1===i?this.unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)},setWindowSize(t,r){c(r,e),l.set(t,r),d.delete(t)}}},e.pippenger=function(t,e,r,n){if(u(r,t),h(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,s=(0,i.bitLen)(BigInt(r.length)),a=s>12?s-3:s>4?s-2:s?2:1,c=(1<<a)-1,f=new Array(c+1).fill(o);let d=o;for(let t=Math.floor((e.BITS-1)/a)*a;t>=0;t-=a){f.fill(o);for(let e=0;e<n.length;e++){const i=n[e],o=Number(i>>BigInt(t)&BigInt(c));f[o]=f[o].add(r[e])}let e=o;for(let t=f.length-1,r=o;t>0;t--)r=r.add(f[t]),e=e.add(r);if(d=d.add(e),0!==t)for(let t=0;t<a;t++)d=d.double()}return d},e.precomputeMSMUnsafe=function(t,e,r,n){c(n,e.BITS),u(r,t);const i=t.ZERO,o=2**n-1,s=Math.ceil(e.BITS/n),a=BigInt((1<<n)-1),f=r.map((t=>{const e=[];for(let r=0,n=t;r<o;r++)e.push(n),n=n.add(t);return e}));return t=>{if(h(t,e),t.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let e=0;e<s;e++){if(o!==i)for(let t=0;t<n;t++)o=o.double();const r=BigInt(s*n-(e+1)*n);for(let e=0;e<t.length;e++){const n=t[e],i=Number(n>>r&a);i&&(o=o.add(f[e][i-1]))}}return o}},e.validateBasic=function(t){return(0,n.validateField)(t.Fp),(0,i.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})};const n=r(4967),i=r(1484),o=BigInt(0),s=BigInt(1);function a(t,e){const r=e.negate();return t?r:e}function c(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function f(t,e){return c(t,e),{windows:Math.ceil(e/t)+1,windowSize:2**(t-1)}}function u(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach(((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)}))}function h(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach(((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)}))}const d=new WeakMap,l=new WeakMap;function w(t){return l.get(t)||1}},8276:(t,e,r)=>{"use strict";var n=r(6698),i=r(4729),o=r(2861).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(t,e){return t<<e|t>>>32-e}function f(t,e,r,n,i,o,s){return c(t+(e&r|~e&n)+i+o|0,s)+e|0}function u(t,e,r,n,i,o,s){return c(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return c(t+(e^r^n)+i+o|0,s)+e|0}function d(t,e,r,n,i,o,s){return c(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=f(r,n,i,o,t[0],3614090360,7),o=f(o,r,n,i,t[1],3905402710,12),i=f(i,o,r,n,t[2],606105819,17),n=f(n,i,o,r,t[3],3250441966,22),r=f(r,n,i,o,t[4],4118548399,7),o=f(o,r,n,i,t[5],1200080426,12),i=f(i,o,r,n,t[6],2821735955,17),n=f(n,i,o,r,t[7],4249261313,22),r=f(r,n,i,o,t[8],1770035416,7),o=f(o,r,n,i,t[9],2336552879,12),i=f(i,o,r,n,t[10],4294925233,17),n=f(n,i,o,r,t[11],2304563134,22),r=f(r,n,i,o,t[12],1804603682,7),o=f(o,r,n,i,t[13],4254626195,12),i=f(i,o,r,n,t[14],2792965006,17),r=u(r,n=f(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=u(o,r,n,i,t[6],3225465664,9),i=u(i,o,r,n,t[11],643717713,14),n=u(n,i,o,r,t[0],3921069994,20),r=u(r,n,i,o,t[5],3593408605,5),o=u(o,r,n,i,t[10],38016083,9),i=u(i,o,r,n,t[15],3634488961,14),n=u(n,i,o,r,t[4],3889429448,20),r=u(r,n,i,o,t[9],568446438,5),o=u(o,r,n,i,t[14],3275163606,9),i=u(i,o,r,n,t[3],4107603335,14),n=u(n,i,o,r,t[8],1163531501,20),r=u(r,n,i,o,t[13],2850285829,5),o=u(o,r,n,i,t[2],4243563512,9),i=u(i,o,r,n,t[7],1735328473,14),r=h(r,n=u(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=d(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=d(o,r,n,i,t[7],1126891415,10),i=d(i,o,r,n,t[14],2878612391,15),n=d(n,i,o,r,t[5],4237533241,21),r=d(r,n,i,o,t[12],1700485571,6),o=d(o,r,n,i,t[3],2399980690,10),i=d(i,o,r,n,t[10],4293915773,15),n=d(n,i,o,r,t[1],2240044497,21),r=d(r,n,i,o,t[8],1873313359,6),o=d(o,r,n,i,t[15],4264355552,10),i=d(i,o,r,n,t[6],2734768916,15),n=d(n,i,o,r,t[13],1309151649,21),r=d(r,n,i,o,t[4],4149444226,6),o=d(o,r,n,i,t[11],3174756917,10),i=d(i,o,r,n,t[2],718787259,15),n=d(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},2244:(t,e,r)=>{var n=r(1158),i=r(5037);function o(t){this.rand=t||new i.Rand}t.exports=o,o.create=function(t){return new o(t)},o.prototype._randbelow=function(t){var e=t.bitLength(),r=Math.ceil(e/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(t)>=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),c=0;!a.testn(c);c++);for(var f=t.shrn(c),u=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var d=h.toRed(o).redPow(f);if(0!==d.cmp(s)&&0!==d.cmp(u)){for(var l=1;l<c;l++){if(0===(d=d.redSqr()).cmp(s))return!1;if(0===d.cmp(u))break}if(l===c)return!1}}return!0},o.prototype.getDivisor=function(t,e){var r=t.bitLength(),i=n.mont(t),o=new n(1).toRed(i);e||(e=Math.max(1,r/48|0));for(var s=t.subn(1),a=0;!s.testn(a);a++);for(var c=t.shrn(a),f=s.toRed(i);e>0;e--){var u=this._randrange(new n(2),s),h=t.gcd(u);if(0!==h.cmpn(1))return h;var d=u.toRed(i).redPow(c);if(0!==d.cmp(o)&&0!==d.cmp(f)){for(var l=1;l<a;l++){if(0===(d=d.redSqr()).cmp(o))return d.fromRed().subn(1).gcd(t);if(0===d.cmp(f))break}if(l===a)return(d=d.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},3349:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},4367:(t,e)=>{"use strict";var r=e;function n(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16));else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}}]);
2
+ (this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[657],{3562:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getHash=s,e.createCurve=function(t,e){const r=e=>(0,o.weierstrass)({...t,...s(e)});return{...r(e),create:r}};const n=r(9615),i=r(9175),o=r(1705);function s(t){return{hash:t,hmac:(e,...r)=>(0,n.hmac)(t,e,(0,i.concatBytes)(...r)),randomBytes:i.randomBytes}}},2422:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.wNAF=function(t,e){return{constTimeNegate:a,hasPrecomputes:t=>1!==w(t),unsafeLadder(e,r,n=t.ZERO){let i=e;for(;r>o;)r&s&&(n=n.add(i)),i=i.double(),r>>=s;return n},precomputeWindow(t,r){const{windows:n,windowSize:i}=f(r,e),o=[];let s=t,a=s;for(let t=0;t<n;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(r,n,i){const{windows:o,windowSize:c}=f(r,e);let u=t.ZERO,h=t.BASE;const d=BigInt(2**r-1),l=2**r,w=BigInt(r);for(let t=0;t<o;t++){const e=t*c;let r=Number(i&d);i>>=w,r>c&&(r-=l,i+=s);const o=e,f=e+Math.abs(r)-1,p=t%2!=0,g=r<0;0===r?h=h.add(a(p,n[o])):u=u.add(a(g,n[f]))}return{p:u,f:h}},wNAFUnsafe(r,n,i,a=t.ZERO){const{windows:c,windowSize:u}=f(r,e),h=BigInt(2**r-1),d=2**r,l=BigInt(r);for(let t=0;t<c;t++){const e=t*u;if(i===o)break;let r=Number(i&h);if(i>>=l,r>u&&(r-=d,i+=s),0===r)continue;let c=n[e+Math.abs(r)-1];r<0&&(c=c.negate()),a=a.add(c)}return a},getPrecomputes(t,e,r){let n=d.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&d.set(e,r(n))),n},wNAFCached(t,e,r){const n=w(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)},wNAFCachedUnsafe(t,e,r,n){const i=w(t);return 1===i?this.unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)},setWindowSize(t,r){c(r,e),l.set(t,r),d.delete(t)}}},e.pippenger=function(t,e,r,n){if(u(r,t),h(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,s=(0,i.bitLen)(BigInt(r.length)),a=s>12?s-3:s>4?s-2:s?2:1,c=(1<<a)-1,f=new Array(c+1).fill(o);let d=o;for(let t=Math.floor((e.BITS-1)/a)*a;t>=0;t-=a){f.fill(o);for(let e=0;e<n.length;e++){const i=n[e],o=Number(i>>BigInt(t)&BigInt(c));f[o]=f[o].add(r[e])}let e=o;for(let t=f.length-1,r=o;t>0;t--)r=r.add(f[t]),e=e.add(r);if(d=d.add(e),0!==t)for(let t=0;t<a;t++)d=d.double()}return d},e.precomputeMSMUnsafe=function(t,e,r,n){c(n,e.BITS),u(r,t);const i=t.ZERO,o=2**n-1,s=Math.ceil(e.BITS/n),a=BigInt((1<<n)-1),f=r.map((t=>{const e=[];for(let r=0,n=t;r<o;r++)e.push(n),n=n.add(t);return e}));return t=>{if(h(t,e),t.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let e=0;e<s;e++){if(o!==i)for(let t=0;t<n;t++)o=o.double();const r=BigInt(s*n-(e+1)*n);for(let e=0;e<t.length;e++){const n=t[e],i=Number(n>>r&a);i&&(o=o.add(f[e][i-1]))}}return o}},e.validateBasic=function(t){return(0,n.validateField)(t.Fp),(0,i.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})};const n=r(4967),i=r(1484),o=BigInt(0),s=BigInt(1);function a(t,e){const r=e.negate();return t?r:e}function c(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function f(t,e){return c(t,e),{windows:Math.ceil(e/t)+1,windowSize:2**(t-1)}}function u(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach(((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)}))}function h(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach(((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)}))}const d=new WeakMap,l=new WeakMap;function w(t){return l.get(t)||1}},8276:(t,e,r)=>{"use strict";var n=r(6698),i=r(4729),o=r(2861).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(t,e){return t<<e|t>>>32-e}function f(t,e,r,n,i,o,s){return c(t+(e&r|~e&n)+i+o|0,s)+e|0}function u(t,e,r,n,i,o,s){return c(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return c(t+(e^r^n)+i+o|0,s)+e|0}function d(t,e,r,n,i,o,s){return c(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=f(r,n,i,o,t[0],3614090360,7),o=f(o,r,n,i,t[1],3905402710,12),i=f(i,o,r,n,t[2],606105819,17),n=f(n,i,o,r,t[3],3250441966,22),r=f(r,n,i,o,t[4],4118548399,7),o=f(o,r,n,i,t[5],1200080426,12),i=f(i,o,r,n,t[6],2821735955,17),n=f(n,i,o,r,t[7],4249261313,22),r=f(r,n,i,o,t[8],1770035416,7),o=f(o,r,n,i,t[9],2336552879,12),i=f(i,o,r,n,t[10],4294925233,17),n=f(n,i,o,r,t[11],2304563134,22),r=f(r,n,i,o,t[12],1804603682,7),o=f(o,r,n,i,t[13],4254626195,12),i=f(i,o,r,n,t[14],2792965006,17),r=u(r,n=f(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=u(o,r,n,i,t[6],3225465664,9),i=u(i,o,r,n,t[11],643717713,14),n=u(n,i,o,r,t[0],3921069994,20),r=u(r,n,i,o,t[5],3593408605,5),o=u(o,r,n,i,t[10],38016083,9),i=u(i,o,r,n,t[15],3634488961,14),n=u(n,i,o,r,t[4],3889429448,20),r=u(r,n,i,o,t[9],568446438,5),o=u(o,r,n,i,t[14],3275163606,9),i=u(i,o,r,n,t[3],4107603335,14),n=u(n,i,o,r,t[8],1163531501,20),r=u(r,n,i,o,t[13],2850285829,5),o=u(o,r,n,i,t[2],4243563512,9),i=u(i,o,r,n,t[7],1735328473,14),r=h(r,n=u(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=d(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=d(o,r,n,i,t[7],1126891415,10),i=d(i,o,r,n,t[14],2878612391,15),n=d(n,i,o,r,t[5],4237533241,21),r=d(r,n,i,o,t[12],1700485571,6),o=d(o,r,n,i,t[3],2399980690,10),i=d(i,o,r,n,t[10],4293915773,15),n=d(n,i,o,r,t[1],2240044497,21),r=d(r,n,i,o,t[8],1873313359,6),o=d(o,r,n,i,t[15],4264355552,10),i=d(i,o,r,n,t[6],2734768916,15),n=d(n,i,o,r,t[13],1309151649,21),r=d(r,n,i,o,t[4],4149444226,6),o=d(o,r,n,i,t[11],3174756917,10),i=d(i,o,r,n,t[2],718787259,15),n=d(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},2244:(t,e,r)=>{var n=r(1158),i=r(5037);function o(t){this.rand=t||new i.Rand}t.exports=o,o.create=function(t){return new o(t)},o.prototype._randbelow=function(t){var e=t.bitLength(),r=Math.ceil(e/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(t)>=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),c=0;!a.testn(c);c++);for(var f=t.shrn(c),u=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var d=h.toRed(o).redPow(f);if(0!==d.cmp(s)&&0!==d.cmp(u)){for(var l=1;l<c;l++){if(0===(d=d.redSqr()).cmp(s))return!1;if(0===d.cmp(u))break}if(l===c)return!1}}return!0},o.prototype.getDivisor=function(t,e){var r=t.bitLength(),i=n.mont(t),o=new n(1).toRed(i);e||(e=Math.max(1,r/48|0));for(var s=t.subn(1),a=0;!s.testn(a);a++);for(var c=t.shrn(a),f=s.toRed(i);e>0;e--){var u=this._randrange(new n(2),s),h=t.gcd(u);if(0!==h.cmpn(1))return h;var d=u.toRed(i).redPow(c);if(0!==d.cmp(o)&&0!==d.cmp(f)){for(var l=1;l<a;l++){if(0===(d=d.redSqr()).cmp(o))return d.fromRed().subn(1).gcd(t);if(0===d.cmp(f))break}if(l===a)return(d=d.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},3349:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},4367:(t,e)=>{"use strict";var r=e;function n(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16));else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 705.nostr-crypto-utils.min.js.LICENSE.txt */
2
- "use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[705],{1705:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DER=void 0,e.weierstrassPoints=y,e.weierstrass=function(t){const r=function(t){const e=(0,n.validateBasic)(t);return i.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:l,n:u}=r,h=l.BYTES+1,f=2*l.BYTES+1;function m(t){return o.mod(t,u)}function p(t){return o.invert(t,u)}const{ProjectivePoint:w,normPrivateKeyToScalar:g,weierstrassEquation:E,isWithinCurveOrder:v}=y({...r,toBytes(t,e,r){const n=e.toAffine(),o=l.toBytes(n.x),a=i.concatBytes;return(0,s.abool)("isCompressed",r),r?a(Uint8Array.from([e.hasEvenY()?2:3]),o):a(Uint8Array.from([4]),o,l.toBytes(n.y))},fromBytes(t){const e=t.length,r=t[0],n=t.subarray(1);if(e!==h||2!==r&&3!==r){if(e===f&&4===r)return{x:l.fromBytes(n.subarray(0,l.BYTES)),y:l.fromBytes(n.subarray(l.BYTES,2*l.BYTES))};throw new Error("invalid Point, expected length of "+h+", or uncompressed "+f+", got "+e)}{const t=i.bytesToNumberBE(n);if(!i.inRange(t,c,l.ORDER))throw new Error("Point is not on curve");const e=E(t);let o;try{o=l.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("Point is not on curve"+e)}return!(1&~r)!=((o&c)===c)&&(o=l.neg(o)),{x:t,y:o}}}}),b=t=>i.bytesToHex(i.numberToBytesBE(t,r.nByteLength));function B(t){return t>u>>c}const x=(t,e,r)=>i.bytesToNumberBE(t.slice(e,r));class R{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const e=r.nByteLength;return t=(0,s.ensureBytes)("compactSignature",t,2*e),new R(x(t,0,e),x(t,e,2*e))}static fromDER(t){const{r,s:n}=e.DER.toSig((0,s.ensureBytes)("DER",t));return new R(r,n)}assertValidity(){i.aInRange("r",this.r,c,u),i.aInRange("s",this.s,c,u)}addRecoveryBit(t){return new R(this.r,this.s,t)}recoverPublicKey(t){const{r:e,s:n,recovery:o}=this,i=T((0,s.ensureBytes)("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const a=2===o||3===o?e+r.n:e;if(a>=l.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=1&o?"03":"02",d=w.fromHex(u+b(a)),c=p(a),h=m(-i*c),f=m(n*c),y=w.BASE.multiplyAndAddUnsafe(d,h,f);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return B(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,m(-this.s),this.recovery):this}toDERRawBytes(){return i.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return i.hexToBytes(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const S={isValidPrivateKey(t){try{return g(t),!0}catch(t){return!1}},normPrivateKeyToScalar:g,randomPrivateKey:()=>{const t=o.getMinHashLength(r.n);return o.mapHashToField(r.randomBytes(t),r.n)},precompute:(t=8,e=w.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function O(t){const e=i.isBytes(t),r="string"==typeof t,n=(e||r)&&t.length;return e?n===h||n===f:r?n===2*h||n===2*f:t instanceof w}const A=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=i.bytesToNumberBE(t),n=8*t.length-r.nBitLength;return n>0?e>>BigInt(n):e},T=r.bits2int_modN||function(t){return m(A(t))},q=i.bitMask(r.nBitLength);function z(t){return i.aInRange("num < 2^"+r.nBitLength,t,d,q),i.numberToBytesBE(t,r.nByteLength)}const N={lowS:r.lowS,prehash:!1},P={lowS:r.lowS,prehash:!1};return w.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(t,e=!0){return w.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(O(t))throw new Error("first arg must be private key");if(!O(e))throw new Error("second arg must be public key");return w.fromHex(e).multiply(g(t)).toRawBytes(r)},sign:function(t,e,n=N){const{seed:o,k2sig:u}=function(t,e,n=N){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:u}=r;let{lowS:h,prehash:f,extraEntropy:y}=n;null==h&&(h=!0),t=(0,s.ensureBytes)("msgHash",t),a(n),f&&(t=(0,s.ensureBytes)("prehashed msgHash",o(t)));const E=T(t),b=g(e),x=[z(b),z(E)];if(null!=y&&!1!==y){const t=!0===y?u(l.BYTES):y;x.push((0,s.ensureBytes)("extraEntropy",t))}const S=i.concatBytes(...x),O=E;return{seed:S,k2sig:function(t){const e=A(t);if(!v(e))return;const r=p(e),n=w.BASE.multiply(e).toAffine(),o=m(n.x);if(o===d)return;const i=m(r*m(O+o*b));if(i===d)return;let s=(n.x===o?0:2)|Number(n.y&c),a=i;return h&&B(i)&&(a=function(t){return B(t)?m(-t):t}(i),s^=1),new R(o,a,s)}}}(t,e,n),h=r;return i.createHmacDrbg(h.hash.outputLen,h.nByteLength,h.hmac)(o,u)},verify:function(t,n,o,l=P){const u=t;n=(0,s.ensureBytes)("msgHash",n),o=(0,s.ensureBytes)("publicKey",o);const{lowS:d,prehash:c,format:h}=l;if(a(l),"strict"in l)throw new Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw new Error("format must be compact or der");const f="string"==typeof u||i.isBytes(u),y=!f&&!h&&"object"==typeof u&&null!==u&&"bigint"==typeof u.r&&"bigint"==typeof u.s;if(!f&&!y)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let g,E;try{if(y&&(g=new R(u.r,u.s)),f){try{"compact"!==h&&(g=R.fromDER(u))}catch(t){if(!(t instanceof e.DER.Err))throw t}g||"der"===h||(g=R.fromCompact(u))}E=w.fromHex(o)}catch(t){return!1}if(!g)return!1;if(d&&g.hasHighS())return!1;c&&(n=r.hash(n));const{r:v,s:b}=g,B=T(n),x=p(b),S=m(B*x),O=m(v*x),A=w.BASE.multiplyAndAddUnsafe(E,S,O)?.toAffine();return!!A&&m(A.x)===v},ProjectivePoint:w,Signature:R,utils:S}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(t,e){if(o.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let o,i,s,a,l,u,d,c;o=t.sqr(n),o=t.mul(o,e.Z),i=t.sqr(o),i=t.add(i,o),s=t.add(i,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(i),!t.eql(i,t.ZERO)),a=t.mul(a,e.A),i=t.sqr(s),u=t.sqr(a),l=t.mul(u,e.A),i=t.add(i,l),i=t.mul(i,s),u=t.mul(u,a),l=t.mul(u,e.B),i=t.add(i,l),d=t.mul(o,s);const{isValid:h,value:f}=r(i,u);c=t.mul(o,n),c=t.mul(c,f),d=t.cmov(d,s,h),c=t.cmov(c,f,h);const m=t.isOdd(n)===t.isOdd(c);return c=t.cmov(t.neg(c),c,m),d=t.div(d,a),{x:d,y:c}}};const n=r(2422),o=r(4967),i=r(1484),s=r(1484);function a(t){void 0!==t.lowS&&(0,s.abool)("lowS",t.lowS),void 0!==t.prehash&&(0,s.abool)("prehash",t.prehash)}const{bytesToNumberBE:l,hexToBytes:u}=i;e.DER={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(t,r)=>{const{Err:n}=e.DER;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const o=r.length/2,s=i.numberToHexUnpadded(o);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?i.numberToHexUnpadded(s.length/2|128):"";return i.numberToHexUnpadded(t)+a+s+r},decode(t,r){const{Err:n}=e.DER;let o=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[o++]!==t)throw new n("tlv.decode: wrong tlv");const i=r[o++];let s=0;if(128&i){const t=127&i;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const e=r.subarray(o,o+t);if(e.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===e[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of e)s=s<<8|t;if(o+=t,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=i;const a=r.subarray(o,o+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:r.subarray(o+s)}}},_int:{encode(t){const{Err:r}=e.DER;if(t<d)throw new r("integer: negative integers are not allowed");let n=i.numberToHexUnpadded(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new r("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:r}=e.DER;if(128&t[0])throw new r("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new r("invalid signature integer: unnecessary leading zero");return l(t)}},toSig(t){const{Err:r,_int:n,_tlv:o}=e.DER,s="string"==typeof t?u(t):t;i.abytes(s);const{v:a,l}=o.decode(48,s);if(l.length)throw new r("invalid signature: left bytes after parsing");const{v:d,l:c}=o.decode(2,a),{v:h,l:f}=o.decode(2,c);if(f.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(d),s:n.decode(h)}},hexFromSig(t){const{_tlv:r,_int:n}=e.DER,o=r.encode(2,n.encode(t.r))+r.encode(2,n.encode(t.s));return r.encode(48,o)}};const d=BigInt(0),c=BigInt(1),h=BigInt(2),f=BigInt(3),m=BigInt(4);function y(t){const e=function(t){const e=(0,n.validateBasic)(t);i.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:o,a:s}=e;if(r){if(!o.eql(s,o.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,a=o.Field(e.n,e.nBitLength),l=e.toBytes||((t,e,n)=>{const o=e.toAffine();return i.concatBytes(Uint8Array.from([4]),r.toBytes(o.x),r.toBytes(o.y))}),u=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function h(t){const{a:n,b:o}=e,i=r.sqr(t),s=r.mul(i,t);return r.add(r.add(s,r.mul(t,n)),o)}if(!r.eql(r.sqr(e.Gy),h(e.Gx)))throw new Error("bad generator point: equation left != right");function m(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:a,n:l}=e;if(r&&"bigint"!=typeof t){if(i.isBytes(t)&&(t=i.bytesToHex(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("invalid private key");t=t.padStart(2*n,"0")}let u;try{u="bigint"==typeof t?t:i.bytesToNumberBE((0,s.ensureBytes)("private key",t,n))}catch(e){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof t)}return a&&(u=o.mod(u,l)),i.aInRange("private key",u,c,l),u}function y(t){if(!(t instanceof g))throw new Error("ProjectivePoint expected")}const p=(0,s.memoized)(((t,e)=>{const{px:n,py:o,pz:i}=t;if(r.eql(i,r.ONE))return{x:n,y:o};const s=t.is0();null==e&&(e=s?r.ONE:r.inv(i));const a=r.mul(n,e),l=r.mul(o,e),u=r.mul(i,e);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:l}})),w=(0,s.memoized)((t=>{if(t.is0()){if(e.allowInfinityPoint&&!r.is0(t.py))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=t.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not FE");const i=r.sqr(o),s=h(n);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class g{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof g)throw new Error("projective point not allowed");const o=t=>r.eql(t,r.ZERO);return o(e)&&o(n)?g.ZERO:new g(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(g.fromAffine)}static fromHex(t){const e=g.fromAffine(u((0,s.ensureBytes)("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return g.BASE.multiply(m(t))}static msm(t,e){return(0,n.pippenger)(g,a,t,e)}_setWindowSize(t){v.setWindowSize(this,t)}assertValidity(){w(this)}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){y(t);const{px:e,py:n,pz:o}=this,{px:i,py:s,pz:a}=t,l=r.eql(r.mul(e,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return l&&u}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,o=r.mul(n,f),{px:i,py:s,pz:a}=this;let l=r.ZERO,u=r.ZERO,d=r.ZERO,c=r.mul(i,i),h=r.mul(s,s),m=r.mul(a,a),y=r.mul(i,s);return y=r.add(y,y),d=r.mul(i,a),d=r.add(d,d),l=r.mul(t,d),u=r.mul(o,m),u=r.add(l,u),l=r.sub(h,u),u=r.add(h,u),u=r.mul(l,u),l=r.mul(y,l),d=r.mul(o,d),m=r.mul(t,m),y=r.sub(c,m),y=r.mul(t,y),y=r.add(y,d),d=r.add(c,c),c=r.add(d,c),c=r.add(c,m),c=r.mul(c,y),u=r.add(u,c),m=r.mul(s,a),m=r.add(m,m),c=r.mul(m,y),l=r.sub(l,c),d=r.mul(m,h),d=r.add(d,d),d=r.add(d,d),new g(l,u,d)}add(t){y(t);const{px:n,py:o,pz:i}=this,{px:s,py:a,pz:l}=t;let u=r.ZERO,d=r.ZERO,c=r.ZERO;const h=e.a,m=r.mul(e.b,f);let p=r.mul(n,s),w=r.mul(o,a),E=r.mul(i,l),v=r.add(n,o),b=r.add(s,a);v=r.mul(v,b),b=r.add(p,w),v=r.sub(v,b),b=r.add(n,i);let B=r.add(s,l);return b=r.mul(b,B),B=r.add(p,E),b=r.sub(b,B),B=r.add(o,i),u=r.add(a,l),B=r.mul(B,u),u=r.add(w,E),B=r.sub(B,u),c=r.mul(h,b),u=r.mul(m,E),c=r.add(u,c),u=r.sub(w,c),c=r.add(w,c),d=r.mul(u,c),w=r.add(p,p),w=r.add(w,p),E=r.mul(h,E),b=r.mul(m,b),w=r.add(w,E),E=r.sub(p,E),E=r.mul(h,E),b=r.add(b,E),p=r.mul(w,b),d=r.add(d,p),p=r.mul(B,b),u=r.mul(v,u),u=r.sub(u,p),p=r.mul(v,w),c=r.mul(B,c),c=r.add(c,p),new g(u,d,c)}subtract(t){return this.add(t.negate())}is0(){return this.equals(g.ZERO)}wNAF(t){return v.wNAFCached(this,t,g.normalizeZ)}multiplyUnsafe(t){const{endo:n,n:o}=e;i.aInRange("scalar",t,d,o);const s=g.ZERO;if(t===d)return s;if(this.is0()||t===c)return this;if(!n||v.hasPrecomputes(this))return v.wNAFCachedUnsafe(this,t,g.normalizeZ);let{k1neg:a,k1:l,k2neg:u,k2:h}=n.splitScalar(t),f=s,m=s,y=this;for(;l>d||h>d;)l&c&&(f=f.add(y)),h&c&&(m=m.add(y)),y=y.double(),l>>=c,h>>=c;return a&&(f=f.negate()),u&&(m=m.negate()),m=new g(r.mul(m.px,n.beta),m.py,m.pz),f.add(m)}multiply(t){const{endo:n,n:o}=e;let s,a;if(i.aInRange("scalar",t,c,o),n){const{k1neg:e,k1:o,k2neg:i,k2:l}=n.splitScalar(t);let{p:u,f:d}=this.wNAF(o),{p:c,f:h}=this.wNAF(l);u=v.constTimeNegate(e,u),c=v.constTimeNegate(i,c),c=new g(r.mul(c.px,n.beta),c.py,c.pz),s=u.add(c),a=d.add(h)}else{const{p:e,f:r}=this.wNAF(t);s=e,a=r}return g.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(t,e,r){const n=g.BASE,o=(t,e)=>e!==d&&e!==c&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),i=o(this,e).add(o(t,r));return i.is0()?void 0:i}toAffine(t){return p(this,t)}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===c)return!0;if(r)return r(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===c?this:r?r(g,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return(0,s.abool)("isCompressed",t),this.assertValidity(),l(g,this,t)}toHex(t=!0){return(0,s.abool)("isCompressed",t),i.bytesToHex(this.toRawBytes(t))}}g.BASE=new g(e.Gx,e.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);const E=e.nBitLength,v=(0,n.wNAF)(g,e.endo?Math.ceil(E/2):E);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:m,weierstrassEquation:h,isWithinCurveOrder:function(t){return i.inRange(t,c,e.n)}}}function p(t,e){const r=t.ORDER;let n=d;for(let t=r-c;t%h===d;t/=h)n+=c;const o=n,i=h<<o-c-c,s=i*h,a=(r-c)/s,l=(a-c)/h,u=s-c,y=i,p=t.pow(e,a),w=t.pow(e,(a+c)/h);let g=(e,r)=>{let n=p,i=t.pow(r,u),s=t.sqr(i);s=t.mul(s,r);let a=t.mul(e,s);a=t.pow(a,l),a=t.mul(a,i),i=t.mul(a,r),s=t.mul(a,e);let d=t.mul(s,i);a=t.pow(d,y);let f=t.eql(a,t.ONE);i=t.mul(s,w),a=t.mul(d,n),s=t.cmov(i,s,f),d=t.cmov(a,d,f);for(let e=o;e>c;e--){let r=e-h;r=h<<r-c;let o=t.pow(d,r);const a=t.eql(o,t.ONE);i=t.mul(s,n),n=t.mul(n,n),o=t.mul(d,n),s=t.cmov(i,s,a),d=t.cmov(o,d,a)}return{isValid:f,value:s}};if(t.ORDER%m===f){const r=(t.ORDER-f)/m,n=t.sqrt(t.neg(e));g=(e,o)=>{let i=t.sqr(o);const s=t.mul(e,o);i=t.mul(i,s);let a=t.pow(i,r);a=t.mul(a,s);const l=t.mul(a,n),u=t.mul(t.sqr(a),o),d=t.eql(u,e);return{isValid:d,value:t.cmov(l,a,d)}}}return g}}}]);
2
+ "use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[705],{1705:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DER=e.DERErr=void 0,e.weierstrassPoints=p,e.weierstrass=function(t){const r=function(t){const e=(0,n.validateBasic)(t);return i.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:l,n:u}=r,d=l.BYTES+1,f=2*l.BYTES+1;function m(t){return(0,o.mod)(t,u)}function y(t){return(0,o.invert)(t,u)}const{ProjectivePoint:w,normPrivateKeyToScalar:g,weierstrassEquation:E,isWithinCurveOrder:v}=p({...r,toBytes(t,e,r){const n=e.toAffine(),o=l.toBytes(n.x),a=i.concatBytes;return(0,s.abool)("isCompressed",r),r?a(Uint8Array.from([e.hasEvenY()?2:3]),o):a(Uint8Array.from([4]),o,l.toBytes(n.y))},fromBytes(t){const e=t.length,r=t[0],n=t.subarray(1);if(e!==d||2!==r&&3!==r){if(e===f&&4===r)return{x:l.fromBytes(n.subarray(0,l.BYTES)),y:l.fromBytes(n.subarray(l.BYTES,2*l.BYTES))};throw new Error("invalid Point, expected length of "+d+", or uncompressed "+f+", got "+e)}{const t=i.bytesToNumberBE(n);if(!i.inRange(t,h,l.ORDER))throw new Error("Point is not on curve");const e=E(t);let o;try{o=l.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("Point is not on curve"+e)}return!(1&~r)!=((o&h)===h)&&(o=l.neg(o)),{x:t,y:o}}}}),b=t=>i.bytesToHex(i.numberToBytesBE(t,r.nByteLength));function B(t){return t>u>>h}const R=(t,e,r)=>i.bytesToNumberBE(t.slice(e,r));class x{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const e=r.nByteLength;return t=(0,s.ensureBytes)("compactSignature",t,2*e),new x(R(t,0,e),R(t,e,2*e))}static fromDER(t){const{r,s:n}=e.DER.toSig((0,s.ensureBytes)("DER",t));return new x(r,n)}assertValidity(){i.aInRange("r",this.r,h,u),i.aInRange("s",this.s,h,u)}addRecoveryBit(t){return new x(this.r,this.s,t)}recoverPublicKey(t){const{r:e,s:n,recovery:o}=this,i=T((0,s.ensureBytes)("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const a=2===o||3===o?e+r.n:e;if(a>=l.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=1&o?"03":"02",d=w.fromHex(u+b(a)),c=y(a),h=m(-i*c),f=m(n*c),p=w.BASE.multiplyAndAddUnsafe(d,h,f);if(!p)throw new Error("point at infinify");return p.assertValidity(),p}hasHighS(){return B(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,m(-this.s),this.recovery):this}toDERRawBytes(){return i.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return i.hexToBytes(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const S={isValidPrivateKey(t){try{return g(t),!0}catch(t){return!1}},normPrivateKeyToScalar:g,randomPrivateKey:()=>{const t=(0,o.getMinHashLength)(r.n);return(0,o.mapHashToField)(r.randomBytes(t),r.n)},precompute:(t=8,e=w.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function O(t){const e=i.isBytes(t),r="string"==typeof t,n=(e||r)&&t.length;return e?n===d||n===f:r?n===2*d||n===2*f:t instanceof w}const A=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=i.bytesToNumberBE(t),n=8*t.length-r.nBitLength;return n>0?e>>BigInt(n):e},T=r.bits2int_modN||function(t){return m(A(t))},q=i.bitMask(r.nBitLength);function z(t){return i.aInRange("num < 2^"+r.nBitLength,t,c,q),i.numberToBytesBE(t,r.nByteLength)}const N={lowS:r.lowS,prehash:!1},P={lowS:r.lowS,prehash:!1};return w.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(t,e=!0){return w.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(O(t))throw new Error("first arg must be private key");if(!O(e))throw new Error("second arg must be public key");return w.fromHex(e).multiply(g(t)).toRawBytes(r)},sign:function(t,e,n=N){const{seed:o,k2sig:u}=function(t,e,n=N){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:u}=r;let{lowS:d,prehash:f,extraEntropy:p}=n;null==d&&(d=!0),t=(0,s.ensureBytes)("msgHash",t),a(n),f&&(t=(0,s.ensureBytes)("prehashed msgHash",o(t)));const E=T(t),b=g(e),R=[z(b),z(E)];if(null!=p&&!1!==p){const t=!0===p?u(l.BYTES):p;R.push((0,s.ensureBytes)("extraEntropy",t))}const S=i.concatBytes(...R),O=E;return{seed:S,k2sig:function(t){const e=A(t);if(!v(e))return;const r=y(e),n=w.BASE.multiply(e).toAffine(),o=m(n.x);if(o===c)return;const i=m(r*m(O+o*b));if(i===c)return;let s=(n.x===o?0:2)|Number(n.y&h),a=i;return d&&B(i)&&(a=function(t){return B(t)?m(-t):t}(i),s^=1),new x(o,a,s)}}}(t,e,n),d=r;return i.createHmacDrbg(d.hash.outputLen,d.nByteLength,d.hmac)(o,u)},verify:function(t,n,o,l=P){const u=t;n=(0,s.ensureBytes)("msgHash",n),o=(0,s.ensureBytes)("publicKey",o);const{lowS:d,prehash:c,format:h}=l;if(a(l),"strict"in l)throw new Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw new Error("format must be compact or der");const f="string"==typeof u||i.isBytes(u),p=!f&&!h&&"object"==typeof u&&null!==u&&"bigint"==typeof u.r&&"bigint"==typeof u.s;if(!f&&!p)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let g,E;try{if(p&&(g=new x(u.r,u.s)),f){try{"compact"!==h&&(g=x.fromDER(u))}catch(t){if(!(t instanceof e.DER.Err))throw t}g||"der"===h||(g=x.fromCompact(u))}E=w.fromHex(o)}catch(t){return!1}if(!g)return!1;if(d&&g.hasHighS())return!1;c&&(n=r.hash(n));const{r:v,s:b}=g,B=T(n),R=y(b),S=m(B*R),O=m(v*R),A=w.BASE.multiplyAndAddUnsafe(E,S,O)?.toAffine();return!!A&&m(A.x)===v},ProjectivePoint:w,Signature:x,utils:S}},e.SWUFpSqrtRatio=w,e.mapToCurveSimpleSWU=function(t,e){if((0,o.validateField)(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=w(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let o,i,s,a,l,u,d,c;o=t.sqr(n),o=t.mul(o,e.Z),i=t.sqr(o),i=t.add(i,o),s=t.add(i,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(i),!t.eql(i,t.ZERO)),a=t.mul(a,e.A),i=t.sqr(s),u=t.sqr(a),l=t.mul(u,e.A),i=t.add(i,l),i=t.mul(i,s),u=t.mul(u,a),l=t.mul(u,e.B),i=t.add(i,l),d=t.mul(o,s);const{isValid:h,value:f}=r(i,u);c=t.mul(o,n),c=t.mul(c,f),d=t.cmov(d,s,h),c=t.cmov(c,f,h);const m=t.isOdd(n)===t.isOdd(c);return c=t.cmov(t.neg(c),c,m),d=t.div(d,a),{x:d,y:c}}};const n=r(2422),o=r(4967),i=r(1484),s=r(1484);function a(t){void 0!==t.lowS&&(0,s.abool)("lowS",t.lowS),void 0!==t.prehash&&(0,s.abool)("prehash",t.prehash)}const{bytesToNumberBE:l,hexToBytes:u}=i;class d extends Error{constructor(t=""){super(t)}}e.DERErr=d,e.DER={Err:d,_tlv:{encode:(t,r)=>{const{Err:n}=e.DER;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const o=r.length/2,s=i.numberToHexUnpadded(o);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?i.numberToHexUnpadded(s.length/2|128):"";return i.numberToHexUnpadded(t)+a+s+r},decode(t,r){const{Err:n}=e.DER;let o=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[o++]!==t)throw new n("tlv.decode: wrong tlv");const i=r[o++];let s=0;if(128&i){const t=127&i;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const e=r.subarray(o,o+t);if(e.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===e[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of e)s=s<<8|t;if(o+=t,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=i;const a=r.subarray(o,o+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:r.subarray(o+s)}}},_int:{encode(t){const{Err:r}=e.DER;if(t<c)throw new r("integer: negative integers are not allowed");let n=i.numberToHexUnpadded(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new r("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:r}=e.DER;if(128&t[0])throw new r("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new r("invalid signature integer: unnecessary leading zero");return l(t)}},toSig(t){const{Err:r,_int:n,_tlv:o}=e.DER,s="string"==typeof t?u(t):t;i.abytes(s);const{v:a,l}=o.decode(48,s);if(l.length)throw new r("invalid signature: left bytes after parsing");const{v:d,l:c}=o.decode(2,a),{v:h,l:f}=o.decode(2,c);if(f.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(d),s:n.decode(h)}},hexFromSig(t){const{_tlv:r,_int:n}=e.DER,o=r.encode(2,n.encode(t.r))+r.encode(2,n.encode(t.s));return r.encode(48,o)}};const c=BigInt(0),h=BigInt(1),f=BigInt(2),m=BigInt(3),y=BigInt(4);function p(t){const e=function(t){const e=(0,n.validateBasic)(t);i.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:o,a:s}=e;if(r){if(!o.eql(s,o.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,a=(0,o.Field)(e.n,e.nBitLength),l=e.toBytes||((t,e,n)=>{const o=e.toAffine();return i.concatBytes(Uint8Array.from([4]),r.toBytes(o.x),r.toBytes(o.y))}),u=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function d(t){const{a:n,b:o}=e,i=r.sqr(t),s=r.mul(i,t);return r.add(r.add(s,r.mul(t,n)),o)}if(!r.eql(r.sqr(e.Gy),d(e.Gx)))throw new Error("bad generator point: equation left != right");function f(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:a,n:l}=e;if(r&&"bigint"!=typeof t){if(i.isBytes(t)&&(t=i.bytesToHex(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("invalid private key");t=t.padStart(2*n,"0")}let u;try{u="bigint"==typeof t?t:i.bytesToNumberBE((0,s.ensureBytes)("private key",t,n))}catch(e){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof t)}return a&&(u=(0,o.mod)(u,l)),i.aInRange("private key",u,h,l),u}function y(t){if(!(t instanceof g))throw new Error("ProjectivePoint expected")}const p=(0,s.memoized)(((t,e)=>{const{px:n,py:o,pz:i}=t;if(r.eql(i,r.ONE))return{x:n,y:o};const s=t.is0();null==e&&(e=s?r.ONE:r.inv(i));const a=r.mul(n,e),l=r.mul(o,e),u=r.mul(i,e);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:l}})),w=(0,s.memoized)((t=>{if(t.is0()){if(e.allowInfinityPoint&&!r.is0(t.py))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=t.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not FE");const i=r.sqr(o),s=d(n);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class g{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof g)throw new Error("projective point not allowed");const o=t=>r.eql(t,r.ZERO);return o(e)&&o(n)?g.ZERO:new g(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(g.fromAffine)}static fromHex(t){const e=g.fromAffine(u((0,s.ensureBytes)("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return g.BASE.multiply(f(t))}static msm(t,e){return(0,n.pippenger)(g,a,t,e)}_setWindowSize(t){v.setWindowSize(this,t)}assertValidity(){w(this)}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){y(t);const{px:e,py:n,pz:o}=this,{px:i,py:s,pz:a}=t,l=r.eql(r.mul(e,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return l&&u}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,o=r.mul(n,m),{px:i,py:s,pz:a}=this;let l=r.ZERO,u=r.ZERO,d=r.ZERO,c=r.mul(i,i),h=r.mul(s,s),f=r.mul(a,a),y=r.mul(i,s);return y=r.add(y,y),d=r.mul(i,a),d=r.add(d,d),l=r.mul(t,d),u=r.mul(o,f),u=r.add(l,u),l=r.sub(h,u),u=r.add(h,u),u=r.mul(l,u),l=r.mul(y,l),d=r.mul(o,d),f=r.mul(t,f),y=r.sub(c,f),y=r.mul(t,y),y=r.add(y,d),d=r.add(c,c),c=r.add(d,c),c=r.add(c,f),c=r.mul(c,y),u=r.add(u,c),f=r.mul(s,a),f=r.add(f,f),c=r.mul(f,y),l=r.sub(l,c),d=r.mul(f,h),d=r.add(d,d),d=r.add(d,d),new g(l,u,d)}add(t){y(t);const{px:n,py:o,pz:i}=this,{px:s,py:a,pz:l}=t;let u=r.ZERO,d=r.ZERO,c=r.ZERO;const h=e.a,f=r.mul(e.b,m);let p=r.mul(n,s),w=r.mul(o,a),E=r.mul(i,l),v=r.add(n,o),b=r.add(s,a);v=r.mul(v,b),b=r.add(p,w),v=r.sub(v,b),b=r.add(n,i);let B=r.add(s,l);return b=r.mul(b,B),B=r.add(p,E),b=r.sub(b,B),B=r.add(o,i),u=r.add(a,l),B=r.mul(B,u),u=r.add(w,E),B=r.sub(B,u),c=r.mul(h,b),u=r.mul(f,E),c=r.add(u,c),u=r.sub(w,c),c=r.add(w,c),d=r.mul(u,c),w=r.add(p,p),w=r.add(w,p),E=r.mul(h,E),b=r.mul(f,b),w=r.add(w,E),E=r.sub(p,E),E=r.mul(h,E),b=r.add(b,E),p=r.mul(w,b),d=r.add(d,p),p=r.mul(B,b),u=r.mul(v,u),u=r.sub(u,p),p=r.mul(v,w),c=r.mul(B,c),c=r.add(c,p),new g(u,d,c)}subtract(t){return this.add(t.negate())}is0(){return this.equals(g.ZERO)}wNAF(t){return v.wNAFCached(this,t,g.normalizeZ)}multiplyUnsafe(t){const{endo:n,n:o}=e;i.aInRange("scalar",t,c,o);const s=g.ZERO;if(t===c)return s;if(this.is0()||t===h)return this;if(!n||v.hasPrecomputes(this))return v.wNAFCachedUnsafe(this,t,g.normalizeZ);let{k1neg:a,k1:l,k2neg:u,k2:d}=n.splitScalar(t),f=s,m=s,y=this;for(;l>c||d>c;)l&h&&(f=f.add(y)),d&h&&(m=m.add(y)),y=y.double(),l>>=h,d>>=h;return a&&(f=f.negate()),u&&(m=m.negate()),m=new g(r.mul(m.px,n.beta),m.py,m.pz),f.add(m)}multiply(t){const{endo:n,n:o}=e;let s,a;if(i.aInRange("scalar",t,h,o),n){const{k1neg:e,k1:o,k2neg:i,k2:l}=n.splitScalar(t);let{p:u,f:d}=this.wNAF(o),{p:c,f:h}=this.wNAF(l);u=v.constTimeNegate(e,u),c=v.constTimeNegate(i,c),c=new g(r.mul(c.px,n.beta),c.py,c.pz),s=u.add(c),a=d.add(h)}else{const{p:e,f:r}=this.wNAF(t);s=e,a=r}return g.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(t,e,r){const n=g.BASE,o=(t,e)=>e!==c&&e!==h&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),i=o(this,e).add(o(t,r));return i.is0()?void 0:i}toAffine(t){return p(this,t)}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===h)return!0;if(r)return r(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===h?this:r?r(g,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return(0,s.abool)("isCompressed",t),this.assertValidity(),l(g,this,t)}toHex(t=!0){return(0,s.abool)("isCompressed",t),i.bytesToHex(this.toRawBytes(t))}}g.BASE=new g(e.Gx,e.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);const E=e.nBitLength,v=(0,n.wNAF)(g,e.endo?Math.ceil(E/2):E);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:function(t){return i.inRange(t,h,e.n)}}}function w(t,e){const r=t.ORDER;let n=c;for(let t=r-h;t%f===c;t/=f)n+=h;const o=n,i=f<<o-h-h,s=i*f,a=(r-h)/s,l=(a-h)/f,u=s-h,d=i,p=t.pow(e,a),w=t.pow(e,(a+h)/f);let g=(e,r)=>{let n=p,i=t.pow(r,u),s=t.sqr(i);s=t.mul(s,r);let a=t.mul(e,s);a=t.pow(a,l),a=t.mul(a,i),i=t.mul(a,r),s=t.mul(a,e);let c=t.mul(s,i);a=t.pow(c,d);let m=t.eql(a,t.ONE);i=t.mul(s,w),a=t.mul(c,n),s=t.cmov(i,s,m),c=t.cmov(a,c,m);for(let e=o;e>h;e--){let r=e-f;r=f<<r-h;let o=t.pow(c,r);const a=t.eql(o,t.ONE);i=t.mul(s,n),n=t.mul(n,n),o=t.mul(c,n),s=t.cmov(i,s,a),c=t.cmov(o,c,a)}return{isValid:m,value:s}};if(t.ORDER%y===m){const r=(t.ORDER-m)/y,n=t.sqrt(t.neg(e));g=(e,o)=>{let i=t.sqr(o);const s=t.mul(e,o);i=t.mul(i,s);let a=t.pow(i,r);a=t.mul(a,s);const l=t.mul(a,n),u=t.mul(t.sqr(a),o),d=t.eql(u,e);return{isValid:d,value:t.cmov(l,a,d)}}}return g}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 761.nostr-crypto-utils.min.js.LICENSE.txt */
2
- "use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[761],{1761:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.expand_message_xmd=f,t.expand_message_xof=c,t.hash_to_field=d,t.isogenyMap=function(e,t){const r=t.map((e=>Array.from(e).reverse()));return(t,n)=>{const[o,i,s,u]=r.map((r=>r.reduce(((r,n)=>e.add(e.mul(r,t),n)))));return t=e.div(o,i),n=e.mul(n,e.div(s,u)),{x:t,y:n}}},t.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,o){const i=d(n,2,{...r,DST:r.DST,...o}),s=e.fromAffine(t(i[0])),u=e.fromAffine(t(i[1])),a=s.add(u).clearCofactor();return a.assertValidity(),a},encodeToCurve(n,o){const i=d(n,1,{...r,DST:r.encodeDST,...o}),s=e.fromAffine(t(i[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(r){if(!Array.isArray(r))throw new Error("mapToCurve: expected array of bigints");for(const e of r)if("bigint"!=typeof e)throw new Error("mapToCurve: expected array of bigints");const n=e.fromAffine(t(r)).clearCofactor();return n.assertValidity(),n}}};const n=r(4967),o=r(1484),i=o.bytesToNumberBE;function s(e,t){if(a(e),a(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function u(e,t){const r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function a(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function f(e,t,r,n){(0,o.abytes)(e),(0,o.abytes)(t),a(r),t.length>255&&(t=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:f}=n,c=Math.ceil(r/i);if(r>65535||c>255)throw new Error("expand_message_xmd: invalid lenInBytes");const d=(0,o.concatBytes)(t,s(t.length,1)),l=s(0,f),h=s(r,2),p=new Array(c),g=n((0,o.concatBytes)(l,e,h,s(0,1),d));p[0]=n((0,o.concatBytes)(g,s(1,1),d));for(let e=1;e<=c;e++){const t=[u(g,p[e-1]),s(e+1,1),d];p[e]=n((0,o.concatBytes)(...t))}return(0,o.concatBytes)(...p).slice(0,r)}function c(e,t,r,n,i){if((0,o.abytes)(e),(0,o.abytes)(t),a(r),t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(s(r,2)).update(t).update(s(t.length,1)).digest()}function d(e,t,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:u,m:d,hash:l,expand:h,DST:p}=r;(0,o.abytes)(e),a(t);const g="string"==typeof p?(0,o.utf8ToBytes)(p):p,w=s.toString(2).length,y=Math.ceil((w+u)/8),m=t*d*y;let E;if("xmd"===h)E=f(e,g,m,l);else if("xof"===h)E=c(e,g,m,u,l);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');E=e}const b=new Array(t);for(let e=0;e<t;e++){const t=new Array(d);for(let r=0;r<d;r++){const o=y*(r+e*d),u=E.subarray(o,o+y);t[r]=(0,n.mod)(i(u),s)}b[e]=t}return b}},4967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNegativeLE=void 0,t.mod=d,t.pow=l,t.pow2=function(e,t,r){let n=e;for(;t-- >o;)n*=n,n%=r;return n},t.invert=h,t.tonelliShanks=p,t.FpSqrt=g,t.validateField=function(e){const t=w.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,n.validateObject)(e,t)},t.FpPow=y,t.FpInvertBatch=m,t.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?h(r,e.ORDER):e.inv(r))},t.FpLegendre=E,t.FpIsSquare=function(e){const t=E(e.ORDER);return r=>{const n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}},t.nLength=b,t.Field=function(e,t,r=!1,s={}){if(e<=o)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:u,nByteLength:a}=b(e,t);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const c=Object.freeze({ORDER:e,BITS:u,BYTES:a,MASK:(0,n.bitMask)(u),ZERO:o,ONE:i,create:t=>d(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return o<=t&&t<e},is0:e=>e===o,isOdd:e=>(e&i)===i,neg:t=>d(-t,e),eql:(e,t)=>e===t,sqr:t=>d(t*t,e),add:(t,r)=>d(t+r,e),sub:(t,r)=>d(t-r,e),mul:(t,r)=>d(t*r,e),pow:(e,t)=>y(c,e,t),div:(t,r)=>d(t*h(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>h(t,e),sqrt:s.sqrt||(t=>(f||(f=g(e)),f(c,t))),invertBatch:e=>m(c,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?(0,n.numberToBytesLE)(e,a):(0,n.numberToBytesBE)(e,a),fromBytes:e=>{if(e.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+e.length);return r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e)}});return Object.freeze(c)},t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},t.hashToPrivateScalar=function(e,t,r=!1){const o=(e=(0,n.ensureBytes)("privateHash",e)).length,s=b(t).nByteLength+8;if(s<24||o<s||o>1024)throw new Error("hashToPrivateScalar: expected "+s+"-1024 bytes of input, got "+o);return d(r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e),t-i)+i},t.getFieldBytesLength=v,t.getMinHashLength=B,t.mapHashToField=function(e,t,r=!1){const o=e.length,s=v(t),u=B(t);if(o<16||o<u||o>1024)throw new Error("expected "+u+"-1024 bytes of input, got "+o);const a=d(r?(0,n.bytesToNumberBE)(e):(0,n.bytesToNumberLE)(e),t-i)+i;return r?(0,n.numberToBytesLE)(a,s):(0,n.numberToBytesBE)(a,s)};const n=r(1484),o=BigInt(0),i=BigInt(1),s=BigInt(2),u=BigInt(3),a=BigInt(4),f=BigInt(5),c=BigInt(8);function d(e,t){const r=e%t;return r>=o?r:t+r}function l(e,t,r){if(t<o)throw new Error("invalid exponent, negatives unsupported");if(r<=o)throw new Error("invalid modulus");if(r===i)return o;let n=i;for(;t>o;)t&i&&(n=n*e%r),e=e*e%r,t>>=i;return n}function h(e,t){if(e===o)throw new Error("invert: expected non-zero number");if(t<=o)throw new Error("invert: expected positive modulus, got "+t);let r=d(e,t),n=t,s=o,u=i,a=i,f=o;for(;r!==o;){const e=n/r,t=n%r,o=s-a*e,i=u-f*e;n=r,r=t,s=a,u=f,a=o,f=i}if(n!==i)throw new Error("invert: does not exist");return d(s,t)}function p(e){const t=(e-i)/s;let r,n,u;for(r=e-i,n=0;r%s===o;r/=s,n++);for(u=s;u<e&&l(u,t,e)!==e-i;u++)if(u>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===n){const t=(e+i)/a;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}const f=(r+i)/s;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let s=n,a=e.pow(e.mul(e.ONE,u),r),c=e.pow(o,f),d=e.pow(o,r);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(d);t<s&&!e.eql(r,e.ONE);t++)r=e.sqr(r);const r=e.pow(a,i<<BigInt(s-t-1));a=e.sqr(r),c=e.mul(c,r),d=e.mul(d,a),s=t}return c}}function g(e){if(e%a===u){const t=(e+i)/a;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}if(e%c===f){const t=(e-f)/c;return function(e,r){const n=e.mul(r,s),o=e.pow(n,t),i=e.mul(r,o),u=e.mul(e.mul(i,s),o),a=e.mul(i,e.sub(u,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return p(e)}t.isNegativeLE=(e,t)=>(d(e,t)&i)===i;const w=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function y(e,t,r){if(r<o)throw new Error("invalid exponent, negatives unsupported");if(r===o)return e.ONE;if(r===i)return t;let n=e.ONE,s=t;for(;r>o;)r&i&&(n=e.mul(n,s)),s=e.sqr(s),r>>=i;return n}function m(e,t){const r=new Array(t.length),n=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),o=e.inv(n);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),o),r}function E(e){const t=(e-i)/s;return(e,r)=>e.pow(r,t)}function b(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function v(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function B(e){const t=v(e);return t+Math.ceil(t/2)}}}]);
2
+ "use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[761],{1761:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.expand_message_xmd=f,t.expand_message_xof=c,t.hash_to_field=d,t.isogenyMap=function(e,t){const r=t.map((e=>Array.from(e).reverse()));return(t,n)=>{const[o,i,s,u]=r.map((r=>r.reduce(((r,n)=>e.add(e.mul(r,t),n)))));return t=e.div(o,i),n=e.mul(n,e.div(s,u)),{x:t,y:n}}},t.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,o){const i=d(n,2,{...r,DST:r.DST,...o}),s=e.fromAffine(t(i[0])),u=e.fromAffine(t(i[1])),a=s.add(u).clearCofactor();return a.assertValidity(),a},encodeToCurve(n,o){const i=d(n,1,{...r,DST:r.encodeDST,...o}),s=e.fromAffine(t(i[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(r){if(!Array.isArray(r))throw new Error("mapToCurve: expected array of bigints");for(const e of r)if("bigint"!=typeof e)throw new Error("mapToCurve: expected array of bigints");const n=e.fromAffine(t(r)).clearCofactor();return n.assertValidity(),n}}};const n=r(4967),o=r(1484),i=o.bytesToNumberBE;function s(e,t){if(a(e),a(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function u(e,t){const r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function a(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function f(e,t,r,n){(0,o.abytes)(e),(0,o.abytes)(t),a(r),t.length>255&&(t=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:f}=n,c=Math.ceil(r/i);if(r>65535||c>255)throw new Error("expand_message_xmd: invalid lenInBytes");const d=(0,o.concatBytes)(t,s(t.length,1)),l=s(0,f),h=s(r,2),p=new Array(c),g=n((0,o.concatBytes)(l,e,h,s(0,1),d));p[0]=n((0,o.concatBytes)(g,s(1,1),d));for(let e=1;e<=c;e++){const t=[u(g,p[e-1]),s(e+1,1),d];p[e]=n((0,o.concatBytes)(...t))}return(0,o.concatBytes)(...p).slice(0,r)}function c(e,t,r,n,i){if((0,o.abytes)(e),(0,o.abytes)(t),a(r),t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(s(r,2)).update(t).update(s(t.length,1)).digest()}function d(e,t,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:u,m:d,hash:l,expand:h,DST:p}=r;(0,o.abytes)(e),a(t);const g="string"==typeof p?(0,o.utf8ToBytes)(p):p,w=s.toString(2).length,y=Math.ceil((w+u)/8),E=t*d*y;let m;if("xmd"===h)m=f(e,g,E,l);else if("xof"===h)m=c(e,g,E,u,l);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');m=e}const b=new Array(t);for(let e=0;e<t;e++){const t=new Array(d);for(let r=0;r<d;r++){const o=y*(r+e*d),u=m.subarray(o,o+y);t[r]=(0,n.mod)(i(u),s)}b[e]=t}return b}},4967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNegativeLE=void 0,t.mod=d,t.pow=l,t.pow2=function(e,t,r){let n=e;for(;t-- >o;)n*=n,n%=r;return n},t.invert=h,t.tonelliShanks=p,t.FpSqrt=g,t.validateField=function(e){const t=w.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,n.validateObject)(e,t)},t.FpPow=y,t.FpInvertBatch=E,t.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?h(r,e.ORDER):e.inv(r))},t.FpLegendre=m,t.FpIsSquare=function(e){const t=m(e.ORDER);return r=>{const n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}},t.nLength=b,t.Field=function(e,t,r=!1,s={}){if(e<=o)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:u,nByteLength:a}=b(e,t);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const c=Object.freeze({ORDER:e,isLE:r,BITS:u,BYTES:a,MASK:(0,n.bitMask)(u),ZERO:o,ONE:i,create:t=>d(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return o<=t&&t<e},is0:e=>e===o,isOdd:e=>(e&i)===i,neg:t=>d(-t,e),eql:(e,t)=>e===t,sqr:t=>d(t*t,e),add:(t,r)=>d(t+r,e),sub:(t,r)=>d(t-r,e),mul:(t,r)=>d(t*r,e),pow:(e,t)=>y(c,e,t),div:(t,r)=>d(t*h(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>h(t,e),sqrt:s.sqrt||(t=>(f||(f=g(e)),f(c,t))),invertBatch:e=>E(c,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?(0,n.numberToBytesLE)(e,a):(0,n.numberToBytesBE)(e,a),fromBytes:e=>{if(e.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+e.length);return r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e)}});return Object.freeze(c)},t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},t.hashToPrivateScalar=function(e,t,r=!1){const o=(e=(0,n.ensureBytes)("privateHash",e)).length,s=b(t).nByteLength+8;if(s<24||o<s||o>1024)throw new Error("hashToPrivateScalar: expected "+s+"-1024 bytes of input, got "+o);return d(r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e),t-i)+i},t.getFieldBytesLength=v,t.getMinHashLength=B,t.mapHashToField=function(e,t,r=!1){const o=e.length,s=v(t),u=B(t);if(o<16||o<u||o>1024)throw new Error("expected "+u+"-1024 bytes of input, got "+o);const a=d(r?(0,n.bytesToNumberLE)(e):(0,n.bytesToNumberBE)(e),t-i)+i;return r?(0,n.numberToBytesLE)(a,s):(0,n.numberToBytesBE)(a,s)};const n=r(1484),o=BigInt(0),i=BigInt(1),s=BigInt(2),u=BigInt(3),a=BigInt(4),f=BigInt(5),c=BigInt(8);function d(e,t){const r=e%t;return r>=o?r:t+r}function l(e,t,r){if(t<o)throw new Error("invalid exponent, negatives unsupported");if(r<=o)throw new Error("invalid modulus");if(r===i)return o;let n=i;for(;t>o;)t&i&&(n=n*e%r),e=e*e%r,t>>=i;return n}function h(e,t){if(e===o)throw new Error("invert: expected non-zero number");if(t<=o)throw new Error("invert: expected positive modulus, got "+t);let r=d(e,t),n=t,s=o,u=i,a=i,f=o;for(;r!==o;){const e=n/r,t=n%r,o=s-a*e,i=u-f*e;n=r,r=t,s=a,u=f,a=o,f=i}if(n!==i)throw new Error("invert: does not exist");return d(s,t)}function p(e){const t=(e-i)/s;let r,n,u;for(r=e-i,n=0;r%s===o;r/=s,n++);for(u=s;u<e&&l(u,t,e)!==e-i;u++)if(u>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===n){const t=(e+i)/a;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}const f=(r+i)/s;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let s=n,a=e.pow(e.mul(e.ONE,u),r),c=e.pow(o,f),d=e.pow(o,r);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(d);t<s&&!e.eql(r,e.ONE);t++)r=e.sqr(r);const r=e.pow(a,i<<BigInt(s-t-1));a=e.sqr(r),c=e.mul(c,r),d=e.mul(d,a),s=t}return c}}function g(e){if(e%a===u){const t=(e+i)/a;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}if(e%c===f){const t=(e-f)/c;return function(e,r){const n=e.mul(r,s),o=e.pow(n,t),i=e.mul(r,o),u=e.mul(e.mul(i,s),o),a=e.mul(i,e.sub(u,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return p(e)}t.isNegativeLE=(e,t)=>(d(e,t)&i)===i;const w=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function y(e,t,r){if(r<o)throw new Error("invalid exponent, negatives unsupported");if(r===o)return e.ONE;if(r===i)return t;let n=e.ONE,s=t;for(;r>o;)r&i&&(n=e.mul(n,s)),s=e.sqr(s),r>>=i;return n}function E(e,t){const r=new Array(t.length),n=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),o=e.inv(n);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),o),r}function m(e){const t=(e-i)/s;return(e,r)=>e.pow(r,t)}function b(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function v(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function B(e){const t=v(e);return t+Math.ceil(t/2)}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 774.nostr-crypto-utils.min.js.LICENSE.txt */
2
- (this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[774],{7557:(t,e)=>{"use strict";function i(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function s(t,...e){if(!((i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name))throw new Error("Uint8Array expected");var i;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function r(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");i(t.outputLen),i(t.blockLen)}function n(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function o(t,e){s(t);const i=e.outputLen;if(t.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}Object.defineProperty(e,"__esModule",{value:!0}),e.anumber=i,e.number=i,e.abytes=s,e.bytes=s,e.ahash=r,e.aexists=n,e.aoutput=o;const a={number:i,bytes:s,hash:r,exists:n,output:o};e.default=a},7202:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const s=i(7557),r=i(9175);e.Chi=(t,e,i)=>t&e^~t&i,e.Maj=(t,e,i)=>t&e^t&i^e&i;class n extends r.Hash{constructor(t,e,i,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,r.createView)(this.buffer)}update(t){(0,s.aexists)(this);const{view:e,buffer:i,blockLen:n}=this,o=(t=(0,r.toBytes)(t)).length;for(let s=0;s<o;){const a=Math.min(n-this.pos,o-s);if(a!==n)i.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=(0,r.createView)(t);for(;n<=o-s;s+=n)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,s.aexists)(this),(0,s.aoutput)(t,this),this.finished=!0;const{buffer:e,view:i,blockLen:n,isLE:o}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>n-a&&(this.process(i,0),a=0);for(let t=a;t<n;t++)e[t]=0;!function(t,e,i,s){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),h=s?4:0,c=s?0:4;t.setUint32(e+h,o,s),t.setUint32(e+c,a,s)}(i,n-8,BigInt(8*this.length),o),this.process(i,0);const h=(0,r.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)h.setUint32(4*t,f[t],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const i=t.slice(0,e);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:i,length:s,finished:r,destroyed:n,pos:o}=this;return t.length=s,t.pos=o,t.finished=r,t.destroyed=n,s%e&&t.buffer.set(i),t}}e.HashMD=n},5145:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},9615:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const s=i(7557),r=i(9175);class n extends r.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,s.ahash)(t);const i=(0,r.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,o=new Uint8Array(n);o.set(i.length>n?t.create().update(i).digest():i);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),o.fill(0)}update(t){return(0,s.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,s.aexists)(this),(0,s.abytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:i,finished:s,destroyed:r,blockLen:n,outputLen:o}=this;return t.finished=s,t.destroyed=r,t.blockLen=n,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=i._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n,e.hmac=(t,e,i)=>new n(t,e).update(i).digest(),e.hmac.create=(t,e)=>new n(t,e)},2623:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=e.SHA256=void 0;const s=i(7202),r=i(9175),n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class h extends s.HashMD{constructor(){super(64,32,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4],this.F=0|o[5],this.G=0|o[6],this.H=0|o[7]}get(){const{A:t,B:e,C:i,D:s,E:r,F:n,G:o,H:a}=this;return[t,e,i,s,r,n,o,a]}set(t,e,i,s,r,n,o,a){this.A=0|t,this.B=0|e,this.C=0|i,this.D=0|s,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(t,e){for(let i=0;i<16;i++,e+=4)a[i]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],i=a[t-2],s=(0,r.rotr)(e,7)^(0,r.rotr)(e,18)^e>>>3,n=(0,r.rotr)(i,17)^(0,r.rotr)(i,19)^i>>>10;a[t]=n+a[t-7]+s+a[t-16]|0}let{A:i,B:o,C:h,D:c,E:u,F:f,G:y,H:d}=this;for(let t=0;t<64;t++){const e=d+((0,r.rotr)(u,6)^(0,r.rotr)(u,11)^(0,r.rotr)(u,25))+(0,s.Chi)(u,f,y)+n[t]+a[t]|0,p=((0,r.rotr)(i,2)^(0,r.rotr)(i,13)^(0,r.rotr)(i,22))+(0,s.Maj)(i,o,h)|0;d=y,y=f,f=u,u=c+e|0,c=h,h=o,o=i,i=e+p|0}i=i+this.A|0,o=o+this.B|0,h=h+this.C|0,c=c+this.D|0,u=u+this.E|0,f=f+this.F|0,y=y+this.G|0,d=d+this.H|0,this.set(i,o,h,c,u,f,y,d)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=h;class c extends h{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,r.wrapConstructor)((()=>new h)),e.sha224=(0,r.wrapConstructor)((()=>new c))},9175:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let i=0;i<t.length;i++)t[i]=(0,e.byteSwap)(t[i])},e.bytesToHex=function(t){(0,r.abytes)(t);let e="";for(let i=0;i<t.length;i++)e+=n[t[i]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,i=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const s=new Uint8Array(i);for(let e=0,r=0;e<i;e++,r+=2){const i=a(t.charCodeAt(r)),n=a(t.charCodeAt(r+1));if(void 0===i||void 0===n){const e=t[r]+t[r+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+r)}s[e]=16*i+n}return s},e.asyncLoop=async function(t,i,s){let r=Date.now();for(let n=0;n<t;n++){s(n);const t=Date.now()-r;t>=0&&t<i||(await(0,e.nextTick)(),r+=t)}},e.utf8ToBytes=h,e.toBytes=c,e.concatBytes=function(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];(0,r.abytes)(s),e+=s.length}const i=new Uint8Array(e);for(let e=0,s=0;e<t.length;e++){const r=t[e];i.set(r,s),s+=r.length}return i},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(c(e)).digest(),i=t();return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,i)=>t(i).update(c(e)).digest(),i=t({});return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,i)=>t(i).update(c(e)).digest(),i=t({});return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(s.crypto&&"function"==typeof s.crypto.getRandomValues)return s.crypto.getRandomValues(new Uint8Array(t));if(s.crypto&&"function"==typeof s.crypto.randomBytes)return s.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const s=i(5145),r=i(7557);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.rotl=(t,e)=>t<<e|t>>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t);const n=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),o={_0:48,_9:57,A:65,F:70,a:97,f:102};function a(t){return t>=o._0&&t<=o._9?t-o._0:t>=o.A&&t<=o.F?t-(o.A-10):t>=o.a&&t<=o.f?t-(o.a-10):void 0}function h(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function c(t){return"string"==typeof t&&(t=h(t)),(0,r.abytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}}},1137:(t,e,i)=>{"use strict";var s=i(7568);e.certificate=i(6413);var r=s.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));e.RSAPrivateKey=r;var n=s.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));e.RSAPublicKey=n;var o=s.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),a=s.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())}));e.PublicKey=a;var h=s.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(o),this.key("subjectPrivateKey").octstr())}));e.PrivateKey=h;var c=s.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));e.EncryptedPrivateKey=c;var u=s.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));e.DSAPrivateKey=u,e.DSAparam=s.define("DSAparam",(function(){this.int()}));var f=s.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})})),y=s.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(f),this.key("publicKey").optional().explicit(1).bitstr())}));e.ECPrivateKey=y,e.signature=s.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},6413:(t,e,i)=>{"use strict";var s=i(7568),r=s.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),n=s.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),o=s.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),a=s.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())})),h=s.define("RelativeDistinguishedName",(function(){this.setof(n)})),c=s.define("RDNSequence",(function(){this.seqof(h)})),u=s.define("Name",(function(){this.choice({rdnSequence:this.use(c)})})),f=s.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(r),this.key("notAfter").use(r))})),y=s.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),d=s.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(o),this.key("issuer").use(u),this.key("validity").use(f),this.key("subject").use(u),this.key("subjectPublicKeyInfo").use(a),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(y).optional())})),p=s.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(o),this.key("signatureValue").bitstr())}));t.exports=p},4101:(t,e,i)=>{"use strict";var s=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,r=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,o=i(8078),a=i(1241),h=i(2861).Buffer;t.exports=function(t,e){var i,c=t.toString(),u=c.match(s);if(u){var f="aes"+u[1],y=h.from(u[2],"hex"),d=h.from(u[3].replace(/[\r\n]/g,""),"base64"),p=o(e,y.slice(0,8),parseInt(u[1],10)).key,l=[],b=a.createDecipheriv(f,p,y);l.push(b.update(d)),l.push(b.final()),i=h.concat(l)}else{var g=c.match(n);i=h.from(g[2].replace(/[\r\n]/g,""),"base64")}return{tag:c.match(r)[1],data:i}}},8170:(t,e,i)=>{"use strict";var s=i(1137),r=i(5579),n=i(4101),o=i(1241),a=i(8396),h=i(2861).Buffer;function c(t){var e;"object"!=typeof t||h.isBuffer(t)||(e=t.passphrase,t=t.key),"string"==typeof t&&(t=h.from(t));var i,c,u=n(t,e),f=u.tag,y=u.data;switch(f){case"CERTIFICATE":c=s.certificate.decode(y,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=s.PublicKey.decode(y,"der")),i=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=s.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+i)}case"ENCRYPTED PRIVATE KEY":y=function(t,e){var i=t.algorithm.decrypt.kde.kdeparams.salt,s=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),n=r[t.algorithm.decrypt.cipher.algo.join(".")],c=t.algorithm.decrypt.cipher.iv,u=t.subjectPrivateKey,f=parseInt(n.split("-")[1],10)/8,y=a.pbkdf2Sync(e,i,s,f,"sha1"),d=o.createDecipheriv(n,y,c),p=[];return p.push(d.update(u)),p.push(d.final()),h.concat(p)}(y=s.EncryptedPrivateKey.decode(y,"der"),e);case"PRIVATE KEY":switch(i=(c=s.PrivateKey.decode(y,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:s.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=s.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+i)}case"RSA PUBLIC KEY":return s.RSAPublicKey.decode(y,"der");case"RSA PRIVATE KEY":return s.RSAPrivateKey.decode(y,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:s.DSAPrivateKey.decode(y,"der")};case"EC PRIVATE KEY":return{curve:(y=s.ECPrivateKey.decode(y,"der")).parameters.value,privateKey:y.privateKey};default:throw new Error("unknown key type "+f)}}c.signature=s.signature,t.exports=c},8396:(t,e,i)=>{e.pbkdf2=i(3832),e.pbkdf2Sync=i(1352)},3832:(t,e,i)=>{var s,r,n=i(2861).Buffer,o=i(4196),a=i(2455),h=i(1352),c=i(3382),u={}&&{}.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},y=[];function d(){return r||(r=i.g.process&&i.g.process.nextTick?i.g.process.nextTick:i.g.queueMicrotask?i.g.queueMicrotask:i.g.setImmediate?i.g.setImmediate:i.g.setTimeout)}function p(t,e,i,s,r){return u.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then((function(t){return u.deriveBits({name:"PBKDF2",salt:e,iterations:i,hash:{name:r}},t,s<<3)})).then((function(t){return n.from(t)}))}t.exports=function(t,e,r,l,b,g){"function"==typeof b&&(g=b,b=void 0);var k=f[(b=b||"sha1").toLowerCase()];if(k&&"function"==typeof i.g.Promise){if(o(r,l),t=c(t,a,"Password"),e=c(e,a,"Salt"),"function"!=typeof g)throw new Error("No callback provided to pbkdf2");!function(t,e){t.then((function(t){d()((function(){e(null,t)}))}),(function(t){d()((function(){e(t)}))}))}(function(t){if(i.g.process&&!i.g.process.browser)return Promise.resolve(!1);if(!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(void 0!==y[t])return y[t];var e=p(s=s||n.alloc(8),s,10,128,t).then((function(){return!0})).catch((function(){return!1}));return y[t]=e,e}(k).then((function(i){return i?p(t,e,r,l,k):h(t,e,r,l,b)})),g)}else d()((function(){var i;try{i=h(t,e,r,l,b)}catch(t){return g(t)}g(null,i)}))}},2455:(t,e,i)=>{var s,r=i(5606);s=i.g.process&&i.g.process.browser?"utf-8":i.g.process&&i.g.process.version?parseInt(r.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",t.exports=s},4196:t=>{var e=Math.pow(2,30)-1;t.exports=function(t,i){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof i)throw new TypeError("Key length not a number");if(i<0||i>e||i!=i)throw new TypeError("Bad key length")}},1352:(t,e,i)=>{var s=i(320),r=i(6011),n=i(2802),o=i(2861).Buffer,a=i(4196),h=i(2455),c=i(3382),u=o.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function y(t,e,i){var a=function(t){return"rmd160"===t||"ripemd160"===t?function(t){return(new r).update(t).digest()}:"md5"===t?s:function(e){return n(t).update(e).digest()}}(t),h="sha512"===t||"sha384"===t?128:64;e.length>h?e=a(e):e.length<h&&(e=o.concat([e,u],h));for(var c=o.allocUnsafe(h+f[t]),y=o.allocUnsafe(h+f[t]),d=0;d<h;d++)c[d]=54^e[d],y[d]=92^e[d];var p=o.allocUnsafe(h+i+4);c.copy(p,0,0,h),this.ipad1=p,this.ipad2=c,this.opad=y,this.alg=t,this.blocksize=h,this.hash=a,this.size=f[t]}y.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,i,s,r){a(i,s);var n=new y(r=r||"sha1",t=c(t,h,"Password"),(e=c(e,h,"Salt")).length),u=o.allocUnsafe(s),d=o.allocUnsafe(e.length+4);e.copy(d,0,0,e.length);for(var p=0,l=f[r],b=Math.ceil(s/l),g=1;g<=b;g++){d.writeUInt32BE(g,e.length);for(var k=n.run(d,n.ipad1),w=k,v=1;v<i;v++){w=n.run(w,n.ipad2);for(var m=0;m<l;m++)k[m]^=w[m]}k.copy(u,p),p+=l}return u}},3382:(t,e,i)=>{var s=i(2861).Buffer;t.exports=function(t,e,i){if(s.isBuffer(t))return t;if("string"==typeof t)return s.from(t,e);if(ArrayBuffer.isView(t))return s.from(t.buffer);throw new TypeError(i+" must be a string, a Buffer, a typed array or a DataView")}},5579:t=>{"use strict";t.exports=JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}')}}]);
2
+ (this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[774],{7557:(t,e)=>{"use strict";function i(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function s(t,...e){if(!((i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name))throw new Error("Uint8Array expected");var i;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}Object.defineProperty(e,"__esModule",{value:!0}),e.anumber=i,e.abytes=s,e.ahash=function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");i(t.outputLen),i(t.blockLen)},e.aexists=function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},e.aoutput=function(t,e){s(t);const i=e.outputLen;if(t.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}},7202:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=void 0,e.setBigUint64=n,e.Chi=function(t,e,i){return t&e^~t&i},e.Maj=function(t,e,i){return t&e^t&i^e&i};const s=i(7557),r=i(9175);function n(t,e,i,s){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),h=s?4:0,c=s?0:4;t.setUint32(e+h,o,s),t.setUint32(e+c,a,s)}class o extends r.Hash{constructor(t,e,i,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,r.createView)(this.buffer)}update(t){(0,s.aexists)(this);const{view:e,buffer:i,blockLen:n}=this,o=(t=(0,r.toBytes)(t)).length;for(let s=0;s<o;){const a=Math.min(n-this.pos,o-s);if(a!==n)i.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=(0,r.createView)(t);for(;n<=o-s;s+=n)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,s.aexists)(this),(0,s.aoutput)(t,this),this.finished=!0;const{buffer:e,view:i,blockLen:o,isLE:a}=this;let{pos:h}=this;e[h++]=128,this.buffer.subarray(h).fill(0),this.padOffset>o-h&&(this.process(i,0),h=0);for(let t=h;t<o;t++)e[t]=0;n(i,o-8,BigInt(8*this.length),a),this.process(i,0);const c=(0,r.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,y=this.get();if(f>y.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)c.setUint32(4*t,y[t],a)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const i=t.slice(0,e);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:i,length:s,finished:r,destroyed:n,pos:o}=this;return t.length=s,t.pos=o,t.finished=r,t.destroyed=n,s%e&&t.buffer.set(i),t}}e.HashMD=o},5145:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},9615:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const s=i(7557),r=i(9175);class n extends r.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,s.ahash)(t);const i=(0,r.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,o=new Uint8Array(n);o.set(i.length>n?t.create().update(i).digest():i);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),o.fill(0)}update(t){return(0,s.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,s.aexists)(this),(0,s.abytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:i,finished:s,destroyed:r,blockLen:n,outputLen:o}=this;return t.finished=s,t.destroyed=r,t.blockLen=n,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=i._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n,e.hmac=(t,e,i)=>new n(t,e).update(i).digest(),e.hmac.create=(t,e)=>new n(t,e)},2623:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=e.SHA256=void 0;const s=i(7202),r=i(9175),n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class h extends s.HashMD{constructor(){super(64,32,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4],this.F=0|o[5],this.G=0|o[6],this.H=0|o[7]}get(){const{A:t,B:e,C:i,D:s,E:r,F:n,G:o,H:a}=this;return[t,e,i,s,r,n,o,a]}set(t,e,i,s,r,n,o,a){this.A=0|t,this.B=0|e,this.C=0|i,this.D=0|s,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(t,e){for(let i=0;i<16;i++,e+=4)a[i]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],i=a[t-2],s=(0,r.rotr)(e,7)^(0,r.rotr)(e,18)^e>>>3,n=(0,r.rotr)(i,17)^(0,r.rotr)(i,19)^i>>>10;a[t]=n+a[t-7]+s+a[t-16]|0}let{A:i,B:o,C:h,D:c,E:u,F:f,G:y,H:d}=this;for(let t=0;t<64;t++){const e=d+((0,r.rotr)(u,6)^(0,r.rotr)(u,11)^(0,r.rotr)(u,25))+(0,s.Chi)(u,f,y)+n[t]+a[t]|0,p=((0,r.rotr)(i,2)^(0,r.rotr)(i,13)^(0,r.rotr)(i,22))+(0,s.Maj)(i,o,h)|0;d=y,y=f,f=u,u=c+e|0,c=h,h=o,o=i,i=e+p|0}i=i+this.A|0,o=o+this.B|0,h=h+this.C|0,c=c+this.D|0,u=u+this.E|0,f=f+this.F|0,y=y+this.G|0,d=d+this.H|0,this.set(i,o,h,c,u,f,y,d)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=h;class c extends h{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,r.wrapConstructor)((()=>new h)),e.sha224=(0,r.wrapConstructor)((()=>new c))},9175:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.isLE=void 0,e.isBytes=function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name},e.u8=function(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)},e.u32=function(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))},e.createView=function(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)},e.rotr=function(t,e){return t<<32-e|t>>>e},e.rotl=function(t,e){return t<<e|t>>>32-e>>>0},e.byteSwap=n,e.byteSwap32=function(t){for(let e=0;e<t.length;e++)t[e]=n(t[e])},e.bytesToHex=function(t){(0,r.abytes)(t);let e="";for(let i=0;i<t.length;i++)e+=o[t[i]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,i=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const s=new Uint8Array(i);for(let e=0,r=0;e<i;e++,r+=2){const i=h(t.charCodeAt(r)),n=h(t.charCodeAt(r+1));if(void 0===i||void 0===n){const e=t[r]+t[r+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+r)}s[e]=16*i+n}return s},e.asyncLoop=async function(t,i,s){let r=Date.now();for(let n=0;n<t;n++){s(n);const t=Date.now()-r;t>=0&&t<i||(await(0,e.nextTick)(),r+=t)}},e.utf8ToBytes=c,e.toBytes=u,e.concatBytes=function(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];(0,r.abytes)(s),e+=s.length}const i=new Uint8Array(e);for(let e=0,s=0;e<t.length;e++){const r=t[e];i.set(r,s),s+=r.length}return i},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(u(e)).digest(),i=t();return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,i)=>t(i).update(u(e)).digest(),i=t({});return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,i)=>t(i).update(u(e)).digest(),i=t({});return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(s.crypto&&"function"==typeof s.crypto.getRandomValues)return s.crypto.getRandomValues(new Uint8Array(t));if(s.crypto&&"function"==typeof s.crypto.randomBytes)return s.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const s=i(5145),r=i(7557);function n(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwapIfBE=e.isLE?t=>t:t=>n(t);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),a={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(t){return t>=a._0&&t<=a._9?t-a._0:t>=a.A&&t<=a.F?t-(a.A-10):t>=a.a&&t<=a.f?t-(a.a-10):void 0}function c(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function u(t){return"string"==typeof t&&(t=c(t)),(0,r.abytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}}},1137:(t,e,i)=>{"use strict";var s=i(7568);e.certificate=i(6413);var r=s.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));e.RSAPrivateKey=r;var n=s.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));e.RSAPublicKey=n;var o=s.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),a=s.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())}));e.PublicKey=a;var h=s.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(o),this.key("subjectPrivateKey").octstr())}));e.PrivateKey=h;var c=s.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));e.EncryptedPrivateKey=c;var u=s.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));e.DSAPrivateKey=u,e.DSAparam=s.define("DSAparam",(function(){this.int()}));var f=s.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})})),y=s.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(f),this.key("publicKey").optional().explicit(1).bitstr())}));e.ECPrivateKey=y,e.signature=s.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},6413:(t,e,i)=>{"use strict";var s=i(7568),r=s.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),n=s.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),o=s.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),a=s.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())})),h=s.define("RelativeDistinguishedName",(function(){this.setof(n)})),c=s.define("RDNSequence",(function(){this.seqof(h)})),u=s.define("Name",(function(){this.choice({rdnSequence:this.use(c)})})),f=s.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(r),this.key("notAfter").use(r))})),y=s.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),d=s.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(o),this.key("issuer").use(u),this.key("validity").use(f),this.key("subject").use(u),this.key("subjectPublicKeyInfo").use(a),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(y).optional())})),p=s.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(o),this.key("signatureValue").bitstr())}));t.exports=p},4101:(t,e,i)=>{"use strict";var s=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,r=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,o=i(8078),a=i(1241),h=i(2861).Buffer;t.exports=function(t,e){var i,c=t.toString(),u=c.match(s);if(u){var f="aes"+u[1],y=h.from(u[2],"hex"),d=h.from(u[3].replace(/[\r\n]/g,""),"base64"),p=o(e,y.slice(0,8),parseInt(u[1],10)).key,l=[],b=a.createDecipheriv(f,p,y);l.push(b.update(d)),l.push(b.final()),i=h.concat(l)}else{var g=c.match(n);i=h.from(g[2].replace(/[\r\n]/g,""),"base64")}return{tag:c.match(r)[1],data:i}}},8170:(t,e,i)=>{"use strict";var s=i(1137),r=i(5579),n=i(4101),o=i(1241),a=i(8396),h=i(2861).Buffer;function c(t){var e;"object"!=typeof t||h.isBuffer(t)||(e=t.passphrase,t=t.key),"string"==typeof t&&(t=h.from(t));var i,c,u=n(t,e),f=u.tag,y=u.data;switch(f){case"CERTIFICATE":c=s.certificate.decode(y,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=s.PublicKey.decode(y,"der")),i=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=s.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+i)}case"ENCRYPTED PRIVATE KEY":y=function(t,e){var i=t.algorithm.decrypt.kde.kdeparams.salt,s=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),n=r[t.algorithm.decrypt.cipher.algo.join(".")],c=t.algorithm.decrypt.cipher.iv,u=t.subjectPrivateKey,f=parseInt(n.split("-")[1],10)/8,y=a.pbkdf2Sync(e,i,s,f,"sha1"),d=o.createDecipheriv(n,y,c),p=[];return p.push(d.update(u)),p.push(d.final()),h.concat(p)}(y=s.EncryptedPrivateKey.decode(y,"der"),e);case"PRIVATE KEY":switch(i=(c=s.PrivateKey.decode(y,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:s.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=s.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+i)}case"RSA PUBLIC KEY":return s.RSAPublicKey.decode(y,"der");case"RSA PRIVATE KEY":return s.RSAPrivateKey.decode(y,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:s.DSAPrivateKey.decode(y,"der")};case"EC PRIVATE KEY":return{curve:(y=s.ECPrivateKey.decode(y,"der")).parameters.value,privateKey:y.privateKey};default:throw new Error("unknown key type "+f)}}c.signature=s.signature,t.exports=c},8396:(t,e,i)=>{e.pbkdf2=i(3832),e.pbkdf2Sync=i(1352)},3832:(t,e,i)=>{var s,r,n=i(2861).Buffer,o=i(4196),a=i(2455),h=i(1352),c=i(3382),u={}&&{}.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},y=[];function d(){return r||(r=i.g.process&&i.g.process.nextTick?i.g.process.nextTick:i.g.queueMicrotask?i.g.queueMicrotask:i.g.setImmediate?i.g.setImmediate:i.g.setTimeout)}function p(t,e,i,s,r){return u.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then((function(t){return u.deriveBits({name:"PBKDF2",salt:e,iterations:i,hash:{name:r}},t,s<<3)})).then((function(t){return n.from(t)}))}t.exports=function(t,e,r,l,b,g){"function"==typeof b&&(g=b,b=void 0);var k=f[(b=b||"sha1").toLowerCase()];if(k&&"function"==typeof i.g.Promise){if(o(r,l),t=c(t,a,"Password"),e=c(e,a,"Salt"),"function"!=typeof g)throw new Error("No callback provided to pbkdf2");!function(t,e){t.then((function(t){d()((function(){e(null,t)}))}),(function(t){d()((function(){e(t)}))}))}(function(t){if(i.g.process&&!i.g.process.browser)return Promise.resolve(!1);if(!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(void 0!==y[t])return y[t];var e=p(s=s||n.alloc(8),s,10,128,t).then((function(){return!0})).catch((function(){return!1}));return y[t]=e,e}(k).then((function(i){return i?p(t,e,r,l,k):h(t,e,r,l,b)})),g)}else d()((function(){var i;try{i=h(t,e,r,l,b)}catch(t){return g(t)}g(null,i)}))}},2455:(t,e,i)=>{var s,r=i(5606);s=i.g.process&&i.g.process.browser?"utf-8":i.g.process&&i.g.process.version?parseInt(r.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",t.exports=s},4196:t=>{var e=Math.pow(2,30)-1;t.exports=function(t,i){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof i)throw new TypeError("Key length not a number");if(i<0||i>e||i!=i)throw new TypeError("Bad key length")}},1352:(t,e,i)=>{var s=i(320),r=i(6011),n=i(2802),o=i(2861).Buffer,a=i(4196),h=i(2455),c=i(3382),u=o.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function y(t,e,i){var a=function(t){return"rmd160"===t||"ripemd160"===t?function(t){return(new r).update(t).digest()}:"md5"===t?s:function(e){return n(t).update(e).digest()}}(t),h="sha512"===t||"sha384"===t?128:64;e.length>h?e=a(e):e.length<h&&(e=o.concat([e,u],h));for(var c=o.allocUnsafe(h+f[t]),y=o.allocUnsafe(h+f[t]),d=0;d<h;d++)c[d]=54^e[d],y[d]=92^e[d];var p=o.allocUnsafe(h+i+4);c.copy(p,0,0,h),this.ipad1=p,this.ipad2=c,this.opad=y,this.alg=t,this.blocksize=h,this.hash=a,this.size=f[t]}y.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,i,s,r){a(i,s);var n=new y(r=r||"sha1",t=c(t,h,"Password"),(e=c(e,h,"Salt")).length),u=o.allocUnsafe(s),d=o.allocUnsafe(e.length+4);e.copy(d,0,0,e.length);for(var p=0,l=f[r],b=Math.ceil(s/l),g=1;g<=b;g++){d.writeUInt32BE(g,e.length);for(var k=n.run(d,n.ipad1),w=k,v=1;v<i;v++){w=n.run(w,n.ipad2);for(var m=0;m<l;m++)k[m]^=w[m]}k.copy(u,p),p+=l}return u}},3382:(t,e,i)=>{var s=i(2861).Buffer;t.exports=function(t,e,i){if(s.isBuffer(t))return t;if("string"==typeof t)return s.from(t,e);if(ArrayBuffer.isView(t))return s.from(t.buffer);throw new TypeError(i+" must be a string, a Buffer, a typed array or a DataView")}},5579:t=>{"use strict";t.exports=JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}')}}]);
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NostrCryptoUtils=e():(t.NostrCryptoUtils=t.NostrCryptoUtils||{},t.NostrCryptoUtils.crypto=e())}(this,(()=>(()=>{var t,e,r,o={8300:(t,e,r)=>{"use strict";var o=r(8510),n=r(3039),i=r(1565);new class{constructor(){this.cryptoInstance=null,this.initPromise=this.initialize()}async initialize(){this.cryptoInstance=await(async()=>{if("undefined"!=typeof window)return{};if(void 0!==r.g)return{};try{const t=await Promise.resolve().then(r.t.bind(r,1565,19));if(t.webcrypto)return t.webcrypto}catch{n.vF.debug("Node crypto not available, falling back to crypto-browserify")}return i})()}async ensureInitialized(){if(await this.initPromise,!this.cryptoInstance)throw new Error("Crypto implementation not initialized");return this.cryptoInstance}async getSubtle(){return(await this.ensureInitialized()).subtle}async getRandomValues(t){return(await this.ensureInitialized()).getRandomValues(t)}},o.ko.sign,o.ko.verify},3039:(t,e,r)=>{"use strict";r.d(e,{vF:()=>s});var o=r(4874),n=r.n(o),i=r(5606);const s=n()({name:"nostr-crypto-utils",level:i.env.LOG_LEVEL||"info",transport:void 0,formatters:{level:t=>({level:t.toUpperCase()}),log:t=>{if(t&&"object"==typeof t&&"err"in t){const e={...t};if(e.err instanceof Error){const t=e.err;e.err={message:t.message,stack:t.stack,name:t.name}}return e}return t}}})},8982:()=>{},7790:()=>{},1638:()=>{},2668:()=>{},7965:()=>{},6089:()=>{},9368:()=>{},4688:()=>{},1069:()=>{},3779:()=>{},7199:()=>{}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var r=n[t]={id:t,loaded:!1,exports:{}};return o[t].call(r.exports,r,r.exports,i),r.loaded=!0,r.exports}i.m=o,t=[],i.O=(e,r,o,n)=>{if(!r){var s=1/0;for(u=0;u<t.length;u++){for(var[r,o,n]=t[u],a=!0,l=0;l<r.length;l++)(!1&n||s>=n)&&Object.keys(i.O).every((t=>i.O[t](r[l])))?r.splice(l--,1):(a=!1,n<s&&(s=n));if(a){t.splice(u--,1);var c=o();void 0!==c&&(e=c)}}return e}n=n||0;for(var u=t.length;u>0&&t[u-1][2]>n;u--)t[u]=t[u-1];t[u]=[r,o,n]},i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var n=Object.create(null);i.r(n);var s={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>t[e]));return s.default=()=>t,i.d(n,s),n},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t={584:0};i.O.j=e=>0===t[e];var e=(e,r)=>{var o,n,[s,a,l]=r,c=0;if(s.some((e=>0!==t[e]))){for(o in a)i.o(a,o)&&(i.m[o]=a[o]);if(l)var u=l(i)}for(e&&e(r);c<s.length;c++)n=s[c],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return i.O(u)},r=this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();var s=i.O(void 0,[851,344,404,156,503,636,69,801,995,473,26,128,54,490,430,657,158,761,510,705,774,985,509,802,310,829,890,287,565],(()=>i(8300)));return(s=i.O(s)).default})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NostrCryptoUtils=e():(t.NostrCryptoUtils=t.NostrCryptoUtils||{},t.NostrCryptoUtils.crypto=e())}(this,(()=>(()=>{var t,e,r,o={8300:(t,e,r)=>{"use strict";var o=r(8510),n=r(3039),i=r(1565);new class{constructor(){this.cryptoInstance=null,this.initPromise=this.initialize()}async initialize(){this.cryptoInstance=await(async()=>{if("undefined"!=typeof window)return{};if(void 0!==r.g)return{};try{const t=await Promise.resolve().then(r.t.bind(r,1565,19));if(t.webcrypto)return t.webcrypto}catch{n.vF.debug("Node crypto not available, falling back to crypto-browserify")}return i})()}async ensureInitialized(){if(await this.initPromise,!this.cryptoInstance)throw new Error("Crypto implementation not initialized");return this.cryptoInstance}async getSubtle(){return(await this.ensureInitialized()).subtle}async getRandomValues(t){return(await this.ensureInitialized()).getRandomValues(t)}},o.ko.sign,o.ko.verify},3039:(t,e,r)=>{"use strict";r.d(e,{vF:()=>a});var o,n=r(4874),i=r.n(n),s=r(5606);!function(t){t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR"}(o||(o={}));const a=i()({name:"nostr-crypto-utils",level:s.env.LOG_LEVEL||"info",transport:void 0,formatters:{level:t=>({level:t.toUpperCase()}),log:t=>{if(t&&"object"==typeof t&&"err"in t){const e={...t};if(e.err instanceof Error){const t=e.err;e.err={message:t.message,stack:t.stack,name:t.name}}return e}return t}}})},8982:()=>{},7790:()=>{},1638:()=>{},2668:()=>{},7965:()=>{},6089:()=>{},9368:()=>{},4688:()=>{},1069:()=>{},3779:()=>{},7199:()=>{}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var r=n[t]={id:t,loaded:!1,exports:{}};return o[t].call(r.exports,r,r.exports,i),r.loaded=!0,r.exports}i.m=o,t=[],i.O=(e,r,o,n)=>{if(!r){var s=1/0;for(u=0;u<t.length;u++){for(var[r,o,n]=t[u],a=!0,l=0;l<r.length;l++)(!1&n||s>=n)&&Object.keys(i.O).every((t=>i.O[t](r[l])))?r.splice(l--,1):(a=!1,n<s&&(s=n));if(a){t.splice(u--,1);var c=o();void 0!==c&&(e=c)}}return e}n=n||0;for(var u=t.length;u>0&&t[u-1][2]>n;u--)t[u]=t[u-1];t[u]=[r,o,n]},i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var n=Object.create(null);i.r(n);var s={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>t[e]));return s.default=()=>t,i.d(n,s),n},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t={584:0};i.O.j=e=>0===t[e];var e=(e,r)=>{var o,n,[s,a,l]=r,c=0;if(s.some((e=>0!==t[e]))){for(o in a)i.o(a,o)&&(i.m[o]=a[o]);if(l)var u=l(i)}for(e&&e(r);c<s.length;c++)n=s[c],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return i.O(u)},r=this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();var s=i.O(void 0,[851,344,404,156,503,636,419,801,995,473,26,128,54,490,430,657,158,761,510,705,774,985,509,802,310,829,890,287],(()=>i(8300)));return(s=i.O(s)).default})()));
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NostrCryptoUtils=e():(t.NostrCryptoUtils=t.NostrCryptoUtils||{},t.NostrCryptoUtils.main=e())}(this,(()=>(()=>{var t,e,E,r={8300:(t,e,E)=>{"use strict";var r=E(8510),n=E(3039),i=E(1565);new class{constructor(){this.cryptoInstance=null,this.initPromise=this.initialize()}async initialize(){this.cryptoInstance=await(async()=>{if("undefined"!=typeof window)return{};if(void 0!==E.g)return{};try{const t=await Promise.resolve().then(E.t.bind(E,1565,19));if(t.webcrypto)return t.webcrypto}catch{n.vF.debug("Node crypto not available, falling back to crypto-browserify")}return i})()}async ensureInitialized(){if(await this.initPromise,!this.cryptoInstance)throw new Error("Crypto implementation not initialized");return this.cryptoInstance}async getSubtle(){return(await this.ensureInitialized()).subtle}async getRandomValues(t){return(await this.ensureInitialized()).getRandomValues(t)}},r.ko.sign,r.ko.verify},675:(t,e,E)=>{"use strict";var r,n,i;!function(t){t[t.SET_METADATA=0]="SET_METADATA",t[t.TEXT_NOTE=1]="TEXT_NOTE",t[t.RECOMMEND_SERVER=2]="RECOMMEND_SERVER",t[t.CONTACTS=3]="CONTACTS",t[t.ENCRYPTED_DIRECT_MESSAGE=4]="ENCRYPTED_DIRECT_MESSAGE",t[t.EVENT_DELETION=5]="EVENT_DELETION",t[t.REPOST=6]="REPOST",t[t.REACTION=7]="REACTION",t[t.CHANNEL_CREATION=40]="CHANNEL_CREATION",t[t.CHANNEL_METADATA=41]="CHANNEL_METADATA",t[t.CHANNEL_MESSAGE=42]="CHANNEL_MESSAGE",t[t.CHANNEL_HIDE_MESSAGE=43]="CHANNEL_HIDE_MESSAGE",t[t.CHANNEL_MUTE_USER=44]="CHANNEL_MUTE_USER",t[t.AUTH=22242]="AUTH",t[t.AUTH_RESPONSE=22243]="AUTH_RESPONSE"}(r||(r={})),function(t){t.EVENT="EVENT",t.NOTICE="NOTICE",t.OK="OK",t.EOSE="EOSE",t.REQ="REQ",t.CLOSE="CLOSE",t.AUTH="AUTH"}(n||(n={})),function(t){t[t.SET_METADATA=0]="SET_METADATA",t[t.TEXT_NOTE=1]="TEXT_NOTE",t[t.RECOMMEND_SERVER=2]="RECOMMEND_SERVER",t[t.CONTACT_LIST=3]="CONTACT_LIST",t[t.ENCRYPTED_DIRECT_MESSAGE=4]="ENCRYPTED_DIRECT_MESSAGE",t[t.DELETE=5]="DELETE",t[t.REPOST=6]="REPOST",t[t.REACTION=7]="REACTION",t[t.BADGE_AWARD=8]="BADGE_AWARD",t[t.CHANNEL_CREATE=40]="CHANNEL_CREATE",t[t.CHANNEL_METADATA=41]="CHANNEL_METADATA",t[t.CHANNEL_MESSAGE=42]="CHANNEL_MESSAGE",t[t.CHANNEL_HIDE_MESSAGE=43]="CHANNEL_HIDE_MESSAGE",t[t.CHANNEL_MUTE_USER=44]="CHANNEL_MUTE_USER",t[t.CHANNEL_RESERVE=45]="CHANNEL_RESERVE",t[t.REPORTING=1984]="REPORTING",t[t.ZAP_REQUEST=9734]="ZAP_REQUEST",t[t.ZAP=9735]="ZAP",t[t.MUTE_LIST=1e4]="MUTE_LIST",t[t.PIN_LIST=10001]="PIN_LIST",t[t.RELAY_LIST_METADATA=10002]="RELAY_LIST_METADATA",t[t.CLIENT_AUTH=22242]="CLIENT_AUTH",t[t.NOSTR_CONNECT=24133]="NOSTR_CONNECT",t[t.CATEGORIZED_PEOPLE=3e4]="CATEGORIZED_PEOPLE",t[t.CATEGORIZED_BOOKMARKS=30001]="CATEGORIZED_BOOKMARKS",t[t.PROFILE_BADGES=30008]="PROFILE_BADGES",t[t.BADGE_DEFINITION=30009]="BADGE_DEFINITION",t[t.LONG_FORM=30023]="LONG_FORM",t[t.APPLICATION_SPECIFIC=30078]="APPLICATION_SPECIFIC"}(i||(i={})),E(8300);var o=E(3039),a=E(1565);new class{constructor(){this.cryptoInstance=null,this.initPromise=this.initialize()}async initialize(){this.cryptoInstance=await(async()=>{if("undefined"!=typeof window)return{};if(void 0!==E.g)return{};try{const t=await Promise.resolve().then(E.t.bind(E,1565,19));if(t.webcrypto)return t.webcrypto}catch{o.vF.debug("Node crypto not available, falling back to crypto-browserify")}return a})()}async ensureInitialized(){if(await this.initPromise,!this.cryptoInstance)throw new Error("Crypto implementation not initialized");return this.cryptoInstance}async getSubtle(){return(await this.ensureInitialized()).subtle}async getRandomValues(t){return(await this.ensureInitialized()).getRandomValues(t)}},E(2343),E(8287),E(8287).Buffer},3039:(t,e,E)=>{"use strict";E.d(e,{vF:()=>a});var r,n=E(4874),i=E.n(n),o=E(5606);!function(t){t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR"}(r||(r={}));const a=i()({name:"nostr-crypto-utils",level:o.env.LOG_LEVEL||"info",transport:void 0,formatters:{level:t=>({level:t.toUpperCase()}),log:t=>{if(t&&"object"==typeof t&&"err"in t){const e={...t};if(e.err instanceof Error){const t=e.err;e.err={message:t.message,stack:t.stack,name:t.name}}return e}return t}}})},8982:()=>{},7790:()=>{},1638:()=>{},2668:()=>{},7965:()=>{},6089:()=>{},9368:()=>{},4688:()=>{},1069:()=>{},3779:()=>{},7199:()=>{}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var E=n[t]={id:t,loaded:!1,exports:{}};return r[t].call(E.exports,E,E.exports,i),E.loaded=!0,E.exports}i.m=r,t=[],i.O=(e,E,r,n)=>{if(!E){var o=1/0;for(A=0;A<t.length;A++){for(var[E,r,n]=t[A],a=!0,s=0;s<E.length;s++)(!1&n||o>=n)&&Object.keys(i.O).every((t=>i.O[t](E[s])))?E.splice(s--,1):(a=!1,n<o&&(o=n));if(a){t.splice(A--,1);var T=r();void 0!==T&&(e=T)}}return e}n=n||0;for(var A=t.length;A>0&&t[A-1][2]>n;A--)t[A]=t[A-1];t[A]=[E,r,n]},i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},E=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(t,r){if(1&r&&(t=this(t)),8&r)return t;if("object"==typeof t&&t){if(4&r&&t.__esModule)return t;if(16&r&&"function"==typeof t.then)return t}var n=Object.create(null);i.r(n);var o={};e=e||[null,E({}),E([]),E(E)];for(var a=2&r&&t;"object"==typeof a&&!~e.indexOf(a);a=E(a))Object.getOwnPropertyNames(a).forEach((e=>o[e]=()=>t[e]));return o.default=()=>t,i.d(n,o),n},i.d=(t,e)=>{for(var E in e)i.o(e,E)&&!i.o(t,E)&&Object.defineProperty(t,E,{enumerable:!0,get:e[E]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t={584:0,792:0};i.O.j=e=>0===t[e];var e=(e,E)=>{var r,n,[o,a,s]=E,T=0;if(o.some((e=>0!==t[e]))){for(r in a)i.o(a,r)&&(i.m[r]=a[r]);if(s)var A=s(i)}for(e&&e(E);T<o.length;T++)n=o[T],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return i.O(A)},E=this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[];E.forEach(e.bind(null,0)),E.push=e.bind(null,E.push.bind(E))})();var o=i.O(void 0,[851,344,404,156,503,636,419,801,995,473,26,128,54,490,430,657,158,761,510,705,774,985,509,802,310,829,890,343,668],(()=>i(675)));return(o=i.O(o)).default})()));
@@ -1 +1 @@
1
- !function(E,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.NostrCryptoUtils=t():(E.NostrCryptoUtils=E.NostrCryptoUtils||{},E.NostrCryptoUtils.protocol=t())}(this,(()=>(()=>{"use strict";var E={6354:(E,t,N)=>{var T,o;!function(E){E[E.SET_METADATA=0]="SET_METADATA",E[E.TEXT_NOTE=1]="TEXT_NOTE",E[E.RECOMMEND_SERVER=2]="RECOMMEND_SERVER",E[E.CONTACTS=3]="CONTACTS",E[E.ENCRYPTED_DIRECT_MESSAGE=4]="ENCRYPTED_DIRECT_MESSAGE",E[E.EVENT_DELETION=5]="EVENT_DELETION",E[E.REACTION=7]="REACTION",E[E.CHANNEL_CREATE=40]="CHANNEL_CREATE",E[E.CHANNEL_METADATA=41]="CHANNEL_METADATA",E[E.CHANNEL_MESSAGE=42]="CHANNEL_MESSAGE",E[E.CHANNEL_HIDE_MESSAGE=43]="CHANNEL_HIDE_MESSAGE",E[E.CHANNEL_MUTE_USER=44]="CHANNEL_MUTE_USER",E[E.AUTH=22242]="AUTH",E[E.AUTH_RESPONSE=22243]="AUTH_RESPONSE"}(T||(T={})),function(E){E.EVENT="EVENT",E.REQ="REQ",E.CLOSE="CLOSE",E.NOTICE="NOTICE",E.EOSE="EOSE",E.OK="OK",E.AUTH="AUTH",E.ERROR="ERROR",E.COUNT="COUNT"}(o||(o={}))}},t={};function N(T){var o=t[T];if(void 0!==o)return o.exports;var A=t[T]={exports:{}};return E[T](A,A.exports,N),A.exports}N.d=(E,t)=>{for(var T in t)N.o(t,T)&&!N.o(E,T)&&Object.defineProperty(E,T,{enumerable:!0,get:t[T]})},N.o=(E,t)=>Object.prototype.hasOwnProperty.call(E,t);var T={};return N(6354),T.default})()));
1
+ !function(E,N){"object"==typeof exports&&"object"==typeof module?module.exports=N():"function"==typeof define&&define.amd?define([],N):"object"==typeof exports?exports.NostrCryptoUtils=N():(E.NostrCryptoUtils=E.NostrCryptoUtils||{},E.NostrCryptoUtils.protocol=N())}(this,(()=>(()=>{"use strict";var E,N,T,A,C={};return(A=E||(E={}))[A.SET_METADATA=0]="SET_METADATA",A[A.TEXT_NOTE=1]="TEXT_NOTE",A[A.RECOMMEND_SERVER=2]="RECOMMEND_SERVER",A[A.CONTACTS=3]="CONTACTS",A[A.ENCRYPTED_DIRECT_MESSAGE=4]="ENCRYPTED_DIRECT_MESSAGE",A[A.EVENT_DELETION=5]="EVENT_DELETION",A[A.REPOST=6]="REPOST",A[A.REACTION=7]="REACTION",A[A.CHANNEL_CREATION=40]="CHANNEL_CREATION",A[A.CHANNEL_METADATA=41]="CHANNEL_METADATA",A[A.CHANNEL_MESSAGE=42]="CHANNEL_MESSAGE",A[A.CHANNEL_HIDE_MESSAGE=43]="CHANNEL_HIDE_MESSAGE",A[A.CHANNEL_MUTE_USER=44]="CHANNEL_MUTE_USER",A[A.AUTH=22242]="AUTH",A[A.AUTH_RESPONSE=22243]="AUTH_RESPONSE",(T=N||(N={})).EVENT="EVENT",T.NOTICE="NOTICE",T.OK="OK",T.EOSE="EOSE",T.REQ="REQ",T.CLOSE="CLOSE",T.AUTH="AUTH",C.default})()));
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module event
3
+ * @description Event handling utilities for Nostr
4
+ */
5
+ export { createEvent, serializeEvent, getEventHash } from './creation';
6
+ export { validateEvent, calculateEventId } from './signing';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/event/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * @module event
4
+ * @description Event handling utilities for Nostr
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.calculateEventId = exports.validateEvent = exports.getEventHash = exports.serializeEvent = exports.createEvent = void 0;
8
+ var creation_1 = require("./creation");
9
+ Object.defineProperty(exports, "createEvent", { enumerable: true, get: function () { return creation_1.createEvent; } });
10
+ Object.defineProperty(exports, "serializeEvent", { enumerable: true, get: function () { return creation_1.serializeEvent; } });
11
+ Object.defineProperty(exports, "getEventHash", { enumerable: true, get: function () { return creation_1.getEventHash; } });
12
+ var signing_1 = require("./signing");
13
+ Object.defineProperty(exports, "validateEvent", { enumerable: true, get: function () { return signing_1.validateEvent; } });
14
+ Object.defineProperty(exports, "calculateEventId", { enumerable: true, get: function () { return signing_1.calculateEventId; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/event/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCAAuE;AAA9D,uGAAA,WAAW,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,wGAAA,YAAY,OAAA;AAClD,qCAA4D;AAAnD,wGAAA,aAAa,OAAA;AAAE,2GAAA,gBAAgB,OAAA"}
@@ -16,4 +16,16 @@ export declare function signEvent(event: NostrEvent, privateKey: string): Promis
16
16
  * @returns True if signature is valid
17
17
  */
18
18
  export declare function verifySignature(event: SignedNostrEvent): boolean;
19
+ /**
20
+ * Validates a Nostr event
21
+ * @param event - Event to validate
22
+ * @returns True if event is valid
23
+ */
24
+ export declare function validateEvent(event: SignedNostrEvent): boolean;
25
+ /**
26
+ * Calculates the event ID for a Nostr event
27
+ * @param event - Event to calculate ID for
28
+ * @returns Event ID
29
+ */
30
+ export declare function calculateEventId(event: NostrEvent): Promise<string>;
19
31
  //# sourceMappingURL=signing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../../src/event/signing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7D;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC,CAc3B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAWhE"}
1
+ {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../../src/event/signing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7D;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC,CAc3B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAWhE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAa9D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnE"}
@@ -6,6 +6,8 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.signEvent = signEvent;
8
8
  exports.verifySignature = verifySignature;
9
+ exports.validateEvent = validateEvent;
10
+ exports.calculateEventId = calculateEventId;
9
11
  const secp256k1_1 = require("@noble/curves/secp256k1");
10
12
  const utils_1 = require("@noble/curves/abstract/utils");
11
13
  const logger_1 = require("../utils/logger");
@@ -45,4 +47,31 @@ function verifySignature(event) {
45
47
  return false;
46
48
  }
47
49
  }
50
+ /**
51
+ * Validates a Nostr event
52
+ * @param event - Event to validate
53
+ * @returns True if event is valid
54
+ */
55
+ function validateEvent(event) {
56
+ try {
57
+ // Check required fields
58
+ if (!event.id || !event.pubkey || !event.sig) {
59
+ return false;
60
+ }
61
+ // Verify signature
62
+ return verifySignature(event);
63
+ }
64
+ catch (error) {
65
+ logger_1.logger.error('Error validating event:', error);
66
+ return false;
67
+ }
68
+ }
69
+ /**
70
+ * Calculates the event ID for a Nostr event
71
+ * @param event - Event to calculate ID for
72
+ * @returns Event ID
73
+ */
74
+ function calculateEventId(event) {
75
+ return (0, creation_1.getEventHash)(event);
76
+ }
48
77
  //# sourceMappingURL=signing.js.map