@mysten/sui 2.35.0 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/bcs.d.mts.map +1 -1
  4. package/dist/bcs/bcs.mjs +52 -16
  5. package/dist/bcs/bcs.mjs.map +1 -1
  6. package/dist/bcs/index.d.mts +12 -3
  7. package/dist/bcs/index.d.mts.map +1 -1
  8. package/dist/cryptography/publickey.mjs +1 -0
  9. package/dist/cryptography/publickey.mjs.map +1 -1
  10. package/dist/cryptography/signature-scheme.d.mts +4 -1
  11. package/dist/cryptography/signature-scheme.d.mts.map +1 -1
  12. package/dist/cryptography/signature-scheme.mjs +6 -3
  13. package/dist/cryptography/signature-scheme.mjs.map +1 -1
  14. package/dist/cryptography/signature.d.mts +1 -1
  15. package/dist/cryptography/signature.mjs +2 -1
  16. package/dist/cryptography/signature.mjs.map +1 -1
  17. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  18. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  19. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  20. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  21. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  22. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  23. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  24. package/dist/keypairs/mldsa65/index.d.mts +3 -0
  25. package/dist/keypairs/mldsa65/index.mjs +4 -0
  26. package/dist/keypairs/mldsa65/keypair.d.mts +67 -0
  27. package/dist/keypairs/mldsa65/keypair.d.mts.map +1 -0
  28. package/dist/keypairs/mldsa65/keypair.mjs +91 -0
  29. package/dist/keypairs/mldsa65/keypair.mjs.map +1 -0
  30. package/dist/keypairs/mldsa65/publickey.d.mts +37 -0
  31. package/dist/keypairs/mldsa65/publickey.d.mts.map +1 -0
  32. package/dist/keypairs/mldsa65/publickey.mjs +64 -0
  33. package/dist/keypairs/mldsa65/publickey.mjs.map +1 -0
  34. package/dist/multisig/publickey.d.mts +18 -3
  35. package/dist/multisig/publickey.d.mts.map +1 -1
  36. package/dist/multisig/publickey.mjs +29 -11
  37. package/dist/multisig/publickey.mjs.map +1 -1
  38. package/dist/transactions/Transaction.d.mts +6 -6
  39. package/dist/verify/verify.d.mts.map +1 -1
  40. package/dist/verify/verify.mjs +6 -2
  41. package/dist/verify/verify.mjs.map +1 -1
  42. package/dist/version.mjs +1 -1
  43. package/dist/version.mjs.map +1 -1
  44. package/dist/zklogin/address-seed.d.mts +6 -0
  45. package/dist/zklogin/address-seed.d.mts.map +1 -0
  46. package/dist/zklogin/address-seed.mjs +51 -0
  47. package/dist/zklogin/address-seed.mjs.map +1 -0
  48. package/dist/zklogin/address.d.mts.map +1 -1
  49. package/dist/zklogin/address.mjs +2 -1
  50. package/dist/zklogin/address.mjs.map +1 -1
  51. package/dist/zklogin/bcs.d.mts +14 -14
  52. package/dist/zklogin/index.d.mts +2 -1
  53. package/dist/zklogin/index.mjs +3 -2
  54. package/dist/zklogin/nonce.mjs +1 -1
  55. package/dist/zklogin/publickey.d.mts.map +1 -1
  56. package/dist/zklogin/publickey.mjs +2 -2
  57. package/dist/zklogin/publickey.mjs.map +1 -1
  58. package/dist/zklogin/utils.d.mts +1 -3
  59. package/dist/zklogin/utils.d.mts.map +1 -1
  60. package/dist/zklogin/utils.mjs +1 -46
  61. package/dist/zklogin/utils.mjs.map +1 -1
  62. package/docs/cryptography/index.md +7 -6
  63. package/docs/cryptography/keypairs.md +13 -1
  64. package/docs/llms-index.md +1 -1
  65. package/package.json +9 -3
  66. package/src/bcs/bcs.ts +73 -14
  67. package/src/cryptography/publickey.ts +1 -0
  68. package/src/cryptography/signature-scheme.ts +4 -1
  69. package/src/cryptography/signature.ts +1 -0
  70. package/src/keypairs/mldsa65/index.ts +5 -0
  71. package/src/keypairs/mldsa65/keypair.ts +128 -0
  72. package/src/keypairs/mldsa65/publickey.ts +95 -0
  73. package/src/multisig/publickey.ts +68 -23
  74. package/src/verify/verify.ts +8 -2
  75. package/src/version.ts +1 -1
  76. package/src/zklogin/address-seed.ts +86 -0
  77. package/src/zklogin/address.ts +2 -6
  78. package/src/zklogin/index.ts +1 -2
  79. package/src/zklogin/publickey.ts +4 -4
  80. package/src/zklogin/utils.ts +0 -83
@@ -1,6 +1,6 @@
1
1
  import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
