@dynamic-labs-wallet/svm 1.0.92 → 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 CHANGED
@@ -254,7 +254,13 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
254
254
  const slicedBytes = decoded.slice(0, 32);
255
255
  return Buffer.from(slicedBytes).toString('hex');
256
256
  }
257
- getPublicKeyFromPrivateKey(privateKey) {
257
+ getPublicKeyFromPrivateKey(privateKey, opts) {
258
+ if (opts == null ? void 0 : opts.isRawScalar) {
259
+ // `privateKey` is a raw 32-byte ed25519 signing scalar (hex), not a seed.
260
+ // Derive the address as A = s·B rather than seed-expanding it.
261
+ const publicKeyBytes = browser.getEd25519PublicKeyFromRawScalar(privateKey);
262
+ return bs58.encode(publicKeyBytes);
263
+ }
258
264
  const privateKeyBytes = bs58.decode(privateKey);
259
265
  const keypair = web3_js.Keypair.fromSecretKey(privateKeyBytes);
260
266
  const publicKeyBase58 = keypair.publicKey.toBase58();
@@ -271,29 +277,35 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
271
277
  * @param thresholdSignatureScheme The threshold signature scheme to use
272
278
  * @param password The password for encrypted backup shares
273
279
  * @returns The account address, raw public key, and client key shares
274
- */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, signedSessionId, publicAddressCheck, legacyWalletId }) {
280
+ */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, signedSessionId, publicAddressCheck, legacyWalletId, isRawScalarImport }) {
275
281
  try {
276
282
  let ceremonyCeremonyCompleteResolver;
277
283
  const ceremonyCompletePromise = new Promise((resolve)=>{
278
284
  ceremonyCeremonyCompleteResolver = resolve;
279
285
  });
280
286
  //get public key from private key
281
- const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
287
+ const publicKey = this.getPublicKeyFromPrivateKey(privateKey, {
288
+ isRawScalar: isRawScalarImport
289
+ });
282
290
  if (publicAddressCheck && publicKey !== publicAddressCheck) {
283
291
  throw new Error(`Public address mismatch: derived address ${publicKey} !== public address ${publicAddressCheck}`);
284
292
  }
285
- const formattedPrivateKey = this.decodePrivateKeyForSolana(privateKey);
293
+ // Raw scalar: pass the 32-byte scalar hex straight through to the MPC importer.
294
+ // Seed-based: decode the bs58 secret key down to its 32-byte seed (hex).
295
+ const formattedPrivateKey = isRawScalarImport ? privateKey.replace(/^0x/, '') : this.decodePrivateKeyForSolana(privateKey);
286
296
  const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
287
297
  chainName,
288
298
  privateKey: formattedPrivateKey,
289
299
  thresholdSignatureScheme,
300
+ isRawScalarImport,
290
301
  onCeremonyComplete: (accountAddress, walletId, shareSetId)=>{
291
302
  this.initializeWalletMapEntry({
292
303
  accountAddress,
293
304
  walletId,
294
305
  chainName: this.chainName,
295
306
  thresholdSignatureScheme,
296
- shareSetId
307
+ shareSetId,
308
+ variant: isRawScalarImport ? 'ed25519Standard' : undefined
297
309
  });
298
310
  ceremonyCeremonyCompleteResolver(undefined);
299
311
  },
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DynamicWalletClient, getMPCChainConfig, ERROR_KEYGEN_FAILED, ERROR_PASSWORD_MISMATCH, ERROR_CREATE_WALLET_ACCOUNT, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_SIGN_MESSAGE, ERROR_IMPORT_PRIVATE_KEY } from '@dynamic-labs-wallet/browser';
1
+ import { DynamicWalletClient, getMPCChainConfig, ERROR_KEYGEN_FAILED, ERROR_PASSWORD_MISMATCH, ERROR_CREATE_WALLET_ACCOUNT, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_SIGN_MESSAGE, getEd25519PublicKeyFromRawScalar, ERROR_IMPORT_PRIVATE_KEY } from '@dynamic-labs-wallet/browser';
2
2
  import { VersionedMessage, VersionedTransaction, Keypair } from '@solana/web3.js';
3
3
  import bs58 from 'bs58';
4
4
 
@@ -252,7 +252,13 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
252
252
  const slicedBytes = decoded.slice(0, 32);
253
253
  return Buffer.from(slicedBytes).toString('hex');
254
254
  }
255
- getPublicKeyFromPrivateKey(privateKey) {
255
+ getPublicKeyFromPrivateKey(privateKey, opts) {
256
+ if (opts == null ? void 0 : opts.isRawScalar) {
257
+ // `privateKey` is a raw 32-byte ed25519 signing scalar (hex), not a seed.
258
+ // Derive the address as A = s·B rather than seed-expanding it.
259
+ const publicKeyBytes = getEd25519PublicKeyFromRawScalar(privateKey);
260
+ return bs58.encode(publicKeyBytes);
261
+ }
256
262
  const privateKeyBytes = bs58.decode(privateKey);
257
263
  const keypair = Keypair.fromSecretKey(privateKeyBytes);
258
264
  const publicKeyBase58 = keypair.publicKey.toBase58();
@@ -269,29 +275,35 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
269
275
  * @param thresholdSignatureScheme The threshold signature scheme to use
270
276
  * @param password The password for encrypted backup shares
271
277
  * @returns The account address, raw public key, and client key shares
272
- */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, signedSessionId, publicAddressCheck, legacyWalletId }) {
278
+ */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, signedSessionId, publicAddressCheck, legacyWalletId, isRawScalarImport }) {
273
279
  try {
274
280
  let ceremonyCeremonyCompleteResolver;
275
281
  const ceremonyCompletePromise = new Promise((resolve)=>{
276
282
  ceremonyCeremonyCompleteResolver = resolve;
277
283
  });
278
284
  //get public key from private key
279
- const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
285
+ const publicKey = this.getPublicKeyFromPrivateKey(privateKey, {
286
+ isRawScalar: isRawScalarImport
287
+ });
280
288
  if (publicAddressCheck && publicKey !== publicAddressCheck) {
281
289
  throw new Error(`Public address mismatch: derived address ${publicKey} !== public address ${publicAddressCheck}`);
282
290
  }
283
- const formattedPrivateKey = this.decodePrivateKeyForSolana(privateKey);
291
+ // Raw scalar: pass the 32-byte scalar hex straight through to the MPC importer.
292
+ // Seed-based: decode the bs58 secret key down to its 32-byte seed (hex).
293
+ const formattedPrivateKey = isRawScalarImport ? privateKey.replace(/^0x/, '') : this.decodePrivateKeyForSolana(privateKey);
284
294
  const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
285
295
  chainName,
286
296
  privateKey: formattedPrivateKey,
287
297
  thresholdSignatureScheme,
298
+ isRawScalarImport,
288
299
  onCeremonyComplete: (accountAddress, walletId, shareSetId)=>{
289
300
  this.initializeWalletMapEntry({
290
301
  accountAddress,
291
302
  walletId,
292
303
  chainName: this.chainName,
293
304
  thresholdSignatureScheme,
294
- shareSetId
305
+ shareSetId,
306
+ variant: isRawScalarImport ? 'ed25519Standard' : undefined
295
307
  });
296
308
  ceremonyCeremonyCompleteResolver(undefined);
297
309
  },
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/svm",
3
- "version": "1.0.92",
3
+ "version": "1.0.93",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/browser": "1.0.92",
7
+ "@dynamic-labs-wallet/browser": "1.0.93",
8
8
  "@solana/web3.js": "^1.98.2",
9
9
  "bs58": "^6.0.0",
10
10
  "@dynamic-labs/sdk-api-core": "^0.0.1093"
@@ -85,7 +85,9 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
85
85
  * @returns The hex string
86
86
  */
87
87
  decodePrivateKeyForSolana(privateKey: string): string;
88
- getPublicKeyFromPrivateKey(privateKey: string): string;
88
+ getPublicKeyFromPrivateKey(privateKey: string, opts?: {
89
+ isRawScalar?: boolean;
90
+ }): string;
89
91
  encodePublicKey(publicKey: Uint8Array): string;
90
92
  /**
91
93
  * Imports the private key for a given account address
@@ -96,7 +98,7 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
96
98
  * @param password The password for encrypted backup shares
97
99
  * @returns The account address, raw public key, and client key shares
98
100
  */
99
- importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, signedSessionId, publicAddressCheck, legacyWalletId, }: {
101
+ importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, signedSessionId, publicAddressCheck, legacyWalletId, isRawScalarImport, }: {
100
102
  privateKey: string;
101
103
  chainName: string;
102
104
  thresholdSignatureScheme: ThresholdSignatureScheme;
@@ -106,6 +108,13 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
106
108
  publicAddressCheck?: string;
107
109
  /** ID of the legacy embedded wallet being upgraded to v3 */
108
110
  legacyWalletId?: string;
111
+ /**
112
+ * When true, `privateKey` is a raw 32-byte ed25519 signing scalar (hex),
113
+ * e.g. one exported from an external MPC system (Fireblocks Embedded
114
+ * Wallets), rather than a bs58-encoded Solana secret key / seed. Routes the
115
+ * import through the non-exportable `Ed25519` protocol.
116
+ */
117
+ isRawScalarImport?: boolean;
109
118
  }): Promise<{
110
119
  accountAddress: string;
111
120
  rawPublicKey: Uint8Array | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/svm/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAQnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,8BAA8B,EACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAerE,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,eAAe,EACf,YAAY,EACZ,iBAAiB,GAClB,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,YA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