@protontech/openpgp 6.0.0-beta.0 → 6.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/lightweight/argon2id.min.mjs +2 -2
  2. package/dist/lightweight/argon2id.min.mjs.map +1 -1
  3. package/dist/lightweight/argon2id.mjs +5 -28
  4. package/dist/lightweight/legacy_ciphers.min.mjs +2 -2
  5. package/dist/lightweight/legacy_ciphers.min.mjs.map +1 -1
  6. package/dist/lightweight/legacy_ciphers.mjs +6 -51
  7. package/dist/lightweight/noble_curves.min.mjs +11 -11
  8. package/dist/lightweight/noble_curves.min.mjs.map +1 -1
  9. package/dist/lightweight/noble_curves.mjs +477 -465
  10. package/dist/lightweight/noble_hashes.min.mjs +2 -2
  11. package/dist/lightweight/noble_hashes.min.mjs.map +1 -1
  12. package/dist/lightweight/noble_hashes.mjs +19 -31
  13. package/dist/lightweight/openpgp.min.mjs +2 -2
  14. package/dist/lightweight/openpgp.min.mjs.map +1 -1
  15. package/dist/lightweight/openpgp.mjs +600 -458
  16. package/dist/lightweight/sha3.min.mjs +3 -3
  17. package/dist/lightweight/sha3.min.mjs.map +1 -1
  18. package/dist/lightweight/sha3.mjs +80 -80
  19. package/dist/node/openpgp.cjs +1254 -5443
  20. package/dist/node/openpgp.min.cjs +11 -12
  21. package/dist/node/openpgp.min.cjs.map +1 -1
  22. package/dist/node/openpgp.min.mjs +11 -12
  23. package/dist/node/openpgp.min.mjs.map +1 -1
  24. package/dist/node/openpgp.mjs +1254 -5443
  25. package/dist/openpgp.js +1247 -5436
  26. package/dist/openpgp.min.js +11 -12
  27. package/dist/openpgp.min.js.map +1 -1
  28. package/dist/openpgp.min.mjs +11 -12
  29. package/dist/openpgp.min.mjs.map +1 -1
  30. package/dist/openpgp.mjs +1247 -5436
  31. package/openpgp.d.ts +62 -60
  32. package/package.json +16 -10
  33. package/dist/lightweight/bn.interface.min.mjs +0 -3
  34. package/dist/lightweight/bn.interface.min.mjs.map +0 -1
  35. package/dist/lightweight/bn.interface.mjs +0 -3807
  36. package/dist/lightweight/interface.min.mjs +0 -3
  37. package/dist/lightweight/interface.min.mjs.map +0 -1
  38. package/dist/lightweight/interface.mjs +0 -16
  39. package/dist/lightweight/native.interface.min.mjs +0 -3
  40. package/dist/lightweight/native.interface.min.mjs.map +0 -1
  41. package/dist/lightweight/native.interface.mjs +0 -456
package/openpgp.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /* eslint-disable max-lines, @typescript-eslint/indent */
2
+
1
3
  /**
2
4
  * Type definitions for OpenPGP.js http://openpgpjs.org/
3
5
  *
@@ -64,8 +66,8 @@ export abstract class Key {
64
66
  // NB: the order of the `update` declarations matters, since PublicKey includes PrivateKey
65
67
  public update(sourceKey: PrivateKey, date?: Date, config?: Config): Promise<PrivateKey>;
66
68
  public update(sourceKey: PublicKey, date?: Date, config?: Config): Promise<PublicKey>;
67
- public signPrimaryUser(privateKeys: PrivateKey[], date?: Date, userID?: UserID, config?: Config): Promise<this>
68
- public signAllUsers(privateKeys: PrivateKey[], date?: Date, config?: Config): Promise<this>
69
+ public signPrimaryUser(privateKeys: PrivateKey[], date?: Date, userID?: UserID, config?: Config): Promise<this>;
70
+ public signAllUsers(privateKeys: PrivateKey[], date?: Date, config?: Config): Promise<this>;
69
71
  public verifyPrimaryKey(date?: Date, userID?: UserID, config?: Config): Promise<void>; // throws on error
70
72
  public verifyPrimaryUser(publicKeys: PublicKey[], date?: Date, userIDs?: UserID, config?: Config): Promise<{ keyID: KeyID, valid: boolean | null }[]>;
71
73
  public verifyAllUsers(publicKeys?: PublicKey[], date?: Date, config?: Config): Promise<{ userID: string, keyID: KeyID, valid: boolean | null }[]>;
@@ -92,7 +94,7 @@ export class PrivateKey extends PublicKey {
92
94
  public revoke(reason?: ReasonForRevocation, date?: Date, config?: Config): Promise<PrivateKey>;
93
95
  public isDecrypted(): boolean;
94
96
  public addSubkey(options: SubkeyOptions): Promise<PrivateKey>;
95
- public getDecryptionKeys(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<PrivateKey | Subkey>
97
+ public getDecryptionKeys(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<PrivateKey | Subkey>;
96
98
  public update(sourceKey: PublicKey, date?: Date, config?: Config): Promise<PrivateKey>;
97
99
  }
98
100
 
@@ -108,9 +110,9 @@ export class Subkey {
108
110
  public getCreationTime(): Date;
109
111
  public getAlgorithmInfo(): AlgorithmInfo;
110
112
  public getKeyID(): KeyID;
111
- public getExpirationTime(date?: Date, config?: Config): Promise<Date | typeof Infinity | null>
113
+ public getExpirationTime(date?: Date, config?: Config): Promise<Date | typeof Infinity | null>;
112
114
  public isRevoked(signature: SignaturePacket, key: AnyKeyPacket, date?: Date, config?: Config): Promise<boolean>;
113
- public update(subKey: Subkey, date?: Date, config?: Config): Promise<void>
115
+ public update(subKey: Subkey, date?: Date, config?: Config): Promise<void>;
114
116
  public revoke(primaryKey: SecretKeyPacket, reasonForRevocation?: ReasonForRevocation, date?: Date, config?: Config): Promise<Subkey>;
115
117
  }
116
118
 
@@ -200,25 +202,25 @@ export function createMessage<T extends MaybeStream<string>>(options: { text: T,
200
202
  export function createMessage<T extends MaybeStream<Uint8Array>>(options: { binary: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
201
203
 
202
204
  export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<
203
- T extends WebStream<infer X> ? WebStream<string> :
204
- T extends NodeWebStream<infer X> ? NodeWebStream<string> :
205
+ T extends WebStream<Data> ? WebStream<string> :
206
+ T extends NodeWebStream<Data> ? NodeWebStream<string> :
205
207
  string
206
208
  >;
207
209
  export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'binary' }): Promise<
208
- T extends WebStream<infer X> ? WebStream<Uint8Array> :
209
- T extends NodeWebStream<infer X> ? NodeWebStream<Uint8Array> :
210
+ T extends WebStream<Data> ? WebStream<Uint8Array> :
211
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
210
212
  Uint8Array
211
213
  >;
212
214
  export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
213
215
 
214
216
  export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format?: 'armored' }): Promise<
215
- T extends WebStream<infer X> ? WebStream<string> :
216
- T extends NodeWebStream<infer X> ? NodeWebStream<string> :
217
+ T extends WebStream<Data> ? WebStream<string> :
218
+ T extends NodeWebStream<Data> ? NodeWebStream<string> :
217
219
  string
218
220
  >;
219
221
  export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'binary' }): Promise<
220
- T extends WebStream<infer X> ? WebStream<Uint8Array> :
221
- T extends NodeWebStream<infer X> ? NodeWebStream<Uint8Array> :
222
+ T extends WebStream<Data> ? WebStream<Uint8Array> :
223
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
222
224
  Uint8Array
223
225
  >;
224
226
  export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
@@ -227,26 +229,26 @@ export function sign(options: SignOptions & { message: CleartextMessage, format:
227
229
 
228
230
  export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T>, format: 'binary' }): Promise<DecryptMessageResult & {
229
231
  data:
230
- T extends WebStream<infer X> ? WebStream<Uint8Array> :
231
- T extends NodeWebStream<infer X> ? NodeWebStream<Uint8Array> :
232
+ T extends WebStream<Data> ? WebStream<Uint8Array> :
233
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
232
234
  Uint8Array
233
235
  }>;
234
236
  export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T> }): Promise<DecryptMessageResult & {
235
237
  data:
236
- T extends WebStream<infer X> ? WebStream<string> :
237
- T extends NodeWebStream<infer X> ? NodeWebStream<string> :
238
+ T extends WebStream<Data> ? WebStream<string> :
239
+ T extends NodeWebStream<Data> ? NodeWebStream<string> :
238
240
  string
239
241
  }>;
240
242
 
241
243
  export function verify(options: VerifyOptions & { message: CleartextMessage, format?: 'utf8' }): Promise<VerifyMessageResult<string>>;
242
244
  export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T>, format: 'binary' }): Promise<VerifyMessageResult<
243
- T extends WebStream<infer X> ? WebStream<Uint8Array> :
244
- T extends NodeWebStream<infer X> ? NodeWebStream<Uint8Array> :
245
+ T extends WebStream<Data> ? WebStream<Uint8Array> :
246
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
245
247
  Uint8Array
246
248
  >>;
247
249
  export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult<
248
- T extends WebStream<infer X> ? WebStream<string> :
249
- T extends NodeWebStream<infer X> ? NodeWebStream<string> :
250
+ T extends WebStream<Data> ? WebStream<string> :
251
+ T extends NodeWebStream<Data> ? NodeWebStream<string> :
250
252
  string
251
253
  >>;
252
254
 
@@ -273,7 +275,7 @@ export class Message<T extends MaybeStream<Data>> {
273
275
  /** Encrypt the message
274
276
  @param encryptionKeys array of public keys, used to encrypt the message
275
277
  */