2
- import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts
@@ -31,9 +31,9 @@ interface IMovePackageServiceClient {
31
31
  declare class MovePackageServiceClient implements IMovePackageServiceClient, ServiceInfo {
32
32
  private readonly _transport;
33
33
  typeName: string;
34
- methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
34
+ methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
35
35
  options: {
36
- [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
36
+ [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
37
37
  };
38
38
  constructor(_transport: RpcTransport);
39
39
  /**
@@ -1,6 +1,6 @@
1
1
  import { LookupNameRequest, LookupNameResponse, ReverseLookupNameRequest, ReverseLookupNameResponse } from "./name_service.mjs";
2
- import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime6 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc6 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/name_service.client.d.ts
@@ -23,9 +23,9 @@ interface INameServiceClient {
23
23
  declare class NameServiceClient implements INameServiceClient, ServiceInfo {
24
24
  private readonly _transport;
25
25
  typeName: string;
26
- methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
26
+ methods: _protobuf_ts_runtime_rpc6.MethodInfo<any, any>[];
27
27
  options: {
28
- [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
28
+ [extensionName: string]: _protobuf_ts_runtime6.JsonValue;
29
29
  };
30
30
  constructor(_transport: RpcTransport);
31
31
  /**
@@ -1,6 +1,6 @@
1
1
  import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
2
- import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts
@@ -21,9 +21,9 @@ interface ISignatureVerificationServiceClient {
21
21
  declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
22
22
  private readonly _transport;
23
23
  typeName: string;
24
- methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
24
+ methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
25
25
  options: {
26
- [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
26
+ [extensionName: string]: _protobuf_ts_runtime3.JsonValue;
27
27
  };
28
28
  constructor(_transport: RpcTransport);
29
29
  /**
@@ -1,6 +1,6 @@
1
1
  import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
2
- import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
@@ -35,9 +35,9 @@ interface IStateServiceClient {
35
35
  declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
36
36
  private readonly _transport;
37
37
  typeName: string;
38
- methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
38
+ methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
39
39
  options: {
40
- [extensionName: string]: _protobuf_ts_runtime3.JsonValue;
40
+ [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
41
41
  };
42
42
  constructor(_transport: RpcTransport);
43
43
  /**
@@ -1,6 +1,6 @@
1
1
  import { ExecuteTransactionRequest, ExecuteTransactionResponse, SimulateTransactionRequest, SimulateTransactionResponse } from "./transaction_execution_service.mjs";
2
- import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts
@@ -23,9 +23,9 @@ interface ITransactionExecutionServiceClient {
23
23
  declare class TransactionExecutionServiceClient implements ITransactionExecutionServiceClient, ServiceInfo {
24
24
  private readonly _transport;
25
25
  typeName: string;
26
- methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
26
+ methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
27
27
  options: {
28
- [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
28
+ [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
29
29
  };
30
30
  constructor(_transport: RpcTransport);
31
31
  /**
@@ -0,0 +1,3 @@
1
+ import { MLDSA65PublicKey, MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE } from "./publickey.mjs";
2
+ import { MLDSA65Keypair, MLDSA65KeypairData } from "./keypair.mjs";
3
+ export { MLDSA65Keypair, type MLDSA65KeypairData, MLDSA65PublicKey, MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE };
@@ -0,0 +1,4 @@
1
+ import { MLDSA65PublicKey, MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE } from "./publickey.mjs";
2
+ import { MLDSA65Keypair } from "./keypair.mjs";
3
+
4
+ export { MLDSA65Keypair, MLDSA65PublicKey, MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE };
@@ -0,0 +1,67 @@
1
+ import { SignatureScheme } from "../../cryptography/signature-scheme.mjs";
2
+ import { Keypair } from "../../cryptography/keypair.mjs";
3
+ import { MLDSA65PublicKey } from "./publickey.mjs";
4
+
5
+ //#region src/keypairs/mldsa65/keypair.d.ts
6
+ /**
7
+ * ML-DSA-65 Keypair data. `seed` is the 32-byte FIPS 204 seed, the only form
8
+ * that is ever exported or stored (`suiprivkey`, keystore). `secretKey` is the
9
+ * 4032-byte signing key expanded from it, kept so signing does not re-expand.
10
+ */
11
+ interface MLDSA65KeypairData {
12
+ seed: Uint8Array;
13
+ secretKey: Uint8Array;
14
+ publicKey: Uint8Array;
15
+ }
16
+ /**
17
+ * An ML-DSA-65 (FIPS 204) Keypair used for signing transactions.
18
+ */
19
+ declare class MLDSA65Keypair extends Keypair {
20
+ private keypair;
21
+ /**
22
+ * Create a new ML-DSA-65 keypair instance.
23
+ * Generate random keypair if no {@link MLDSA65Keypair} is provided.
24
+ *
25
+ * @param keypair ML-DSA-65 keypair
26
+ */
27
+ constructor(keypair?: MLDSA65KeypairData);
28
+ /**
29
+ * Get the key scheme of the keypair MLDSA65
30
+ */
31
+ getKeyScheme(): SignatureScheme;
32
+ /**
33
+ * Generate a new random ML-DSA-65 keypair
34
+ */
35
+ static generate(): MLDSA65Keypair;
36
+ /**
37
+ * Create an ML-DSA-65 keypair from its 32-byte seed.
38
+ *
39
+ * @param secretKey the 32-byte seed as a byte array or Bech32 secret key string
40
+ */
41
+ static fromSecretKey(secretKey: Uint8Array | string): MLDSA65Keypair;
42
+ /**
43
+ * Generate a keypair from a 32 byte seed. Same as {@link fromSecretKey}:
44
+ * for ML-DSA-65 the seed is the secret key.
45
+ *
46
+ * @param seed seed byte array
47
+ */
48
+ static fromSeed(seed: Uint8Array): MLDSA65Keypair;
49
+ /**
50
+ * The public key for this ML-DSA-65 keypair
51
+ */
52
+ getPublicKey(): MLDSA65PublicKey;
53
+ /**
54
+ * The Bech32 secret key string for this ML-DSA-65 keypair, encoding the 32-byte seed.
55
+ */
56
+ getSecretKey(): string;
57
+ /**
58
+ * Return the signature for the provided data using ML-DSA-65.
59
+ *
60
+ * Hedged signing: 32 fresh random bytes go into every signature, so signing the
61
+ * same data twice gives two different valid signatures.
62
+ */
63
+ sign(data: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
64
+ }
65
+ //#endregion
66
+ export { MLDSA65Keypair, MLDSA65KeypairData };
67
+ //# sourceMappingURL=keypair.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.d.mts","names":[],"sources":["../../../src/keypairs/mldsa65/keypair.ts"],"mappings":";;;;;;;AAoBA;;;UAAiB,kBAAA;EAChB,IAAA,EAAM,UAAA;EACN,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,UAAA;AAAA;;;;cAMC,cAAA,SAAuB,OAAA;EAAA,QAC3B,OAAA;EAPG;;;AAMZ;;;cASa,OAAA,GAAU,kBAAA;EAYN;;;EAAhB,YAAA,CAAA,GAAgB,eAAA;EA0CM;;;EAAA,OAnCf,QAAA,CAAA,GAAY,cAAA;EA2DQ;;;;;EAAA,OAlDpB,aAAA,CAAc,SAAA,EAAW,UAAA,YAAsB,cAAA;EArCnB;;;;;;EAAA,OA+D5B,QAAA,CAAS,IAAA,EAAM,UAAA,GAAa,cAAA;EAnC5B;;;EA0CP,YAAA,CAAA,GAAgB,gBAAA;EAjCK;;;EAwCrB,YAAA,CAAA;EAdgB;;;;;;EAwBV,IAAA,CAAK,IAAA,EAAM,UAAA,GAAU,OAAA,CAAA,UAAA,CAAA,WAAA;AAAA"}
@@ -0,0 +1,91 @@
1
+ import { Keypair, PRIVATE_KEY_SIZE, decodeSuiPrivateKey, encodeSuiPrivateKey } from "../../cryptography/keypair.mjs";
2
+ import { MLDSA65PublicKey } from "./publickey.mjs";
3
+ import { randomBytes } from "@noble/hashes/utils.js";
4
+ import { ml_dsa65 } from "@noble/post-quantum/ml-dsa.js";
5
+
6
+ //#region src/keypairs/mldsa65/keypair.ts
7
+ /**
8
+ * An ML-DSA-65 (FIPS 204) Keypair used for signing transactions.
9
+ */
10
+ var MLDSA65Keypair = class MLDSA65Keypair extends Keypair {
11
+ /**
12
+ * Create a new ML-DSA-65 keypair instance.
13
+ * Generate random keypair if no {@link MLDSA65Keypair} is provided.
14
+ *
15
+ * @param keypair ML-DSA-65 keypair
16
+ */
17
+ constructor(keypair) {
18
+ super();
19
+ if (keypair) this.keypair = keypair;
20
+ else this.keypair = expand(randomBytes(PRIVATE_KEY_SIZE));
21
+ }
22
+ /**
23
+ * Get the key scheme of the keypair MLDSA65
24
+ */
25
+ getKeyScheme() {
26
+ return "MLDSA65";
27
+ }
28
+ /**
29
+ * Generate a new random ML-DSA-65 keypair
30
+ */
31
+ static generate() {
32
+ return new MLDSA65Keypair();
33
+ }
34
+ /**
35
+ * Create an ML-DSA-65 keypair from its 32-byte seed.
36
+ *
37
+ * @param secretKey the 32-byte seed as a byte array or Bech32 secret key string
38
+ */
39
+ static fromSecretKey(secretKey) {
40
+ if (typeof secretKey === "string") {
41
+ const decoded = decodeSuiPrivateKey(secretKey);
42
+ if (decoded.scheme !== "MLDSA65") throw new Error(`Expected a MLDSA65 keypair, got ${decoded.scheme}`);
43
+ return this.fromSecretKey(decoded.secretKey);
44
+ }
45
+ if (secretKey.length !== PRIVATE_KEY_SIZE) throw new Error(`Wrong secretKey size. Expected ${PRIVATE_KEY_SIZE} bytes, got ${secretKey.length}.`);
46
+ return new MLDSA65Keypair(expand(secretKey));
47
+ }
48
+ /**
49
+ * Generate a keypair from a 32 byte seed. Same as {@link fromSecretKey}:
50
+ * for ML-DSA-65 the seed is the secret key.
51
+ *
52
+ * @param seed seed byte array
53
+ */
54
+ static fromSeed(seed) {
55
+ return MLDSA65Keypair.fromSecretKey(seed);
56
+ }
57
+ /**
58
+ * The public key for this ML-DSA-65 keypair
59
+ */
60
+ getPublicKey() {
61
+ return new MLDSA65PublicKey(this.keypair.publicKey);
62
+ }
63
+ /**
64
+ * The Bech32 secret key string for this ML-DSA-65 keypair, encoding the 32-byte seed.
65
+ */
66
+ getSecretKey() {
67
+ return encodeSuiPrivateKey(this.keypair.seed, this.getKeyScheme());
68
+ }
69
+ /**
70
+ * Return the signature for the provided data using ML-DSA-65.
71
+ *
72
+ * Hedged signing: 32 fresh random bytes go into every signature, so signing the
73
+ * same data twice gives two different valid signatures.
74
+ */
75
+ async sign(data) {
76
+ return ml_dsa65.sign(data, this.keypair.secretKey);
77
+ }
78
+ };
79
+ function expand(input) {
80
+ const seed = Uint8Array.from(input);
81
+ const { publicKey, secretKey } = ml_dsa65.keygen(seed);
82
+ return {
83
+ seed,
84
+ secretKey,
85
+ publicKey
86
+ };
87
+ }
88
+
89
+ //#endregion
90
+ export { MLDSA65Keypair };
91
+ //# sourceMappingURL=keypair.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.mjs","names":[],"sources":["../../../src/keypairs/mldsa65/keypair.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { randomBytes } from '@noble/hashes/utils.js';\nimport { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';\n\nimport {\n\tdecodeSuiPrivateKey,\n\tencodeSuiPrivateKey,\n\tKeypair,\n\tPRIVATE_KEY_SIZE,\n} from '../../cryptography/keypair.js';\nimport type { SignatureScheme } from '../../cryptography/signature-scheme.js';\nimport { MLDSA65PublicKey } from './publickey.js';\n\n/**\n * ML-DSA-65 Keypair data. `seed` is the 32-byte FIPS 204 seed, the only form\n * that is ever exported or stored (`suiprivkey`, keystore). `secretKey` is the\n * 4032-byte signing key expanded from it, kept so signing does not re-expand.\n */\nexport interface MLDSA65KeypairData {\n\tseed: Uint8Array;\n\tsecretKey: Uint8Array;\n\tpublicKey: Uint8Array;\n}\n\n/**\n * An ML-DSA-65 (FIPS 204) Keypair used for signing transactions.\n */\nexport class MLDSA65Keypair extends Keypair {\n\tprivate keypair: MLDSA65KeypairData;\n\n\t/**\n\t * Create a new ML-DSA-65 keypair instance.\n\t * Generate random keypair if no {@link MLDSA65Keypair} is provided.\n\t *\n\t * @param keypair ML-DSA-65 keypair\n\t */\n\tconstructor(keypair?: MLDSA65KeypairData) {\n\t\tsuper();\n\t\tif (keypair) {\n\t\t\tthis.keypair = keypair;\n\t\t} else {\n\t\t\tthis.keypair = expand(randomBytes(PRIVATE_KEY_SIZE));\n\t\t}\n\t}\n\n\t/**\n\t * Get the key scheme of the keypair MLDSA65\n\t */\n\tgetKeyScheme(): SignatureScheme {\n\t\treturn 'MLDSA65';\n\t}\n\n\t/**\n\t * Generate a new random ML-DSA-65 keypair\n\t */\n\tstatic generate(): MLDSA65Keypair {\n\t\treturn new MLDSA65Keypair();\n\t}\n\n\t/**\n\t * Create an ML-DSA-65 keypair from its 32-byte seed.\n\t *\n\t * @param secretKey the 32-byte seed as a byte array or Bech32 secret key string\n\t */\n\tstatic fromSecretKey(secretKey: Uint8Array | string): MLDSA65Keypair {\n\t\tif (typeof secretKey === 'string') {\n\t\t\tconst decoded = decodeSuiPrivateKey(secretKey);\n\n\t\t\tif (decoded.scheme !== 'MLDSA65') {\n\t\t\t\tthrow new Error(`Expected a MLDSA65 keypair, got ${decoded.scheme}`);\n\t\t\t}\n\n\t\t\treturn this.fromSecretKey(decoded.secretKey);\n\t\t}\n\n\t\tif (secretKey.length !== PRIVATE_KEY_SIZE) {\n\t\t\tthrow new Error(\n\t\t\t\t`Wrong secretKey size. Expected ${PRIVATE_KEY_SIZE} bytes, got ${secretKey.length}.`,\n\t\t\t);\n\t\t}\n\n\t\treturn new MLDSA65Keypair(expand(secretKey));\n\t}\n\n\t/**\n\t * Generate a keypair from a 32 byte seed. Same as {@link fromSecretKey}:\n\t * for ML-DSA-65 the seed is the secret key.\n\t *\n\t * @param seed seed byte array\n\t */\n\tstatic fromSeed(seed: Uint8Array): MLDSA65Keypair {\n\t\treturn MLDSA65Keypair.fromSecretKey(seed);\n\t}\n\n\t/**\n\t * The public key for this ML-DSA-65 keypair\n\t */\n\tgetPublicKey(): MLDSA65PublicKey {\n\t\treturn new MLDSA65PublicKey(this.keypair.publicKey);\n\t}\n\n\t/**\n\t * The Bech32 secret key string for this ML-DSA-65 keypair, encoding the 32-byte seed.\n\t */\n\tgetSecretKey(): string {\n\t\treturn encodeSuiPrivateKey(this.keypair.seed, this.getKeyScheme());\n\t}\n\n\t/**\n\t * Return the signature for the provided data using ML-DSA-65.\n\t *\n\t * Hedged signing: 32 fresh random bytes go into every signature, so signing the\n\t * same data twice gives two different valid signatures.\n\t */\n\tasync sign(data: Uint8Array) {\n\t\treturn ml_dsa65.sign(data, this.keypair.secretKey) as Uint8Array<ArrayBuffer>;\n\t}\n}\n\nfunction expand(input: Uint8Array): MLDSA65KeypairData {\n\t// Own the seed: the caller may wipe or reuse its buffer, and the exported\n\t// secret key must keep matching the signing key.\n\tconst seed = Uint8Array.from(input);\n\tconst { publicKey, secretKey } = ml_dsa65.keygen(seed);\n\treturn { seed, secretKey, publicKey };\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,iBAAb,MAAa,uBAAuB,QAAQ;;;;;;;CAS3C,YAAY,SAA8B;AACzC,SAAO;AACP,MAAI,QACH,MAAK,UAAU;MAEf,MAAK,UAAU,OAAO,YAAY,iBAAiB,CAAC;;;;;CAOtD,eAAgC;AAC/B,SAAO;;;;;CAMR,OAAO,WAA2B;AACjC,SAAO,IAAI,gBAAgB;;;;;;;CAQ5B,OAAO,cAAc,WAAgD;AACpE,MAAI,OAAO,cAAc,UAAU;GAClC,MAAM,UAAU,oBAAoB,UAAU;AAE9C,OAAI,QAAQ,WAAW,UACtB,OAAM,IAAI,MAAM,mCAAmC,QAAQ,SAAS;AAGrE,UAAO,KAAK,cAAc,QAAQ,UAAU;;AAG7C,MAAI,UAAU,WAAW,iBACxB,OAAM,IAAI,MACT,kCAAkC,iBAAiB,cAAc,UAAU,OAAO,GAClF;AAGF,SAAO,IAAI,eAAe,OAAO,UAAU,CAAC;;;;;;;;CAS7C,OAAO,SAAS,MAAkC;AACjD,SAAO,eAAe,cAAc,KAAK;;;;;CAM1C,eAAiC;AAChC,SAAO,IAAI,iBAAiB,KAAK,QAAQ,UAAU;;;;;CAMpD,eAAuB;AACtB,SAAO,oBAAoB,KAAK,QAAQ,MAAM,KAAK,cAAc,CAAC;;;;;;;;CASnE,MAAM,KAAK,MAAkB;AAC5B,SAAO,SAAS,KAAK,MAAM,KAAK,QAAQ,UAAU;;;AAIpD,SAAS,OAAO,OAAuC;CAGtD,MAAM,OAAO,WAAW,KAAK,MAAM;CACnC,MAAM,EAAE,WAAW,cAAc,SAAS,OAAO,KAAK;AACtD,QAAO;EAAE;EAAM;EAAW;EAAW"}
@@ -0,0 +1,37 @@
1
+ import { PublicKey, PublicKeyInitData } from "../../cryptography/publickey.mjs";
2
+
3
+ //#region src/keypairs/mldsa65/publickey.d.ts
4
+ declare const MLDSA65_PUBLIC_KEY_SIZE = 1952;
5
+ declare const MLDSA65_SIGNATURE_SIZE = 3309;
6
+ /**
7
+ * An ML-DSA-65 (FIPS 204) public key
8
+ */
9
+ declare class MLDSA65PublicKey extends PublicKey {
10
+ static SIZE: number;
11
+ private data;
12
+ /**
13
+ * Create a new MLDSA65PublicKey object
14
+ * @param value ML-DSA-65 public key as buffer or base-64 encoded string
15
+ */
16
+ constructor(value: PublicKeyInitData);
17
+ /**
18
+ * Checks if two ML-DSA-65 public keys are equal
19
+ */
20
+ equals(publicKey: MLDSA65PublicKey): boolean;
21
+ /**
22
+ * Return the byte array representation of the ML-DSA-65 public key
23
+ */
24
+ toRawBytes(): Uint8Array<ArrayBuffer>;
25
+ /**
26
+ * Return the signature scheme flag of the ML-DSA-65 public key
27
+ */
28
+ flag(): number;
29
+ /**
30
+ * Verifies that the signature is valid for for the provided message.
31
+ * Pure ML-DSA-65 with an empty context string.
32
+ */
33
+ verify(message: Uint8Array, signature: Uint8Array | string): Promise<boolean>;
34
+ }
35
+ //#endregion
36
+ export { MLDSA65PublicKey, MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE };
37
+ //# sourceMappingURL=publickey.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publickey.d.mts","names":[],"sources":["../../../src/keypairs/mldsa65/publickey.ts"],"mappings":";;;cAca,uBAAA;AAAA,cACA,sBAAA;;;;cAKA,gBAAA,SAAyB,SAAA;EAAA,OAC9B,IAAA;EAAA,QACC,IAAA;;;;AAFT;cAQa,KAAA,EAAO,iBAAA;;;;EAqBV,MAAA,CAAO,SAAA,EAAW,gBAAA;EAOb;;;EAAd,UAAA,CAAA,GAAc,UAAA,CAAW,WAAA;EApCY;;;EA2CrC,IAAA,CAAA;EA1CO;;;;EAkDD,MAAA,CAAO,OAAA,EAAS,UAAA,EAAY,SAAA,EAAW,UAAA,YAAsB,OAAA;AAAA"}
@@ -0,0 +1,64 @@
1
+ import { SIGNATURE_SCHEME_TO_FLAG } from "../../cryptography/signature-scheme.mjs";
2
+ import { PublicKey, bytesEqual, parseSerializedKeypairSignature } from "../../cryptography/publickey.mjs";
3
+ import { fromBase64 } from "@mysten/bcs";
4
+ import { ml_dsa65 } from "@noble/post-quantum/ml-dsa.js";
5
+
6
+ //#region src/keypairs/mldsa65/publickey.ts
7
+ const MLDSA65_PUBLIC_KEY_SIZE = 1952;
8
+ const MLDSA65_SIGNATURE_SIZE = 3309;
9
+ /**
10
+ * An ML-DSA-65 (FIPS 204) public key
11
+ */
12
+ var MLDSA65PublicKey = class extends PublicKey {
13
+ static {
14
+ this.SIZE = MLDSA65_PUBLIC_KEY_SIZE;
15
+ }
16
+ /**
17
+ * Create a new MLDSA65PublicKey object
18
+ * @param value ML-DSA-65 public key as buffer or base-64 encoded string
19
+ */
20
+ constructor(value) {
21
+ super();
22
+ if (typeof value === "string") this.data = fromBase64(value);
23
+ else if (value instanceof Uint8Array) this.data = value;
24
+ else this.data = Uint8Array.from(value);
25
+ if (this.data.length !== MLDSA65_PUBLIC_KEY_SIZE) throw new Error(`Invalid public key input. Expected ${MLDSA65_PUBLIC_KEY_SIZE} bytes, got ${this.data.length}`);
26
+ }
27
+ /**
28
+ * Checks if two ML-DSA-65 public keys are equal
29
+ */
30
+ equals(publicKey) {
31
+ return super.equals(publicKey);
32
+ }
33
+ /**
34
+ * Return the byte array representation of the ML-DSA-65 public key
35
+ */
36
+ toRawBytes() {
37
+ return this.data;
38
+ }
39
+ /**
40
+ * Return the signature scheme flag of the ML-DSA-65 public key
41
+ */
42
+ flag() {
43
+ return SIGNATURE_SCHEME_TO_FLAG["MLDSA65"];
44
+ }
45
+ /**
46
+ * Verifies that the signature is valid for for the provided message.
47
+ * Pure ML-DSA-65 with an empty context string.
48
+ */
49
+ async verify(message, signature) {
50
+ let bytes;
51
+ if (typeof signature === "string") {
52
+ const parsed = parseSerializedKeypairSignature(signature);
53
+ if (parsed.signatureScheme !== "MLDSA65") throw new Error("Invalid signature scheme");
54
+ if (!bytesEqual(this.toRawBytes(), parsed.publicKey)) throw new Error("Signature does not match public key");
55
+ bytes = parsed.signature;
56
+ } else bytes = signature;
57
+ if (bytes.length !== MLDSA65_SIGNATURE_SIZE) return false;
58
+ return ml_dsa65.verify(bytes, message, this.toRawBytes());
59
+ }
60
+ };
61
+
62
+ //#endregion
63
+ export { MLDSA65PublicKey, MLDSA65_PUBLIC_KEY_SIZE, MLDSA65_SIGNATURE_SIZE };
64
+ //# sourceMappingURL=publickey.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publickey.mjs","names":[],"sources":["../../../src/keypairs/mldsa65/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\nimport { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';\n\nimport {\n\tbytesEqual,\n\tparseSerializedKeypairSignature,\n\tPublicKey,\n} from '../../cryptography/publickey.js';\nimport type { PublicKeyInitData } from '../../cryptography/publickey.js';\nimport { SIGNATURE_SCHEME_TO_FLAG } from '../../cryptography/signature-scheme.js';\n\nexport const MLDSA65_PUBLIC_KEY_SIZE = 1952;\nexport const MLDSA65_SIGNATURE_SIZE = 3309;\n\n/**\n * An ML-DSA-65 (FIPS 204) public key\n */\nexport class MLDSA65PublicKey extends PublicKey {\n\tstatic SIZE = MLDSA65_PUBLIC_KEY_SIZE;\n\tprivate data: Uint8Array<ArrayBuffer>;\n\n\t/**\n\t * Create a new MLDSA65PublicKey object\n\t * @param value ML-DSA-65 public key as buffer or base-64 encoded string\n\t */\n\tconstructor(value: PublicKeyInitData) {\n\t\tsuper();\n\n\t\tif (typeof value === 'string') {\n\t\t\tthis.data = fromBase64(value);\n\t\t} else if (value instanceof Uint8Array) {\n\t\t\tthis.data = value as Uint8Array<ArrayBuffer>;\n\t\t} else {\n\t\t\tthis.data = Uint8Array.from(value);\n\t\t}\n\n\t\tif (this.data.length !== MLDSA65_PUBLIC_KEY_SIZE) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid public key input. Expected ${MLDSA65_PUBLIC_KEY_SIZE} bytes, got ${this.data.length}`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if two ML-DSA-65 public keys are equal\n\t */\n\toverride equals(publicKey: MLDSA65PublicKey): boolean {\n\t\treturn super.equals(publicKey);\n\t}\n\n\t/**\n\t * Return the byte array representation of the ML-DSA-65 public key\n\t */\n\ttoRawBytes(): Uint8Array<ArrayBuffer> {\n\t\treturn this.data;\n\t}\n\n\t/**\n\t * Return the signature scheme flag of the ML-DSA-65 public key\n\t */\n\tflag(): number {\n\t\treturn SIGNATURE_SCHEME_TO_FLAG['MLDSA65'];\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message.\n\t * Pure ML-DSA-65 with an empty context string.\n\t */\n\tasync verify(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tlet bytes;\n\t\tif (typeof signature === 'string') {\n\t\t\tconst parsed = parseSerializedKeypairSignature(signature);\n\t\t\tif (parsed.signatureScheme !== 'MLDSA65') {\n\t\t\t\tthrow new Error('Invalid signature scheme');\n\t\t\t}\n\n\t\t\tif (!bytesEqual(this.toRawBytes(), parsed.publicKey)) {\n\t\t\t\tthrow new Error('Signature does not match public key');\n\t\t\t}\n\n\t\t\tbytes = parsed.signature;\n\t\t} else {\n\t\t\tbytes = signature;\n\t\t}\n\n\t\tif (bytes.length !== MLDSA65_SIGNATURE_SIZE) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn ml_dsa65.verify(bytes, message, this.toRawBytes());\n\t}\n}\n"],"mappings":";;;;;;AAcA,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;;;;AAKtC,IAAa,mBAAb,cAAsC,UAAU;;cACjC;;;;;;CAOd,YAAY,OAA0B;AACrC,SAAO;AAEP,MAAI,OAAO,UAAU,SACpB,MAAK,OAAO,WAAW,MAAM;WACnB,iBAAiB,WAC3B,MAAK,OAAO;MAEZ,MAAK,OAAO,WAAW,KAAK,MAAM;AAGnC,MAAI,KAAK,KAAK,WAAW,wBACxB,OAAM,IAAI,MACT,sCAAsC,wBAAwB,cAAc,KAAK,KAAK,SACtF;;;;;CAOH,AAAS,OAAO,WAAsC;AACrD,SAAO,MAAM,OAAO,UAAU;;;;;CAM/B,aAAsC;AACrC,SAAO,KAAK;;;;;CAMb,OAAe;AACd,SAAO,yBAAyB;;;;;;CAOjC,MAAM,OAAO,SAAqB,WAAkD;EACnF,IAAI;AACJ,MAAI,OAAO,cAAc,UAAU;GAClC,MAAM,SAAS,gCAAgC,UAAU;AACzD,OAAI,OAAO,oBAAoB,UAC9B,OAAM,IAAI,MAAM,2BAA2B;AAG5C,OAAI,CAAC,WAAW,KAAK,YAAY,EAAE,OAAO,UAAU,CACnD,OAAM,IAAI,MAAM,sCAAsC;AAGvD,WAAQ,OAAO;QAEf,SAAQ;AAGT,MAAI,MAAM,WAAW,uBACpB,QAAO;AAGR,SAAO,SAAS,OAAO,OAAO,SAAS,KAAK,YAAY,CAAC"}
@@ -15,6 +15,8 @@ type CompressedSignature = {
15
15
  ZkLogin: Uint8Array;
16
16
  } | {
17
17
  Passkey: Uint8Array;
18
+ } | {
19
+ MLDSA65: Uint8Array;
18
20
  };
19
21
  type PublicKeyEnum = {
20
22
  ED25519: Uint8Array;
@@ -26,6 +28,8 @@ type PublicKeyEnum = {
26
28
  ZkLogin: Uint8Array;
27
29
  } | {
28
30
  Passkey: Uint8Array;
31
+ } | {
32
+ MLDSA65: Uint8Array;
29
33
  };
30
34
  type PubkeyEnumWeightPair = {
31
35
  pubKey: PublicKeyEnum;
@@ -50,6 +54,7 @@ type ParsedPartialMultiSigSignature = {
50
54
  * A MultiSig public key
51
55
  */
52
56
  declare class MultiSigPublicKey extends PublicKey {
57
+ #private;
53
58
  private rawBytes;
54
59
  private multisigPublicKey;
55
60
  private publicKeys;
@@ -69,13 +74,15 @@ declare class MultiSigPublicKey extends PublicKey {
69
74
  */
70
75
  static fromPublicKeys({
71
76
  threshold,
72
- publicKeys
77
+ publicKeys,
78
+ client
73
79
  }: {
74
80
  threshold: number;
75
81
  publicKeys: {
76
82
  publicKey: PublicKey;
77
83
  weight: number;
78
- }[];
84
+ }[]; /** Client used to verify zkLogin member signatures */
85
+ client?: ClientWithCoreApi;
79
86
  }): MultiSigPublicKey;
80
87
  /**
81
88
  * Checks if two MultiSig public keys are equal
@@ -100,9 +107,17 @@ declare class MultiSigPublicKey extends PublicKey {
100
107
  */
101
108
  flag(): number;
102
109
  /**
103
- * Verifies that the signature is valid for for the provided message
110
+ * Verifies that the signature is valid for the provided message
104
111
  */
105
112
  verify(message: Uint8Array, multisigSignature: string): Promise<boolean>;
113
+ /**
114
+ * Verifies that the signature is valid for the provided PersonalMessage
115
+ */
116
+ verifyPersonalMessage(message: Uint8Array, multisigSignature: string): Promise<boolean>;
117
+ /**
118
+ * Verifies that the signature is valid for the provided Transaction
119
+ */
120
+ verifyTransaction(transaction: Uint8Array, multisigSignature: string): Promise<boolean>;
106
121
  /**
107
122
  * Combines multiple partial signatures into a single multisig, ensuring that each public key signs only once
108
123
  * and that all the public keys involved are known and valid, and then serializes multisig into the standard format
@@ -1 +1 @@
1
- {"version":3,"file":"publickey.d.mts","names":[],"sources":["../../src/multisig/publickey.ts"],"mappings":";;;;;;;KAsBK,mBAAA;EACA,OAAA,EAAS,UAAA;AAAA;EACT,SAAA,EAAW,UAAA;AAAA;EACX,SAAA,EAAW,UAAA;AAAA;EACX,OAAA,EAAS,UAAA;AAAA;EACT,OAAA,EAAS,UAAA;AAAA;AAAA,KAET,aAAA;EACA,OAAA,EAAS,UAAA;AAAA;EACT,SAAA,EAAW,UAAA;AAAA;EACX,SAAA,EAAW,UAAA;AAAA;EACX,OAAA,EAAS,UAAA;AAAA;EACT,OAAA,EAAS,UAAA;AAAA;AAAA,KAET,oBAAA;EACJ,MAAA,EAAQ,aAAA;EACR,MAAA;AAAA;AAAA,KAGI,uBAAA;EACJ,MAAA,EAAQ,oBAAA;EACR,SAAA;AAAA;AAAA,KAGW,cAAA;EACX,IAAA,EAAM,mBAAA;EACN,MAAA;EACA,WAAA,EAAa,uBAAA;AAAA;AAAA,KAGT,8BAAA;EACJ,eAAA,EAAiB,eAAA;EACjB,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,SAAA;EACX,MAAA;AAAA;;;;cAQY,iBAAA,SAA0B,SAAA;EAAA,QAC9B,QAAA;EAAA,QACA,iBAAA;EAAA,QACA,UAAA;EA9BR;;;;EACM;AAAA;;;EAwCL,KAAA,WAAgB,UAAA,GAAa,uBAAA,EAC7B,OAAA;IAAW,MAAA,GAAS,iBAAA;EAAA;EArCb;;;EAAA,OAkGD,cAAA,CAAA;IACN,SAAA;IACA;EAAA;IAEA,SAAA;IACA,UAAA;MAAc,SAAA,EAAW,SAAA;MAAW,MAAA;IAAA;EAAA,IACpC,iBAAA;EAlGD;;;EAmHS,MAAA,CAAO,SAAA,EAAW,iBAAA;EAlHS;AACnC;;EAwHD,UAAA,CAAA,GAAc,UAAA,CAAW,WAAA;EAIzB,aAAA,CAAA;;eAzGY,SAAA;EAAA;EA6GZ,YAAA,CAAA;EAIA,SAAA,CAAA,GAAa,OAAA,GAAU,MAAA,EAAQ,MAAA,IAAO,cAAA;EAjIrB;;;EAwIR,YAAA,CAAA;EAtIE;;;EA2JX,IAAA,CAAA;EAlJY;;;EAyJN,MAAA,CAAO,OAAA,EAAS,UAAA,EAAY,iBAAA,WAA4B,OAAA;EA3IhC;;;;EA+K9B,wBAAA,CAAyB,UAAA;AAAA;;;;iBA8DV,sBAAA,CACf,QAAA,EAAU,cAAA,EACV,OAAA;EAAW,MAAA,GAAS,iBAAA;AAAA,IAClB,8BAAA"}
1
+ {"version":3,"file":"publickey.d.mts","names":[],"sources":["../../src/multisig/publickey.ts"],"mappings":";;;;;;;KAsBK,mBAAA;EACA,OAAA,EAAS,UAAA;AAAA;EACT,SAAA,EAAW,UAAA;AAAA;EACX,SAAA,EAAW,UAAA;AAAA;EACX,OAAA,EAAS,UAAA;AAAA;EACT,OAAA,EAAS,UAAA;AAAA;EACT,OAAA,EAAS,UAAA;AAAA;AAAA,KAET,aAAA;EACA,OAAA,EAAS,UAAA;AAAA;EACT,SAAA,EAAW,UAAA;AAAA;EACX,SAAA,EAAW,UAAA;AAAA;EACX,OAAA,EAAS,UAAA;AAAA;EACT,OAAA,EAAS,UAAA;AAAA;EACT,OAAA,EAAS,UAAA;AAAA;AAAA,KAET,oBAAA;EACJ,MAAA,EAAQ,aAAA;EACR,MAAA;AAAA;AAAA,KAGI,uBAAA;EACJ,MAAA,EAAQ,oBAAA;EACR,SAAA;AAAA;AAAA,KAGW,cAAA;EACX,IAAA,EAAM,mBAAA;EACN,MAAA;EACA,WAAA,EAAa,uBAAA;AAAA;AAAA,KAGT,8BAAA;EACJ,eAAA,EAAiB,eAAA;EACjB,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,SAAA;EACX,MAAA;AAAA;;;;cAQY,iBAAA,SAA0B,SAAA;EAAA;UAC9B,QAAA;EAAA,QACA,iBAAA;EAAA,QACA,UAAA;EA9Ba;;;;EACf;;AAAA;;EAyCL,KAAA,WAAgB,UAAA,GAAa,uBAAA,EAC7B,OAAA;IAAW,MAAA,GAAS,iBAAA;EAAA;EAtCrB;;;EAAA,OAqGO,cAAA,CAAA;IACN,SAAA;IACA,UAAA;IACA;EAAA;IAEA,SAAA;IACA,UAAA;MAAc,SAAA,EAAW,SAAA;MAAW,MAAA;IAAA,KAtGrC;IAwGC,MAAA,GAAS,iBAAA;EAAA,IACT,iBAAA;EAvGD;;;EA2HS,MAAA,CAAO,SAAA,EAAW,iBAAA;EAxHvB;;;EA+HJ,UAAA,CAAA,GAAc,UAAA,CAAW,WAAA;EAIzB,aAAA,CAAA;;eAlHY,SAAA;EAAA;EAsHZ,YAAA,CAAA;EAIA,SAAA,CAAA,GAAa,OAAA,GAAU,MAAA,EAAQ,MAAA,IAAO,cAAA;EAzItC;;;EAgJS,YAAA,CAAA;EA9IT;;;EAoKA,IAAA,CAAA;EA5J8B;;;EAmKxB,MAAA,CAAO,OAAA,EAAS,UAAA,EAAY,iBAAA,WAA4B,OAAA;EAnJzC;;;EA4JZ,qBAAA,CAAsB,OAAA,EAAS,UAAA,EAAY,iBAAA,WAA4B,OAAA;EAvFtD;;;EAkGjB,iBAAA,CAAkB,WAAA,EAAa,UAAA,EAAY,iBAAA,WAA4B,OAAA;EApEvD;;;;EAoHzB,wBAAA,CAAyB,UAAA;AAAA;;;;iBA+DV,sBAAA,CACf,QAAA,EAAU,cAAA,EACV,OAAA;EAAW,MAAA,GAAS,iBAAA;AAAA,IAClB,8BAAA"}
@@ -17,11 +17,13 @@ const MIN_SIGNER_IN_MULTISIG = 1;
17
17
  * A MultiSig public key
18
18
  */
19
19
  var MultiSigPublicKey = class MultiSigPublicKey extends PublicKey {
20
+ #options;
20
21
  /**
21
22
  * Create a new MultiSigPublicKey object
22
23
  */
23
24
  constructor(value, options = {}) {
24
25
  super();
26
+ this.#options = options;
25
27
  if (typeof value === "string") {
26
28
  this.rawBytes = fromBase64(value);
27
29
  this.multisigPublicKey = suiBcs.MultiSigPublicKey.parse(this.rawBytes);
@@ -53,7 +55,7 @@ var MultiSigPublicKey = class MultiSigPublicKey extends PublicKey {
53
55
  /**
54
56
  * A static method to create a new MultiSig publickey instance from a set of public keys and their associated weights pairs and threshold.
55
57
  */
56
- static fromPublicKeys({ threshold, publicKeys }) {
58
+ static fromPublicKeys({ threshold, publicKeys, client }) {
57
59
  return new MultiSigPublicKey({
58
60
  pk_map: publicKeys.map(({ publicKey, weight }) => {
59
61
  return {
@@ -62,7 +64,7 @@ var MultiSigPublicKey = class MultiSigPublicKey extends PublicKey {
62
64
  };
63
65
  }),
64
66
  threshold
65
- });
67
+ }, { client });
66
68
  }
67
69
  /**
68
70
  * Checks if two MultiSig public keys are equal
@@ -89,18 +91,19 @@ var MultiSigPublicKey = class MultiSigPublicKey extends PublicKey {
89
91
  * Return the Sui address associated with this MultiSig public key
90
92
  */
91
93
  toSuiAddress() {
92
- const maxLength = 1 + 65 * MAX_SIGNER_IN_MULTISIG + 2;
93
- const tmp = new Uint8Array(maxLength);
94
+ const suiBytes = this.publicKeys.map(({ publicKey }) => publicKey.toSuiBytes());
95
+ const length = 3 + suiBytes.reduce((sum, bytes) => sum + bytes.length + 1, 0);
96
+ const tmp = new Uint8Array(length);
94
97
  tmp.set([SIGNATURE_SCHEME_TO_FLAG["MultiSig"]]);
95
98
  tmp.set(suiBcs.u16().serialize(this.multisigPublicKey.threshold).toBytes(), 1);
96
99
  let i = 3;
97
- for (const { publicKey, weight } of this.publicKeys) {
98
- const bytes = publicKey.toSuiBytes();
100
+ for (const [j, { weight }] of this.publicKeys.entries()) {
101
+ const bytes = suiBytes[j];
99
102
  tmp.set(bytes, i);
100
103
  i += bytes.length;
101
104
  tmp.set([weight], i++);
102
105
  }
103
- return normalizeSuiAddress(bytesToHex(blake2b(tmp.slice(0, i), { dkLen: 32 })));
106
+ return normalizeSuiAddress(bytesToHex(blake2b(tmp, { dkLen: 32 })));
104
107
  }
105
108
  /**
106
109
  * Return the Sui address associated with this MultiSig public key
@@ -109,16 +112,31 @@ var MultiSigPublicKey = class MultiSigPublicKey extends PublicKey {
109
112
  return SIGNATURE_SCHEME_TO_FLAG["MultiSig"];
110
113
  }
111
114
  /**
112
- * Verifies that the signature is valid for for the provided message
115
+ * Verifies that the signature is valid for the provided message
113
116
  */
114
117
  async verify(message, multisigSignature) {
118
+ return this.#verifyMembers(multisigSignature, (publicKey, signature) => publicKey.verify(message, signature));
119
+ }
120
+ /**
121
+ * Verifies that the signature is valid for the provided PersonalMessage
122
+ */
123
+ verifyPersonalMessage(message, multisigSignature) {
124
+ return this.#verifyMembers(multisigSignature, (publicKey, signature) => publicKey.verifyPersonalMessage(message, signature));
125
+ }
126
+ /**
127
+ * Verifies that the signature is valid for the provided Transaction
128
+ */
129
+ verifyTransaction(transaction, multisigSignature) {
130
+ return this.#verifyMembers(multisigSignature, (publicKey, signature) => publicKey.verifyTransaction(transaction, signature));
131
+ }
132
+ async #verifyMembers(multisigSignature, verifyMember) {
115
133
  const parsed = parseSerializedSignature(multisigSignature);
116
134
  if (parsed.signatureScheme !== "MultiSig") throw new Error("Invalid signature scheme");
117
135
  const { multisig } = parsed;
118
136
  let signatureWeight = 0;
119
137
  if (!bytesEqual(suiBcs.MultiSigPublicKey.serialize(this.multisigPublicKey).toBytes(), suiBcs.MultiSigPublicKey.serialize(multisig.multisig_pk).toBytes())) return false;
120
- for (const { publicKey, weight, signature } of parsePartialSignatures(multisig)) {
121
- if (!await publicKey.verify(message, signature)) return false;
138
+ for (const { publicKey, weight, signature } of parsePartialSignatures(multisig, this.#options)) {
139
+ if (!await verifyMember(publicKey, signature)) return false;
122
140
  signatureWeight += weight;
123
141
  }
124
142
  return signatureWeight >= this.multisigPublicKey.threshold;
@@ -152,7 +170,7 @@ var MultiSigPublicKey = class MultiSigPublicKey extends PublicKey {
152
170
  bitmap,
153
171
  multisig_pk: this.multisigPublicKey
154
172
  };
155
- const bytes = suiBcs.MultiSig.serialize(multisig, { maxSize: 8192 }).toBytes();
173
+ const bytes = suiBcs.MultiSig.serialize(multisig, { maxSize: 65536 }).toBytes();
156
174
  const tmp = new Uint8Array(bytes.length + 1);
157
175
  tmp.set([SIGNATURE_SCHEME_TO_FLAG["MultiSig"]]);
158
176
  tmp.set(bytes, 1);