nostr-crypto-utils 0.4.16 → 0.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -75
- package/dist/browser/287.nostr-crypto-utils.min.js +1 -1
- package/dist/browser/348.nostr-crypto-utils.min.js +2 -0
- package/dist/browser/349.nostr-crypto-utils.min.js +1 -0
- package/dist/browser/510.nostr-crypto-utils.min.js +1 -1
- package/dist/browser/538.nostr-crypto-utils.min.js +2 -0
- package/dist/browser/574.nostr-crypto-utils.min.js +2 -0
- package/dist/browser/575.nostr-crypto-utils.min.js +2 -0
- package/dist/browser/705.nostr-crypto-utils.min.js +1 -1
- package/dist/browser/crypto.nostr-crypto-utils.min.js +1 -1
- package/dist/browser/main-31743c5a.nostr-crypto-utils.min.js +1 -0
- package/dist/browser/main-96d4916e.nostr-crypto-utils.min.js +1 -1
- package/dist/cjs/crypto.js +2 -6
- package/dist/cjs/crypto.js.map +1 -1
- package/dist/cjs/nips/nip-04.js +2 -6
- package/dist/cjs/nips/nip-04.js.map +1 -1
- package/dist/cjs/nips/nip-26.js +6 -8
- package/dist/cjs/nips/nip-26.js.map +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/validation.js +1 -1
- package/dist/cjs/utils/validation.js.map +1 -1
- package/dist/esm/crypto.js +2 -3
- package/dist/esm/crypto.js.map +1 -1
- package/dist/esm/nips/nip-04.js +2 -3
- package/dist/esm/nips/nip-04.js.map +1 -1
- package/dist/esm/nips/nip-26.js +4 -6
- package/dist/esm/nips/nip-26.js.map +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/validation.js +1 -1
- package/dist/esm/utils/validation.js.map +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/examples/basic-usage.ts +33 -0
- package/examples/nip-04.ts +35 -0
- package/examples/nip-19.ts +46 -0
- package/package.json +20 -11
- package/src/crypto.ts +4 -4
- package/src/nips/nip-04.ts +4 -4
- package/src/nips/nip-26.ts +5 -7
- package/src/types/index.ts +1 -0
- package/src/utils/validation.ts +1 -1
- package/dist/browser/128.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/156.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/158.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/26.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/310.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/343.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/344.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/404.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/419.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/430.nostr-crypto-utils.min.js +0 -2
- package/dist/browser/473.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/490.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/503.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/509.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/54.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/636.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/657.nostr-crypto-utils.min.js +0 -2
- package/dist/browser/668.nostr-crypto-utils.min.js +0 -2
- package/dist/browser/668.nostr-crypto-utils.min.js.LICENSE.txt +0 -6
- package/dist/browser/761.nostr-crypto-utils.min.js +0 -2
- package/dist/browser/801.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/802.nostr-crypto-utils.min.js +0 -2
- package/dist/browser/802.nostr-crypto-utils.min.js.LICENSE.txt +0 -1
- package/dist/browser/829.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/851.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/88.nostr-crypto-utils.min.js +0 -2
- package/dist/browser/890.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/910.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/985.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/995.nostr-crypto-utils.min.js +0 -1
- package/dist/browser/main-43dd7041.nostr-crypto-utils.min.js +0 -1
- /package/dist/browser/{657.nostr-crypto-utils.min.js.LICENSE.txt → 348.nostr-crypto-utils.min.js.LICENSE.txt} +0 -0
- /package/dist/browser/{430.nostr-crypto-utils.min.js.LICENSE.txt → 538.nostr-crypto-utils.min.js.LICENSE.txt} +0 -0
- /package/dist/browser/{88.nostr-crypto-utils.min.js.LICENSE.txt → 574.nostr-crypto-utils.min.js.LICENSE.txt} +0 -0
- /package/dist/browser/{761.nostr-crypto-utils.min.js.LICENSE.txt → 575.nostr-crypto-utils.min.js.LICENSE.txt} +0 -0
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ This library provides essential cryptographic operations and utilities required
|
|
|
63
63
|
- Supports both ESM and CJS formats
|
|
64
64
|
- Cross-platform compatible (Node.js and browser environments)
|
|
65
65
|
|
|
66
|
-
[](https://www.npmjs.com/package/nostr-crypto-utils)
|
|
67
67
|
[](http://www.typescriptlang.org/)
|
|
68
68
|
[](https://github.com/HumanjavaEnterprises/nostr-crypto-utils/blob/main/LICENSE)
|
|
69
69
|
[](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
|
|
@@ -148,7 +148,7 @@ import {
|
|
|
148
148
|
naddrEncode,
|
|
149
149
|
nrelayEncode,
|
|
150
150
|
decode
|
|
151
|
-
} from '
|
|
151
|
+
} from 'nostr-crypto-utils';
|
|
152
152
|
|
|
153
153
|
// Encode a public key
|
|
154
154
|
const npub = npubEncode('7f3b6c2444c526fc7b3a48b0a1e38fb6a5a4062d4a097c9e96feb3c1df2f36d0');
|
|
@@ -202,6 +202,7 @@ try {
|
|
|
202
202
|
} catch (error) {
|
|
203
203
|
console.error(error); // Error: Invalid hex string
|
|
204
204
|
}
|
|
205
|
+
```
|
|
205
206
|
|
|
206
207
|
### Type System
|
|
207
208
|
|
|
@@ -448,11 +449,11 @@ These examples demonstrate real-world usage patterns from production Nostr appli
|
|
|
448
449
|
|
|
449
450
|
## Integration with nostr-nsec-seedphrase
|
|
450
451
|
|
|
451
|
-
This library is designed to work seamlessly with [
|
|
452
|
+
This library is designed to work seamlessly with [nostr-nsec-seedphrase](https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase) to provide a complete solution for Nostr key management and cryptographic operations:
|
|
452
453
|
|
|
453
454
|
```typescript
|
|
454
|
-
import { generateSeedPhrase } from '
|
|
455
|
-
import { createTextNoteEvent, signEvent } from '
|
|
455
|
+
import { generateSeedPhrase } from 'nostr-nsec-seedphrase';
|
|
456
|
+
import { createTextNoteEvent, signEvent } from 'nostr-crypto-utils';
|
|
456
457
|
|
|
457
458
|
// Generate keys using nostr-nsec-seedphrase
|
|
458
459
|
const seedPhrase = generateSeedPhrase();
|
|
@@ -481,7 +482,7 @@ You can use this library to create delegate tokens for use on web servers or oth
|
|
|
481
482
|
### Basic Delegation Example
|
|
482
483
|
|
|
483
484
|
```typescript
|
|
484
|
-
import { createDelegation, validateDelegation } from '
|
|
485
|
+
import { createDelegation, validateDelegation } from 'nostr-crypto-utils';
|
|
485
486
|
|
|
486
487
|
// Create a delegation token (delegator's perspective)
|
|
487
488
|
const delegatorKeyPair = await generateKeyPair();
|
|
@@ -510,7 +511,7 @@ const isValid = await validateDelegation({
|
|
|
510
511
|
Here's how to use delegation tokens in a web server context:
|
|
511
512
|
|
|
512
513
|
```typescript
|
|
513
|
-
import { createEvent, signEventWithDelegation } from '
|
|
514
|
+
import { createEvent, signEventWithDelegation } from 'nostr-crypto-utils';
|
|
514
515
|
|
|
515
516
|
// On your server, store these securely
|
|
516
517
|
const DELEGATE_PRIVKEY = 'nsec1...'; // Your server's private key
|
|
@@ -589,7 +590,7 @@ For more details on delegation, see the [NIP-26 specification](https://github.co
|
|
|
589
590
|
Enable debug mode to get detailed logging:
|
|
590
591
|
|
|
591
592
|
```typescript
|
|
592
|
-
import { setDebugLevel } from '
|
|
593
|
+
import { setDebugLevel } from 'nostr-crypto-utils';
|
|
593
594
|
|
|
594
595
|
// Enable debug logging
|
|
595
596
|
setDebugLevel('debug');
|
|
@@ -671,53 +672,6 @@ const testEventSigning = async (event, delegation) => {
|
|
|
671
672
|
|
|
672
673
|
For more help, join our [Discord community](https://discord.gg/nostr) or [open an issue](https://github.com/humanjavaenterprises/nostr-crypto-utils/issues).
|
|
673
674
|
|
|
674
|
-
## Installation
|
|
675
|
-
|
|
676
|
-
```bash
|
|
677
|
-
npm install @humanjavaenterprises/nostr-crypto-utils
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
## Quick Start
|
|
681
|
-
|
|
682
|
-
```typescript
|
|
683
|
-
import { createKeyPair, createTextNoteEvent, signEvent } from '@humanjavaenterprises/nostr-crypto-utils';
|
|
684
|
-
|
|
685
|
-
// Generate a new key pair
|
|
686
|
-
const keyPair = createKeyPair();
|
|
687
|
-
|
|
688
|
-
// Create a text note event
|
|
689
|
-
const event = createTextNoteEvent({
|
|
690
|
-
content: 'Hello Nostr!',
|
|
691
|
-
pubkey: keyPair.publicKey,
|
|
692
|
-
created_at: Math.floor(Date.now() / 1000)
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// Sign the event
|
|
696
|
-
const signedEvent = signEvent(event, keyPair.privateKey);
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
## Documentation
|
|
700
|
-
|
|
701
|
-
Comprehensive documentation is available at [https://humanjavaenterprises.github.io/nostr-crypto-utils/](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
|
|
702
|
-
|
|
703
|
-
## Type Safety
|
|
704
|
-
|
|
705
|
-
This library is written in TypeScript and provides comprehensive type definitions for all functions and data structures. Type checking is enforced at compile time to catch potential errors early.
|
|
706
|
-
|
|
707
|
-
```typescript
|
|
708
|
-
import { NostrEvent, NostrFilter, ValidationResult } from '@humanjavaenterprises/nostr-crypto-utils';
|
|
709
|
-
|
|
710
|
-
// All types are properly defined
|
|
711
|
-
const filter: NostrFilter = {
|
|
712
|
-
kinds: [NostrEventKind.TEXT_NOTE],
|
|
713
|
-
"#t": ["nostr", "crypto"], // Filter by custom tag
|
|
714
|
-
limit: 10
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
// Validation results include type information
|
|
718
|
-
const result: ValidationResult = validateEvent(event);
|
|
719
|
-
```
|
|
720
|
-
|
|
721
675
|
## Contributing
|
|
722
676
|
|
|
723
677
|
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
|
|
@@ -728,29 +682,14 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
728
682
|
|
|
729
683
|
## Changelog
|
|
730
684
|
|
|
731
|
-
|
|
732
|
-
- 🔒 Improved type safety with stricter TypeScript checks
|
|
733
|
-
- 🐛 Fixed crypto implementation for cross-platform compatibility
|
|
734
|
-
- ✨ Added comprehensive validation for all message types
|
|
735
|
-
- 📝 Updated documentation with more examples
|
|
736
|
-
|
|
737
|
-
### v0.2.0 (2024-12-26)
|
|
738
|
-
- 🎉 Initial public release
|
|
739
|
-
- ✨ Added support for NIP-01 and NIP-04
|
|
740
|
-
- 🔑 Implemented key pair generation and management
|
|
741
|
-
- 📝 Added comprehensive documentation
|
|
685
|
+
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
|
|
742
686
|
|
|
743
687
|
## Support
|
|
744
688
|
|
|
745
|
-
-
|
|
746
|
-
-
|
|
747
|
-
-
|
|
689
|
+
- [Documentation](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
|
|
690
|
+
- [Issue Tracker](https://github.com/HumanjavaEnterprises/nostr-crypto-utils/issues)
|
|
691
|
+
- [Discussions](https://github.com/HumanjavaEnterprises/nostr-crypto-utils/discussions)
|
|
748
692
|
|
|
749
693
|
## Related Projects
|
|
750
694
|
|
|
751
|
-
- [
|
|
752
|
-
|
|
753
|
-
---
|
|
754
|
-
<div align="center">
|
|
755
|
-
Made with ❤️ by <a href="https://github.com/humanjavaenterprises">Humanjava Enterprises</a>
|
|
756
|
-
</div>
|
|
695
|
+
- [nostr-nsec-seedphrase](https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase) - Generate and manage Nostr private keys using BIP-39 seed phrases
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 287.nostr-crypto-utils.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[287,668],{8287(t,e,r){const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const f=2147483647;function s(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|y(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return c(t),s(t<0?0:0|y(t))}function p(t){const e=t.length<0?0:0|y(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function y(t){if(t>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function w(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return R(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:B(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):B(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function B(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,s/=2,u/=2,r/=2}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=!1;break}if(r)return o}return-1}function E(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(Z(n))return f;t[r+f]=n}return f}function m(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function I(t,e,r,n){return X(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return X(W(e),t,r,n)}function A(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function v(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function R(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=T));return r}(n)}e.kMaxLength=f,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return h(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return a(t)},u.allocUnsafeSlow=function(t){return a(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(J(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)d(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?R(this,0,t):w.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const s=Math.min(o,f),h=this.slice(n,i),c=t.slice(e,r);for(let t=0;t<s;++t)if(h[t]!==c[t]){o=h[t],f=c[t];break}return o<f?-1:f<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":case"latin1":case"binary":return I(this,t,e,r);case"base64":return U(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function L(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=H[t[n]];return i}function _(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function $(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function P(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function k(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return e=+e,r>>>=0,o||k(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||k(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||$(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||$(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||$(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||$(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||$(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=K(function(t){Y(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=K(function(t){Y(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||$(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||$(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||$(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||$(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||$(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=K(function(t){Y(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=K(function(t){Y(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||$(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||$(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||$(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||$(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=K(function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=K(function(t,e=0){return P(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=K(function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=K(function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f]}return this};const M={};function j(t,e,r){M[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function D(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function z(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){Y(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,i,o)}function Y(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw Y(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),j("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),j("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const V=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const H=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function K(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}}}]);
|
|
2
|
+
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[287],{287(t,e,r){const n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.IS=50;const f=2147483647;function s(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|y(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?s(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return c(t),s(t<0?0:0|y(t))}function p(t){const e=t.length<0?0:0|y(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function y(t){if(t>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function w(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return R(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:B(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):B(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function B(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,s/=2,u/=2,r/=2}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=!1;break}if(r)return o}return-1}function E(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(H(n))return f;t[r+f]=n}return f}function m(t,e,r,n){return J(q(e,t.length-r),t,r,n)}function I(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return J(W(e),t,r,n)}function A(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function v(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function R(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f}return function(t){const e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=O));return r}(n)}u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return h(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return a(t)},u.allocUnsafeSlow=function(t){return a(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(Z(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Z(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)d(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?R(this,0,t):w.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(Z(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const s=Math.min(o,f),h=this.slice(n,i),c=t.slice(e,r);for(let t=0;t<s;++t)if(h[t]!==c[t]){o=h[t],f=c[t];break}return o<f?-1:f<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":case"latin1":case"binary":return I(this,t,e,r);case"base64":return U(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const O=4096;function T(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function L(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=K[t[n]];return i}function _(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function $(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function k(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||$(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||$(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||$(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||$(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||$(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Q(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Q(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||$(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||$(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||$(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||$(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||$(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||$(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Q(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=Q(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||$(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||$(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||$(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||$(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Q(function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Q(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Q(function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Q(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f]}return this};const j={};function M(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function D(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function z(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||Y(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function Y(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new j.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),M("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const V=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}const K=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Q(t){return"undefined"==typeof BigInt?X:t}function X(){throw new Error("BigInt not supported")}}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 348.nostr-crypto-utils.min.js.LICENSE.txt */
|
|
2
|
+
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[348],{967(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.isNegativeLE=void 0,t.mod=h,t.pow=function(e,t,n){return B(R(n),e,t)},t.pow2=function(e,t,n){let r=e;for(;t-- >o;)r*=r,r%=n;return r},t.invert=w,t.tonelliShanks=b,t.FpSqrt=y,t.validateField=function(e){const t=q.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,r._validateObject)(e,t),e},t.FpPow=B,t.FpInvertBatch=v,t.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?w(n,e.ORDER):e.inv(n))},t.FpLegendre=O,t.FpIsSquare=function(e,t){return 1===O(e,t)},t.nLength=N,t.Field=R,t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},t.hashToPrivateScalar=function(e,t,n=!1){const o=(e=(0,r.ensureBytes)("privateHash",e)).length,s=N(t).nByteLength+8;if(s<24||o<s||o>1024)throw new Error("hashToPrivateScalar: expected "+s+"-1024 bytes of input, got "+o);return h(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-i)+i},t.getFieldBytesLength=L,t.getMinHashLength=T,t.mapHashToField=function(e,t,n=!1){const o=e.length,s=L(t),u=T(t);if(o<16||o<u||o>1024)throw new Error("expected "+u+"-1024 bytes of input, got "+o);const l=h(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-i)+i;return n?(0,r.numberToBytesLE)(l,s):(0,r.numberToBytesBE)(l,s)};const r=n(627),o=BigInt(0),i=BigInt(1),s=BigInt(2),u=BigInt(3),l=BigInt(4),f=BigInt(5),d=BigInt(7),c=BigInt(8),a=BigInt(9),g=BigInt(16);function h(e,t){const n=e%t;return n>=o?n:t+n}function w(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 n=h(e,t),r=t,s=o,u=i,l=i,f=o;for(;n!==o;){const e=r/n,t=r%n,o=s-l*e,i=u-f*e;r=n,n=t,s=l,u=f,l=o,f=i}if(r!==i)throw new Error("invert: does not exist");return h(s,t)}function E(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function m(e,t){const n=(e.ORDER+i)/l,r=e.pow(t,n);return E(e,r,t),r}function p(e,t){const n=(e.ORDER-f)/c,r=e.mul(t,s),o=e.pow(r,n),i=e.mul(t,o),u=e.mul(e.mul(i,s),o),l=e.mul(i,e.sub(u,e.ONE));return E(e,l,t),l}function b(e){if(e<u)throw new Error("sqrt is not defined for small field");let t=e-i,n=0;for(;t%s===o;)t/=s,n++;let r=s;const l=R(e);for(;1===O(l,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return m;let f=l.pow(r,t);const d=(t+i)/s;return function(e,r){if(e.is0(r))return r;if(1!==O(e,r))throw new Error("Cannot find square root");let o=n,s=e.mul(e.ONE,f),u=e.pow(r,t),l=e.pow(r,d);for(;!e.eql(u,e.ONE);){if(e.is0(u))return e.ZERO;let t=1,n=e.sqr(u);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=i<<BigInt(o-t-1),f=e.pow(s,r);o=t,s=e.sqr(f),u=e.mul(u,s),l=e.mul(l,f)}return l}}function y(e){return e%l===u?m:e%c===f?p:e%g===a?function(e){const t=R(e),n=b(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+d)/g;return(e,t)=>{let n=e.pow(t,s),u=e.mul(n,r);const l=e.mul(n,o),f=e.mul(n,i),d=e.eql(e.sqr(u),t),c=e.eql(e.sqr(l),t);n=e.cmov(n,u,d),u=e.cmov(f,l,c);const a=e.eql(e.sqr(u),t),g=e.cmov(n,u,a);return E(e,g,t),g}}(e):b(e)}t.isNegativeLE=(e,t)=>(h(e,t)&i)===i;const q=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function B(e,t,n){if(n<o)throw new Error("invalid exponent, negatives unsupported");if(n===o)return e.ONE;if(n===i)return t;let r=e.ONE,s=t;for(;n>o;)n&i&&(r=e.mul(r,s)),s=e.sqr(s),n>>=i;return r}function v(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n)),e.ONE),i=e.inv(o);return t.reduceRight((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n)),i),r}function O(e,t){const n=(e.ORDER-i)/s,r=e.pow(t,n),o=e.eql(r,e.ONE),u=e.eql(r,e.ZERO),l=e.eql(r,e.neg(e.ONE));if(!o&&!u&&!l)throw new Error("invalid Legendre symbol result");return o?1:u?0:-1}function N(e,t){void 0!==t&&(0,r.anumber)(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function R(e,t,n=!1,s={}){if(e<=o)throw new Error("invalid field: expected ORDER > 0, got "+e);let u,l,f,d=!1;if("object"==typeof t&&null!=t){if(s.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(u=e.BITS),e.sqrt&&(l=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(d=e.modFromBytes),f=e.allowedLengths}else"number"==typeof t&&(u=t),s.sqrt&&(l=s.sqrt);const{nBitLength:c,nByteLength:a}=N(e,u);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let g;const E=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:a,MASK:(0,r.bitMask)(c),ZERO:o,ONE:i,allowedLengths:f,create:t=>h(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,isValidNot0:e=>!E.is0(e)&&E.isValid(e),isOdd:e=>(e&i)===i,neg:t=>h(-t,e),eql:(e,t)=>e===t,sqr:t=>h(t*t,e),add:(t,n)=>h(t+n,e),sub:(t,n)=>h(t-n,e),mul:(t,n)=>h(t*n,e),pow:(e,t)=>B(E,e,t),div:(t,n)=>h(t*w(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>w(t,e),sqrt:l||(t=>(g||(g=y(e)),g(E,t))),toBytes:e=>n?(0,r.numberToBytesLE)(e,a):(0,r.numberToBytesBE)(e,a),fromBytes:(t,o=!0)=>{if(f){if(!f.includes(t.length)||t.length>a)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+t.length);const e=new Uint8Array(a);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+t.length);let i=n?(0,r.bytesToNumberLE)(t):(0,r.bytesToNumberBE)(t);if(d&&(i=h(i,e)),!o&&!E.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:e=>v(E,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(E)}function L(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 T(e){const t=L(e);return t+Math.ceil(t/2)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[349],{606(e){var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var l,a=[],c=!1,u=-1;function f(){c&&l&&(c=!1,l.length?a=l.concat(a):u=-1,a.length&&h())}function h(){if(!c){var e=o(f);c=!0;for(var t=a.length;t;){for(l=a,a=[];++u<t;)l&&l[u].run();u=-1,t=a.length}l=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function b(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];a.push(new v(e,t)),1!==a.length||c||o(h)},v.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=b,n.addListener=b,n.once=b,n.off=b,n.removeListener=b,n.removeAllListeners=b,n.emit=b,n.prependListener=b,n.prependOnceListener=b,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},793(e){"use strict";function t(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}e.exports=function(e,r,n){var i=n&&n.stringify||t;if("object"==typeof e&&null!==e){var s=r.length+1;if(1===s)return e;var o=new Array(s);o[0]=i(e);for(var l=1;l<s;l++)o[l]=i(r[l]);return o.join(" ")}if("string"!=typeof e)return e;var a=r.length;if(0===a)return e;for(var c="",u=0,f=-1,h=e&&e.length||0,v=0;v<h;){if(37===e.charCodeAt(v)&&v+1<h){switch(f=f>-1?f:0,e.charCodeAt(v+1)){case 100:case 102:if(u>=a)break;if(null==r[u])break;f<v&&(c+=e.slice(f,v)),c+=Number(r[u]),f=v+2,v++;break;case 105:if(u>=a)break;if(null==r[u])break;f<v&&(c+=e.slice(f,v)),c+=Math.floor(Number(r[u])),f=v+2,v++;break;case 79:case 111:case 106:if(u>=a)break;if(void 0===r[u])break;f<v&&(c+=e.slice(f,v));var b=typeof r[u];if("string"===b){c+="'"+r[u]+"'",f=v+2,v++;break}if("function"===b){c+=r[u].name||"<anonymous>",f=v+2,v++;break}c+=i(r[u]),f=v+2,v++;break;case 115:if(u>=a)break;f<v&&(c+=e.slice(f,v)),c+=String(r[u]),f=v+2,v++;break;case 37:f<v&&(c+=e.slice(f,v)),c+="%",f=v+2,v++,u--}++u}++v}return-1===f?e:(f<h&&(c+=e.slice(f)),c)}},874(e,t,r){"use strict";const n=r(793);e.exports=f;const i=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},s={mapHttpRequest:d,mapHttpResponse:d,wrapRequestSerializer:m,wrapResponseSerializer:m,wrapErrorSerializer:m,req:d,res:d,err:g,errWithCause:g};function o(e,t){return"silent"===e?1/0:t.levels.values[e]}const l=Symbol("pino.logFuncs"),a=Symbol("pino.hierarchy"),c={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function u(e,t){const r={logger:t,parent:e[a]};t[a]=r}function f(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!=typeof t.send)throw Error("pino: transmit option must have a send function");const r=e.browser.write||i;e.browser.write&&(e.browser.asObject=!0);const n=e.serializers||{},s=function(e,t){return Array.isArray(e)?e.filter(function(e){return"!stdSerializers.err"!==e}):!0===e&&Object.keys(t)}(e.browser.serialize,n);let a=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(a=!1);const g=Object.keys(e.customLevels||{}),d=["error","fatal","warn","info","debug","trace"].concat(g);"function"==typeof r&&d.forEach(function(e){r[e]=r}),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const m=e.level||"info",w=Object.create(r);w.log||(w.log=y),function(e,t,r){const n={};t.forEach(e=>{n[e]=r[e]?r[e]:i[e]||i[c[e]||"log"]||y}),e[l]=n}(w,d,r),u({},w),Object.defineProperty(w,"levelVal",{get:function(){return o(this.level,this)}}),Object.defineProperty(w,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,h(this,z,w,"error"),h(this,z,w,"fatal"),h(this,z,w,"warn"),h(this,z,w,"info"),h(this,z,w,"debug"),h(this,z,w,"trace"),g.forEach(e=>{h(this,z,w,e)})}});const z={transmit:t,serialize:s,asObject:e.browser.asObject,formatters:e.browser.formatters,levels:d,timestamp:p(e)};return w.levels=function(e){const t=e.customLevels||{};return{values:Object.assign({},f.levels.values,t),labels:Object.assign({},f.levels.labels,function(e){const t={};return Object.keys(e).forEach(function(r){t[e[r]]=r}),t}(t))}}(e),w.level=m,w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=n,w._serialize=s,w._stdErrSerialize=a,w.child=function(r,i){if(!r)throw new Error("missing bindings for child Pino");i=i||{},s&&r.serializers&&(i.serializers=r.serializers);const o=i.serializers;if(s&&o){var l=Object.assign({},n,o),a=!0===e.browser.serialize?Object.keys(l):s;delete r.serializers,v([r],a,l,this._stdErrSerialize)}function c(e){this._childLevel=1+(0|e._childLevel),this.bindings=r,l&&(this.serializers=l,this._serialize=a),t&&(this._logEvent=b([].concat(e._logEvent.bindings,r)))}c.prototype=this;const f=new c(this);return u(this,f),f.level=this.level,f},t&&(w._logEvent=b()),w}function h(e,t,r,s){if(Object.defineProperty(e,s,{value:o(e.level,r)>o(s,r)?y:r[l][s],writable:!0,enumerable:!0,configurable:!0}),!t.transmit&&e[s]===y)return;e[s]=function(e,t,r,s){return a=e[l][s],function(){const l=t.timestamp(),c=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===i?i:this;for(var f=0;f<c.length;f++)c[f]=arguments[f];if(t.serialize&&!t.asObject&&v(c,this._serialize,this.serializers,this._stdErrSerialize),t.asObject||t.formatters?a.call(u,function(e,t,r,i,s={}){const{level:o=()=>e.levels.values[t],log:l=e=>e}=s;e._serialize&&v(r,e._serialize,e.serializers,e._stdErrSerialize);const a=r.slice();let c=a[0];const u={};i&&(u.time=i),u.level=o(t,e.levels.values[t]);let f=1+(0|e._childLevel);if(f<1&&(f=1),null!==c&&"object"==typeof c){for(;f--&&"object"==typeof a[0];)Object.assign(u,a.shift());c=a.length?n(a.shift(),a):void 0}else"string"==typeof c&&(c=n(a.shift(),a));return void 0!==c&&(u.msg=c),l(u)}(this,s,c,l,t.formatters)):a.apply(u,c),t.transmit){const n=t.transmit.level||e._level,i=r.levels.values[n],a=r.levels.values[s];if(a<i)return;!function(e,t,r){const n=t.send,i=t.ts,s=t.methodLevel,o=t.methodValue,l=t.val,a=e._logEvent.bindings;v(r,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=r.filter(function(e){return-1===a.indexOf(e)}),e._logEvent.level.label=s,e._logEvent.level.value=o,n(s,e._logEvent,l),e._logEvent=b(a)}(this,{ts:l,methodLevel:s,methodValue:a,transmitLevel:n,transmitValue:r.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:o(e._level,r)},c)}};var a}(e,t,r,s);const c=function(e){const t=[];e.bindings&&t.push(e.bindings);let r=e[a];for(;r.parent;)r=r.parent,r.logger.bindings&&t.push(r.logger.bindings);return t.reverse()}(e);0!==c.length&&(e[s]=function(e,t){return function(){return t.apply(this,[...e,...arguments])}}(c,e[s]))}function v(e,t,r,n){for(const i in e)if(n&&e[i]instanceof Error)e[i]=f.stdSerializers.err(e[i]);else if("object"==typeof e[i]&&!Array.isArray(e[i]))for(const n in e[i])t&&t.indexOf(n)>-1&&n in r&&(e[i][n]=r[n](e[i][n]))}function b(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function g(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}function p(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?w:z}function d(){return{}}function m(e){return e}function y(){}function w(){return!1}function z(){return Date.now()}f.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},f.stdSerializers=s,f.stdTimeFunctions=Object.assign({},{nullTime:w,epochTime:z,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),e.exports.default=f,e.exports.pino=f}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 510.nostr-crypto-utils.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[510],{8510(e,t,n){t.ND=t.ko=t.bI=void 0;const r=n(7076),f=n(9175),o=n(3562),i=n(1761),a=n(4967),c=n(1705),s=n(8627),u={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},b={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},d=BigInt(0),y=BigInt(1),g=BigInt(2),p=(0,a.Field)(u.p,{sqrt:function(e){const t=u.p,n=BigInt(3),r=BigInt(6),f=BigInt(11),o=BigInt(22),i=BigInt(23),c=BigInt(44),s=BigInt(88),b=e*e*e%t,d=b*b*e%t,y=(0,a.pow2)(d,n,t)*d%t,l=(0,a.pow2)(y,n,t)*d%t,B=(0,a.pow2)(l,g,t)*b%t,m=(0,a.pow2)(B,f,t)*B%t,h=(0,a.pow2)(m,o,t)*m%t,x=(0,a.pow2)(h,c,t)*h%t,w=(0,a.pow2)(x,s,t)*x%t,I=(0,a.pow2)(w,c,t)*h%t,E=(0,a.pow2)(I,n,t)*d%t,T=(0,a.pow2)(E,i,t)*m%t,v=(0,a.pow2)(T,r,t)*b%t,S=(0,a.pow2)(v,g,t);if(!p.eql(p.sqr(S),e))throw new Error("Cannot find square root");return S}});t.bI=(0,o.createCurve)({...u,Fp:p,lowS:!0,endo:b},r.sha256);const l={};function B(e,...t){let n=l[e];if(void 0===n){const t=(0,r.sha256)((0,s.utf8ToBytes)(e));n=(0,s.concatBytes)(t,t),l[e]=n}return(0,r.sha256)((0,s.concatBytes)(n,...t))}const m=e=>e.toBytes(!0).slice(1),h=(()=>t.bI.Point)(),x=e=>e%g===d;function w(e){const{Fn:t,BASE:n}=h,r=(0,c._normFnElement)(t,e),f=n.multiply(r);return{scalar:x(f.y)?r:t.neg(r),bytes:m(f)}}function I(e){const t=p;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let f=t.sqrt(r);x(f)||(f=t.neg(f));const o=h.fromAffine({x:e,y:f});return o.assertValidity(),o}const E=s.bytesToNumberBE;function T(...e){return h.Fn.create(E(B("BIP0340/challenge",...e)))}function v(e){return w(e).bytes}function S(e,t,n=(0,f.randomBytes)(32)){const{Fn:r}=h,o=(0,s.ensureBytes)("message",e),{bytes:i,scalar:a}=w(t),c=(0,s.ensureBytes)("auxRand",n,32),u=r.toBytes(a^E(B("BIP0340/aux",c))),b=B("BIP0340/nonce",u,i,o),{bytes:d,scalar:y}=w(b),g=T(d,i,o),p=new Uint8Array(64);if(p.set(d,0),p.set(r.toBytes(r.create(y+g*a)),32),!U(p,o,i))throw new Error("sign: Invalid signature produced");return p}function U(e,t,n){const{Fn:r,BASE:f}=h,o=(0,s.ensureBytes)("signature",e,64),i=(0,s.ensureBytes)("message",t),a=(0,s.ensureBytes)("publicKey",n,32);try{const e=I(E(a)),t=E(o.subarray(0,32));if(!(0,s.inRange)(t,y,u.p))return!1;const n=E(o.subarray(32,64));if(!(0,s.inRange)(n,y,u.n))return!1;const c=T(r.toBytes(t),m(e),i),b=f.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(c))),{x:d,y:g}=b.toAffine();return!(b.is0()||!x(g)||d!==t)}catch(e){return!1}}t.ko=(()=>{const e=(e=(0,f.randomBytes)(48))=>(0,a.mapHashToField)(e,u.n);return t.bI.utils.randomSecretKey,{keygen:function(t){const n=e(t);return{secretKey:n,publicKey:v(n)}},getPublicKey:v,sign:S,verify:U,Point:h,utils:{randomSecretKey:e,randomPrivateKey:e,taggedHash:B,lift_x:I,pointToBytes:m,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,mod:a.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const A=(()=>(0,i.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))))(),O=(()=>(0,c.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}))();t.ND=(0,i.createHasher)(t.bI.Point,e=>{const{x:t,y:n}=O(p.create(e[0]));return A(t,n)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:r.sha256}),t.ND.hashToCurve,t.ND.encodeToCurve},8627(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.notImplemented=t.bitMask=t.utf8ToBytes=t.randomBytes=t.isBytes=t.hexToBytes=t.concatBytes=t.bytesToUtf8=t.bytesToHex=t.anumber=t.abytes=void 0,t.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},t._abool2=function(e,t=""){if("boolean"!=typeof e)throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e);return e},t._abytes2=function(e,t,n=""){const f=(0,r.isBytes)(e),o=e?.length,i=void 0!==t;if(!f||i&&o!==t)throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(f?`length=${o}`:"type="+typeof e));return e},t.numberToHexUnpadded=a,t.hexToNumber=c,t.bytesToNumberBE=function(e){return c((0,r.bytesToHex)(e))},t.bytesToNumberLE=function(e){return(0,r.abytes)(e),c((0,r.bytesToHex)(Uint8Array.from(e).reverse()))},t.numberToBytesBE=s,t.numberToBytesLE=function(e,t){return s(e,t).reverse()},t.numberToVarBytesBE=function(e){return(0,r.hexToBytes)(a(e))},t.ensureBytes=function(e,t,n){let f;if("string"==typeof t)try{f=(0,r.hexToBytes)(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!(0,r.isBytes)(t))throw new Error(e+" must be hex string or Uint8Array");f=Uint8Array.from(t)}const o=f.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return f},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},t.copyBytes=function(e){return Uint8Array.from(e)},t.asciiToBytes=function(e){return Uint8Array.from(e,(t,n)=>{const r=t.charCodeAt(0);if(1!==t.length||r>127)throw new Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})},t.inRange=b,t.aInRange=function(e,t,n,r){if(!b(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)},t.bitLen=function(e){let t;for(t=0;e>o;e>>=i,t+=1);return t},t.bitGet=function(e,t){return e>>BigInt(t)&i},t.bitSet=function(e,t,n){return e|(n?i:o)<<BigInt(t)},t.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const f=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let i=f(e),a=f(e),c=0;const s=()=>{i.fill(1),a.fill(0),c=0},u=(...e)=>n(a,i,...e),b=(e=f(0))=>{a=u(o(0),e),i=u(),0!==e.length&&(a=u(o(1),e),i=u())},d=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=u();const t=i.slice();n.push(t),e+=i.length}return(0,r.concatBytes)(...n)};return(e,t)=>{let n;for(s(),b(e);!(n=t(d()));)b();return s(),n}},t.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const f=d[n];if("function"!=typeof f)throw new Error("invalid validator function");const o=e[t];if(!(r&&void 0===o||f(o,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+o)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},t.isHash=function(e){return"function"==typeof e&&Number.isSafeInteger(e.outputLen)},t._validateObject=function(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const f=e[t];if(r&&void 0===f)return;const o=typeof f;if(o!==n||null===f)throw new Error(`param "${t}" is invalid: expected ${n}, got ${o}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))},t.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const f=t.get(n);if(void 0!==f)return f;const o=e(n,...r);return t.set(n,o),o}};const r=n(9175);var f=n(9175);Object.defineProperty(t,"abytes",{enumerable:!0,get:function(){return f.abytes}}),Object.defineProperty(t,"anumber",{enumerable:!0,get:function(){return f.anumber}}),Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return f.bytesToHex}}),Object.defineProperty(t,"bytesToUtf8",{enumerable:!0,get:function(){return f.bytesToUtf8}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return f.concatBytes}}),Object.defineProperty(t,"hexToBytes",{enumerable:!0,get:function(){return f.hexToBytes}}),Object.defineProperty(t,"isBytes",{enumerable:!0,get:function(){return f.isBytes}}),Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return f.randomBytes}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return f.utf8ToBytes}});const o=BigInt(0),i=BigInt(1);function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?o:BigInt("0x"+e)}function s(e,t){return(0,r.hexToBytes)(e.toString(16).padStart(2*t,"0"))}const u=e=>"bigint"==typeof e&&o<=e;function b(e,t,n){return u(e)&&u(t)&&u(n)&&t<=e&&e<n}t.bitMask=e=>(i<<BigInt(e))-i;const d={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||(0,r.isBytes)(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};t.notImplemented=()=>{throw new Error("not implemented")}}}]);
|
|
2
|
+
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[510],{510(e,t,n){t.ND=t.ko=t.bI=void 0;const r=n(76),f=n(175),o=n(562),i=n(761),a=n(967),c=n(705),s=n(627),u={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},b={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},d=BigInt(0),y=BigInt(1),g=BigInt(2),p=(0,a.Field)(u.p,{sqrt:function(e){const t=u.p,n=BigInt(3),r=BigInt(6),f=BigInt(11),o=BigInt(22),i=BigInt(23),c=BigInt(44),s=BigInt(88),b=e*e*e%t,d=b*b*e%t,y=(0,a.pow2)(d,n,t)*d%t,l=(0,a.pow2)(y,n,t)*d%t,B=(0,a.pow2)(l,g,t)*b%t,m=(0,a.pow2)(B,f,t)*B%t,h=(0,a.pow2)(m,o,t)*m%t,x=(0,a.pow2)(h,c,t)*h%t,w=(0,a.pow2)(x,s,t)*x%t,I=(0,a.pow2)(w,c,t)*h%t,E=(0,a.pow2)(I,n,t)*d%t,T=(0,a.pow2)(E,i,t)*m%t,v=(0,a.pow2)(T,r,t)*b%t,S=(0,a.pow2)(v,g,t);if(!p.eql(p.sqr(S),e))throw new Error("Cannot find square root");return S}});t.bI=(0,o.createCurve)({...u,Fp:p,lowS:!0,endo:b},r.sha256);const l={};function B(e,...t){let n=l[e];if(void 0===n){const t=(0,r.sha256)((0,s.utf8ToBytes)(e));n=(0,s.concatBytes)(t,t),l[e]=n}return(0,r.sha256)((0,s.concatBytes)(n,...t))}const m=e=>e.toBytes(!0).slice(1),h=(()=>t.bI.Point)(),x=e=>e%g===d;function w(e){const{Fn:t,BASE:n}=h,r=(0,c._normFnElement)(t,e),f=n.multiply(r);return{scalar:x(f.y)?r:t.neg(r),bytes:m(f)}}function I(e){const t=p;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let f=t.sqrt(r);x(f)||(f=t.neg(f));const o=h.fromAffine({x:e,y:f});return o.assertValidity(),o}const E=s.bytesToNumberBE;function T(...e){return h.Fn.create(E(B("BIP0340/challenge",...e)))}function v(e){return w(e).bytes}function S(e,t,n=(0,f.randomBytes)(32)){const{Fn:r}=h,o=(0,s.ensureBytes)("message",e),{bytes:i,scalar:a}=w(t),c=(0,s.ensureBytes)("auxRand",n,32),u=r.toBytes(a^E(B("BIP0340/aux",c))),b=B("BIP0340/nonce",u,i,o),{bytes:d,scalar:y}=w(b),g=T(d,i,o),p=new Uint8Array(64);if(p.set(d,0),p.set(r.toBytes(r.create(y+g*a)),32),!U(p,o,i))throw new Error("sign: Invalid signature produced");return p}function U(e,t,n){const{Fn:r,BASE:f}=h,o=(0,s.ensureBytes)("signature",e,64),i=(0,s.ensureBytes)("message",t),a=(0,s.ensureBytes)("publicKey",n,32);try{const e=I(E(a)),t=E(o.subarray(0,32));if(!(0,s.inRange)(t,y,u.p))return!1;const n=E(o.subarray(32,64));if(!(0,s.inRange)(n,y,u.n))return!1;const c=T(r.toBytes(t),m(e),i),b=f.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(c))),{x:d,y:g}=b.toAffine();return!(b.is0()||!x(g)||d!==t)}catch(e){return!1}}t.ko=(()=>{const e=(e=(0,f.randomBytes)(48))=>(0,a.mapHashToField)(e,u.n);return t.bI.utils.randomSecretKey,{keygen:function(t){const n=e(t);return{secretKey:n,publicKey:v(n)}},getPublicKey:v,sign:S,verify:U,Point:h,utils:{randomSecretKey:e,randomPrivateKey:e,taggedHash:B,lift_x:I,pointToBytes:m,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,mod:a.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const A=(()=>(0,i.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))))(),O=(()=>(0,c.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}))();t.ND=(0,i.createHasher)(t.bI.Point,e=>{const{x:t,y:n}=O(p.create(e[0]));return A(t,n)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:r.sha256}),t.ND.hashToCurve,t.ND.encodeToCurve},627(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.notImplemented=t.bitMask=t.utf8ToBytes=t.randomBytes=t.isBytes=t.hexToBytes=t.concatBytes=t.bytesToUtf8=t.bytesToHex=t.anumber=t.abytes=void 0,t.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},t._abool2=function(e,t=""){if("boolean"!=typeof e)throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e);return e},t._abytes2=function(e,t,n=""){const f=(0,r.isBytes)(e),o=e?.length,i=void 0!==t;if(!f||i&&o!==t)throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(f?`length=${o}`:"type="+typeof e));return e},t.numberToHexUnpadded=a,t.hexToNumber=c,t.bytesToNumberBE=function(e){return c((0,r.bytesToHex)(e))},t.bytesToNumberLE=function(e){return(0,r.abytes)(e),c((0,r.bytesToHex)(Uint8Array.from(e).reverse()))},t.numberToBytesBE=s,t.numberToBytesLE=function(e,t){return s(e,t).reverse()},t.numberToVarBytesBE=function(e){return(0,r.hexToBytes)(a(e))},t.ensureBytes=function(e,t,n){let f;if("string"==typeof t)try{f=(0,r.hexToBytes)(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!(0,r.isBytes)(t))throw new Error(e+" must be hex string or Uint8Array");f=Uint8Array.from(t)}const o=f.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return f},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},t.copyBytes=function(e){return Uint8Array.from(e)},t.asciiToBytes=function(e){return Uint8Array.from(e,(t,n)=>{const r=t.charCodeAt(0);if(1!==t.length||r>127)throw new Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})},t.inRange=b,t.aInRange=function(e,t,n,r){if(!b(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)},t.bitLen=function(e){let t;for(t=0;e>o;e>>=i,t+=1);return t},t.bitGet=function(e,t){return e>>BigInt(t)&i},t.bitSet=function(e,t,n){return e|(n?i:o)<<BigInt(t)},t.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const f=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let i=f(e),a=f(e),c=0;const s=()=>{i.fill(1),a.fill(0),c=0},u=(...e)=>n(a,i,...e),b=(e=f(0))=>{a=u(o(0),e),i=u(),0!==e.length&&(a=u(o(1),e),i=u())},d=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=u();const t=i.slice();n.push(t),e+=i.length}return(0,r.concatBytes)(...n)};return(e,t)=>{let n;for(s(),b(e);!(n=t(d()));)b();return s(),n}},t.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const f=d[n];if("function"!=typeof f)throw new Error("invalid validator function");const o=e[t];if(!(r&&void 0===o||f(o,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+o)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},t.isHash=function(e){return"function"==typeof e&&Number.isSafeInteger(e.outputLen)},t._validateObject=function(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const f=e[t];if(r&&void 0===f)return;const o=typeof f;if(o!==n||null===f)throw new Error(`param "${t}" is invalid: expected ${n}, got ${o}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))},t.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const f=t.get(n);if(void 0!==f)return f;const o=e(n,...r);return t.set(n,o),o}};const r=n(175);var f=n(175);Object.defineProperty(t,"abytes",{enumerable:!0,get:function(){return f.abytes}}),Object.defineProperty(t,"anumber",{enumerable:!0,get:function(){return f.anumber}}),Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return f.bytesToHex}}),Object.defineProperty(t,"bytesToUtf8",{enumerable:!0,get:function(){return f.bytesToUtf8}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return f.concatBytes}}),Object.defineProperty(t,"hexToBytes",{enumerable:!0,get:function(){return f.hexToBytes}}),Object.defineProperty(t,"isBytes",{enumerable:!0,get:function(){return f.isBytes}}),Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return f.randomBytes}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return f.utf8ToBytes}});const o=BigInt(0),i=BigInt(1);function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?o:BigInt("0x"+e)}function s(e,t){return(0,r.hexToBytes)(e.toString(16).padStart(2*t,"0"))}const u=e=>"bigint"==typeof e&&o<=e;function b(e,t,n){return u(e)&&u(t)&&u(n)&&t<=e&&e<n}t.bitMask=e=>(i<<BigInt(e))-i;const d={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||(0,r.isBytes)(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};t.notImplemented=()=>{throw new Error("not implemented")}}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 538.nostr-crypto-utils.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[538],{526(r,t){"use strict";t.byteLength=function(r){var t=c(r),e=t[0],n=t[1];return 3*(e+n)/4-n},t.toByteArray=function(r){var t,e,i=c(r),f=i[0],a=i[1],h=new o(function(r,t,e){return 3*(t+e)/4-e}(0,f,a)),s=0,u=a>0?f-4:f;for(e=0;e<u;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],h[s++]=t>>16&255,h[s++]=t>>8&255,h[s++]=255&t;return 2===a&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,h[s++]=255&t),1===a&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,h[s++]=t>>8&255,h[s++]=255&t),h},t.fromByteArray=function(r){for(var t,n=r.length,o=n%3,i=[],f=16383,c=0,a=n-o;c<a;c+=f)i.push(h(r,c,c+f>a?a:c+f));return 1===o?(t=r[n-1],i.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],i.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"=")),i.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)e[f]=i[f],n[i.charCodeAt(f)]=f;function c(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function a(r){return e[r>>18&63]+e[r>>12&63]+e[r>>6&63]+e[63&r]}function h(r,t,e){for(var n,o=[],i=t;i<e;i+=3)n=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),o.push(a(n));return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},343(r,t){"use strict";const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let r=0;r<32;r++){const t=e.charAt(r);n[t]=r}function o(r){const t=r>>25;return(33554431&r)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function i(r){let t=1;for(let e=0;e<r.length;++e){const n=r.charCodeAt(e);if(n<33||n>126)return"Invalid prefix ("+r+")";t=o(t)^n>>5}t=o(t);for(let e=0;e<r.length;++e){const n=r.charCodeAt(e);t=o(t)^31&n}return t}function f(r,t,e,n){let o=0,i=0;const f=(1<<e)-1,c=[];for(let n=0;n<r.length;++n)for(o=o<<t|r[n],i+=t;i>=e;)i-=e,c.push(o>>i&f);if(n)i>0&&c.push(o<<e-i&f);else{if(i>=t)return"Excess padding";if(o<<e-i&f)return"Non-zero padding"}return c}function c(r){return f(r,8,5,!0)}function a(r){const t=f(r,5,8,!1);if(Array.isArray(t))return t}function h(r){const t=f(r,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function s(r){let t;function f(r,e){if(e=e||90,r.length<8)return r+" too short";if(r.length>e)return"Exceeds length limit";const f=r.toLowerCase(),c=r.toUpperCase();if(r!==f&&r!==c)return"Mixed-case string "+r;const a=(r=f).lastIndexOf("1");if(-1===a)return"No separator character for "+r;if(0===a)return"Missing prefix for "+r;const h=r.slice(0,a),s=r.slice(a+1);if(s.length<6)return"Data too short";let u=i(h);if("string"==typeof u)return u;const l=[];for(let r=0;r<s.length;++r){const t=s.charAt(r),e=n[t];if(void 0===e)return"Unknown character "+t;u=o(u)^e,r+6>=s.length||l.push(e)}return u!==t?"Invalid checksum for "+r:{prefix:h,words:l}}return t="bech32"===r?1:734539939,{decodeUnsafe:function(r,t){const e=f(r,t);if("object"==typeof e)return e},decode:function(r,t){const e=f(r,t);if("object"==typeof e)return e;throw new Error(e)},encode:function(r,n,f){if(f=f||90,r.length+7+n.length>f)throw new TypeError("Exceeds length limit");let c=i(r=r.toLowerCase());if("string"==typeof c)throw new Error(c);let a=r+"1";for(let r=0;r<n.length;++r){const t=n[r];if(t>>5)throw new Error("Non 5-bit word");c=o(c)^t,a+=e.charAt(t)}for(let r=0;r<6;++r)c=o(c);c^=t;for(let r=0;r<6;++r)a+=e.charAt(c>>5*(5-r)&31);return a},toWords:c,fromWordsUnsafe:a,fromWords:h}}s("bech32"),s("bech32m")},251(r,t){t.read=function(r,t,e,n,o){var i,f,c=8*o-n-1,a=(1<<c)-1,h=a>>1,s=-7,u=e?o-1:0,l=e?-1:1,d=r[t+u];for(u+=l,i=d&(1<<-s)-1,d>>=-s,s+=c;s>0;i=256*i+r[t+u],u+=l,s-=8);for(f=i&(1<<-s)-1,i>>=-s,s+=n;s>0;f=256*f+r[t+u],u+=l,s-=8);if(0===i)i=1-h;else{if(i===a)return f?NaN:1/0*(d?-1:1);f+=Math.pow(2,n),i-=h}return(d?-1:1)*f*Math.pow(2,i-n)},t.write=function(r,t,e,n,o,i){var f,c,a,h=8*i-o-1,s=(1<<h)-1,u=s>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,w=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,f=s):(f=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-f))<1&&(f--,a*=2),(t+=f+u>=1?l/a:l*Math.pow(2,1-u))*a>=2&&(f++,a/=2),f+u>=s?(c=0,f=s):f+u>=1?(c=(t*a-1)*Math.pow(2,o),f+=u):(c=t*Math.pow(2,u-1)*Math.pow(2,o),f=0));o>=8;r[e+d]=255&c,d+=p,c/=256,o-=8);for(f=f<<o|c,h+=o;h>0;r[e+d]=255&f,d+=p,f/=256,h-=8);r[e+d-p]|=128*w}}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 574.nostr-crypto-utils.min.js.LICENSE.txt */
|
|
2
|
+
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[574],{202(t,e,s){Object.defineProperty(e,"__esModule",{value:!0}),e.SHA512_IV=e.SHA384_IV=e.SHA224_IV=e.SHA256_IV=e.HashMD=void 0,e.setBigUint64=o,e.Chi=function(t,e,s){return t&e^~t&s},e.Maj=function(t,e,s){return t&e^t&s^e&s};const r=s(175);function o(t,e,s,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,s,r);const o=BigInt(32),n=BigInt(4294967295),i=Number(s>>o&n),h=Number(s&n),c=r?4:0,a=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+a,h,r)}class n extends r.Hash{constructor(t,e,s,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=s,this.isLE=o,this.buffer=new Uint8Array(t),this.view=(0,r.createView)(this.buffer)}update(t){(0,r.aexists)(this),t=(0,r.toBytes)(t),(0,r.abytes)(t);const{view:e,buffer:s,blockLen:o}=this,n=t.length;for(let i=0;i<n;){const h=Math.min(o-this.pos,n-i);if(h===o){const e=(0,r.createView)(t);for(;o<=n-i;i+=o)this.process(e,i);continue}s.set(t.subarray(i,i+h),this.pos),this.pos+=h,i+=h,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,r.aexists)(this),(0,r.aoutput)(t,this),this.finished=!0;const{buffer:e,view:s,blockLen:n,isLE:i}=this;let{pos:h}=this;e[h++]=128,(0,r.clean)(this.buffer.subarray(h)),this.padOffset>n-h&&(this.process(s,0),h=0);for(let t=h;t<n;t++)e[t]=0;o(s,n-8,BigInt(8*this.length),i),this.process(s,0);const c=(0,r.createView)(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=a/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<d;t++)c.setUint32(4*t,f[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const s=t.slice(0,e);return this.destroy(),s}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:s,length:r,finished:o,destroyed:n,pos:i}=this;return t.destroyed=n,t.finished=o,t.length=r,t.pos=i,r%e&&t.buffer.set(s),t}clone(){return this._cloneInto()}}e.HashMD=n,e.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),e.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),e.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])},318(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.toBig=e.shrSL=e.shrSH=e.rotrSL=e.rotrSH=e.rotrBL=e.rotrBH=e.rotr32L=e.rotr32H=e.rotlSL=e.rotlSH=e.rotlBL=e.rotlBH=e.add5L=e.add5H=e.add4L=e.add4H=e.add3L=e.add3H=void 0,e.add=y,e.fromBig=o,e.split=n;const s=BigInt(2**32-1),r=BigInt(32);function o(t,e=!1){return e?{h:Number(t&s),l:Number(t>>r&s)}:{h:0|Number(t>>r&s),l:0|Number(t&s)}}function n(t,e=!1){const s=t.length;let r=new Uint32Array(s),n=new Uint32Array(s);for(let i=0;i<s;i++){const{h:s,l:h}=o(t[i],e);[r[i],n[i]]=[s,h]}return[r,n]}const i=(t,e)=>BigInt(t>>>0)<<r|BigInt(e>>>0);e.toBig=i;const h=(t,e,s)=>t>>>s;e.shrSH=h;const c=(t,e,s)=>t<<32-s|e>>>s;e.shrSL=c;const a=(t,e,s)=>t>>>s|e<<32-s;e.rotrSH=a;const d=(t,e,s)=>t<<32-s|e>>>s;e.rotrSL=d;const f=(t,e,s)=>t<<64-s|e>>>s-32;e.rotrBH=f;const l=(t,e,s)=>t>>>s-32|e<<64-s;e.rotrBL=l;const u=(t,e)=>e;e.rotr32H=u;const H=(t,e)=>t;e.rotr32L=H;const b=(t,e,s)=>t<<s|e>>>32-s;e.rotlSH=b;const p=(t,e,s)=>e<<s|t>>>32-s;e.rotlSL=p;const A=(t,e,s)=>e<<s-32|t>>>64-s;e.rotlBH=A;const x=(t,e,s)=>t<<s-32|e>>>64-s;function y(t,e,s,r){const o=(e>>>0)+(r>>>0);return{h:t+s+(o/2**32|0)|0,l:0|o}}e.rotlBL=x;const S=(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0);e.add3L=S;const g=(t,e,s,r)=>e+s+r+(t/2**32|0)|0;e.add3H=g;const w=(t,e,s,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(r>>>0);e.add4L=w;const L=(t,e,s,r,o)=>e+s+r+o+(t/2**32|0)|0;e.add4H=L;const I=(t,e,s,r,o)=>(t>>>0)+(e>>>0)+(s>>>0)+(r>>>0)+(o>>>0);e.add5L=I;const _=(t,e,s,r,o,n)=>e+s+r+o+n+(t/2**32|0)|0;e.add5H=_;const B={fromBig:o,split:n,toBig:i,shrSH:h,shrSL:c,rotrSH:a,rotrSL:d,rotrBH:f,rotrBL:l,rotr32H:u,rotr32L:H,rotlSH:b,rotlSL:p,rotlBH:A,rotlBL:x,add:y,add3L:S,add3H:g,add4L:w,add4H:L,add5H:_,add5L:I};e.default=B},145(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},615(t,e,s){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const r=s(175);class o extends r.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,r.ahash)(t);const s=(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 o=this.blockLen,n=new Uint8Array(o);n.set(s.length>o?t.create().update(s).digest():s);for(let t=0;t<n.length;t++)n[t]^=54;this.iHash.update(n),this.oHash=t.create();for(let t=0;t<n.length;t++)n[t]^=106;this.oHash.update(n),(0,r.clean)(n)}update(t){return(0,r.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,r.aexists)(this),(0,r.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:s,finished:r,destroyed:o,blockLen:n,outputLen:i}=this;return t.finished=r,t.destroyed=o,t.blockLen=n,t.outputLen=i,t.oHash=e._cloneInto(t.oHash),t.iHash=s._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o,e.hmac=(t,e,s)=>new o(t,e).update(s).digest(),e.hmac.create=(t,e)=>new o(t,e)},76(t,e,s){Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_224=e.sha512_256=e.sha384=e.sha512=e.sha224=e.sha256=e.SHA512_256=e.SHA512_224=e.SHA384=e.SHA512=e.SHA224=e.SHA256=void 0;const r=s(202),o=s(318),n=s(175),i=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),h=new Uint32Array(64);class c extends r.HashMD{constructor(t=32){super(64,t,8,!1),this.A=0|r.SHA256_IV[0],this.B=0|r.SHA256_IV[1],this.C=0|r.SHA256_IV[2],this.D=0|r.SHA256_IV[3],this.E=0|r.SHA256_IV[4],this.F=0|r.SHA256_IV[5],this.G=0|r.SHA256_IV[6],this.H=0|r.SHA256_IV[7]}get(){const{A:t,B:e,C:s,D:r,E:o,F:n,G:i,H:h}=this;return[t,e,s,r,o,n,i,h]}set(t,e,s,r,o,n,i,h){this.A=0|t,this.B=0|e,this.C=0|s,this.D=0|r,this.E=0|o,this.F=0|n,this.G=0|i,this.H=0|h}process(t,e){for(let s=0;s<16;s++,e+=4)h[s]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=h[t-15],s=h[t-2],r=(0,n.rotr)(e,7)^(0,n.rotr)(e,18)^e>>>3,o=(0,n.rotr)(s,17)^(0,n.rotr)(s,19)^s>>>10;h[t]=o+h[t-7]+r+h[t-16]|0}let{A:s,B:o,C:c,D:a,E:d,F:f,G:l,H:u}=this;for(let t=0;t<64;t++){const e=u+((0,n.rotr)(d,6)^(0,n.rotr)(d,11)^(0,n.rotr)(d,25))+(0,r.Chi)(d,f,l)+i[t]+h[t]|0,H=((0,n.rotr)(s,2)^(0,n.rotr)(s,13)^(0,n.rotr)(s,22))+(0,r.Maj)(s,o,c)|0;u=l,l=f,f=d,d=a+e|0,a=c,c=o,o=s,s=e+H|0}s=s+this.A|0,o=o+this.B|0,c=c+this.C|0,a=a+this.D|0,d=d+this.E|0,f=f+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(s,o,c,a,d,f,l,u)}roundClean(){(0,n.clean)(h)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,n.clean)(this.buffer)}}e.SHA256=c;class a extends c{constructor(){super(28),this.A=0|r.SHA224_IV[0],this.B=0|r.SHA224_IV[1],this.C=0|r.SHA224_IV[2],this.D=0|r.SHA224_IV[3],this.E=0|r.SHA224_IV[4],this.F=0|r.SHA224_IV[5],this.G=0|r.SHA224_IV[6],this.H=0|r.SHA224_IV[7]}}e.SHA224=a;const d=(()=>o.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),f=(()=>d[0])(),l=(()=>d[1])(),u=new Uint32Array(80),H=new Uint32Array(80);class b extends r.HashMD{constructor(t=64){super(128,t,16,!1),this.Ah=0|r.SHA512_IV[0],this.Al=0|r.SHA512_IV[1],this.Bh=0|r.SHA512_IV[2],this.Bl=0|r.SHA512_IV[3],this.Ch=0|r.SHA512_IV[4],this.Cl=0|r.SHA512_IV[5],this.Dh=0|r.SHA512_IV[6],this.Dl=0|r.SHA512_IV[7],this.Eh=0|r.SHA512_IV[8],this.El=0|r.SHA512_IV[9],this.Fh=0|r.SHA512_IV[10],this.Fl=0|r.SHA512_IV[11],this.Gh=0|r.SHA512_IV[12],this.Gl=0|r.SHA512_IV[13],this.Hh=0|r.SHA512_IV[14],this.Hl=0|r.SHA512_IV[15]}get(){const{Ah:t,Al:e,Bh:s,Bl:r,Ch:o,Cl:n,Dh:i,Dl:h,Eh:c,El:a,Fh:d,Fl:f,Gh:l,Gl:u,Hh:H,Hl:b}=this;return[t,e,s,r,o,n,i,h,c,a,d,f,l,u,H,b]}set(t,e,s,r,o,n,i,h,c,a,d,f,l,u,H,b){this.Ah=0|t,this.Al=0|e,this.Bh=0|s,this.Bl=0|r,this.Ch=0|o,this.Cl=0|n,this.Dh=0|i,this.Dl=0|h,this.Eh=0|c,this.El=0|a,this.Fh=0|d,this.Fl=0|f,this.Gh=0|l,this.Gl=0|u,this.Hh=0|H,this.Hl=0|b}process(t,e){for(let s=0;s<16;s++,e+=4)u[s]=t.getUint32(e),H[s]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|u[t-15],s=0|H[t-15],r=o.rotrSH(e,s,1)^o.rotrSH(e,s,8)^o.shrSH(e,s,7),n=o.rotrSL(e,s,1)^o.rotrSL(e,s,8)^o.shrSL(e,s,7),i=0|u[t-2],h=0|H[t-2],c=o.rotrSH(i,h,19)^o.rotrBH(i,h,61)^o.shrSH(i,h,6),a=o.rotrSL(i,h,19)^o.rotrBL(i,h,61)^o.shrSL(i,h,6),d=o.add4L(n,a,H[t-7],H[t-16]),f=o.add4H(d,r,c,u[t-7],u[t-16]);u[t]=0|f,H[t]=0|d}let{Ah:s,Al:r,Bh:n,Bl:i,Ch:h,Cl:c,Dh:a,Dl:d,Eh:b,El:p,Fh:A,Fl:x,Gh:y,Gl:S,Hh:g,Hl:w}=this;for(let t=0;t<80;t++){const e=o.rotrSH(b,p,14)^o.rotrSH(b,p,18)^o.rotrBH(b,p,41),L=o.rotrSL(b,p,14)^o.rotrSL(b,p,18)^o.rotrBL(b,p,41),I=b&A^~b&y,_=p&x^~p&S,B=o.add5L(w,L,_,l[t],H[t]),V=o.add5H(B,g,e,I,f[t],u[t]),E=0|B,U=o.rotrSH(s,r,28)^o.rotrBH(s,r,34)^o.rotrBH(s,r,39),C=o.rotrSL(s,r,28)^o.rotrBL(s,r,34)^o.rotrBL(s,r,39),m=s&n^s&h^n&h,D=r&i^r&c^i&c;g=0|y,w=0|S,y=0|A,S=0|x,A=0|b,x=0|p,({h:b,l:p}=o.add(0|a,0|d,0|V,0|E)),a=0|h,d=0|c,h=0|n,c=0|i,n=0|s,i=0|r;const k=o.add3L(E,C,D);s=o.add3H(k,V,U,m),r=0|k}({h:s,l:r}=o.add(0|this.Ah,0|this.Al,0|s,0|r)),({h:n,l:i}=o.add(0|this.Bh,0|this.Bl,0|n,0|i)),({h,l:c}=o.add(0|this.Ch,0|this.Cl,0|h,0|c)),({h:a,l:d}=o.add(0|this.Dh,0|this.Dl,0|a,0|d)),({h:b,l:p}=o.add(0|this.Eh,0|this.El,0|b,0|p)),({h:A,l:x}=o.add(0|this.Fh,0|this.Fl,0|A,0|x)),({h:y,l:S}=o.add(0|this.Gh,0|this.Gl,0|y,0|S)),({h:g,l:w}=o.add(0|this.Hh,0|this.Hl,0|g,0|w)),this.set(s,r,n,i,h,c,a,d,b,p,A,x,y,S,g,w)}roundClean(){(0,n.clean)(u,H)}destroy(){(0,n.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=b;class p extends b{constructor(){super(48),this.Ah=0|r.SHA384_IV[0],this.Al=0|r.SHA384_IV[1],this.Bh=0|r.SHA384_IV[2],this.Bl=0|r.SHA384_IV[3],this.Ch=0|r.SHA384_IV[4],this.Cl=0|r.SHA384_IV[5],this.Dh=0|r.SHA384_IV[6],this.Dl=0|r.SHA384_IV[7],this.Eh=0|r.SHA384_IV[8],this.El=0|r.SHA384_IV[9],this.Fh=0|r.SHA384_IV[10],this.Fl=0|r.SHA384_IV[11],this.Gh=0|r.SHA384_IV[12],this.Gl=0|r.SHA384_IV[13],this.Hh=0|r.SHA384_IV[14],this.Hl=0|r.SHA384_IV[15]}}e.SHA384=p;const A=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),x=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class y extends b{constructor(){super(28),this.Ah=0|A[0],this.Al=0|A[1],this.Bh=0|A[2],this.Bl=0|A[3],this.Ch=0|A[4],this.Cl=0|A[5],this.Dh=0|A[6],this.Dl=0|A[7],this.Eh=0|A[8],this.El=0|A[9],this.Fh=0|A[10],this.Fl=0|A[11],this.Gh=0|A[12],this.Gl=0|A[13],this.Hh=0|A[14],this.Hl=0|A[15]}}e.SHA512_224=y;class S extends b{constructor(){super(32),this.Ah=0|x[0],this.Al=0|x[1],this.Bh=0|x[2],this.Bl=0|x[3],this.Ch=0|x[4],this.Cl=0|x[5],this.Dh=0|x[6],this.Dl=0|x[7],this.Eh=0|x[8],this.El=0|x[9],this.Fh=0|x[10],this.Fl=0|x[11],this.Gh=0|x[12],this.Gl=0|x[13],this.Hh=0|x[14],this.Hl=0|x[15]}}e.SHA512_256=S,e.sha256=(0,n.createHasher)(()=>new c),e.sha224=(0,n.createHasher)(()=>new a),e.sha512=(0,n.createHasher)(()=>new b),e.sha384=(0,n.createHasher)(()=>new p),e.sha512_256=(0,n.createHasher)(()=>new S),e.sha512_224=(0,n.createHasher)(()=>new y)},175(t,e,s){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.Hash=e.nextTick=e.swap32IfBE=e.byteSwapIfBE=e.swap8IfBE=e.isLE=void 0,e.isBytes=o,e.anumber=n,e.abytes=i,e.ahash=function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");n(t.outputLen),n(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){i(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)},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.clean=function(...t){for(let e=0;e<t.length;e++)t[e].fill(0)},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=h,e.byteSwap32=c,e.bytesToHex=function(t){if(i(t),a)return t.toHex();let e="";for(let s=0;s<t.length;s++)e+=d[t[s]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(a)return Uint8Array.fromHex(t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(s);for(let e=0,o=0;e<s;e++,o+=2){const s=f(t.charCodeAt(o)),n=f(t.charCodeAt(o+1));if(void 0===s||void 0===n){const e=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+o)}r[e]=16*s+n}return r},e.asyncLoop=async function(t,s,r){let o=Date.now();for(let n=0;n<t;n++){r(n);const t=Date.now()-o;t>=0&&t<s||(await(0,e.nextTick)(),o+=t)}},e.utf8ToBytes=l,e.bytesToUtf8=function(t){return(new TextDecoder).decode(t)},e.toBytes=u,e.kdfInputToBytes=function(t){return"string"==typeof t&&(t=l(t)),i(t),t},e.concatBytes=function(...t){let e=0;for(let s=0;s<t.length;s++){const r=t[s];i(r),e+=r.length}const s=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const o=t[e];s.set(o,r),r+=o.length}return s},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.createHasher=H,e.createOptHasher=b,e.createXOFer=p,e.randomBytes=function(t=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(t));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return Uint8Array.from(r.crypto.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")};const r=s(145);function o(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function i(t,...e){if(!o(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function h(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function c(t){for(let e=0;e<t.length;e++)t[e]=h(t[e]);return t}e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.swap8IfBE=e.isLE?t=>t:t=>h(t),e.byteSwapIfBE=e.swap8IfBE,e.swap32IfBE=e.isLE?t=>t:c;const a=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function f(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function l(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function u(t){return"string"==typeof t&&(t=l(t)),i(t),t}function H(t){const e=e=>t().update(u(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function b(t){const e=(e,s)=>t(s).update(u(e)).digest(),s=t({});return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=e=>t(e),e}function p(t){const e=(e,s)=>t(s).update(u(e)).digest(),s=t({});return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=e=>t(e),e}e.nextTick=async()=>{},e.Hash=class{},e.wrapConstructor=H,e.wrapConstructorWithOpts=b,e.wrapXOFConstructorWithOpts=p}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 575.nostr-crypto-utils.min.js.LICENSE.txt */
|
|
2
|
+
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[575],{562(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.getHash=function(e){return{hash:e}},t.createCurve=function(e,t){const r=t=>(0,n.weierstrass)({...e,hash:t});return{...r(t),create:r}};const n=r(705)},422(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.wNAF=void 0,t.negateCt=a,t.normalizeZ=function(e,t){const r=(0,o.FpInvertBatch)(e.Fp,t.map(e=>e.Z));return t.map((t,n)=>e.fromAffine(t.toAffine(r[n])))},t.mulEndoUnsafe=function(e,t,r,n){let o=t,a=e.ZERO,c=e.ZERO;for(;r>i||n>i;)r&s&&(a=a.add(o)),n&s&&(c=c.add(o)),o=o.double(),r>>=s,n>>=s;return{p1:a,p2:c}},t.pippenger=function(e,t,r,o){d(r,e),l(o,t);const i=r.length,s=o.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,n.bitLen)(BigInt(i));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const u=(0,n.bitMask)(f),h=new Array(Number(u)+1).fill(a);let p=a;for(let e=Math.floor((t.BITS-1)/f)*f;e>=0;e-=f){h.fill(a);for(let t=0;t<s;t++){const n=o[t],i=Number(n>>BigInt(e)&u);h[i]=h[i].add(r[t])}let t=a;for(let e=h.length-1,r=a;e>0;e--)r=r.add(h[e]),t=t.add(r);if(p=p.add(t),0!==e)for(let e=0;e<f;e++)p=p.double()}return p},t.precomputeMSMUnsafe=function(e,t,r,o){c(o,t.BITS),d(r,e);const i=e.ZERO,s=2**o-1,a=Math.ceil(t.BITS/o),f=(0,n.bitMask)(o),u=r.map(e=>{const t=[];for(let r=0,n=e;r<s;r++)t.push(n),n=n.add(e);return t});return e=>{if(l(e,t),e.length>r.length)throw new Error("array of scalars must be smaller than array of points");let n=i;for(let t=0;t<a;t++){if(n!==i)for(let e=0;e<o;e++)n=n.double();const r=BigInt(a*o-(t+1)*o);for(let t=0;t<e.length;t++){const o=e[t],i=Number(o>>r&f);i&&(n=n.add(u[t][i-1]))}}return n}},t.validateBasic=function(e){return(0,o.validateField)(e.Fp),(0,n.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,o.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})},t._createCurveFields=function(e,t,r={},n){if(void 0===n&&(n="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const r=t[e];if(!("bigint"==typeof r&&r>i))throw new Error(`CURVE.${e} must be positive bigint`)}const o=b(t.p,r.Fp,n),s=b(t.n,r.Fn,n),a=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of a)if(!o.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:s}};const n=r(627),o=r(967),i=BigInt(0),s=BigInt(1);function a(e,t){const r=t.negate();return e?r:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function f(e,t){c(e,t);const r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:(0,n.bitMask)(e),maxNumber:r,shiftBy:BigInt(e)}}function u(e,t,r){const{windowSize:n,mask:o,maxNumber:i,shiftBy:a}=r;let c=Number(e&o),f=e>>a;c>n&&(c-=i,f+=s);const u=t*n;return{nextN:f,offset:u+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:u}}function d(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function l(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const h=new WeakMap,p=new WeakMap;function w(e){return p.get(e)||1}function g(e){if(e!==i)throw new Error("invalid wNAF")}function b(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,o.validateField)(t),t}return(0,o.Field)(e,{isLE:r})}t.wNAF=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let n=e;for(;t>i;)t&s&&(r=r.add(n)),n=n.double(),t>>=s;return r}precomputeWindow(e,t){const{windows:r,windowSize:n}=f(t,this.bits),o=[];let i=e,s=i;for(let e=0;e<r;e++){s=i,o.push(s);for(let e=1;e<n;e++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(e,t,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,o=this.BASE;const i=f(e,this.bits);for(let e=0;e<i.windows;e++){const{nextN:s,offset:c,isZero:f,isNeg:d,isNegF:l,offsetF:h}=u(r,e,i);r=s,f?o=o.add(a(l,t[h])):n=n.add(a(d,t[c]))}return g(r),{p:n,f:o}}wNAFUnsafe(e,t,r,n=this.ZERO){const o=f(e,this.bits);for(let e=0;e<o.windows&&r!==i;e++){const{nextN:i,offset:s,isZero:a,isNeg:c}=u(r,e,o);if(r=i,!a){const e=t[s];n=n.add(c?e.negate():e)}}return g(r),n}getPrecomputes(e,t,r){let n=h.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&("function"==typeof r&&(n=r(n)),h.set(t,n))),n}cached(e,t,r){const n=w(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)}unsafe(e,t,r,n){const o=w(e);return 1===o?this._unsafeLadder(e,t,n):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),t,n)}createCache(e,t){c(t,this.bits),p.set(e,t),h.delete(e)}hasCache(e){return 1!==w(e)}}},761(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t._DST_scalar=void 0,t.expand_message_xmd=u,t.expand_message_xof=d,t.hash_to_field=l,t.isogenyMap=function(e,t){const r=t.map(e=>Array.from(e).reverse());return(t,n)=>{const[i,s,a,c]=r.map(r=>r.reduce((r,n)=>e.add(e.mul(r,t),n))),[f,u]=(0,o.FpInvertBatch)(e,[s,c],!0);return t=e.mul(i,f),n=e.mul(n,e.mul(a,u)),{x:t,y:n}}},t.createHasher=function(e,r,n){if("function"!=typeof r)throw new Error("mapToCurve() must be defined");function o(t){return e.fromAffine(r(t))}function i(t){const r=t.clearCofactor();return r.equals(e.ZERO)?e.ZERO:(r.assertValidity(),r)}return{defaults:n,hashToCurve(e,t){const r=l(e,2,Object.assign({},n,t)),s=o(r[0]),a=o(r[1]);return i(s.add(a))},encodeToCurve(e,t){const r=n.encodeDST?{DST:n.encodeDST}:{};return i(o(l(e,1,Object.assign({},n,r,t))[0]))},mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return i(o(e))},hashToScalar(r,o){const i=e.Fn.ORDER;return l(r,1,Object.assign({},n,{p:i,m:1,DST:t._DST_scalar},o))[0][0]}}};const n=r(627),o=r(967),i=n.bytesToNumberBE;function s(e,t){if(c(e),c(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 a(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 c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function f(e){if(!(0,n.isBytes)(e)&&"string"!=typeof e)throw new Error("DST must be Uint8Array or string");return"string"==typeof e?(0,n.utf8ToBytes)(e):e}function u(e,t,r,o){(0,n.abytes)(e),c(r),(t=f(t)).length>255&&(t=o((0,n.concatBytes)((0,n.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:u}=o,d=Math.ceil(r/i);if(r>65535||d>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,n.concatBytes)(t,s(t.length,1)),h=s(0,u),p=s(r,2),w=new Array(d),g=o((0,n.concatBytes)(h,e,p,s(0,1),l));w[0]=o((0,n.concatBytes)(g,s(1,1),l));for(let e=1;e<=d;e++){const t=[a(g,w[e-1]),s(e+1,1),l];w[e]=o((0,n.concatBytes)(...t))}return(0,n.concatBytes)(...w).slice(0,r)}function d(e,t,r,o,i){if((0,n.abytes)(e),c(r),(t=f(t)).length>255){const e=Math.ceil(2*o/8);t=i.create({dkLen:e}).update((0,n.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 l(e,t,r){(0,n._validateObject)(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:s,k:a,m:f,hash:l,expand:h,DST:p}=r;if(!(0,n.isHash)(r.hash))throw new Error("expected valid hash");(0,n.abytes)(e),c(t);const w=s.toString(2).length,g=Math.ceil((w+a)/8),b=t*f*g;let m;if("xmd"===h)m=u(e,p,b,l);else if("xof"===h)m=d(e,p,b,a,l);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');m=e}const y=new Array(t);for(let e=0;e<t;e++){const t=new Array(f);for(let r=0;r<f;r++){const n=g*(r+e*f),a=m.subarray(n,n+g);t[r]=(0,o.mod)(i(a),s)}y[e]=t}return y}t._DST_scalar=(0,n.utf8ToBytes)("HashToScalar-")}}]);
|
|
@@ -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(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.DER=t.DERErr=void 0,t._splitEndoScalar=u,t._normFnElement=g,t.weierstrassN=b,t.SWUFpSqrtRatio=v,t.mapToCurveSimpleSWU=function(e,t){(0,a.validateField)(e);const{A:r,B:n,Z:o}=t;if(!e.isValid(r)||!e.isValid(n)||!e.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");const s=v(e,o);if(!e.isOdd)throw new Error("Field does not have .isOdd()");return t=>{let i,c,u,l,d,f,m,y;i=e.sqr(t),i=e.mul(i,o),c=e.sqr(i),c=e.add(c,i),u=e.add(c,e.ONE),u=e.mul(u,n),l=e.cmov(o,e.neg(c),!e.eql(c,e.ZERO)),l=e.mul(l,r),c=e.sqr(u),f=e.sqr(l),d=e.mul(f,r),c=e.add(c,d),c=e.mul(c,u),f=e.mul(f,l),d=e.mul(f,n),c=e.add(c,d),m=e.mul(i,u);const{isValid:h,value:p}=s(c,f);y=e.mul(i,t),y=e.mul(y,p),m=e.cmov(m,u,h),y=e.cmov(y,p,h);const w=e.isOdd(t)===e.isOdd(y);y=e.cmov(e.neg(y),y,w);const g=(0,a.FpInvertBatch)(e,[l],!0)[0];return m=e.mul(m,g),{x:m,y}}},t.ecdh=R,t.ecdsa=O,t.weierstrassPoints=function(e){const{CURVE:t,curveOpts:r}=S(e);return function(e,t){const{Fp:r,Fn:n}=t;const o=x(r,e.a,e.b);return Object.assign({},{CURVE:e,Point:t,ProjectivePoint:t,normPrivateKeyToScalar:e=>g(n,e),weierstrassEquation:o,isWithinCurveOrder:function(e){return(0,s.inRange)(e,y,n.ORDER)}})}(e,b(t,r))},t._legacyHelperEquat=x,t.weierstrass=function(e){const{CURVE:t,curveOpts:r,hash:n,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:r}=S(e),n={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,hash:e.hash,ecdsaOpts:n}}(e);return function(e,t){const r=t.Point;return Object.assign({},t,{ProjectivePoint:r,CURVE:Object.assign({},e,(0,a.nLength)(r.Fn.ORDER,r.Fn.BITS))})}(e,O(b(t,r),n,o))};const n=r(9615),o=r(9175),s=r(8627),i=r(2422),a=r(4967),c=(e,t)=>(e+(e>=0?t:-t)/h)/t;function u(e,t,r){const[[n,o],[i,a]]=t,u=c(a*e,r),l=c(-o*e,r);let d=e-u*n-l*i,f=-u*o-l*a;const h=d<m,p=f<m;h&&(d=-d),p&&(f=-f);const w=(0,s.bitMask)(Math.ceil((0,s.bitLen)(r)/2))+y;if(d<m||d>=w||f<m||f>=w)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:d,k2neg:p,k2:f}}function l(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function d(e,t){const r={};for(let n of Object.keys(t))r[n]=void 0===e[n]?t[n]:e[n];return(0,s._abool2)(r.lowS,"lowS"),(0,s._abool2)(r.prehash,"prehash"),void 0!==r.format&&l(r.format),r}class f extends Error{constructor(e=""){super(e)}}t.DERErr=f,t.DER={Err:f,_tlv:{encode:(e,r)=>{const{Err:n}=t.DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const o=r.length/2,i=(0,s.numberToHexUnpadded)(o);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?(0,s.numberToHexUnpadded)(i.length/2|128):"";return(0,s.numberToHexUnpadded)(e)+a+i+r},decode(e,r){const{Err:n}=t.DER;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[o++]!==e)throw new n("tlv.decode: wrong tlv");const s=r[o++];let i=0;if(128&s){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const t=r.subarray(o,o+e);if(t.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===t[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of t)i=i<<8|e;if(o+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=r.subarray(o,o+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:r.subarray(o+i)}}},_int:{encode(e){const{Err:r}=t.DER;if(e<m)throw new r("integer: negative integers are not allowed");let n=(0,s.numberToHexUnpadded)(e);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(e){const{Err:r}=t.DER;if(128&e[0])throw new r("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new r("invalid signature integer: unnecessary leading zero");return(0,s.bytesToNumberBE)(e)}},toSig(e){const{Err:r,_int:n,_tlv:o}=t.DER,i=(0,s.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,i);if(c.length)throw new r("invalid signature: left bytes after parsing");const{v:u,l}=o.decode(2,a),{v:d,l:f}=o.decode(2,l);if(f.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(u),s:n.decode(d)}},hexFromSig(e){const{_tlv:r,_int:n}=t.DER,o=r.encode(2,n.encode(e.r))+r.encode(2,n.encode(e.s));return r.encode(48,o)}};const m=BigInt(0),y=BigInt(1),h=BigInt(2),p=BigInt(3),w=BigInt(4);function g(e,t){const{BYTES:r}=e;let n;if("bigint"==typeof t)n=t;else{let o=(0,s.ensureBytes)("private key",t);try{n=e.fromBytes(o)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof t}`)}}if(!e.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function b(e,t={}){const r=(0,i._createCurveFields)("weierstrass",e,t),{Fp:n,Fn:o}=r;let a=r.CURVE;const{h:c,n:l}=a;(0,s._validateObject)(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:d}=t;if(d&&(!n.is0(a.a)||"bigint"!=typeof d.beta||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const f=B(n,o);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const b=t.toBytes||function(e,t,r){const{x:o,y:i}=t.toAffine(),a=n.toBytes(o);if((0,s._abool2)(r,"isCompressed"),r){h();const e=!n.isOdd(i);return(0,s.concatBytes)(E(e),a)}return(0,s.concatBytes)(Uint8Array.of(4),a,n.toBytes(i))},v=t.fromBytes||function(e){(0,s._abytes2)(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:r}=f,o=e.length,i=e[0],a=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===r&&4===i){const e=n.BYTES,t=n.fromBytes(a.subarray(0,e)),r=n.fromBytes(a.subarray(e,2*e));if(!O(t,r))throw new Error("bad point: is not on curve");return{x:t,y:r}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${r}`)}{const e=n.fromBytes(a);if(!n.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=R(e);let r;try{r=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}return h(),!(1&~i)!==n.isOdd(r)&&(r=n.neg(r)),{x:e,y:r}}};function R(e){const t=n.sqr(e),r=n.mul(t,e);return n.add(n.add(r,n.mul(e,a.a)),a.b)}function O(e,t){const r=n.sqr(t),o=R(e);return n.eql(r,o)}if(!O(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const S=n.mul(n.pow(a.a,p),w),x=n.mul(n.sqr(a.b),BigInt(27));if(n.is0(n.add(S,x)))throw new Error("bad curve params: a or b");function F(e,t,r=!1){if(!n.isValid(t)||r&&n.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function U(e){if(!(e instanceof Z))throw new Error("ProjectivePoint expected")}function P(e){if(!d||!d.basises)throw new Error("no endo");return u(e,d.basises,o.ORDER)}const T=(0,s.memoized)((e,t)=>{const{X:r,Y:o,Z:s}=e;if(n.eql(s,n.ONE))return{x:r,y:o};const i=e.is0();null==t&&(t=i?n.ONE:n.inv(s));const a=n.mul(r,t),c=n.mul(o,t),u=n.mul(s,t);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),V=(0,s.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:o}=e.toAffine();if(!n.isValid(r)||!n.isValid(o))throw new Error("bad point: x or y not field elements");if(!O(r,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function K(e,t,r,o,s){return r=new Z(n.mul(r.X,e),r.Y,r.Z),t=(0,i.negateCt)(o,t),r=(0,i.negateCt)(s,r),t.add(r)}class Z{constructor(e,t,r){this.X=F("x",e),this.Y=F("y",t,!0),this.Z=F("z",r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof Z)throw new Error("projective point not allowed");return n.is0(t)&&n.is0(r)?Z.ZERO:new Z(t,r,n.ONE)}static fromBytes(e){const t=Z.fromAffine(v((0,s._abytes2)(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return Z.fromBytes((0,s.ensureBytes)("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return C.createCache(this,e),t||this.multiply(p),this}assertValidity(){V(this)}hasEvenY(){const{y:e}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(e)}equals(e){U(e);const{X:t,Y:r,Z:o}=this,{X:s,Y:i,Z:a}=e,c=n.eql(n.mul(t,a),n.mul(s,o)),u=n.eql(n.mul(r,a),n.mul(i,o));return c&&u}negate(){return new Z(this.X,n.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,r=n.mul(t,p),{X:o,Y:s,Z:i}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(o,o),f=n.mul(s,s),m=n.mul(i,i),y=n.mul(o,s);return y=n.add(y,y),l=n.mul(o,i),l=n.add(l,l),c=n.mul(e,l),u=n.mul(r,m),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(y,c),l=n.mul(r,l),m=n.mul(e,m),y=n.sub(d,m),y=n.mul(e,y),y=n.add(y,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,m),d=n.mul(d,y),u=n.add(u,d),m=n.mul(s,i),m=n.add(m,m),d=n.mul(m,y),c=n.sub(c,d),l=n.mul(m,f),l=n.add(l,l),l=n.add(l,l),new Z(c,u,l)}add(e){U(e);const{X:t,Y:r,Z:o}=this,{X:s,Y:i,Z:c}=e;let u=n.ZERO,l=n.ZERO,d=n.ZERO;const f=a.a,m=n.mul(a.b,p);let y=n.mul(t,s),h=n.mul(r,i),w=n.mul(o,c),g=n.add(t,r),b=n.add(s,i);g=n.mul(g,b),b=n.add(y,h),g=n.sub(g,b),b=n.add(t,o);let E=n.add(s,c);return b=n.mul(b,E),E=n.add(y,w),b=n.sub(b,E),E=n.add(r,o),u=n.add(i,c),E=n.mul(E,u),u=n.add(h,w),E=n.sub(E,u),d=n.mul(f,b),u=n.mul(m,w),d=n.add(u,d),u=n.sub(h,d),d=n.add(h,d),l=n.mul(u,d),h=n.add(y,y),h=n.add(h,y),w=n.mul(f,w),b=n.mul(m,b),h=n.add(h,w),w=n.sub(y,w),w=n.mul(f,w),b=n.add(b,w),y=n.mul(h,b),l=n.add(l,y),y=n.mul(E,b),u=n.mul(g,u),u=n.sub(u,y),y=n.mul(g,h),d=n.mul(E,d),d=n.add(d,y),new Z(u,l,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(Z.ZERO)}multiply(e){const{endo:r}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let n,s;const a=e=>C.cached(this,e,e=>(0,i.normalizeZ)(Z,e));if(r){const{k1neg:t,k1:o,k2neg:i,k2:c}=P(e),{p:u,f:l}=a(o),{p:d,f}=a(c);s=l.add(f),n=K(r.beta,u,d,t,i)}else{const{p:t,f:r}=a(e);n=t,s=r}return(0,i.normalizeZ)(Z,[n,s])[0]}multiplyUnsafe(e){const{endo:r}=t,n=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===m||n.is0())return Z.ZERO;if(e===y)return n;if(C.hasCache(this))return this.multiply(e);if(r){const{k1neg:t,k1:o,k2neg:s,k2:a}=P(e),{p1:c,p2:u}=(0,i.mulEndoUnsafe)(Z,n,o,a);return K(r.beta,c,u,t,s)}return C.unsafe(n,e)}multiplyAndAddUnsafe(e,t,r){const n=this.multiplyUnsafe(t).add(e.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(e){return T(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return c===y||(e?e(Z,this):C.unsafe(this,l).is0())}clearCofactor(){const{clearCofactor:e}=t;return c===y?this:e?e(Z,this):this.multiplyUnsafe(c)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}toBytes(e=!0){return(0,s._abool2)(e,"isCompressed"),this.assertValidity(),b(Z,this,e)}toHex(e=!0){return(0,s.bytesToHex)(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return(0,i.normalizeZ)(Z,e)}static msm(e,t){return(0,i.pippenger)(Z,o,e,t)}static fromPrivateKey(e){return Z.BASE.multiply(g(o,e))}}Z.BASE=new Z(a.Gx,a.Gy,n.ONE),Z.ZERO=new Z(n.ZERO,n.ONE,n.ZERO),Z.Fp=n,Z.Fn=o;const k=o.BITS,C=new i.wNAF(Z,t.endo?Math.ceil(k/2):k);return Z.BASE.precompute(8),Z}function E(e){return Uint8Array.of(e?2:3)}function v(e,t){const r=e.ORDER;let n=m;for(let e=r-y;e%h===m;e/=h)n+=y;const o=n,s=h<<o-y-y,i=s*h,a=(r-y)/i,c=(a-y)/h,u=i-y,l=s,d=e.pow(t,a),f=e.pow(t,(a+y)/h);let g=(t,r)=>{let n=d,s=e.pow(r,u),i=e.sqr(s);i=e.mul(i,r);let a=e.mul(t,i);a=e.pow(a,c),a=e.mul(a,s),s=e.mul(a,r),i=e.mul(a,t);let m=e.mul(i,s);a=e.pow(m,l);let p=e.eql(a,e.ONE);s=e.mul(i,f),a=e.mul(m,n),i=e.cmov(s,i,p),m=e.cmov(a,m,p);for(let t=o;t>y;t--){let r=t-h;r=h<<r-y;let o=e.pow(m,r);const a=e.eql(o,e.ONE);s=e.mul(i,n),n=e.mul(n,n),o=e.mul(m,n),i=e.cmov(s,i,a),m=e.cmov(o,m,a)}return{isValid:p,value:i}};if(e.ORDER%w===p){const r=(e.ORDER-p)/w,n=e.sqrt(e.neg(t));g=(t,o)=>{let s=e.sqr(o);const i=e.mul(t,o);s=e.mul(s,i);let a=e.pow(s,r);a=e.mul(a,i);const c=e.mul(a,n),u=e.mul(e.sqr(a),o),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return g}function B(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function R(e,t={}){const{Fn:r}=e,n=t.randomBytes||s.randomBytes,o=Object.assign(B(e.Fp,r),{seed:(0,a.getMinHashLength)(r.ORDER)});function i(e){try{return!!g(r,e)}catch(e){return!1}}function c(e=n(o.seed)){return(0,a.mapHashToField)((0,s._abytes2)(e,o.seed,"seed"),r.ORDER)}function u(t,n=!0){return e.BASE.multiply(g(r,t)).toBytes(n)}function l(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:n,publicKey:i,publicKeyUncompressed:a}=o;if(r.allowedLengths||n===i)return;const c=(0,s.ensureBytes)("key",t).length;return c===i||c===a}const d={isValidSecretKey:i,isValidPublicKey:function(t,r){const{publicKey:n,publicKeyUncompressed:s}=o;try{const o=t.length;return!(!0===r&&o!==n||!1===r&&o!==s||!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:e=>g(r,e),precompute:(t=8,r=e.BASE)=>r.precompute(t,!1)};return Object.freeze({getPublicKey:u,getSharedSecret:function(t,n,o=!0){if(!0===l(t))throw new Error("first arg must be private key");if(!1===l(n))throw new Error("second arg must be public key");const s=g(r,t);return e.fromHex(n).multiply(s).toBytes(o)},keygen:function(e){const t=c(e);return{secretKey:t,publicKey:u(t)}},Point:e,utils:d,lengths:o})}function O(e,r,i={}){(0,o.ahash)(r),(0,s._validateObject)(i,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const a=i.randomBytes||s.randomBytes,c=i.hmac||((e,...t)=>(0,n.hmac)(r,e,(0,s.concatBytes)(...t))),{Fp:u,Fn:f}=e,{ORDER:p,BITS:w}=f,{keygen:b,getPublicKey:v,getSharedSecret:B,utils:O,lengths:S}=R(e,i),x={prehash:!1,lowS:"boolean"==typeof i.lowS&&i.lowS,format:void 0,extraEntropy:!1},F="compact";function U(e){return e>p>>y}function P(e,t){if(!f.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class T{constructor(e,t,r){this.r=P("r",e),this.s=P("s",t),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(e,r=F){let n;if(function(e,t){l(t);const r=S.signature,n="compact"===t?r:"recovered"===t?r+1:void 0;(0,s._abytes2)(e,n,`${t} signature`)}(e,r),"der"===r){const{r,s:n}=t.DER.toSig((0,s._abytes2)(e));return new T(r,n)}"recovered"===r&&(n=e[0],r="compact",e=e.subarray(1));const o=f.BYTES,i=e.subarray(0,o),a=e.subarray(o,2*o);return new T(f.fromBytes(i),f.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes((0,s.hexToBytes)(e),t)}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(t){const r=u.ORDER,{r:n,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(p*h<r&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?n+p:n;if(!u.isValid(a))throw new Error("recovery id 2 or 3 invalid");const c=u.toBytes(a),l=e.fromBytes((0,s.concatBytes)(E(!(1&i)),c)),d=f.inv(a),m=K((0,s.ensureBytes)("msgHash",t)),y=f.create(-m*d),w=f.create(o*d),g=e.BASE.multiplyUnsafe(y).add(l.multiplyUnsafe(w));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return U(this.s)}toBytes(e=F){if(l(e),"der"===e)return(0,s.hexToBytes)(t.DER.hexFromSig(this));const r=f.toBytes(this.r),n=f.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,s.concatBytes)(Uint8Array.of(this.recovery),r,n)}return(0,s.concatBytes)(r,n)}toHex(e){return(0,s.bytesToHex)(this.toBytes(e))}assertValidity(){}static fromCompact(e){return T.fromBytes((0,s.ensureBytes)("sig",e),"compact")}static fromDER(e){return T.fromBytes((0,s.ensureBytes)("sig",e),"der")}normalizeS(){return this.hasHighS()?new T(this.r,f.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,s.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,s.bytesToHex)(this.toBytes("compact"))}}const V=i.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,s.bytesToNumberBE)(e),r=8*e.length-w;return r>0?t>>BigInt(r):t},K=i.bits2int_modN||function(e){return f.create(V(e))},Z=(0,s.bitMask)(w);function k(e){return(0,s.aInRange)("num < 2^"+w,e,m,Z),f.toBytes(e)}function C(e,t){return(0,s._abytes2)(e,void 0,"message"),t?(0,s._abytes2)(r(e),void 0,"prehashed message"):e}return Object.freeze({keygen:b,getPublicKey:v,getSharedSecret:B,utils:O,lengths:S,Point:e,sign:function(t,n,o={}){t=(0,s.ensureBytes)("message",t);const{seed:i,k2sig:u}=function(t,r,n){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:i,extraEntropy:c}=d(n,x);t=C(t,i);const u=K(t),l=g(f,r),h=[k(l),k(u)];if(null!=c&&!1!==c){const e=!0===c?a(S.secretKey):c;h.push((0,s.ensureBytes)("extraEntropy",e))}const p=(0,s.concatBytes)(...h),w=u;return{seed:p,k2sig:function(t){const r=V(t);if(!f.isValidNot0(r))return;const n=f.inv(r),s=e.BASE.multiply(r).toAffine(),i=f.create(s.x);if(i===m)return;const a=f.create(n*f.create(w+i*l));if(a===m)return;let c=(s.x===i?0:2)|Number(s.y&y),u=a;return o&&U(a)&&(u=f.neg(a),c^=1),new T(i,u,c)}}}(t,n,o);return(0,s.createHmacDrbg)(r.outputLen,f.BYTES,c)(i,u)},verify:function(r,n,o,i={}){const{lowS:a,prehash:c,format:u}=d(i,x);if(o=(0,s.ensureBytes)("publicKey",o),n=C((0,s.ensureBytes)("message",n),c),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let r;const n="string"==typeof e||(0,s.isBytes)(e),o=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!o)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(o)r=new T(e.r,e.s);else if(n){try{r=T.fromBytes((0,s.ensureBytes)("sig",e),"der")}catch(e){if(!(e instanceof t.DER.Err))throw e}if(!r)try{r=T.fromBytes((0,s.ensureBytes)("sig",e),"compact")}catch(e){return!1}}return r||!1}(r):T.fromBytes((0,s.ensureBytes)("sig",r),u);if(!1===l)return!1;try{const t=e.fromBytes(o);if(a&&l.hasHighS())return!1;const{r,s}=l,i=K(n),c=f.inv(s),u=f.create(i*c),d=f.create(r*c),m=e.BASE.multiplyUnsafe(u).add(t.multiplyUnsafe(d));return!m.is0()&&f.create(m.x)===r}catch(e){return!1}},recoverPublicKey:function(e,t,r={}){const{prehash:n}=d(r,x);return t=C(t,n),T.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:T,hash:r})}function S(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp;let n=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:r,Fn:(0,a.Field)(t.n,{BITS:e.nBitLength,allowedLengths:n,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function x(e,t,r){return function(n){const o=e.sqr(n),s=e.mul(o,n);return e.add(e.add(s,e.mul(n,t)),r)}}}}]);
|
|
2
|
+
"use strict";(this.webpackChunkNostrCryptoUtils=this.webpackChunkNostrCryptoUtils||[]).push([[705],{705(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.DER=t.DERErr=void 0,t._splitEndoScalar=u,t._normFnElement=g,t.weierstrassN=b,t.SWUFpSqrtRatio=v,t.mapToCurveSimpleSWU=function(e,t){(0,a.validateField)(e);const{A:r,B:n,Z:o}=t;if(!e.isValid(r)||!e.isValid(n)||!e.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");const s=v(e,o);if(!e.isOdd)throw new Error("Field does not have .isOdd()");return t=>{let i,c,u,l,d,f,m,y;i=e.sqr(t),i=e.mul(i,o),c=e.sqr(i),c=e.add(c,i),u=e.add(c,e.ONE),u=e.mul(u,n),l=e.cmov(o,e.neg(c),!e.eql(c,e.ZERO)),l=e.mul(l,r),c=e.sqr(u),f=e.sqr(l),d=e.mul(f,r),c=e.add(c,d),c=e.mul(c,u),f=e.mul(f,l),d=e.mul(f,n),c=e.add(c,d),m=e.mul(i,u);const{isValid:h,value:p}=s(c,f);y=e.mul(i,t),y=e.mul(y,p),m=e.cmov(m,u,h),y=e.cmov(y,p,h);const w=e.isOdd(t)===e.isOdd(y);y=e.cmov(e.neg(y),y,w);const g=(0,a.FpInvertBatch)(e,[l],!0)[0];return m=e.mul(m,g),{x:m,y}}},t.ecdh=R,t.ecdsa=O,t.weierstrassPoints=function(e){const{CURVE:t,curveOpts:r}=S(e);return function(e,t){const{Fp:r,Fn:n}=t;const o=x(r,e.a,e.b);return Object.assign({},{CURVE:e,Point:t,ProjectivePoint:t,normPrivateKeyToScalar:e=>g(n,e),weierstrassEquation:o,isWithinCurveOrder:function(e){return(0,s.inRange)(e,y,n.ORDER)}})}(e,b(t,r))},t._legacyHelperEquat=x,t.weierstrass=function(e){const{CURVE:t,curveOpts:r,hash:n,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:r}=S(e),n={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,hash:e.hash,ecdsaOpts:n}}(e);return function(e,t){const r=t.Point;return Object.assign({},t,{ProjectivePoint:r,CURVE:Object.assign({},e,(0,a.nLength)(r.Fn.ORDER,r.Fn.BITS))})}(e,O(b(t,r),n,o))};const n=r(615),o=r(175),s=r(627),i=r(422),a=r(967),c=(e,t)=>(e+(e>=0?t:-t)/h)/t;function u(e,t,r){const[[n,o],[i,a]]=t,u=c(a*e,r),l=c(-o*e,r);let d=e-u*n-l*i,f=-u*o-l*a;const h=d<m,p=f<m;h&&(d=-d),p&&(f=-f);const w=(0,s.bitMask)(Math.ceil((0,s.bitLen)(r)/2))+y;if(d<m||d>=w||f<m||f>=w)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:d,k2neg:p,k2:f}}function l(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function d(e,t){const r={};for(let n of Object.keys(t))r[n]=void 0===e[n]?t[n]:e[n];return(0,s._abool2)(r.lowS,"lowS"),(0,s._abool2)(r.prehash,"prehash"),void 0!==r.format&&l(r.format),r}class f extends Error{constructor(e=""){super(e)}}t.DERErr=f,t.DER={Err:f,_tlv:{encode:(e,r)=>{const{Err:n}=t.DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const o=r.length/2,i=(0,s.numberToHexUnpadded)(o);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?(0,s.numberToHexUnpadded)(i.length/2|128):"";return(0,s.numberToHexUnpadded)(e)+a+i+r},decode(e,r){const{Err:n}=t.DER;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[o++]!==e)throw new n("tlv.decode: wrong tlv");const s=r[o++];let i=0;if(128&s){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const t=r.subarray(o,o+e);if(t.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===t[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of t)i=i<<8|e;if(o+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=r.subarray(o,o+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:r.subarray(o+i)}}},_int:{encode(e){const{Err:r}=t.DER;if(e<m)throw new r("integer: negative integers are not allowed");let n=(0,s.numberToHexUnpadded)(e);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(e){const{Err:r}=t.DER;if(128&e[0])throw new r("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new r("invalid signature integer: unnecessary leading zero");return(0,s.bytesToNumberBE)(e)}},toSig(e){const{Err:r,_int:n,_tlv:o}=t.DER,i=(0,s.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,i);if(c.length)throw new r("invalid signature: left bytes after parsing");const{v:u,l}=o.decode(2,a),{v:d,l:f}=o.decode(2,l);if(f.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(u),s:n.decode(d)}},hexFromSig(e){const{_tlv:r,_int:n}=t.DER,o=r.encode(2,n.encode(e.r))+r.encode(2,n.encode(e.s));return r.encode(48,o)}};const m=BigInt(0),y=BigInt(1),h=BigInt(2),p=BigInt(3),w=BigInt(4);function g(e,t){const{BYTES:r}=e;let n;if("bigint"==typeof t)n=t;else{let o=(0,s.ensureBytes)("private key",t);try{n=e.fromBytes(o)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof t}`)}}if(!e.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function b(e,t={}){const r=(0,i._createCurveFields)("weierstrass",e,t),{Fp:n,Fn:o}=r;let a=r.CURVE;const{h:c,n:l}=a;(0,s._validateObject)(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:d}=t;if(d&&(!n.is0(a.a)||"bigint"!=typeof d.beta||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const f=B(n,o);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const b=t.toBytes||function(e,t,r){const{x:o,y:i}=t.toAffine(),a=n.toBytes(o);if((0,s._abool2)(r,"isCompressed"),r){h();const e=!n.isOdd(i);return(0,s.concatBytes)(E(e),a)}return(0,s.concatBytes)(Uint8Array.of(4),a,n.toBytes(i))},v=t.fromBytes||function(e){(0,s._abytes2)(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:r}=f,o=e.length,i=e[0],a=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===r&&4===i){const e=n.BYTES,t=n.fromBytes(a.subarray(0,e)),r=n.fromBytes(a.subarray(e,2*e));if(!O(t,r))throw new Error("bad point: is not on curve");return{x:t,y:r}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${r}`)}{const e=n.fromBytes(a);if(!n.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=R(e);let r;try{r=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}return h(),!(1&~i)!==n.isOdd(r)&&(r=n.neg(r)),{x:e,y:r}}};function R(e){const t=n.sqr(e),r=n.mul(t,e);return n.add(n.add(r,n.mul(e,a.a)),a.b)}function O(e,t){const r=n.sqr(t),o=R(e);return n.eql(r,o)}if(!O(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const S=n.mul(n.pow(a.a,p),w),x=n.mul(n.sqr(a.b),BigInt(27));if(n.is0(n.add(S,x)))throw new Error("bad curve params: a or b");function F(e,t,r=!1){if(!n.isValid(t)||r&&n.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function U(e){if(!(e instanceof Z))throw new Error("ProjectivePoint expected")}function P(e){if(!d||!d.basises)throw new Error("no endo");return u(e,d.basises,o.ORDER)}const T=(0,s.memoized)((e,t)=>{const{X:r,Y:o,Z:s}=e;if(n.eql(s,n.ONE))return{x:r,y:o};const i=e.is0();null==t&&(t=i?n.ONE:n.inv(s));const a=n.mul(r,t),c=n.mul(o,t),u=n.mul(s,t);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),V=(0,s.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:o}=e.toAffine();if(!n.isValid(r)||!n.isValid(o))throw new Error("bad point: x or y not field elements");if(!O(r,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function K(e,t,r,o,s){return r=new Z(n.mul(r.X,e),r.Y,r.Z),t=(0,i.negateCt)(o,t),r=(0,i.negateCt)(s,r),t.add(r)}class Z{constructor(e,t,r){this.X=F("x",e),this.Y=F("y",t,!0),this.Z=F("z",r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof Z)throw new Error("projective point not allowed");return n.is0(t)&&n.is0(r)?Z.ZERO:new Z(t,r,n.ONE)}static fromBytes(e){const t=Z.fromAffine(v((0,s._abytes2)(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return Z.fromBytes((0,s.ensureBytes)("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return C.createCache(this,e),t||this.multiply(p),this}assertValidity(){V(this)}hasEvenY(){const{y:e}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(e)}equals(e){U(e);const{X:t,Y:r,Z:o}=this,{X:s,Y:i,Z:a}=e,c=n.eql(n.mul(t,a),n.mul(s,o)),u=n.eql(n.mul(r,a),n.mul(i,o));return c&&u}negate(){return new Z(this.X,n.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,r=n.mul(t,p),{X:o,Y:s,Z:i}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(o,o),f=n.mul(s,s),m=n.mul(i,i),y=n.mul(o,s);return y=n.add(y,y),l=n.mul(o,i),l=n.add(l,l),c=n.mul(e,l),u=n.mul(r,m),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(y,c),l=n.mul(r,l),m=n.mul(e,m),y=n.sub(d,m),y=n.mul(e,y),y=n.add(y,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,m),d=n.mul(d,y),u=n.add(u,d),m=n.mul(s,i),m=n.add(m,m),d=n.mul(m,y),c=n.sub(c,d),l=n.mul(m,f),l=n.add(l,l),l=n.add(l,l),new Z(c,u,l)}add(e){U(e);const{X:t,Y:r,Z:o}=this,{X:s,Y:i,Z:c}=e;let u=n.ZERO,l=n.ZERO,d=n.ZERO;const f=a.a,m=n.mul(a.b,p);let y=n.mul(t,s),h=n.mul(r,i),w=n.mul(o,c),g=n.add(t,r),b=n.add(s,i);g=n.mul(g,b),b=n.add(y,h),g=n.sub(g,b),b=n.add(t,o);let E=n.add(s,c);return b=n.mul(b,E),E=n.add(y,w),b=n.sub(b,E),E=n.add(r,o),u=n.add(i,c),E=n.mul(E,u),u=n.add(h,w),E=n.sub(E,u),d=n.mul(f,b),u=n.mul(m,w),d=n.add(u,d),u=n.sub(h,d),d=n.add(h,d),l=n.mul(u,d),h=n.add(y,y),h=n.add(h,y),w=n.mul(f,w),b=n.mul(m,b),h=n.add(h,w),w=n.sub(y,w),w=n.mul(f,w),b=n.add(b,w),y=n.mul(h,b),l=n.add(l,y),y=n.mul(E,b),u=n.mul(g,u),u=n.sub(u,y),y=n.mul(g,h),d=n.mul(E,d),d=n.add(d,y),new Z(u,l,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(Z.ZERO)}multiply(e){const{endo:r}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let n,s;const a=e=>C.cached(this,e,e=>(0,i.normalizeZ)(Z,e));if(r){const{k1neg:t,k1:o,k2neg:i,k2:c}=P(e),{p:u,f:l}=a(o),{p:d,f}=a(c);s=l.add(f),n=K(r.beta,u,d,t,i)}else{const{p:t,f:r}=a(e);n=t,s=r}return(0,i.normalizeZ)(Z,[n,s])[0]}multiplyUnsafe(e){const{endo:r}=t,n=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===m||n.is0())return Z.ZERO;if(e===y)return n;if(C.hasCache(this))return this.multiply(e);if(r){const{k1neg:t,k1:o,k2neg:s,k2:a}=P(e),{p1:c,p2:u}=(0,i.mulEndoUnsafe)(Z,n,o,a);return K(r.beta,c,u,t,s)}return C.unsafe(n,e)}multiplyAndAddUnsafe(e,t,r){const n=this.multiplyUnsafe(t).add(e.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(e){return T(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return c===y||(e?e(Z,this):C.unsafe(this,l).is0())}clearCofactor(){const{clearCofactor:e}=t;return c===y?this:e?e(Z,this):this.multiplyUnsafe(c)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}toBytes(e=!0){return(0,s._abool2)(e,"isCompressed"),this.assertValidity(),b(Z,this,e)}toHex(e=!0){return(0,s.bytesToHex)(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return(0,i.normalizeZ)(Z,e)}static msm(e,t){return(0,i.pippenger)(Z,o,e,t)}static fromPrivateKey(e){return Z.BASE.multiply(g(o,e))}}Z.BASE=new Z(a.Gx,a.Gy,n.ONE),Z.ZERO=new Z(n.ZERO,n.ONE,n.ZERO),Z.Fp=n,Z.Fn=o;const k=o.BITS,C=new i.wNAF(Z,t.endo?Math.ceil(k/2):k);return Z.BASE.precompute(8),Z}function E(e){return Uint8Array.of(e?2:3)}function v(e,t){const r=e.ORDER;let n=m;for(let e=r-y;e%h===m;e/=h)n+=y;const o=n,s=h<<o-y-y,i=s*h,a=(r-y)/i,c=(a-y)/h,u=i-y,l=s,d=e.pow(t,a),f=e.pow(t,(a+y)/h);let g=(t,r)=>{let n=d,s=e.pow(r,u),i=e.sqr(s);i=e.mul(i,r);let a=e.mul(t,i);a=e.pow(a,c),a=e.mul(a,s),s=e.mul(a,r),i=e.mul(a,t);let m=e.mul(i,s);a=e.pow(m,l);let p=e.eql(a,e.ONE);s=e.mul(i,f),a=e.mul(m,n),i=e.cmov(s,i,p),m=e.cmov(a,m,p);for(let t=o;t>y;t--){let r=t-h;r=h<<r-y;let o=e.pow(m,r);const a=e.eql(o,e.ONE);s=e.mul(i,n),n=e.mul(n,n),o=e.mul(m,n),i=e.cmov(s,i,a),m=e.cmov(o,m,a)}return{isValid:p,value:i}};if(e.ORDER%w===p){const r=(e.ORDER-p)/w,n=e.sqrt(e.neg(t));g=(t,o)=>{let s=e.sqr(o);const i=e.mul(t,o);s=e.mul(s,i);let a=e.pow(s,r);a=e.mul(a,i);const c=e.mul(a,n),u=e.mul(e.sqr(a),o),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return g}function B(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function R(e,t={}){const{Fn:r}=e,n=t.randomBytes||s.randomBytes,o=Object.assign(B(e.Fp,r),{seed:(0,a.getMinHashLength)(r.ORDER)});function i(e){try{return!!g(r,e)}catch(e){return!1}}function c(e=n(o.seed)){return(0,a.mapHashToField)((0,s._abytes2)(e,o.seed,"seed"),r.ORDER)}function u(t,n=!0){return e.BASE.multiply(g(r,t)).toBytes(n)}function l(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:n,publicKey:i,publicKeyUncompressed:a}=o;if(r.allowedLengths||n===i)return;const c=(0,s.ensureBytes)("key",t).length;return c===i||c===a}const d={isValidSecretKey:i,isValidPublicKey:function(t,r){const{publicKey:n,publicKeyUncompressed:s}=o;try{const o=t.length;return!(!0===r&&o!==n||!1===r&&o!==s||!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:e=>g(r,e),precompute:(t=8,r=e.BASE)=>r.precompute(t,!1)};return Object.freeze({getPublicKey:u,getSharedSecret:function(t,n,o=!0){if(!0===l(t))throw new Error("first arg must be private key");if(!1===l(n))throw new Error("second arg must be public key");const s=g(r,t);return e.fromHex(n).multiply(s).toBytes(o)},keygen:function(e){const t=c(e);return{secretKey:t,publicKey:u(t)}},Point:e,utils:d,lengths:o})}function O(e,r,i={}){(0,o.ahash)(r),(0,s._validateObject)(i,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const a=i.randomBytes||s.randomBytes,c=i.hmac||((e,...t)=>(0,n.hmac)(r,e,(0,s.concatBytes)(...t))),{Fp:u,Fn:f}=e,{ORDER:p,BITS:w}=f,{keygen:b,getPublicKey:v,getSharedSecret:B,utils:O,lengths:S}=R(e,i),x={prehash:!1,lowS:"boolean"==typeof i.lowS&&i.lowS,format:void 0,extraEntropy:!1},F="compact";function U(e){return e>p>>y}function P(e,t){if(!f.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class T{constructor(e,t,r){this.r=P("r",e),this.s=P("s",t),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(e,r=F){let n;if(function(e,t){l(t);const r=S.signature,n="compact"===t?r:"recovered"===t?r+1:void 0;(0,s._abytes2)(e,n,`${t} signature`)}(e,r),"der"===r){const{r,s:n}=t.DER.toSig((0,s._abytes2)(e));return new T(r,n)}"recovered"===r&&(n=e[0],r="compact",e=e.subarray(1));const o=f.BYTES,i=e.subarray(0,o),a=e.subarray(o,2*o);return new T(f.fromBytes(i),f.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes((0,s.hexToBytes)(e),t)}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(t){const r=u.ORDER,{r:n,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(p*h<r&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?n+p:n;if(!u.isValid(a))throw new Error("recovery id 2 or 3 invalid");const c=u.toBytes(a),l=e.fromBytes((0,s.concatBytes)(E(!(1&i)),c)),d=f.inv(a),m=K((0,s.ensureBytes)("msgHash",t)),y=f.create(-m*d),w=f.create(o*d),g=e.BASE.multiplyUnsafe(y).add(l.multiplyUnsafe(w));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return U(this.s)}toBytes(e=F){if(l(e),"der"===e)return(0,s.hexToBytes)(t.DER.hexFromSig(this));const r=f.toBytes(this.r),n=f.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,s.concatBytes)(Uint8Array.of(this.recovery),r,n)}return(0,s.concatBytes)(r,n)}toHex(e){return(0,s.bytesToHex)(this.toBytes(e))}assertValidity(){}static fromCompact(e){return T.fromBytes((0,s.ensureBytes)("sig",e),"compact")}static fromDER(e){return T.fromBytes((0,s.ensureBytes)("sig",e),"der")}normalizeS(){return this.hasHighS()?new T(this.r,f.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,s.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,s.bytesToHex)(this.toBytes("compact"))}}const V=i.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,s.bytesToNumberBE)(e),r=8*e.length-w;return r>0?t>>BigInt(r):t},K=i.bits2int_modN||function(e){return f.create(V(e))},Z=(0,s.bitMask)(w);function k(e){return(0,s.aInRange)("num < 2^"+w,e,m,Z),f.toBytes(e)}function C(e,t){return(0,s._abytes2)(e,void 0,"message"),t?(0,s._abytes2)(r(e),void 0,"prehashed message"):e}return Object.freeze({keygen:b,getPublicKey:v,getSharedSecret:B,utils:O,lengths:S,Point:e,sign:function(t,n,o={}){t=(0,s.ensureBytes)("message",t);const{seed:i,k2sig:u}=function(t,r,n){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:i,extraEntropy:c}=d(n,x);t=C(t,i);const u=K(t),l=g(f,r),h=[k(l),k(u)];if(null!=c&&!1!==c){const e=!0===c?a(S.secretKey):c;h.push((0,s.ensureBytes)("extraEntropy",e))}const p=(0,s.concatBytes)(...h),w=u;return{seed:p,k2sig:function(t){const r=V(t);if(!f.isValidNot0(r))return;const n=f.inv(r),s=e.BASE.multiply(r).toAffine(),i=f.create(s.x);if(i===m)return;const a=f.create(n*f.create(w+i*l));if(a===m)return;let c=(s.x===i?0:2)|Number(s.y&y),u=a;return o&&U(a)&&(u=f.neg(a),c^=1),new T(i,u,c)}}}(t,n,o);return(0,s.createHmacDrbg)(r.outputLen,f.BYTES,c)(i,u)},verify:function(r,n,o,i={}){const{lowS:a,prehash:c,format:u}=d(i,x);if(o=(0,s.ensureBytes)("publicKey",o),n=C((0,s.ensureBytes)("message",n),c),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let r;const n="string"==typeof e||(0,s.isBytes)(e),o=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!o)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(o)r=new T(e.r,e.s);else if(n){try{r=T.fromBytes((0,s.ensureBytes)("sig",e),"der")}catch(e){if(!(e instanceof t.DER.Err))throw e}if(!r)try{r=T.fromBytes((0,s.ensureBytes)("sig",e),"compact")}catch(e){return!1}}return r||!1}(r):T.fromBytes((0,s.ensureBytes)("sig",r),u);if(!1===l)return!1;try{const t=e.fromBytes(o);if(a&&l.hasHighS())return!1;const{r,s}=l,i=K(n),c=f.inv(s),u=f.create(i*c),d=f.create(r*c),m=e.BASE.multiplyUnsafe(u).add(t.multiplyUnsafe(d));return!m.is0()&&f.create(m.x)===r}catch(e){return!1}},recoverPublicKey:function(e,t,r={}){const{prehash:n}=d(r,x);return t=C(t,n),T.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:T,hash:r})}function S(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp;let n=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:r,Fn:(0,a.Field)(t.n,{BITS:e.nBitLength,allowedLengths:n,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function x(e,t,r){return function(n){const o=e.sqr(n),s=e.mul(o,n);return e.add(e.add(s,e.mul(n,t)),r)}}}}]);
|