276
- public encrypt(encryptionKeys?: PublicKey[], passwords?: string[], sessionKeys?: SessionKey[], wildcard?: boolean, encryptionKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<MaybeStream<Data>>>;
278
+ public encrypt(encryptionKeys?: PublicKey[], passwords?: string[], sessionKeys?: SessionKey[], wildcard?: boolean, encryptionKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<MaybeStream<Data>>>;
277
279
 
278
280
  /** Returns the key IDs of the keys to which the session key is encrypted
279
281
  */
@@ -324,6 +326,7 @@ interface Config {
324
326
  showVersion: boolean;
325
327
  showComment: boolean;
326
328
  aeadProtect: boolean;
329
+ ignoreSEIPDv2FeatureFlag: boolean;
327
330
  allowUnauthenticatedMessages: boolean;
328
331
  allowUnauthenticatedStream: boolean;
329
332
  allowForwardedMessages: boolean;
@@ -352,7 +355,7 @@ interface Config {
352
355
  rejectPublicKeyAlgorithms: Set<enums.publicKey>;
353
356
  rejectCurves: Set<enums.curve>;
354
357
  }
355
- export var config: Config;
358
+ export const config: Config;
356
359
 
357
360
  // PartialConfig has the same properties as Config, but declared as optional.
358
361
  // This interface is relevant for top-level functions, which accept a subset of configuration options
@@ -433,7 +436,7 @@ export class AEADEncryptedDataPacket extends BasePacket {
433
436
  static readonly tag: enums.packet.aeadEncryptedData;
434
437
  private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
435
438
  private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
436
- private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>
439
+ private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>;
437
440
  }
438
441
 
439
442
  export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
@@ -679,7 +682,7 @@ export interface EncryptSessionKeyOptions extends SessionKey {
679
682
  config?: PartialConfig
680
683
  }
681
684
 
682
- interface SerializedKeyPair<T extends string|Uint8Array> {
685
+ interface SerializedKeyPair<T extends string | Uint8Array> {
683
686
  privateKey: T;
684
687
  publicKey: T;
685
688
  }
@@ -747,44 +750,44 @@ export function unarmor(input: string, config?: Config): Promise<{ text: string,
747
750
  /* ############## v5 ENUMS #################### */
748
751
 
749
752
  export namespace enums {
750
- function read(type: typeof armor, e: armor): armorNames;
751
- function read(type: typeof compression, e: compression): compressionNames;
752
- function read(type: typeof hash, e: hash): hashNames;
753
- function read(type: typeof packet, e: packet): packetNames;
754
- function read(type: typeof publicKey, e: publicKey): publicKeyNames;
755
- function read(type: typeof symmetric, e: symmetric): symmetricNames;
756
- function read(type: typeof keyStatus, e: keyStatus): keyStatusNames;
757
- function read(type: typeof keyFlags, e: keyFlags): keyFlagsNames;
753
+ export function read(type: typeof armor, e: armor): armorNames;
754
+ export function read(type: typeof compression, e: compression): compressionNames;
755
+ export function read(type: typeof hash, e: hash): hashNames;
756
+ export function read(type: typeof packet, e: packet): packetNames;
757
+ export function read(type: typeof publicKey, e: publicKey): publicKeyNames;
758
+ export function read(type: typeof symmetric, e: symmetric): symmetricNames;
759
+ export function read(type: typeof keyStatus, e: keyStatus): keyStatusNames;
760
+ export function read(type: typeof keyFlags, e: keyFlags): keyFlagsNames;
758
761
 
759
762
  export type armorNames = 'multipartSection' | 'multipartLast' | 'signed' | 'message' | 'publicKey' | 'privateKey';
760
- enum armor {
763
+ export enum armor {
761
764
  multipartSection = 0,
762
765
  multipartLast = 1,
763
766
  signed = 2,
764
767
  message = 3,
765
768
  publicKey = 4,
766
769
  privateKey = 5,
767
- signature = 6,
770
+ signature = 6
768
771
  }
769
772
 
770
- enum reasonForRevocation {
773
+ export enum reasonForRevocation {
771
774
  noReason = 0, // No reason specified (key revocations or cert revocations)
772
775
  keySuperseded = 1, // Key is superseded (key revocations)
773
776
  keyCompromised = 2, // Key material has been compromised (key revocations)
774
777
  keyRetired = 3, // Key is retired and no longer used (key revocations)
775
- userIDInvalid = 32, // User ID information is no longer valid (cert revocations)
778
+ userIDInvalid = 32 // User ID information is no longer valid (cert revocations)
776
779
  }
777
780
 
778
781
  export type compressionNames = 'uncompressed' | 'zip' | 'zlib' | 'bzip2';
779
- enum compression {
782
+ export enum compression {
780
783
  uncompressed = 0,
781
784
  zip = 1,
782
785
  zlib = 2,
783
- bzip2 = 3,
786
+ bzip2 = 3
784
787
  }
785
788
 
786
789
  export type hashNames = 'md5' | 'sha1' | 'ripemd' | 'sha256' | 'sha384' | 'sha512' | 'sha224' | 'sha3_256' | 'sha3_512';
787
- enum hash {
790
+ export enum hash {
788
791
  md5 = 1,
789
792
  sha1 = 2,
790
793
  ripemd = 3,
@@ -796,10 +799,10 @@ export namespace enums {
796
799
  sha3_512 = 14
797
800
  }
798
801
 
799
- export type packetNames = 'publicKeyEncryptedSessionKey' | 'signature' | 'symEncryptedSessionKey' | 'onePassSignature' | 'secretKey' | 'publicKey'
800
- | 'secretSubkey' | 'compressed' | 'symmetricallyEncrypted' | 'marker' | 'literal' | 'trust' | 'userID' | 'publicSubkey' | 'userAttribute'
801
- | 'symEncryptedIntegrityProtected' | 'modificationDetectionCode' | 'AEADEncryptedDataPacket';
802
- enum packet {
802
+ export type packetNames = 'publicKeyEncryptedSessionKey' | 'signature' | 'symEncryptedSessionKey' | 'onePassSignature' | 'secretKey' | 'publicKey' |
803
+ 'secretSubkey' | 'compressed' | 'symmetricallyEncrypted' | 'marker' | 'literal' | 'trust' | 'userID' | 'publicSubkey' | 'userAttribute' |
804
+ 'symEncryptedIntegrityProtected' | 'modificationDetectionCode' | 'AEADEncryptedDataPacket';
805
+ export enum packet {
803
806
  publicKeyEncryptedSessionKey = 1,
804
807
  signature = 2,
805
808
  symEncryptedSessionKey = 3,
@@ -817,11 +820,11 @@ export namespace enums {
817
820
  userAttribute = 17,
818
821
  symEncryptedIntegrityProtectedData = 18,
819
822
  modificationDetectionCode = 19,
820
- aeadEncryptedData = 20,
823
+ aeadEncryptedData = 20
821
824
  }
822
825
 
823
826
  export type publicKeyNames = 'rsaEncryptSign' | 'rsaEncrypt' | 'rsaSign' | 'elgamal' | 'dsa' | 'ecdh' | 'ecdsa' | 'eddsaLegacy' | 'aedh' | 'aedsa' | 'ed25519' | 'x25519' | 'ed448' | 'x448';
824
- enum publicKey {
827
+ export enum publicKey {
825
828
  rsaEncryptSign = 1,
826
829
  rsaEncrypt = 2,
827
830
  rsaSign = 3,
@@ -838,7 +841,7 @@ export namespace enums {
838
841
  ed448 = 28
839
842
  }
840
843
 
841
- enum curve {
844
+ export enum curve {
842
845
  /** @deprecated use `nistP256` instead */
843
846
  p256 = 'nistP256',
844
847
  nistP256 = 'nistP256',
@@ -861,7 +864,7 @@ export namespace enums {
861
864
  }
862
865
 
863
866
  export type symmetricNames = 'idea' | 'tripledes' | 'cast5' | 'blowfish' | 'aes128' | 'aes192' | 'aes256' | 'twofish';
864
- enum symmetric {
867
+ export enum symmetric {
865
868
  idea = 1,
866
869
  tripledes = 2,
867
870
  cast5 = 3,
@@ -869,21 +872,20 @@ export namespace enums {
869
872
  aes128 = 7,
870
873
  aes192 = 8,
871
874
  aes256 = 9,
872
- twofish = 10,
875
+ twofish = 10
873
876
  }
874
877
 
875
878
  export type keyStatusNames = 'invalid' | 'expired' | 'revoked' | 'valid' | 'noSelfCert';
876
- enum keyStatus {
879
+ export enum keyStatus {
877
880
  invalid = 0,
878
881
  expired = 1,
879
882
  revoked = 2,
880
883
  valid = 3,
881
- noSelfCert = 4,
884
+ noSelfCert = 4
882
885
  }
883
886
 
884
- export type keyFlagsNames = 'certifyKeys' | 'signData' | 'encryptCommunication' | 'encryptStorage' | 'splitPrivateKey' | 'authentication'
885
- | 'sharedPrivateKey';
886
- enum keyFlags {
887
+ export type keyFlagsNames = 'certifyKeys' | 'signData' | 'encryptCommunication' | 'encryptStorage' | 'splitPrivateKey' | 'authentication' | 'sharedPrivateKey';
888
+ export enum keyFlags {
887
889
  certifyKeys = 1,
888
890
  signData = 2,
889
891
  encryptCommunication = 4,
@@ -891,10 +893,10 @@ export namespace enums {
891
893
  splitPrivateKey = 16,
892
894
  authentication = 32,
893
895
  forwardedCommunication = 64,
894
- sharedPrivateKey = 128,
896
+ sharedPrivateKey = 128
895
897
  }
896
898
 
897
- enum signature {
899
+ export enum signature {
898
900
  binary = 0,
899
901
  text = 1,
900
902
  standalone = 2,
@@ -913,21 +915,21 @@ export namespace enums {
913
915
  }
914
916
 
915
917
  export type aeadNames = 'eax' | 'ocb' | 'gcm';
916
- enum aead {
918
+ export enum aead {
917
919
  eax = 1,
918
920
  ocb = 2,
919
921
  experimentalGCM = 100 // Private algorithm
920
922
  }
921
923
 
922
- export type literalFormatNames = 'utf8' | 'binary' | 'text' | 'mime'
923
- enum literal {
924
+ export type literalFormatNames = 'utf8' | 'binary' | 'text' | 'mime';
925
+ export enum literal {
924
926
  binary = 98,
925
927
  text = 116,
926
928
  utf8 = 117,
927
929
  mime = 109
928
930
  }
929
931
 
930
- enum s2k {
932
+ export enum s2k {
931
933
  simple = 0,
932
934
  salted = 1,
933
935
  iterated = 3,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@protontech/openpgp",
3
3
  "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
4
- "version": "6.0.0-beta.0",
4
+ "version": "6.0.0-beta.1",
5
5
  "license": "LGPL-3.0+",
6
6
  "homepage": "https://openpgpjs.org/",
7
7
  "engines": {
@@ -53,7 +53,7 @@
53
53
  "prebrowsertest": "npm run build-test",
54
54
  "browsertest": "npm start -- -o test/unittests.html",
55
55
  "test-browser": "karma start test/karma.conf.cjs",
56
- "test-browserstack": "karma start test/karma.conf.cjs --browsers bs_safari_latest,bs_ios_14,bs_safari_13_1",
56
+ "test-browserstack": "karma start test/karma.conf.cjs --browsers bs_safari_latest,bs_ios_14,bs_safari_14",
57
57
  "coverage": "c8 npm test",
58
58
  "lint": "eslint .",
59
59
  "docs": "jsdoc --configure .jsdocrc.cjs --destination docs --recurse README.md src && printf '%s' 'docs.openpgpjs.org' > docs/CNAME",
@@ -62,10 +62,10 @@
62
62
  "postversion": "git push && git push --tags && npm publish"
63
63
  },
64
64
  "devDependencies": {
65
+ "@noble/curves": "^1.4.0",
66
+ "@noble/hashes": "^1.4.0",
65
67
  "@openpgp/asmcrypto.js": "^3.1.0",
66
68
  "@openpgp/jsdoc": "^3.6.11",
67
- "@openpgp/noble-curves": "^1.3.0",
68
- "@openpgp/noble-hashes": "^1.3.3",
69
69
  "@openpgp/seek-bzip": "^1.0.5-git",
70
70
  "@openpgp/tweetnacl": "^1.0.4-1",
71
71
  "@openpgp/web-stream-tools": "~0.1.1",
@@ -74,17 +74,22 @@
74
74
  "@rollup/plugin-node-resolve": "^15.2.3",
75
75
  "@rollup/plugin-replace": "^5.0.5",
76
76
  "@rollup/plugin-terser": "^0.4.4",
77
+ "@rollup/plugin-typescript": "^11.1.6",
77
78
  "@rollup/plugin-wasm": "^6.2.2",
78
- "@types/chai": "^4.3.14",
79
+ "@types/chai": "^4.3.16",
80
+ "@typescript-eslint/parser": "^7.9.0",
79
81
  "argon2id": "^1.0.1",
80
82
  "benchmark": "^2.1.4",
83
+ "bn.js": "^5.2.1",
81
84
  "c8": "^8.0.1",
82
85
  "chai": "^4.4.1",
83
- "chai-as-promised": "^7.1.1",
86
+ "chai-as-promised": "^7.1.2",
84
87
  "eckey-utils": "^0.7.14",
85
88
  "eslint": "^8.57.0",
86
89
  "eslint-config-airbnb": "^19.0.4",
87
90
  "eslint-config-airbnb-base": "^15.0.0",
91
+ "eslint-config-airbnb-typescript": "^18.0.0",
92
+ "eslint-import-resolver-typescript": "^3.6.1",
88
93
  "eslint-plugin-chai-friendly": "^0.7.4",
89
94
  "eslint-plugin-import": "^2.29.1",
90
95
  "eslint-plugin-unicorn": "^48.0.1",
@@ -98,12 +103,13 @@
98
103
  "karma-mocha-reporter": "^2.2.5",
99
104
  "karma-webkit-launcher": "^2.4.0",
100
105
  "mocha": "^10.4.0",
101
- "playwright": "^1.43.0",
102
- "rollup": "^4.14.1",
106
+ "playwright": "^1.44.0",
107
+ "rollup": "^4.17.2",
103
108
  "sinon": "^17.0.1",
104
109
  "ts-node": "^10.9.2",
105
- "tsx": "^4.7.2",
106
- "typescript": "^5.4.4",
110
+ "tslib": "^2.6.2",
111
+ "tsx": "^4.10.4",
112
+ "typescript": "^5.4.5",
107
113
  "web-streams-polyfill": "^3.3.3"
108
114
  },
109
115
  "repository": {
@@ -1,3 +0,0 @@
1
- /*! OpenPGP.js v6.0.0-beta.0 - 2024-04-18 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};import{B as i}from"./interface.min.mjs";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={exports:{}};!function(t,i){function r(t,i){if(!t)throw Error(i||"Assertion failed")}function e(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,i,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var h;"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;try{h="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function s(t,i){var r=t.charCodeAt(i);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,i,r){var e=s(t,r);return r-1>=i&&(e|=s(t,r-1)<<4),e}function u(t,i,r,e){for(var n=0,h=Math.min(t.length,r),s=i;s<h;s++){var o=t.charCodeAt(s)-48;n*=e,n+=o>=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,e){if("number"==typeof t)return this._initNumber(t,i,e);if("object"==typeof t)return this._initArray(t,i,e);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,e):(this._parseBase(t,i,n),"le"===e&&this._initArray(this.toArray(),i,e)))},n.prototype._initNumber=function(t,i,e){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===e&&this._initArray(this.toArray(),i,e)},n.prototype._initArray=function(t,i,e){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var h,s,o=0;if("be"===e)for(n=t.length-1,h=0;n>=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[h]|=s<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);else if("le"===e)for(n=0,h=0;n<t.length;n+=3)s=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[h]|=s<<o&67108863,this.words[h+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,h++);return this.strip()},n.prototype._parseHex=function(t,i,r){this.length=Math.ceil((t.length-i)/6),this.words=Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,h=0,s=0;if("be"===r)for(e=t.length-1;e>=i;e-=2)n=o(t,i,e)<<h,this.words[s]|=67108863&n,h>=18?(h-=18,s+=1,this.words[s]|=n>>>26):h+=8;else for(e=(t.length-i)%2==0?i+1:i;e<t.length;e+=2)n=o(t,i,e)<<h,this.words[s]|=67108863&n,h>=18?(h-=18,s+=1,this.words[s]|=n>>>26):h+=8;this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var e=0,n=1;n<=67108863;n*=i)e++;e--,n=n/i|0;for(var h=t.length-r,s=h%e,o=Math.min(h,h-s)+r,a=0,l=r;l<o;l+=e)a=u(t,l,l+e,i),this.imuln(n),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a);if(0!==s){var m=1;for(a=u(t,l,t.length,i),l=0;l<s;l++)m*=i;this.imuln(m),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a)}this.strip()},n.prototype.copy=function(t){t.words=Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var a=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,i,r){r.negative=i.negative^t.negative;var e=t.length+i.length|0;r.length=e,e=e-1|0;var n=0|t.words[0],h=0|i.words[0],s=n*h,o=67108863&s,u=s/67108864|0;r.words[0]=o;for(var a=1;a<e;a++){for(var l=u>>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(s=(n=0|t.words[p])*(h=0|i.words[d])+m)/67108864|0,m=67108863&s}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}n.prototype.toString=function(t,i){var e;if(i=0|i||1,16===(t=t||10)||"hex"===t){e="";for(var n=0,h=0,s=0;s<this.length;s++){var o=this.words[s],u=(16777215&(o<<n|h)).toString(16);e=0!=(h=o>>>24-n&16777215)||s!==this.length-1?a[6-u.length]+u+e:u+e,(n+=2)>=26&&(n-=26,s--)}for(0!==h&&(e=h.toString(16)+e);e.length%i!=0;)e="0"+e;return 0!==this.negative&&(e="-"+e),e}if(t===(0|t)&&t>=2&&t<=36){var f=l[t],d=m[t];e="";var p=this.clone();for(p.negative=0;!p.isZero();){var v=p.modn(d).toString(t);e=(p=p.idivn(d)).isZero()?v+e:a[f-v.length]+v+e}for(this.isZero()&&(e="0"+e);e.length%i!=0;)e="0"+e;return 0!==this.negative&&(e="-"+e),e}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==h),this.toArrayLike(h,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,e){var n=this.byteLength(),h=e||Math.max(1,n);r(n<=h,"byte array longer than desired length"),r(h>0,"Requested array length <= 0"),this.strip();var s,o,u="le"===i,a=new t(h),l=this.clone();if(u){for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),a[o]=s;for(;o<h;o++)a[o]=0}else{for(o=0;o<h-n;o++)a[o]=0;for(o=0;!l.isZero();o++)s=l.andln(255),l.iushrn(8),a[h-o-1]=s}return a},n.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 8191&i||(r+=13,i>>>=13),127&i||(r+=7,i>>>=7),15&i||(r+=4,i>>>=4),3&i||(r+=2,i>>>=2),1&i||r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var r=this._zeroBits(this.words[i]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this.strip()},n.prototype.ior=function(t){return r(!(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;r<i.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=i.length,this.strip()},n.prototype.iand=function(t){return r(!(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var e=0;e<r.length;e++)this.words[e]=i.words[e]^r.words[e];if(this!==i)for(;e<i.length;e++)this.words[e]=i.words[e];return this.length=i.length,this.strip()},n.prototype.ixor=function(t){return r(!(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),e=t%26;this._expand(i),e>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return e>0&&(this.words[n]=~this.words[n]&67108863>>26-e),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var e=t/26|0,n=t%26;return this._expand(e+1),this.words[e]=i?this.words[e]|1<<n:this.words[e]&~(1<<n),this.strip()},n.prototype.iadd=function(t){var i,r,e;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(r=this,e=t):(r=t,e=this);for(var n=0,h=0;h<e.length;h++)i=(0|r.words[h])+(0|e.words[h])+n,this.words[h]=67108863&i,n=i>>>26;for(;0!==n&&h<r.length;h++)i=(0|r.words[h])+n,this.words[h]=67108863&i,n=i>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;h<r.length;h++)this.words[h]=r.words[h];return this},n.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,e,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,e=t):(r=t,e=this);for(var h=0,s=0;s<e.length;s++)h=(i=(0|r.words[s])-(0|e.words[s])+h)>>26,this.words[s]=67108863&i;for(;0!==h&&s<r.length;s++)h=(i=(0|r.words[s])+h)>>26,this.words[s]=67108863&i;if(0===h&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,i,r){var e,n,h,s=t.words,o=i.words,u=r.words,a=0,l=0|s[0],m=8191&l,f=l>>>13,d=0|s[1],p=8191&d,v=d>>>13,M=0|s[2],g=8191&M,c=M>>>13,w=0|s[3],y=8191&w,b=w>>>13,_=0|s[4],A=8191&_,k=_>>>13,x=0|s[5],S=8191&x,q=x>>>13,Z=0|s[6],B=8191&Z,R=Z>>>13,N=0|s[7],L=8191&N,I=N>>>13,E=0|s[8],O=8191&E,z=E>>>13,T=0|s[9],j=8191&T,P=T>>>13,K=0|o[0],F=8191&K,U=K>>>13,C=0|o[1],D=8191&C,H=C>>>13,J=0|o[2],W=8191&J,G=J>>>13,Q=0|o[3],V=8191&Q,X=Q>>>13,Y=0|o[4],$=8191&Y,tt=Y>>>13,it=0|o[5],rt=8191&it,et=it>>>13,nt=0|o[6],ht=8191&nt,st=nt>>>13,ot=0|o[7],ut=8191&ot,at=ot>>>13,lt=0|o[8],mt=8191&lt,ft=lt>>>13,dt=0|o[9],pt=8191&dt,vt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var Mt=(a+(e=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,U))+Math.imul(f,F)|0))<<13)|0;a=((h=Math.imul(f,U))+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(p,F),n=(n=Math.imul(p,U))+Math.imul(v,F)|0,h=Math.imul(v,U);var gt=(a+(e=e+Math.imul(m,D)|0)|0)+((8191&(n=(n=n+Math.imul(m,H)|0)+Math.imul(f,D)|0))<<13)|0;a=((h=h+Math.imul(f,H)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,e=Math.imul(g,F),n=(n=Math.imul(g,U))+Math.imul(c,F)|0,h=Math.imul(c,U),e=e+Math.imul(p,D)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(v,D)|0,h=h+Math.imul(v,H)|0;var ct=(a+(e=e+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,G)|0)+Math.imul(f,W)|0))<<13)|0;a=((h=h+Math.imul(f,G)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,e=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(b,F)|0,h=Math.imul(b,U),e=e+Math.imul(g,D)|0,n=(n=n+Math.imul(g,H)|0)+Math.imul(c,D)|0,h=h+Math.imul(c,H)|0,e=e+Math.imul(p,W)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(v,W)|0,h=h+Math.imul(v,G)|0;var wt=(a+(e=e+Math.imul(m,V)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,V)|0))<<13)|0;a=((h=h+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(A,F),n=(n=Math.imul(A,U))+Math.imul(k,F)|0,h=Math.imul(k,U),e=e+Math.imul(y,D)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(b,D)|0,h=h+Math.imul(b,H)|0,e=e+Math.imul(g,W)|0,n=(n=n+Math.imul(g,G)|0)+Math.imul(c,W)|0,h=h+Math.imul(c,G)|0,e=e+Math.imul(p,V)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(v,V)|0,h=h+Math.imul(v,X)|0;var yt=(a+(e=e+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((h=h+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(S,F),n=(n=Math.imul(S,U))+Math.imul(q,F)|0,h=Math.imul(q,U),e=e+Math.imul(A,D)|0,n=(n=n+Math.imul(A,H)|0)+Math.imul(k,D)|0,h=h+Math.imul(k,H)|0,e=e+Math.imul(y,W)|0,n=(n=n+Math.imul(y,G)|0)+Math.imul(b,W)|0,h=h+Math.imul(b,G)|0,e=e+Math.imul(g,V)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,V)|0,h=h+Math.imul(c,X)|0,e=e+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(v,$)|0,h=h+Math.imul(v,tt)|0;var bt=(a+(e=e+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,et)|0)+Math.imul(f,rt)|0))<<13)|0;a=((h=h+Math.imul(f,et)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(B,F),n=(n=Math.imul(B,U))+Math.imul(R,F)|0,h=Math.imul(R,U),e=e+Math.imul(S,D)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(q,D)|0,h=h+Math.imul(q,H)|0,e=e+Math.imul(A,W)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(k,W)|0,h=h+Math.imul(k,G)|0,e=e+Math.imul(y,V)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,V)|0,h=h+Math.imul(b,X)|0,e=e+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,h=h+Math.imul(c,tt)|0,e=e+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,et)|0)+Math.imul(v,rt)|0,h=h+Math.imul(v,et)|0;var _t=(a+(e=e+Math.imul(m,ht)|0)|0)+((8191&(n=(n=n+Math.imul(m,st)|0)+Math.imul(f,ht)|0))<<13)|0;a=((h=h+Math.imul(f,st)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(L,F),n=(n=Math.imul(L,U))+Math.imul(I,F)|0,h=Math.imul(I,U),e=e+Math.imul(B,D)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(R,D)|0,h=h+Math.imul(R,H)|0,e=e+Math.imul(S,W)|0,n=(n=n+Math.imul(S,G)|0)+Math.imul(q,W)|0,h=h+Math.imul(q,G)|0,e=e+Math.imul(A,V)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(k,V)|0,h=h+Math.imul(k,X)|0,e=e+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,h=h+Math.imul(b,tt)|0,e=e+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,et)|0)+Math.imul(c,rt)|0,h=h+Math.imul(c,et)|0,e=e+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(v,ht)|0,h=h+Math.imul(v,st)|0;var At=(a+(e=e+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((h=h+Math.imul(f,at)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(O,F),n=(n=Math.imul(O,U))+Math.imul(z,F)|0,h=Math.imul(z,U),e=e+Math.imul(L,D)|0,n=(n=n+Math.imul(L,H)|0)+Math.imul(I,D)|0,h=h+Math.imul(I,H)|0,e=e+Math.imul(B,W)|0,n=(n=n+Math.imul(B,G)|0)+Math.imul(R,W)|0,h=h+Math.imul(R,G)|0,e=e+Math.imul(S,V)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(q,V)|0,h=h+Math.imul(q,X)|0,e=e+Math.imul(A,$)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(k,$)|0,h=h+Math.imul(k,tt)|0,e=e+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,et)|0)+Math.imul(b,rt)|0,h=h+Math.imul(b,et)|0,e=e+Math.imul(g,ht)|0,n=(n=n+Math.imul(g,st)|0)+Math.imul(c,ht)|0,h=h+Math.imul(c,st)|0,e=e+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(v,ut)|0,h=h+Math.imul(v,at)|0;var kt=(a+(e=e+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((h=h+Math.imul(f,ft)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,e=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(P,F)|0,h=Math.imul(P,U),e=e+Math.imul(O,D)|0,n=(n=n+Math.imul(O,H)|0)+Math.imul(z,D)|0,h=h+Math.imul(z,H)|0,e=e+Math.imul(L,W)|0,n=(n=n+Math.imul(L,G)|0)+Math.imul(I,W)|0,h=h+Math.imul(I,G)|0,e=e+Math.imul(B,V)|0,n=(n=n+Math.imul(B,X)|0)+Math.imul(R,V)|0,h=h+Math.imul(R,X)|0,e=e+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(q,$)|0,h=h+Math.imul(q,tt)|0,e=e+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,et)|0)+Math.imul(k,rt)|0,h=h+Math.imul(k,et)|0,e=e+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,st)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,st)|0,e=e+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,h=h+Math.imul(c,at)|0,e=e+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(v,mt)|0,h=h+Math.imul(v,ft)|0;var xt=(a+(e=e+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,vt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((h=h+Math.imul(f,vt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,e=Math.imul(j,D),n=(n=Math.imul(j,H))+Math.imul(P,D)|0,h=Math.imul(P,H),e=e+Math.imul(O,W)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(z,W)|0,h=h+Math.imul(z,G)|0,e=e+Math.imul(L,V)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,V)|0,h=h+Math.imul(I,X)|0,e=e+Math.imul(B,$)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(R,$)|0,h=h+Math.imul(R,tt)|0,e=e+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,et)|0)+Math.imul(q,rt)|0,h=h+Math.imul(q,et)|0,e=e+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,st)|0)+Math.imul(k,ht)|0,h=h+Math.imul(k,st)|0,e=e+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,h=h+Math.imul(b,at)|0,e=e+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,h=h+Math.imul(c,ft)|0;var St=(a+(e=e+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,vt)|0)+Math.imul(v,pt)|0))<<13)|0;a=((h=h+Math.imul(v,vt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(j,W),n=(n=Math.imul(j,G))+Math.imul(P,W)|0,h=Math.imul(P,G),e=e+Math.imul(O,V)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(z,V)|0,h=h+Math.imul(z,X)|0,e=e+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,h=h+Math.imul(I,tt)|0,e=e+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,et)|0)+Math.imul(R,rt)|0,h=h+Math.imul(R,et)|0,e=e+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,st)|0)+Math.imul(q,ht)|0,h=h+Math.imul(q,st)|0,e=e+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(k,ut)|0,h=h+Math.imul(k,at)|0,e=e+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,ft)|0;var qt=(a+(e=e+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,vt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((h=h+Math.imul(c,vt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,e=Math.imul(j,V),n=(n=Math.imul(j,X))+Math.imul(P,V)|0,h=Math.imul(P,X),e=e+Math.imul(O,$)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(z,$)|0,h=h+Math.imul(z,tt)|0,e=e+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,et)|0)+Math.imul(I,rt)|0,h=h+Math.imul(I,et)|0,e=e+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,st)|0)+Math.imul(R,ht)|0,h=h+Math.imul(R,st)|0,e=e+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(q,ut)|0,h=h+Math.imul(q,at)|0,e=e+Math.imul(A,mt)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(k,mt)|0,h=h+Math.imul(k,ft)|0;var Zt=(a+(e=e+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,vt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((h=h+Math.imul(b,vt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,e=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(P,$)|0,h=Math.imul(P,tt),e=e+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,et)|0)+Math.imul(z,rt)|0,h=h+Math.imul(z,et)|0,e=e+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,st)|0)+Math.imul(I,ht)|0,h=h+Math.imul(I,st)|0,e=e+Math.imul(B,ut)|0,n=(n=n+Math.imul(B,at)|0)+Math.imul(R,ut)|0,h=h+Math.imul(R,at)|0,e=e+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(q,mt)|0,h=h+Math.imul(q,ft)|0;var Bt=(a+(e=e+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,vt)|0)+Math.imul(k,pt)|0))<<13)|0;a=((h=h+Math.imul(k,vt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,e=Math.imul(j,rt),n=(n=Math.imul(j,et))+Math.imul(P,rt)|0,h=Math.imul(P,et),e=e+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(z,ht)|0,h=h+Math.imul(z,st)|0,e=e+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,h=h+Math.imul(I,at)|0,e=e+Math.imul(B,mt)|0,n=(n=n+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,h=h+Math.imul(R,ft)|0;var Rt=(a+(e=e+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,vt)|0)+Math.imul(q,pt)|0))<<13)|0;a=((h=h+Math.imul(q,vt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul(j,ht),n=(n=Math.imul(j,st))+Math.imul(P,ht)|0,h=Math.imul(P,st),e=e+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(z,ut)|0,h=h+Math.imul(z,at)|0,e=e+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,h=h+Math.imul(I,ft)|0;var Nt=(a+(e=e+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,vt)|0)+Math.imul(R,pt)|0))<<13)|0;a=((h=h+Math.imul(R,vt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,e=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(P,ut)|0,h=Math.imul(P,at),e=e+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(z,mt)|0,h=h+Math.imul(z,ft)|0;var Lt=(a+(e=e+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,vt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((h=h+Math.imul(I,vt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,e=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(P,mt)|0,h=Math.imul(P,ft);var It=(a+(e=e+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,vt)|0)+Math.imul(z,pt)|0))<<13)|0;a=((h=h+Math.imul(z,vt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var Et=(a+(e=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,vt))+Math.imul(P,pt)|0))<<13)|0;return a=((h=Math.imul(P,vt))+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,u[0]=Mt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=At,u[8]=kt,u[9]=xt,u[10]=St,u[11]=qt,u[12]=Zt,u[13]=Bt,u[14]=Rt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=Et,0!==a&&(u[19]=a,r.length++),r};function p(t,i,r){return(new v).mulp(t,i,r)}function v(t,i){this.x=t,this.y=i}Math.imul||(d=f),n.prototype.mulTo=function(t,i){var r,e=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,i):e<63?f(this,t,i):e<1024?function(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var e=0,n=0,h=0;h<r.length-1;h++){var s=n;n=0;for(var o=67108863&e,u=Math.min(h,i.length-1),a=Math.max(0,h-t.length+1);a<=u;a++){var l=h-a,m=(0|t.words[l])*(0|i.words[a]),f=67108863&m;o=67108863&(f=f+o|0),n+=(s=(s=s+(m/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}r.words[h]=o,e=s,s=n}return 0!==e?r.words[h]=e:r.length--,r.strip()}(this,t,i):p(this,t,i),r},v.prototype.makeRBT=function(t){for(var i=Array(t),r=n.prototype._countBits(t)-1,e=0;e<t;e++)i[e]=this.revBin(e,r,t);return i},v.prototype.revBin=function(t,i,r){if(0===t||t===r-1)return t;for(var e=0,n=0;n<i;n++)e|=(1&t)<<i-n-1,t>>=1;return e},v.prototype.permute=function(t,i,r,e,n,h){for(var s=0;s<h;s++)e[s]=i[t[s]],n[s]=r[t[s]]},v.prototype.transform=function(t,i,r,e,n,h){this.permute(h,t,i,r,e,n);for(var s=1;s<n;s<<=1)for(var o=s<<1,u=Math.cos(2*Math.PI/o),a=Math.sin(2*Math.PI/o),l=0;l<n;l+=o)for(var m=u,f=a,d=0;d<s;d++){var p=r[l+d],v=e[l+d],M=r[l+d+s],g=e[l+d+s],c=m*M-f*g;g=m*g+f*M,M=c,r[l+d]=p+M,e[l+d]=v+g,r[l+d+s]=p-M,e[l+d+s]=v-g,d!==o&&(c=u*m-a*f,f=u*f+a*m,m=c)}},v.prototype.guessLen13b=function(t,i){var r=1|Math.max(i,t),e=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+e},v.prototype.conjugate=function(t,i,r){if(!(r<=1))for(var e=0;e<r/2;e++){var n=t[e];t[e]=t[r-e-1],t[r-e-1]=n,n=i[e],i[e]=-i[r-e-1],i[r-e-1]=-n}},v.prototype.normalize13b=function(t,i){for(var r=0,e=0;e<i/2;e++){var n=8192*Math.round(t[2*e+1]/i)+Math.round(t[2*e]/i)+r;t[e]=67108863&n,r=n<67108864?0:n/67108864|0}return t},v.prototype.convert13b=function(t,i,e,n){for(var h=0,s=0;s<i;s++)h+=0|t[s],e[2*s]=8191&h,h>>>=13,e[2*s+1]=8191&h,h>>>=13;for(s=2*i;s<n;++s)e[s]=0;r(0===h),r(!(-8192&h))},v.prototype.stub=function(t){for(var i=Array(t),r=0;r<t;r++)i[r]=0;return i},v.prototype.mulp=function(t,i,r){var e=2*this.guessLen13b(t.length,i.length),n=this.makeRBT(e),h=this.stub(e),s=Array(e),o=Array(e),u=Array(e),a=Array(e),l=Array(e),m=Array(e),f=r.words;f.length=e,this.convert13b(t.words,t.length,s,e),this.convert13b(i.words,i.length,a,e),this.transform(s,h,o,u,e,n),this.transform(a,h,l,m,e,n);for(var d=0;d<e;d++){var p=o[d]*l[d]-u[d]*m[d];u[d]=o[d]*m[d]+u[d]*l[d],o[d]=p}return this.conjugate(o,u,e),this.transform(o,u,f,h,e,n),this.conjugate(f,h,e),this.normalize13b(f,e),r.negative=t.negative^i.negative,r.length=t.length+i.length,r.strip()},n.prototype.mul=function(t){var i=new n(null);return i.words=Array(this.length+t.length),this.mulTo(t,i)},n.prototype.mulf=function(t){var i=new n(null);return i.words=Array(this.length+t.length),p(this,t,i)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var i=0,e=0;e<this.length;e++){var n=(0|this.words[e])*t,h=(67108863&n)+(67108863&i);i>>=26,i+=n/67108864|0,i+=h>>>26,this.words[e]=67108863&h}return 0!==i&&(this.words[e]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=Array(t.bitLength()),r=0;r<i.length;r++){var e=r/26|0,n=r%26;i[r]=(t.words[e]&1<<n)>>>n}return i}(t);if(0===i.length)return new n(1);for(var r=this,e=0;e<i.length&&0===i[e];e++,r=r.sqr());if(++e<i.length)for(var h=r.sqr();e<i.length;e++,h=h.sqr())0!==i[e]&&(r=r.mul(h));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var i,e=t%26,n=(t-e)/26,h=67108863>>>26-e<<26-e;if(0!==e){var s=0;for(i=0;i<this.length;i++){var o=this.words[i]&h,u=(0|this.words[i])-o<<e;this.words[i]=u|s,s=o>>>26-e}s&&(this.words[i]=s,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this.strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,i,e){var n;r("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var h=t%26,s=Math.min((t-h)/26,this.length),o=67108863^67108863>>>h<<h,u=e;if(n=Math.max(0,n-=s),u){for(var a=0;a<s;a++)u.words[a]=this.words[a];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,a=0;a<this.length;a++)this.words[a]=this.words[a+s];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-h|m>>>h,l=m&o}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,e){return r(0===this.negative),this.iushrn(t,i,e)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,e=(t-i)/26,n=1<<i;return!(this.length<=e||!(this.words[e]&n))},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var i=t%26,e=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=e)return this;if(0!==i&&e++,this.length=Math.min(e,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this.strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,i,e){var n,h,s=t.length+e;this._expand(s);var o=0;for(n=0;n<t.length;n++){h=(0|this.words[n+e])+o;var u=(0|t.words[n])*i;o=((h-=67108863&u)>>26)-(u/67108864|0),this.words[n+e]=67108863&h}for(;n<this.length-e;n++)o=(h=(0|this.words[n+e])+o)>>26,this.words[n+e]=67108863&h;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n<this.length;n++)o=(h=-(0|this.words[n])+o)>>26,this.words[n]=67108863&h;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=(this.length,t.length),e=this.clone(),h=t,s=0|h.words[h.length-1];0!=(r=26-this._countBits(s))&&(h=h.ushln(r),e.iushln(r),s=0|h.words[h.length-1]);var o,u=e.length-h.length;if("mod"!==i){(o=new n(null)).length=u+1,o.words=Array(o.length);for(var a=0;a<o.length;a++)o.words[a]=0}var l=e.clone()._ishlnsubmul(h,1,u);0===l.negative&&(e=l,o&&(o.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|e.words[h.length+m])+(0|e.words[h.length+m-1]);for(f=Math.min(f/s|0,67108863),e._ishlnsubmul(h,f,m);0!==e.negative;)f--,e.negative=0,e._ishlnsubmul(h,1,m),e.isZero()||(e.negative^=1);o&&(o.words[m]=f)}return o&&o.strip(),e.strip(),"div"!==i&&0!==r&&e.iushrn(r),{div:o||null,mod:e}},n.prototype.divmod=function(t,i,e){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,i),"mod"!==i&&(h=o.div.neg()),"div"!==i&&(s=o.mod.neg(),e&&0!==s.negative&&s.iadd(t)),{div:h,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),i),"mod"!==i&&(h=o.div.neg()),{div:h,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),i),"div"!==i&&(s=o.mod.neg(),e&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i);var h,s,o},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,e=t.ushrn(1),n=t.andln(1),h=r.cmp(e);return h<0||1===n&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,e=0,n=this.length-1;n>=0;n--)e=(i*e+(0|this.words[n]))%t;return e},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,e=this.length-1;e>=0;e--){var n=(0|this.words[e])+67108864*i;this.words[e]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,e=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h=new n(1),s=new n(0),o=new n(0),u=new n(1),a=0;i.isEven()&&e.isEven();)i.iushrn(1),e.iushrn(1),++a;for(var l=e.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;!(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(h.isOdd()||s.isOdd())&&(h.iadd(l),s.isub(m)),h.iushrn(1),s.iushrn(1);for(var p=0,v=1;!(e.words[0]&v)&&p<26;++p,v<<=1);if(p>0)for(e.iushrn(p);p-- >0;)(o.isOdd()||u.isOdd())&&(o.iadd(l),u.isub(m)),o.iushrn(1),u.iushrn(1);i.cmp(e)>=0?(i.isub(e),h.isub(o),s.isub(u)):(e.isub(i),o.isub(h),u.isub(s))}return{a:o,b:u,gcd:e.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,e=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var h,s=new n(1),o=new n(0),u=e.clone();i.cmpn(1)>0&&e.cmpn(1)>0;){for(var a=0,l=1;!(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var m=0,f=1;!(e.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(e.iushrn(m);m-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);i.cmp(e)>=0?(i.isub(e),s.isub(o)):(e.isub(i),o.isub(s))}return(h=0===i.cmpn(1)?s:o).cmpn(0)<0&&h.iadd(t),h},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var e=0;i.isEven()&&r.isEven();e++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var h=i;i=r,r=h}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(e)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,e=(t-i)/26,n=1<<i;if(this.length<=e)return this._expand(e+1),this.words[e]|=n,this;for(var h=n,s=e;0!==h&&s<this.length;s++){var o=0|this.words[s];h=(o+=h)>>>26,o&=67108863,this.words[s]=o}return 0!==h&&(this.words[s]=h,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,e=t<0;if(0!==this.negative&&!e)return-1;if(0===this.negative&&e)return 1;if(this.strip(),this.length>1)i=1;else{e&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,r=this.length-1;r>=0;r--){var e=0|this.words[r],n=0|t.words[r];if(e!==n){e<n?i=-1:e>n&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function g(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function c(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function y(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new n(null);return t.words=Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var e=i<this.n?-1:r.ucmp(this.p);return 0===e?(r.words[0]=0,r.length=1):e>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},g.prototype.split=function(t,i){t.iushrn(this.n,0,i)},g.prototype.imulK=function(t){return t.imul(this.k)},e(c,g),c.prototype.split=function(t,i){for(var r=4194303,e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var h=t.words[9];for(i.words[i.length++]=h&r,n=10;n<t.length;n++){var s=0|t.words[n];t.words[n-10]=(s&r)<<4|h>>>22,h=s}h>>>=22,t.words[n-10]=h,0===h&&t.length>10?t.length-=10:t.length-=9},c.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r<t.length;r++){var e=0|t.words[r];i+=977*e,t.words[r]=67108863&i,i=64*e+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},e(w,g),e(y,g),e(b,g),b.prototype.imulK=function(t){for(var i=0,r=0;r<t.length;r++){var e=19*(0|t.words[r])+i,n=67108863&e;e>>>=26,t.words[r]=n,i=e}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(M[t])return M[t];var i;if("k256"===t)i=new c;else if("p224"===t)i=new w;else if("p192"===t)i=new y;else{if("p25519"!==t)throw Error("Unknown prime "+t);i=new b}return M[t]=i,i},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,i){r(!(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},_.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},_.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var e=this.m.add(new n(1)).iushrn(2);return this.pow(t,e)}for(var h=this.m.subn(1),s=0;!h.isZero()&&0===h.andln(1);)s++,h.iushrn(1);r(!h.isZero());var o=new n(1).toRed(this),u=o.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,h),f=this.pow(t,h.addn(1).iushrn(1)),d=this.pow(t,h),p=s;0!==d.cmp(o);){for(var v=d,M=0;0!==v.cmp(o);M++)v=v.redSqr();r(M<p);var g=this.pow(m,new n(1).iushln(p-M-1));f=f.redMul(g),m=g.redSqr(),d=d.redMul(m),p=M}return f},_.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},_.prototype.pow=function(t,i){if(i.isZero())return new n(1).toRed(this);if(0===i.cmpn(1))return t.clone();var r=Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var e=2;e<r.length;e++)r[e]=this.mul(r[e-1],t);var h=r[0],s=0,o=0,u=i.bitLength()%26;for(0===u&&(u=26),e=i.length-1;e>=0;e--){for(var a=i.words[e],l=u-1;l>=0;l--){var m=a>>l&1;h!==r[0]&&(h=this.sqr(h)),0!==m||0!==s?(s<<=1,s|=m,(4==++o||0===e&&0===l)&&(h=this.mul(h,r[s]),o=0,s=0)):o=0}u=26}return h},_.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},_.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new A(t)},e(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},A.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(e).iushrn(this.shift),h=n;return n.cmp(this.m)>=0?h=n.isub(this.m):n.cmpn(0)<0&&(h=n.iadd(this.m)),h._forceRed(this)},A.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),h=r.isub(e).iushrn(this.shift),s=h;return h.cmp(this.m)>=0?s=h.isub(this.m):h.cmpn(0)<0&&(s=h.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{});var n=/*@__PURE__*/r(e.exports);class h extends i{constructor(t){if(super(),void 0===t)throw Error("Invalid BigInteger input");const i=("string"==typeof t||t instanceof String)&&t.startsWith("0x");this.value=i?new n(t.substring(2),16):new n(t)}clone(){return new h(this.value.clone())}iinc(){return this.value.iadd(new n(1)),this}inc(){return this.clone().iinc()}idec(){return this.value.isub(new n(1)),this}dec(){return this.clone().idec()}iadd(t){return this.value.iadd(t.value),this}add(t){return this.clone().iadd(t)}isub(t){return this.value.isub(t.value),this}sub(t){return this.clone().isub(t)}imul(t){return this.value.imul(t.value),this}mul(t){return this.clone().imul(t)}imod(t){return this.value=this.value.umod(t.value),this}mod(t){return this.clone().imod(t)}modExp(t,i){const r=i.isEven()?n.red(i.value):n.mont(i.value),e=this.clone();return e.value=e.value.toRed(r).redPow(t.value).fromRed(),e}modInv(t){if(!this.gcd(t).isOne())throw Error("Inverse does not exist");return new h(this.value.invm(t.value))}idiv(t){return this.value=this.value.div(t.value),this}div(t){return this.clone().idiv(t)}gcd(t){return new h(this.value.gcd(t.value))}ileftShift(t){return t.isNegative()?this.irightShift(t.negate()):(this.value.ishln(t.value.toNumber()),this)}leftShift(t){return this.clone().ileftShift(t)}irightShift(t){return t.isNegative()?this.ileftShift(t.negate()):(this.value.ishrn(t.value.toNumber()),this)}rightShift(t){return this.clone().irightShift(t)}ixor(t){return this.value.ixor(t.value),this}xor(t){return this.clone().ixor(t)}ibitwiseAnd(t){return this.value.iand(t.value),this}bitwiseAnd(t){return this.clone().ibitwiseAnd(t)}ibitwiseOr(t){return this.value.ior(t.value),this}equal(t){return this.value.eq(t.value)}lt(t){return this.value.lt(t.value)}lte(t){return this.value.lte(t.value)}gt(t){return this.value.gt(t.value)}gte(t){return this.value.gte(t.value)}isZero(){return this.value.isZero()}isOne(){return this.value.eq(new n(1))}isNegative(){return this.value.isNeg()}isEven(){return this.value.isEven()}abs(){const t=this.clone();return t.value=t.value.abs(),t}negate(){const t=this.clone();return t.value.ineg(),t}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}getBit(t){return this.value.testn(t)?1:0}bitLength(){return this.value.bitLength()}byteLength(){return this.value.byteLength()}toUint8Array(t="be",i){return this.value.toArrayLike(Uint8Array,t,i)}}export{h as default};
3
- //# sourceMappingURL=bn.interface.min.mjs.map