@mysten/enoki 1.1.1 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mysten/enoki
2
2
 
3
+ ## 1.2.1
4
+
5
+ ## 1.2.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 7452835: `EnokiKeypair` now extends the shared `ZkLoginSigner` from `@mysten/sui/zklogin`,
10
+ removing duplicated signature-wrapping logic. `signTransaction` / `signPersonalMessage` /
11
+ `getPublicKey` are unchanged. Two behaviors are corrected to match `ZkLoginSigner`:
12
+ `getKeyScheme()` now returns `'ZkLogin'` (previously the ephemeral key's scheme), and `sign()` now
13
+ throws instead of returning a bare ephemeral signature (which was never valid for the zkLogin
14
+ address).
15
+
3
16
  ## 1.1.1
4
17
 
5
18
  ## 1.1.0
@@ -1,10 +1,9 @@
1
- import * as _mysten_sui_cryptography0 from "@mysten/sui/cryptography";
2
- import { SignatureWithBytes, Signer } from "@mysten/sui/cryptography";
3
- import { ZkLoginPublicIdentifier, ZkLoginSignatureInputs } from "@mysten/sui/zklogin";
1
+ import { Signer } from "@mysten/sui/cryptography";
2
+ import { ZkLoginPublicIdentifier, ZkLoginSignatureInputs, ZkLoginSigner } from "@mysten/sui/zklogin";
4
3
 
5
4
  //#region src/EnokiKeypair.d.ts
6
5
  declare class EnokiPublicKey extends ZkLoginPublicIdentifier {}
7
- declare class EnokiKeypair extends Signer {
6
+ declare class EnokiKeypair extends ZkLoginSigner {
8
7
  #private;
9
8
  constructor(input: {
10
9
  address: string;
@@ -12,10 +11,6 @@ declare class EnokiKeypair extends Signer {
12
11
  proof: ZkLoginSignatureInputs;
13
12
  ephemeralKeypair: Signer;
14
13
  });
15
- sign(data: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
16
- signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes>;
17
- signTransaction(bytes: Uint8Array): Promise<SignatureWithBytes>;
18
- getKeyScheme(): _mysten_sui_cryptography0.SignatureScheme;
19
14
  getPublicKey(): EnokiPublicKey;
20
15
  }
21
16
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"EnokiKeypair.d.mts","names":[],"sources":["../src/EnokiKeypair.ts"],"mappings":";;;;;cAQa,cAAA,SAAuB,uBAAA;AAAA,cAEvB,YAAA,SAAqB,MAAA;EAAA;cAMrB,KAAA;IACX,OAAA;IACA,QAAA;IACA,KAAA,EAAO,sBAAA;IACP,gBAAA,EAAkB,MAAA;EAAA;EASb,IAAA,CAAK,IAAA,EAAM,UAAA,GAAU,OAAA,CAAA,UAAA,CAAA,WAAA;EAIrB,mBAAA,CAAoB,KAAA,EAAO,UAAA,GAAa,OAAA,CAAQ,kBAAA;EAgBhD,eAAA,CAAgB,KAAA,EAAO,UAAA,GAAa,OAAA,CAAQ,kBAAA;EAgBlD,YAAA,CAAA,GAhBiD,yBAAA,CAgBrC,eAAA;EAIZ,YAAA,CAAA,GAAY,cAAA;AAAA"}
1
+ {"version":3,"file":"EnokiKeypair.d.mts","names":[],"sources":["../src/EnokiKeypair.ts"],"mappings":";;;;cAOa,cAAA,SAAuB,uBAAA;AAAA,cAEvB,YAAA,SAAqB,aAAA;EAAA;cAGrB,KAAA;IACX,OAAA;IACA,QAAA;IACA,KAAA,EAAO,sBAAA;IACP,gBAAA,EAAkB,MAAA;EAAA;EAcV,YAAA,CAAA,GAAgB,cAAA;AAAA"}
@@ -1,47 +1,18 @@
1
- import { Signer } from "@mysten/sui/cryptography";
2
- import { ZkLoginPublicIdentifier, getZkLoginSignature } from "@mysten/sui/zklogin";
1
+ import { ZkLoginPublicIdentifier, ZkLoginSigner } from "@mysten/sui/zklogin";
3
2
 
4
3
  //#region src/EnokiKeypair.ts
5
4
  var EnokiPublicKey = class extends ZkLoginPublicIdentifier {};
6
- var EnokiKeypair = class extends Signer {
7
- #proof;
8
- #maxEpoch;
9
- #ephemeralKeypair;
5
+ var EnokiKeypair = class extends ZkLoginSigner {
10
6
  #publicKey;
11
7
  constructor(input) {
12
- super();
13
- this.#proof = input.proof;
14
- this.#maxEpoch = input.maxEpoch;
15
- this.#ephemeralKeypair = input.ephemeralKeypair;
16
- this.#publicKey = EnokiPublicKey.fromProof(input.address, input.proof);
17
- }
18
- async sign(data) {
19
- return this.#ephemeralKeypair.sign(data);
20
- }
21
- async signPersonalMessage(bytes) {
22
- const { bytes: signedBytes, signature: userSignature } = await this.#ephemeralKeypair.signPersonalMessage(bytes);
23
- return {
24
- bytes: signedBytes,
25
- signature: getZkLoginSignature({
26
- inputs: this.#proof,
27
- maxEpoch: this.#maxEpoch,
28
- userSignature
29
- })
30
- };
31
- }
32
- async signTransaction(bytes) {
33
- const { bytes: signedBytes, signature: userSignature } = await this.#ephemeralKeypair.signTransaction(bytes);
34
- return {
35
- bytes: signedBytes,
36
- signature: getZkLoginSignature({
37
- inputs: this.#proof,
38
- maxEpoch: this.#maxEpoch,
39
- userSignature
40
- })
41
- };
42
- }
43
- getKeyScheme() {
44
- return this.#ephemeralKeypair.getKeyScheme();
8
+ const publicKey = EnokiPublicKey.fromProof(input.address, input.proof);
9
+ super({
10
+ ephemeralSigner: input.ephemeralKeypair,
11
+ maxEpoch: input.maxEpoch,
12
+ inputs: input.proof,
13
+ legacyAddress: publicKey.legacyAddress
14
+ });
15
+ this.#publicKey = publicKey;
45
16
  }
46
17
  getPublicKey() {
47
18
  return this.#publicKey;
@@ -1 +1 @@
1
- {"version":3,"file":"EnokiKeypair.mjs","names":["#proof","#maxEpoch","#ephemeralKeypair","#publicKey"],"sources":["../src/EnokiKeypair.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SignatureWithBytes } from '@mysten/sui/cryptography';\nimport { Signer } from '@mysten/sui/cryptography';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';\nimport { getZkLoginSignature, ZkLoginPublicIdentifier } from '@mysten/sui/zklogin';\n\nexport class EnokiPublicKey extends ZkLoginPublicIdentifier {}\n\nexport class EnokiKeypair extends Signer {\n\t#proof: ZkLoginSignatureInputs;\n\t#maxEpoch: number;\n\t#ephemeralKeypair: Signer;\n\t#publicKey: EnokiPublicKey;\n\n\tconstructor(input: {\n\t\taddress: string;\n\t\tmaxEpoch: number;\n\t\tproof: ZkLoginSignatureInputs;\n\t\tephemeralKeypair: Signer;\n\t}) {\n\t\tsuper();\n\t\tthis.#proof = input.proof;\n\t\tthis.#maxEpoch = input.maxEpoch;\n\t\tthis.#ephemeralKeypair = input.ephemeralKeypair;\n\t\tthis.#publicKey = EnokiPublicKey.fromProof(input.address, input.proof);\n\t}\n\n\tasync sign(data: Uint8Array) {\n\t\treturn this.#ephemeralKeypair.sign(data);\n\t}\n\n\tasync signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes> {\n\t\tconst { bytes: signedBytes, signature: userSignature } =\n\t\t\tawait this.#ephemeralKeypair.signPersonalMessage(bytes);\n\n\t\tconst zkSignature = getZkLoginSignature({\n\t\t\tinputs: this.#proof,\n\t\t\tmaxEpoch: this.#maxEpoch,\n\t\t\tuserSignature,\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: signedBytes,\n\t\t\tsignature: zkSignature,\n\t\t};\n\t}\n\n\tasync signTransaction(bytes: Uint8Array): Promise<SignatureWithBytes> {\n\t\tconst { bytes: signedBytes, signature: userSignature } =\n\t\t\tawait this.#ephemeralKeypair.signTransaction(bytes);\n\n\t\tconst zkSignature = getZkLoginSignature({\n\t\t\tinputs: this.#proof,\n\t\t\tmaxEpoch: this.#maxEpoch,\n\t\t\tuserSignature,\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: signedBytes,\n\t\t\tsignature: zkSignature,\n\t\t};\n\t}\n\n\tgetKeyScheme() {\n\t\treturn this.#ephemeralKeypair.getKeyScheme();\n\t}\n\n\tgetPublicKey() {\n\t\treturn this.#publicKey;\n\t}\n}\n"],"mappings":";;;;AAQA,IAAa,iBAAb,cAAoC,wBAAwB;AAE5D,IAAa,eAAb,cAAkC,OAAO;CACxC;CACA;CACA;CACA;CAEA,YAAY,OAKT;AACF,SAAO;AACP,QAAKA,QAAS,MAAM;AACpB,QAAKC,WAAY,MAAM;AACvB,QAAKC,mBAAoB,MAAM;AAC/B,QAAKC,YAAa,eAAe,UAAU,MAAM,SAAS,MAAM,MAAM;;CAGvE,MAAM,KAAK,MAAkB;AAC5B,SAAO,MAAKD,iBAAkB,KAAK,KAAK;;CAGzC,MAAM,oBAAoB,OAAgD;EACzE,MAAM,EAAE,OAAO,aAAa,WAAW,kBACtC,MAAM,MAAKA,iBAAkB,oBAAoB,MAAM;AAQxD,SAAO;GACN,OAAO;GACP,WARmB,oBAAoB;IACvC,QAAQ,MAAKF;IACb,UAAU,MAAKC;IACf;IACA,CAAC;GAKD;;CAGF,MAAM,gBAAgB,OAAgD;EACrE,MAAM,EAAE,OAAO,aAAa,WAAW,kBACtC,MAAM,MAAKC,iBAAkB,gBAAgB,MAAM;AAQpD,SAAO;GACN,OAAO;GACP,WARmB,oBAAoB;IACvC,QAAQ,MAAKF;IACb,UAAU,MAAKC;IACf;IACA,CAAC;GAKD;;CAGF,eAAe;AACd,SAAO,MAAKC,iBAAkB,cAAc;;CAG7C,eAAe;AACd,SAAO,MAAKC"}
1
+ {"version":3,"file":"EnokiKeypair.mjs","names":["#publicKey"],"sources":["../src/EnokiKeypair.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';\nimport { ZkLoginPublicIdentifier, ZkLoginSigner } from '@mysten/sui/zklogin';\n\nexport class EnokiPublicKey extends ZkLoginPublicIdentifier {}\n\nexport class EnokiKeypair extends ZkLoginSigner {\n\t#publicKey: EnokiPublicKey;\n\n\tconstructor(input: {\n\t\taddress: string;\n\t\tmaxEpoch: number;\n\t\tproof: ZkLoginSignatureInputs;\n\t\tephemeralKeypair: Signer;\n\t}) {\n\t\t// Resolve the public key exactly as before — `fromProof` matches the proof against the\n\t\t// supplied address and validates it — then bridge that to the base's `legacyAddress` flag.\n\t\tconst publicKey = EnokiPublicKey.fromProof(input.address, input.proof);\n\t\tsuper({\n\t\t\tephemeralSigner: input.ephemeralKeypair,\n\t\t\tmaxEpoch: input.maxEpoch,\n\t\t\tinputs: input.proof,\n\t\t\tlegacyAddress: publicKey.legacyAddress,\n\t\t});\n\t\tthis.#publicKey = publicKey;\n\t}\n\n\toverride getPublicKey(): EnokiPublicKey {\n\t\treturn this.#publicKey;\n\t}\n}\n"],"mappings":";;;AAOA,IAAa,iBAAb,cAAoC,wBAAwB;AAE5D,IAAa,eAAb,cAAkC,cAAc;CAC/C;CAEA,YAAY,OAKT;EAGF,MAAM,YAAY,eAAe,UAAU,MAAM,SAAS,MAAM,MAAM;AACtE,QAAM;GACL,iBAAiB,MAAM;GACvB,UAAU,MAAM;GAChB,QAAQ,MAAM;GACd,eAAe,UAAU;GACzB,CAAC;AACF,QAAKA,YAAa;;CAGnB,AAAS,eAA+B;AACvC,SAAO,MAAKA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/enoki",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "zkLogin authentication and sponsored transactions",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Mysten Labs <build@mystenlabs.com>",
@@ -45,14 +45,14 @@
45
45
  "@wallet-standard/ui": "^1.0.3",
46
46
  "idb-keyval": "^6.2.5",
47
47
  "nanostores": "^1.3.0",
48
- "@mysten/wallet-standard": "^0.21.1",
49
- "@mysten/webcrypto-signer": "^0.2.1",
50
- "@mysten/utils": "^0.4.0"
48
+ "@mysten/utils": "^0.4.0",
49
+ "@mysten/wallet-standard": "^0.21.3",
50
+ "@mysten/webcrypto-signer": "^0.2.3"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@types/react": ">=17.0.0",
54
54
  "react": ">=17.0.0",
55
- "@mysten/sui": "^2.19.0"
55
+ "@mysten/sui": "^2.20.1"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {