@dynamic-labs-wallet/sui 1.0.91 → 1.0.93
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/index.cjs +15 -5
- package/index.esm.js +16 -6
- package/package.json +2 -2
- package/src/client/client.d.ts +11 -2
- package/src/client/client.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -286,8 +286,14 @@ class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
|
286
286
|
* Gets the public key for a given private key
|
|
287
287
|
* @param privateKeyBytes A Buffer containing the Ed25519 private key bytes
|
|
288
288
|
* @returns The public key (Sui address) derived from the private key
|
|
289
|
-
*/ getPublicKeyFromPrivateKey(privateKeyBytes) {
|
|
289
|
+
*/ getPublicKeyFromPrivateKey(privateKeyBytes, opts) {
|
|
290
290
|
try {
|
|
291
|
+
if (opts == null ? void 0 : opts.isRawScalar) {
|
|
292
|
+
// Raw 32-byte ed25519 signing scalar (not a seed): derive A = s·B
|
|
293
|
+
// instead of seed-expanding via Ed25519Keypair.fromSecretKey.
|
|
294
|
+
const publicKeyBytes = browser.getEd25519PublicKeyFromRawScalar(new Uint8Array(privateKeyBytes));
|
|
295
|
+
return new ed25519.Ed25519PublicKey(publicKeyBytes).toSuiAddress();
|
|
296
|
+
}
|
|
291
297
|
// Safe: creates a Uint8Array view over Buffer's underlying memory without copying
|
|
292
298
|
const keypair = ed25519.Ed25519Keypair.fromSecretKey(new Uint8Array(privateKeyBytes));
|
|
293
299
|
const publicKey = keypair.getPublicKey();
|
|
@@ -306,14 +312,16 @@ class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
|
306
312
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
307
313
|
* @param password The password for encrypted backup shares
|
|
308
314
|
* @returns The account address, raw public key, and client key shares
|
|
309
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, signedSessionId, onError, publicAddressCheck, legacyWalletId }) {
|
|
315
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, signedSessionId, onError, publicAddressCheck, legacyWalletId, isRawScalarImport }) {
|
|
310
316
|
try {
|
|
311
317
|
let ceremonyCeremonyCompleteResolver;
|
|
312
318
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
313
319
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
314
320
|
});
|
|
315
|
-
const { privateKey: formattedPrivateKey, privateKeyBytes } =
|
|
316
|
-
const publicKey = this.getPublicKeyFromPrivateKey(privateKeyBytes
|
|
321
|
+
const { privateKey: formattedPrivateKey, privateKeyBytes } = this.convertSuiPrivateKey(isRawScalarImport ? privateKey.replace(/^0x/, '') : privateKey);
|
|
322
|
+
const publicKey = this.getPublicKeyFromPrivateKey(privateKeyBytes, {
|
|
323
|
+
isRawScalar: isRawScalarImport
|
|
324
|
+
});
|
|
317
325
|
if (publicAddressCheck && publicKey !== publicAddressCheck) {
|
|
318
326
|
throw new Error(`Public address mismatch: derived address ${publicKey} !== public address ${publicAddressCheck}`);
|
|
319
327
|
}
|
|
@@ -321,13 +329,15 @@ class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
|
321
329
|
chainName,
|
|
322
330
|
privateKey: formattedPrivateKey,
|
|
323
331
|
thresholdSignatureScheme,
|
|
332
|
+
isRawScalarImport,
|
|
324
333
|
onCeremonyComplete: (accountAddress, walletId, shareSetId)=>{
|
|
325
334
|
this.initializeWalletMapEntry({
|
|
326
335
|
accountAddress,
|
|
327
336
|
walletId,
|
|
328
337
|
chainName: this.chainName,
|
|
329
338
|
thresholdSignatureScheme,
|
|
330
|
-
shareSetId
|
|
339
|
+
shareSetId,
|
|
340
|
+
variant: isRawScalarImport ? 'ed25519Standard' : undefined
|
|
331
341
|
});
|
|
332
342
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
333
343
|
},
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicWalletClient, getMPCChainConfig, ERROR_KEYGEN_FAILED, ERROR_PASSWORD_MISMATCH, ERROR_CREATE_WALLET_ACCOUNT, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_VERIFY_TRANSACTION_SIGNATURE, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_SIGN_MESSAGE, ERROR_IMPORT_PRIVATE_KEY, ERROR_EXPORT_PRIVATE_KEY } from '@dynamic-labs-wallet/browser';
|
|
1
|
+
import { DynamicWalletClient, getMPCChainConfig, ERROR_KEYGEN_FAILED, ERROR_PASSWORD_MISMATCH, ERROR_CREATE_WALLET_ACCOUNT, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_VERIFY_TRANSACTION_SIGNATURE, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_SIGN_MESSAGE, getEd25519PublicKeyFromRawScalar, ERROR_IMPORT_PRIVATE_KEY, ERROR_EXPORT_PRIVATE_KEY } from '@dynamic-labs-wallet/browser';
|
|
2
2
|
import { messageWithIntent, toSerializedSignature } from '@mysten/sui/cryptography';
|
|
3
3
|
import { Ed25519PublicKey, Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
4
|
import { verifyPersonalMessageSignature, verifyTransactionSignature } from '@mysten/sui/verify';
|
|
@@ -284,8 +284,14 @@ class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
284
284
|
* Gets the public key for a given private key
|
|
285
285
|
* @param privateKeyBytes A Buffer containing the Ed25519 private key bytes
|
|
286
286
|
* @returns The public key (Sui address) derived from the private key
|
|
287
|
-
*/ getPublicKeyFromPrivateKey(privateKeyBytes) {
|
|
287
|
+
*/ getPublicKeyFromPrivateKey(privateKeyBytes, opts) {
|
|
288
288
|
try {
|
|
289
|
+
if (opts == null ? void 0 : opts.isRawScalar) {
|
|
290
|
+
// Raw 32-byte ed25519 signing scalar (not a seed): derive A = s·B
|
|
291
|
+
// instead of seed-expanding via Ed25519Keypair.fromSecretKey.
|
|
292
|
+
const publicKeyBytes = getEd25519PublicKeyFromRawScalar(new Uint8Array(privateKeyBytes));
|
|
293
|
+
return new Ed25519PublicKey(publicKeyBytes).toSuiAddress();
|
|
294
|
+
}
|
|
289
295
|
// Safe: creates a Uint8Array view over Buffer's underlying memory without copying
|
|
290
296
|
const keypair = Ed25519Keypair.fromSecretKey(new Uint8Array(privateKeyBytes));
|
|
291
297
|
const publicKey = keypair.getPublicKey();
|
|
@@ -304,14 +310,16 @@ class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
304
310
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
305
311
|
* @param password The password for encrypted backup shares
|
|
306
312
|
* @returns The account address, raw public key, and client key shares
|
|
307
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, signedSessionId, onError, publicAddressCheck, legacyWalletId }) {
|
|
313
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, signedSessionId, onError, publicAddressCheck, legacyWalletId, isRawScalarImport }) {
|
|
308
314
|
try {
|
|
309
315
|
let ceremonyCeremonyCompleteResolver;
|
|
310
316
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
311
317
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
312
318
|
});
|
|
313
|
-
const { privateKey: formattedPrivateKey, privateKeyBytes } =
|
|
314
|
-
const publicKey = this.getPublicKeyFromPrivateKey(privateKeyBytes
|
|
319
|
+
const { privateKey: formattedPrivateKey, privateKeyBytes } = this.convertSuiPrivateKey(isRawScalarImport ? privateKey.replace(/^0x/, '') : privateKey);
|
|
320
|
+
const publicKey = this.getPublicKeyFromPrivateKey(privateKeyBytes, {
|
|
321
|
+
isRawScalar: isRawScalarImport
|
|
322
|
+
});
|
|
315
323
|
if (publicAddressCheck && publicKey !== publicAddressCheck) {
|
|
316
324
|
throw new Error(`Public address mismatch: derived address ${publicKey} !== public address ${publicAddressCheck}`);
|
|
317
325
|
}
|
|
@@ -319,13 +327,15 @@ class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
319
327
|
chainName,
|
|
320
328
|
privateKey: formattedPrivateKey,
|
|
321
329
|
thresholdSignatureScheme,
|
|
330
|
+
isRawScalarImport,
|
|
322
331
|
onCeremonyComplete: (accountAddress, walletId, shareSetId)=>{
|
|
323
332
|
this.initializeWalletMapEntry({
|
|
324
333
|
accountAddress,
|
|
325
334
|
walletId,
|
|
326
335
|
chainName: this.chainName,
|
|
327
336
|
thresholdSignatureScheme,
|
|
328
|
-
shareSetId
|
|
337
|
+
shareSetId,
|
|
338
|
+
variant: isRawScalarImport ? 'ed25519Standard' : undefined
|
|
329
339
|
});
|
|
330
340
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
331
341
|
},
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/sui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.93",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/browser": "1.0.
|
|
7
|
+
"@dynamic-labs-wallet/browser": "1.0.93",
|
|
8
8
|
"@mysten/sui": "1.26.0",
|
|
9
9
|
"@noble/hashes": "1.7.1",
|
|
10
10
|
"bech32-converting": "^1.0.9",
|
package/src/client/client.d.ts
CHANGED
|
@@ -65,7 +65,9 @@ export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
65
65
|
* @param privateKeyBytes A Buffer containing the Ed25519 private key bytes
|
|
66
66
|
* @returns The public key (Sui address) derived from the private key
|
|
67
67
|
*/
|
|
68
|
-
getPublicKeyFromPrivateKey(privateKeyBytes: Buffer
|
|
68
|
+
getPublicKeyFromPrivateKey(privateKeyBytes: Buffer, opts?: {
|
|
69
|
+
isRawScalar?: boolean;
|
|
70
|
+
}): string;
|
|
69
71
|
/**
|
|
70
72
|
* Imports the private key for a given account address
|
|
71
73
|
*
|
|
@@ -75,7 +77,7 @@ export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
75
77
|
* @param password The password for encrypted backup shares
|
|
76
78
|
* @returns The account address, raw public key, and client key shares
|
|
77
79
|
*/
|
|
78
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, signedSessionId, onError, publicAddressCheck, legacyWalletId, }: {
|
|
80
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, signedSessionId, onError, publicAddressCheck, legacyWalletId, isRawScalarImport, }: {
|
|
79
81
|
privateKey: string;
|
|
80
82
|
chainName: string;
|
|
81
83
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
@@ -85,6 +87,13 @@ export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
85
87
|
publicAddressCheck?: string;
|
|
86
88
|
/** ID of the legacy embedded wallet being upgraded to v3 */
|
|
87
89
|
legacyWalletId?: string;
|
|
90
|
+
/**
|
|
91
|
+
* When true, `privateKey` is a raw 32-byte ed25519 signing scalar (hex),
|
|
92
|
+
* e.g. one exported from an external MPC system (Fireblocks Embedded
|
|
93
|
+
* Wallets), rather than a Sui Bech32/hex secret key. Routes the import
|
|
94
|
+
* through the non-exportable `Ed25519` protocol.
|
|
95
|
+
*/
|
|
96
|
+
isRawScalarImport?: boolean;
|
|
88
97
|
}): Promise<{
|
|
89
98
|
accountAddress: string;
|
|
90
99
|
rawPublicKey: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,mBAAmB,EAYnB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACpC,MAAM,8BAA8B,CAAC;AAQtC,OAAO,KAAK,EAAE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