@dynamic-labs-wallet/browser 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 +201 -47
- package/index.esm.js +203 -50
- package/package.json +4 -3
- package/src/client.d.ts +42 -8
- package/src/client.d.ts.map +1 -1
- package/src/ed25519.d.ts +17 -0
- package/src/ed25519.d.ts.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/mpc/mpc.d.ts +13 -6
- package/src/mpc/mpc.d.ts.map +1 -1
- package/src/mpc/types.d.ts +5 -5
- package/src/mpc/types.d.ts.map +1 -1
- package/src/types.d.ts +9 -1
- package/src/types.d.ts.map +1 -1
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BitcoinAddressType, MPC_RELAY_PROD_API_URL, getMPCChainConfig, parseNamespacedVersion, WalletApiError, BackupLocation, ENCRYPTED_SHARES_STORAGE_SUFFIX, Logger, NETWORK_ERROR_STATUS, handleAxiosError, WalletOperation, WalletReadyState, classifyForwardMpcError, isRecoveredForwardMpcConnectionChurn, FEATURE_FLAGS, ThresholdSignatureScheme, getClientThreshold, MPC_CONFIG, getTSSConfig, serializeMessageForForwardMPC, isEvmCompatibleChain, serializeError, getReshareConfig, getRequiredExternalKeyShareId, verifiedCredentialNameToChainEnum, AuthMode, NoopLogger, DynamicApiClient, BusinessAccountClient, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import { BitcoinAddressType, MPC_RELAY_PROD_API_URL, DEFAULT_ED25519_VARIANT, getMPCChainConfig, parseNamespacedVersion, WalletApiError, BackupLocation, ENCRYPTED_SHARES_STORAGE_SUFFIX, Logger, NETWORK_ERROR_STATUS, handleAxiosError, WalletOperation, WalletReadyState, classifyForwardMpcError, isRecoveredForwardMpcConnectionChurn, FEATURE_FLAGS, ThresholdSignatureScheme, getClientThreshold, MPC_CONFIG, getTSSConfig, serializeMessageForForwardMPC, isEvmCompatibleChain, serializeError, getReshareConfig, getRequiredExternalKeyShareId, verifiedCredentialNameToChainEnum, AuthMode, NoopLogger, DynamicApiClient, BusinessAccountClient, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP } from '@dynamic-labs-wallet/core';
|
|
2
2
|
export * from '@dynamic-labs-wallet/core';
|
|
3
3
|
export { Logger } from '@dynamic-labs-wallet/core';
|
|
4
|
-
import { EdBls12377, BIP340, ExportableEd25519, Ecdsa, MessageHash, EcdsaSignature, EcdsaKeygenResult, ExportableEd25519KeygenResult, BIP340KeygenResult } from '#internal/web';
|
|
4
|
+
import { EdBls12377, BIP340, Ed25519, ExportableEd25519, Ecdsa, MessageHash, EcdsaSignature, EcdsaKeygenResult, ExportableEd25519KeygenResult, Ed25519KeygenResult, BIP340KeygenResult } from '#internal/web';
|
|
5
5
|
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519, Ed25519InitKeygenResult, Ed25519KeygenResult, EdBls12377, EdBls12377KeygenResult, MessageHash } from '#internal/web';
|
|
6
6
|
import { v4, validate } from 'uuid';
|
|
7
7
|
import { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
@@ -10,6 +10,8 @@ import loadArgon2idWasm from 'argon2id';
|
|
|
10
10
|
import { AxiosError } from 'axios';
|
|
11
11
|
import gte from 'semver/functions/gte';
|
|
12
12
|
import PQueue from 'p-queue';
|
|
13
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
14
|
+
import { hexToBytes, bytesToNumberLE } from '@noble/curves/abstract/utils';
|
|
13
15
|
|
|
14
16
|
function _extends() {
|
|
15
17
|
_extends = Object.assign || function assign(target) {
|
|
@@ -79,12 +81,17 @@ function _extends() {
|
|
|
79
81
|
return undefined;
|
|
80
82
|
}
|
|
81
83
|
};
|
|
82
|
-
const getMPCSignatureScheme = ({ signingAlgorithm, baseRelayUrl = MPC_RELAY_PROD_API_URL })=>{
|
|
84
|
+
const getMPCSignatureScheme = ({ signingAlgorithm, baseRelayUrl = MPC_RELAY_PROD_API_URL, variant = DEFAULT_ED25519_VARIANT })=>{
|
|
83
85
|
switch(signingAlgorithm){
|
|
84
86
|
case SigningAlgorithm.ECDSA:
|
|
85
87
|
return new Ecdsa(baseRelayUrl);
|
|
86
88
|
case SigningAlgorithm.ED25519:
|
|
87
|
-
|
|
89
|
+
// `Ed25519` (non-exportable) and `ExportableEd25519` are distinct protocol
|
|
90
|
+
// classes with incompatible keyshare formats. Downstream `instanceof`
|
|
91
|
+
// dispatch (createWalletAccount / importPrivateKey / derive*) always tests
|
|
92
|
+
// `ExportableEd25519` before `Ed25519` — most-specific-first — so it stays
|
|
93
|
+
// correct even if `ExportableEd25519` were a subclass of `Ed25519`.
|
|
94
|
+
return variant === 'ed25519Standard' ? new Ed25519(baseRelayUrl) : new ExportableEd25519(baseRelayUrl);
|
|
88
95
|
case SigningAlgorithm.BIP340:
|
|
89
96
|
return new BIP340(baseRelayUrl);
|
|
90
97
|
case SigningAlgorithm.EDBLS12_377:
|
|
@@ -93,11 +100,12 @@ const getMPCSignatureScheme = ({ signingAlgorithm, baseRelayUrl = MPC_RELAY_PROD
|
|
|
93
100
|
throw new Error(`Unsupported signing algorithm: ${signingAlgorithm}`);
|
|
94
101
|
}
|
|
95
102
|
};
|
|
96
|
-
const getMPCSigner = ({ chainName, baseRelayUrl, bitcoinConfig })=>{
|
|
103
|
+
const getMPCSigner = ({ chainName, baseRelayUrl, bitcoinConfig, variant })=>{
|
|
97
104
|
const chainConfig = getMPCChainConfig(chainName, bitcoinConfig);
|
|
98
105
|
const signatureScheme = getMPCSignatureScheme({
|
|
99
106
|
signingAlgorithm: chainConfig.signingAlgorithm,
|
|
100
|
-
baseRelayUrl
|
|
107
|
+
baseRelayUrl,
|
|
108
|
+
variant
|
|
101
109
|
});
|
|
102
110
|
return signatureScheme;
|
|
103
111
|
};
|
|
@@ -3378,28 +3386,34 @@ class DynamicWalletClient {
|
|
|
3378
3386
|
}, this.getTraceContext(traceContext))));
|
|
3379
3387
|
throw new Error('Timed out waiting for wallet creation ceremony to complete');
|
|
3380
3388
|
}
|
|
3381
|
-
async clientInitializeKeyGen({ chainName, thresholdSignatureScheme, bitcoinConfig }) {
|
|
3389
|
+
async clientInitializeKeyGen({ chainName, thresholdSignatureScheme, bitcoinConfig, variant }) {
|
|
3382
3390
|
// Get the mpc signer
|
|
3383
3391
|
const mpcSigner = getMPCSigner({
|
|
3384
3392
|
chainName,
|
|
3385
3393
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
3386
|
-
bitcoinConfig
|
|
3394
|
+
bitcoinConfig,
|
|
3395
|
+
variant
|
|
3387
3396
|
});
|
|
3388
3397
|
const clientThreshold = getClientThreshold(thresholdSignatureScheme);
|
|
3389
3398
|
const keygenInitResults = await Promise.all(Array(clientThreshold).fill(null).map(()=>mpcSigner.initKeygen()));
|
|
3390
3399
|
return keygenInitResults;
|
|
3391
3400
|
}
|
|
3392
|
-
async derivePublicKey({ chainName, keyShare, derivationPath, bitcoinConfig }) {
|
|
3401
|
+
async derivePublicKey({ chainName, keyShare, derivationPath, bitcoinConfig, variant }) {
|
|
3393
3402
|
const mpcSigner = getMPCSigner({
|
|
3394
3403
|
chainName,
|
|
3395
3404
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
3396
|
-
bitcoinConfig
|
|
3405
|
+
bitcoinConfig,
|
|
3406
|
+
variant
|
|
3397
3407
|
});
|
|
3398
3408
|
let publicKey;
|
|
3399
3409
|
if (mpcSigner instanceof Ecdsa) {
|
|
3400
3410
|
publicKey = await mpcSigner.derivePubkey(keyShare, derivationPath);
|
|
3401
3411
|
} else if (mpcSigner instanceof ExportableEd25519) {
|
|
3402
3412
|
publicKey = await mpcSigner.getPubkey(keyShare);
|
|
3413
|
+
} else if (mpcSigner instanceof Ed25519) {
|
|
3414
|
+
// Non-exportable Ed25519 (raw-scalar-imported wallets). Derivation is not
|
|
3415
|
+
// standardized for ed25519, so the root pubkey is taken with an undefined path.
|
|
3416
|
+
publicKey = await mpcSigner.derivePubkey(keyShare, derivationPath);
|
|
3403
3417
|
} else if (mpcSigner instanceof BIP340) {
|
|
3404
3418
|
publicKey = await mpcSigner.deriveTweakPubkey(keyShare, derivationPath);
|
|
3405
3419
|
}
|
|
@@ -3763,7 +3777,7 @@ class DynamicWalletClient {
|
|
|
3763
3777
|
shouldRetry: (error)=>!isNonRetryableCeremonyError(error)
|
|
3764
3778
|
});
|
|
3765
3779
|
}
|
|
3766
|
-
async runImportRawPrivateKeyAttempt({ chainName, privateKey, thresholdSignatureScheme, bitcoinConfig, onError, onCeremonyComplete, traceContext, legacyWalletId, password, signedSessionId }) {
|
|
3780
|
+
async runImportRawPrivateKeyAttempt({ chainName, privateKey, thresholdSignatureScheme, bitcoinConfig, onError, onCeremonyComplete, traceContext, legacyWalletId, password, signedSessionId, isRawScalarImport }) {
|
|
3767
3781
|
const dynamicRequestId = v4();
|
|
3768
3782
|
try {
|
|
3769
3783
|
this.assertPasswordRequired(password);
|
|
@@ -3771,15 +3785,21 @@ class DynamicWalletClient {
|
|
|
3771
3785
|
password,
|
|
3772
3786
|
signedSessionId
|
|
3773
3787
|
});
|
|
3788
|
+
// A raw-scalar import must run on the non-exportable `Ed25519` protocol for
|
|
3789
|
+
// the whole ceremony (init keygen, import, pubkey derivation) so the produced
|
|
3790
|
+
// key shares are consistent. Non-raw imports keep the default ('ed25519Exportable').
|
|
3791
|
+
const variant = isRawScalarImport ? 'ed25519Standard' : undefined;
|
|
3774
3792
|
const mpcSigner = getMPCSigner({
|
|
3775
3793
|
chainName,
|
|
3776
3794
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
3777
|
-
bitcoinConfig
|
|
3795
|
+
bitcoinConfig,
|
|
3796
|
+
variant
|
|
3778
3797
|
});
|
|
3779
3798
|
const clientKeygenInitResults = await this.clientInitializeKeyGen({
|
|
3780
3799
|
chainName,
|
|
3781
3800
|
thresholdSignatureScheme,
|
|
3782
|
-
bitcoinConfig
|
|
3801
|
+
bitcoinConfig,
|
|
3802
|
+
variant
|
|
3783
3803
|
});
|
|
3784
3804
|
const clientKeygenIds = clientKeygenInitResults.map((result)=>result.keygenId);
|
|
3785
3805
|
this.logger.info('[DynamicWaasWalletClient] Client key generation initialized', _extends({
|
|
@@ -3797,7 +3817,9 @@ class DynamicWalletClient {
|
|
|
3797
3817
|
bitcoinConfig,
|
|
3798
3818
|
onError,
|
|
3799
3819
|
onCeremonyComplete,
|
|
3800
|
-
legacyWalletId
|
|
3820
|
+
legacyWalletId,
|
|
3821
|
+
// Persist the protocol variant server-side so later sign/reshare read it back.
|
|
3822
|
+
variant
|
|
3801
3823
|
});
|
|
3802
3824
|
this.logger.info('[DynamicWaasWalletClient] Server key generation initialized', _extends({
|
|
3803
3825
|
roomId,
|
|
@@ -3815,7 +3837,9 @@ class DynamicWalletClient {
|
|
|
3815
3837
|
...serverKeygenIds,
|
|
3816
3838
|
...otherClientKeygenIds
|
|
3817
3839
|
];
|
|
3818
|
-
const importerKeygenResult =
|
|
3840
|
+
const importerKeygenResult = isRawScalarImport ? // uses the 32 bytes directly as the signing scalar instead of
|
|
3841
|
+
// SHA-512-expanding them as an RFC-8032 seed.
|
|
3842
|
+
await mpcSigner.importPrivateKeyImporter(roomId, threshold, privateKey, currentInit, otherKeyGenIds, true) : await mpcSigner.importPrivateKeyImporter(roomId, threshold, privateKey, currentInit, otherKeyGenIds);
|
|
3819
3843
|
return importerKeygenResult;
|
|
3820
3844
|
} else {
|
|
3821
3845
|
const recipientKeygenResult = await mpcSigner.importPrivateKeyRecipient(roomId, threshold, currentInit, [
|
|
@@ -3832,7 +3856,8 @@ class DynamicWalletClient {
|
|
|
3832
3856
|
chainName,
|
|
3833
3857
|
keyShare: clientKeygenResult,
|
|
3834
3858
|
derivationPath,
|
|
3835
|
-
bitcoinConfig
|
|
3859
|
+
bitcoinConfig,
|
|
3860
|
+
variant
|
|
3836
3861
|
});
|
|
3837
3862
|
this.logger.info('[DynamicWaasWalletClient] Completed import of raw private key', _extends({
|
|
3838
3863
|
rawPublicKey,
|
|
@@ -3867,6 +3892,8 @@ class DynamicWalletClient {
|
|
|
3867
3892
|
if (typeof message !== 'string') {
|
|
3868
3893
|
message = `0x${Buffer.from(message).toString('hex')}`;
|
|
3869
3894
|
}
|
|
3895
|
+
// Note: the server signing party (wallet-service) selects the ed25519
|
|
3896
|
+
// protocol variant from its own persisted EAC, so it is NOT threaded here.
|
|
3870
3897
|
const serializedContext = context ? JSON.parse(JSON.stringify(context, (_key, value)=>typeof value === 'bigint' ? value.toString() : value)) : undefined;
|
|
3871
3898
|
const useHttpTransport = this.featureFlags[FEATURE_FLAGS.ENABLE_HTTP_WAAS_TRANSPORT] === true && this.featureFlags[FEATURE_FLAGS.ENABLE_HTTP_WAAS_TRANSPORT_SIGNMESSAGE] === true;
|
|
3872
3899
|
const params = {
|
|
@@ -3930,7 +3957,7 @@ class DynamicWalletClient {
|
|
|
3930
3957
|
}
|
|
3931
3958
|
return signatureBytes;
|
|
3932
3959
|
}
|
|
3933
|
-
async forwardMPCClientSign({ chainName, message, roomId, keyShare, derivationPath, formattedMessage, dynamicRequestId, isFormatted, traceContext, bitcoinConfig }) {
|
|
3960
|
+
async forwardMPCClientSign({ chainName, message, roomId, keyShare, derivationPath, formattedMessage, dynamicRequestId, isFormatted, traceContext, bitcoinConfig, variant }) {
|
|
3934
3961
|
try {
|
|
3935
3962
|
const chainConfig = getMPCChainConfig(chainName, bitcoinConfig);
|
|
3936
3963
|
const signingAlgo = chainConfig.signingAlgorithm;
|
|
@@ -3943,7 +3970,7 @@ class DynamicWalletClient {
|
|
|
3943
3970
|
});
|
|
3944
3971
|
const tweak = this.convertTweakForBIP340(bitcoinConfig == null ? void 0 : bitcoinConfig.tweak);
|
|
3945
3972
|
this.logger.info('Forward MPC enabled, signing message with forward MPC (new)', this.getTraceContext(traceContext));
|
|
3946
|
-
const { signature: signatureBytes } = await this.apiClient.forwardMPCClient.signMessage({
|
|
3973
|
+
const { signature: signatureBytes } = await this.apiClient.forwardMPCClient.signMessage(_extends({
|
|
3947
3974
|
keyshare: keyShare,
|
|
3948
3975
|
message: messageToSign,
|
|
3949
3976
|
relayDomain: this.baseMPCRelayApiUrl || '',
|
|
@@ -3955,7 +3982,9 @@ class DynamicWalletClient {
|
|
|
3955
3982
|
traceContext,
|
|
3956
3983
|
userId: this.userId,
|
|
3957
3984
|
environmentId: this.environmentId
|
|
3958
|
-
}
|
|
3985
|
+
}, variant === 'ed25519Standard' ? {
|
|
3986
|
+
ed25519Variant: 'standard'
|
|
3987
|
+
} : {}));
|
|
3959
3988
|
if (!(signatureBytes instanceof Uint8Array)) {
|
|
3960
3989
|
throw new TypeError(`Invalid signature format: expected Uint8Array, got ${typeof signatureBytes}`);
|
|
3961
3990
|
}
|
|
@@ -3975,15 +4004,22 @@ class DynamicWalletClient {
|
|
|
3975
4004
|
throw error;
|
|
3976
4005
|
}
|
|
3977
4006
|
}
|
|
3978
|
-
async clientSign({ chainName, message, roomId: initialRoomId, keyShare, derivationPath, isFormatted, dynamicRequestId, traceContext, bitcoinConfig, refreshRoom }) {
|
|
4007
|
+
async clientSign({ chainName, message, roomId: initialRoomId, keyShare, derivationPath, isFormatted, dynamicRequestId, traceContext, bitcoinConfig, variant, refreshRoom }) {
|
|
3979
4008
|
// Reassigned when forward MPC fails and we mint a fresh room for the
|
|
3980
4009
|
// relay-based fallback below.
|
|
3981
4010
|
let roomId = initialRoomId;
|
|
4011
|
+
// Non-exportable Ed25519 (raw-scalar import) derives its address at the
|
|
4012
|
+
// root — see derivePrivateKeyFromExport's identical guard. Unlike
|
|
4013
|
+
// ExportableEd25519 (which ignores this arg), Ed25519.sign() *applies* a
|
|
4014
|
+
// non-undefined path, so forwarding the wallet's stored derivation path
|
|
4015
|
+
// here would sign under a derived child key instead of the wallet's own.
|
|
4016
|
+
const effectiveDerivationPath = variant === 'ed25519Standard' ? undefined : derivationPath;
|
|
3982
4017
|
try {
|
|
3983
4018
|
const mpcSigner = getMPCSigner({
|
|
3984
4019
|
chainName,
|
|
3985
4020
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
3986
|
-
bitcoinConfig
|
|
4021
|
+
bitcoinConfig,
|
|
4022
|
+
variant
|
|
3987
4023
|
});
|
|
3988
4024
|
const formattedMessage = isFormatted ? new MessageHash(message) : formatMessage(chainName, message);
|
|
3989
4025
|
this.logger.debug('[DynamicWaasWalletClient] Starting client sign', _extends({
|
|
@@ -4007,12 +4043,13 @@ class DynamicWalletClient {
|
|
|
4007
4043
|
message,
|
|
4008
4044
|
roomId,
|
|
4009
4045
|
keyShare,
|
|
4010
|
-
derivationPath,
|
|
4046
|
+
derivationPath: effectiveDerivationPath,
|
|
4011
4047
|
formattedMessage,
|
|
4012
4048
|
dynamicRequestId,
|
|
4013
4049
|
isFormatted,
|
|
4014
4050
|
traceContext,
|
|
4015
|
-
bitcoinConfig
|
|
4051
|
+
bitcoinConfig,
|
|
4052
|
+
variant
|
|
4016
4053
|
});
|
|
4017
4054
|
} catch (error) {
|
|
4018
4055
|
const errorInfo = classifyForwardMpcError(error);
|
|
@@ -4056,7 +4093,7 @@ class DynamicWalletClient {
|
|
|
4056
4093
|
if (!('sign' in mpcSigner)) {
|
|
4057
4094
|
throw new TypeError(`Message signing is not supported for chain ${chainName} — use signTransaction instead`);
|
|
4058
4095
|
}
|
|
4059
|
-
const signature = await mpcSigner.sign(roomId, keyShare, messageToSign,
|
|
4096
|
+
const signature = await mpcSigner.sign(roomId, keyShare, messageToSign, effectiveDerivationPath, tweak);
|
|
4060
4097
|
return signature;
|
|
4061
4098
|
} catch (error) {
|
|
4062
4099
|
logError({
|
|
@@ -4140,7 +4177,8 @@ class DynamicWalletClient {
|
|
|
4140
4177
|
chainName,
|
|
4141
4178
|
localShares,
|
|
4142
4179
|
recordedKeygenIds,
|
|
4143
|
-
bitcoinConfig
|
|
4180
|
+
bitcoinConfig,
|
|
4181
|
+
variant: this.ed25519VariantForWallet(accountAddress)
|
|
4144
4182
|
});
|
|
4145
4183
|
localKeygenIds = comparison.localKeygenIds;
|
|
4146
4184
|
staleness = comparison.fresh ? 'fresh' : 'stale';
|
|
@@ -4206,11 +4244,14 @@ class DynamicWalletClient {
|
|
|
4206
4244
|
* the server recorded for the wallet's Dynamic backups. Shared by the
|
|
4207
4245
|
* stale-share heal (verifyAndRecoverStaleShare) and the backup preflight
|
|
4208
4246
|
* (ensureLocalSharesAreFresh).
|
|
4209
|
-
*/ async compareShareGenerations({ accountAddress, chainName, localShares, recordedKeygenIds, bitcoinConfig }) {
|
|
4247
|
+
*/ async compareShareGenerations({ accountAddress, chainName, localShares, recordedKeygenIds, bitcoinConfig, variant }) {
|
|
4210
4248
|
const mpcSigner = getMPCSigner({
|
|
4211
4249
|
chainName,
|
|
4212
4250
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
4213
|
-
bitcoinConfig: bitcoinConfig != null ? bitcoinConfig : this.getBitcoinConfigForChain(chainName, accountAddress)
|
|
4251
|
+
bitcoinConfig: bitcoinConfig != null ? bitcoinConfig : this.getBitcoinConfigForChain(chainName, accountAddress),
|
|
4252
|
+
// Raw-scalar (non-exportable Ed25519) wallets: build the matching signer so
|
|
4253
|
+
// getKeygenIdForShare deserializes the Ed25519 share (else "Invalid discriminant").
|
|
4254
|
+
variant
|
|
4214
4255
|
});
|
|
4215
4256
|
const localKeygenIds = await Promise.all(localShares.map((share)=>this.getKeygenIdForShare(mpcSigner, share)));
|
|
4216
4257
|
const recordedSet = new Set(recordedKeygenIds);
|
|
@@ -4368,6 +4409,7 @@ class DynamicWalletClient {
|
|
|
4368
4409
|
dynamicRequestId,
|
|
4369
4410
|
traceContext,
|
|
4370
4411
|
bitcoinConfig,
|
|
4412
|
+
variant: wallet.variant,
|
|
4371
4413
|
// On forward-MPC fallback, re-run the server sign with no roomId so a
|
|
4372
4414
|
// brand-new server-joined room is created for the relay ceremony.
|
|
4373
4415
|
refreshRoom: async ()=>{
|
|
@@ -4667,7 +4709,11 @@ class DynamicWalletClient {
|
|
|
4667
4709
|
const mpcSigner = getMPCSigner({
|
|
4668
4710
|
chainName,
|
|
4669
4711
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
4670
|
-
bitcoinConfig
|
|
4712
|
+
bitcoinConfig,
|
|
4713
|
+
// Raw-scalar (non-exportable Ed25519) wallets must refresh on the same
|
|
4714
|
+
// protocol their shares were created with, or the ceremony fails to
|
|
4715
|
+
// deserialize them ("Invalid discriminant").
|
|
4716
|
+
variant: this.ed25519VariantForWallet(accountAddress)
|
|
4671
4717
|
});
|
|
4672
4718
|
// Ensure client key shares exist before hitting the API
|
|
4673
4719
|
const clientKeyShares = await this.ensureClientShare(accountAddress);
|
|
@@ -4849,11 +4895,26 @@ class DynamicWalletClient {
|
|
|
4849
4895
|
}
|
|
4850
4896
|
return mpcSigner.exportID(share);
|
|
4851
4897
|
}
|
|
4852
|
-
|
|
4898
|
+
/**
|
|
4899
|
+
* The ed25519 protocol variant for an existing wallet, read from the wallet map
|
|
4900
|
+
* (sourced from `walletProperties.settings.variant`, persisted at import).
|
|
4901
|
+
*
|
|
4902
|
+
* It is per-wallet protocol metadata — like `thresholdSignatureScheme` or
|
|
4903
|
+
* `addressType` — and the single source of truth for which signer to build when
|
|
4904
|
+
* operating on a wallet's key shares. Wallets imported from a raw ed25519 scalar
|
|
4905
|
+
* (e.g. Fireblocks Embedded Wallets) are `'ed25519Standard'` (non-exportable `Ed25519`);
|
|
4906
|
+
* everything else is `undefined` → the default exportable protocol. Using the
|
|
4907
|
+
* wrong one fails to deserialize the key share with "Invalid discriminant".
|
|
4908
|
+
*/ ed25519VariantForWallet(accountAddress) {
|
|
4909
|
+
var _this_getWalletFromMap;
|
|
4910
|
+
return (_this_getWalletFromMap = this.getWalletFromMap(accountAddress)) == null ? void 0 : _this_getWalletFromMap.variant;
|
|
4911
|
+
}
|
|
4912
|
+
async getExportId({ chainName, clientKeyShare, bitcoinConfig, accountAddress }) {
|
|
4853
4913
|
const mpcSigner = getMPCSigner({
|
|
4854
4914
|
chainName,
|
|
4855
4915
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
4856
|
-
bitcoinConfig
|
|
4916
|
+
bitcoinConfig,
|
|
4917
|
+
variant: accountAddress ? this.ed25519VariantForWallet(accountAddress) : undefined
|
|
4857
4918
|
});
|
|
4858
4919
|
try {
|
|
4859
4920
|
const exportId = await this.getKeygenIdForShare(mpcSigner, clientKeyShare);
|
|
@@ -4901,7 +4962,8 @@ class DynamicWalletClient {
|
|
|
4901
4962
|
return this.getExportId({
|
|
4902
4963
|
chainName,
|
|
4903
4964
|
clientKeyShare,
|
|
4904
|
-
bitcoinConfig
|
|
4965
|
+
bitcoinConfig,
|
|
4966
|
+
accountAddress
|
|
4905
4967
|
});
|
|
4906
4968
|
}
|
|
4907
4969
|
/**
|
|
@@ -4942,7 +5004,8 @@ class DynamicWalletClient {
|
|
|
4942
5004
|
const existingClientKeygenIds = await Promise.all(existingClientKeyShares.map(async (keyShare)=>await this.getExportId({
|
|
4943
5005
|
chainName,
|
|
4944
5006
|
clientKeyShare: keyShare,
|
|
4945
|
-
bitcoinConfig
|
|
5007
|
+
bitcoinConfig,
|
|
5008
|
+
accountAddress
|
|
4946
5009
|
})));
|
|
4947
5010
|
return {
|
|
4948
5011
|
newClientInitKeygenResults,
|
|
@@ -5011,7 +5074,8 @@ class DynamicWalletClient {
|
|
|
5011
5074
|
const existingClientKeygenId = await this.getExportId({
|
|
5012
5075
|
chainName,
|
|
5013
5076
|
clientKeyShare: existingClientShare,
|
|
5014
|
-
bitcoinConfig
|
|
5077
|
+
bitcoinConfig,
|
|
5078
|
+
accountAddress
|
|
5015
5079
|
});
|
|
5016
5080
|
// Gate matches internalRefresh/Reshare — SSE error rejects awaitTerminal.
|
|
5017
5081
|
let newShareSetId;
|
|
@@ -5620,7 +5684,11 @@ class DynamicWalletClient {
|
|
|
5620
5684
|
const mpcSigner = getMPCSigner({
|
|
5621
5685
|
chainName,
|
|
5622
5686
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
5623
|
-
bitcoinConfig
|
|
5687
|
+
bitcoinConfig,
|
|
5688
|
+
// Raw-scalar (non-exportable Ed25519) wallets must reshare on the same
|
|
5689
|
+
// protocol their shares were created with, or the ceremony fails to
|
|
5690
|
+
// deserialize them ("Invalid discriminant").
|
|
5691
|
+
variant: this.ed25519VariantForWallet(accountAddress)
|
|
5624
5692
|
});
|
|
5625
5693
|
let existingReshareResults;
|
|
5626
5694
|
let newReshareResults;
|
|
@@ -5984,6 +6052,9 @@ class DynamicWalletClient {
|
|
|
5984
6052
|
if (mpcSigner instanceof ExportableEd25519) {
|
|
5985
6053
|
return new ExportableEd25519KeygenResult(extractedPubkey, secretShare);
|
|
5986
6054
|
}
|
|
6055
|
+
if (mpcSigner instanceof Ed25519) {
|
|
6056
|
+
return new Ed25519KeygenResult(extractedPubkey, secretShare);
|
|
6057
|
+
}
|
|
5987
6058
|
return new BIP340KeygenResult(extractedPubkey, secretShare);
|
|
5988
6059
|
}
|
|
5989
6060
|
async exportKey({ accountAddress, chainName, bitcoinConfig, password = undefined, signedSessionId, mfaToken, elevatedAccessToken, traceContext }) {
|
|
@@ -6014,13 +6085,15 @@ class DynamicWalletClient {
|
|
|
6014
6085
|
const mpcSigner = getMPCSigner({
|
|
6015
6086
|
chainName,
|
|
6016
6087
|
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
6017
|
-
bitcoinConfig
|
|
6088
|
+
bitcoinConfig,
|
|
6089
|
+
variant: wallet.variant
|
|
6018
6090
|
});
|
|
6019
6091
|
const reconstructedKeyShare = await this.getReconstructedKeyShare(accountAddress, mpcSigner);
|
|
6020
6092
|
const exportId = await this.getExportId({
|
|
6021
6093
|
chainName,
|
|
6022
6094
|
clientKeyShare: reconstructedKeyShare,
|
|
6023
|
-
bitcoinConfig
|
|
6095
|
+
bitcoinConfig,
|
|
6096
|
+
accountAddress: wallet.accountAddress
|
|
6024
6097
|
});
|
|
6025
6098
|
const data = await this.apiClient.exportKey({
|
|
6026
6099
|
walletId: wallet.walletId,
|
|
@@ -6163,20 +6236,35 @@ class DynamicWalletClient {
|
|
|
6163
6236
|
if (mpcSigner instanceof Ecdsa) {
|
|
6164
6237
|
return mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
6165
6238
|
} else if (mpcSigner instanceof ExportableEd25519) {
|
|
6239
|
+
// ExportableEd25519's exportFullPrivateKey already returns the RFC-8032
|
|
6240
|
+
// form (hex of seed||pubkey); pass it straight through.
|
|
6166
6241
|
return keyExportRaw;
|
|
6242
|
+
} else if (mpcSigner instanceof Ed25519) {
|
|
6243
|
+
// Non-exportable Ed25519's exportFullPrivateKey returns an `spriv`
|
|
6244
|
+
// (extended private key), NOT a raw hex key — it must be parsed to the
|
|
6245
|
+
// actual private scalar. Returning the spriv verbatim makes the chain
|
|
6246
|
+
// client hex-decode it into an empty buffer (blank export field).
|
|
6247
|
+
//
|
|
6248
|
+
// This protocol is only used for raw-scalar import, whose public key is
|
|
6249
|
+
// the ROOT scalar (`A = s·B`, derived at import via derivePubkey(_, undefined)).
|
|
6250
|
+
// The chain-config derivation path stored on the wallet (e.g. Solana's
|
|
6251
|
+
// [44,501,0,0,0]) must NOT be applied here — deriving a child scalar would
|
|
6252
|
+
// export a key that doesn't correspond to the wallet's address.
|
|
6253
|
+
return mpcSigner.derivePrivateKeyFromSpriv(keyExportRaw);
|
|
6167
6254
|
} else if (mpcSigner instanceof BIP340) {
|
|
6168
6255
|
return mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
6169
6256
|
}
|
|
6170
6257
|
return undefined;
|
|
6171
6258
|
}
|
|
6172
|
-
async offlineExportKey({ chainName, keyShares, derivationPath }) {
|
|
6259
|
+
async offlineExportKey({ chainName, keyShares, derivationPath, variant }) {
|
|
6173
6260
|
try {
|
|
6174
6261
|
if (!keyShares || keyShares.length < 2) {
|
|
6175
6262
|
throw new Error(`Must provide at least min threshold of key shares`);
|
|
6176
6263
|
}
|
|
6177
6264
|
const mpcSigner = getMPCSigner({
|
|
6178
6265
|
chainName,
|
|
6179
|
-
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
6266
|
+
baseRelayUrl: this.baseMPCRelayApiUrl,
|
|
6267
|
+
variant
|
|
6180
6268
|
});
|
|
6181
6269
|
const walletKeyShares = keyShares.map((keyShare)=>{
|
|
6182
6270
|
if (!('pubkey' in keyShare)) {
|
|
@@ -6195,6 +6283,10 @@ class DynamicWalletClient {
|
|
|
6195
6283
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, walletDerivationPath);
|
|
6196
6284
|
} else if (mpcSigner instanceof ExportableEd25519) {
|
|
6197
6285
|
derivedPrivateKey = keyExportRaw;
|
|
6286
|
+
} else if (mpcSigner instanceof Ed25519) {
|
|
6287
|
+
// Non-exportable Ed25519 (raw-scalar) returns an `spriv`, not raw hex —
|
|
6288
|
+
// parse it to the root scalar (see derivePrivateKeyFromExport).
|
|
6289
|
+
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromSpriv(keyExportRaw);
|
|
6198
6290
|
} else if (mpcSigner instanceof BIP340) {
|
|
6199
6291
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, walletDerivationPath);
|
|
6200
6292
|
}
|
|
@@ -6400,7 +6492,7 @@ class DynamicWalletClient {
|
|
|
6400
6492
|
* @param thresholdSignatureScheme - The TSS scheme used
|
|
6401
6493
|
* @param derivationPath - Optional derivation path (will be computed from chainConfig if not provided)
|
|
6402
6494
|
* @param additionalProps - Any chain-specific additional properties to merge
|
|
6403
|
-
*/ initializeWalletMapEntry({ accountAddress, walletId, chainName, thresholdSignatureScheme, derivationPath, shareSetId, shareSetType, otherShareSets, additionalProps = {} }) {
|
|
6495
|
+
*/ initializeWalletMapEntry({ accountAddress, walletId, chainName, thresholdSignatureScheme, derivationPath, shareSetId, shareSetType, otherShareSets, variant, additionalProps = {} }) {
|
|
6404
6496
|
this.updateWalletMap(accountAddress, _extends({
|
|
6405
6497
|
accountAddress,
|
|
6406
6498
|
walletId,
|
|
@@ -6414,6 +6506,8 @@ class DynamicWalletClient {
|
|
|
6414
6506
|
shareSetType
|
|
6415
6507
|
} : {}, otherShareSets ? {
|
|
6416
6508
|
otherShareSets
|
|
6509
|
+
} : {}, variant ? {
|
|
6510
|
+
variant
|
|
6417
6511
|
} : {}, {
|
|
6418
6512
|
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
6419
6513
|
}, additionalProps));
|
|
@@ -6633,7 +6727,7 @@ class DynamicWalletClient {
|
|
|
6633
6727
|
tokenSource: googleDriveTokenSource
|
|
6634
6728
|
} : {});
|
|
6635
6729
|
}
|
|
6636
|
-
async publishDelegatedShare({ walletId, shareSetId, delegatedShare, signedSessionId, dynamicRequestId, chainName, bitcoinConfig, isPasswordEncrypted }) {
|
|
6730
|
+
async publishDelegatedShare({ walletId, shareSetId, delegatedShare, signedSessionId, dynamicRequestId, chainName, accountAddress, bitcoinConfig, isPasswordEncrypted }) {
|
|
6637
6731
|
var _publicKey_key, _publicKey_key1, _publicKey_key2;
|
|
6638
6732
|
const publicKey = await this.apiClient.getDelegatedEncryptionKey({
|
|
6639
6733
|
environmentId: this.environmentId
|
|
@@ -6658,7 +6752,8 @@ class DynamicWalletClient {
|
|
|
6658
6752
|
chainName,
|
|
6659
6753
|
clientKeyShare: delegatedShare,
|
|
6660
6754
|
bitcoinConfig,
|
|
6661
|
-
walletId
|
|
6755
|
+
walletId,
|
|
6756
|
+
accountAddress
|
|
6662
6757
|
});
|
|
6663
6758
|
return {
|
|
6664
6759
|
location: BackupLocation.DELEGATED,
|
|
@@ -6824,6 +6919,7 @@ class DynamicWalletClient {
|
|
|
6824
6919
|
signedSessionId: resolvedSignedSessionId,
|
|
6825
6920
|
dynamicRequestId,
|
|
6826
6921
|
chainName: walletData.chainName,
|
|
6922
|
+
accountAddress,
|
|
6827
6923
|
bitcoinConfig,
|
|
6828
6924
|
isPasswordEncrypted
|
|
6829
6925
|
}), {
|
|
@@ -6992,7 +7088,8 @@ class DynamicWalletClient {
|
|
|
6992
7088
|
accountAddress,
|
|
6993
7089
|
chainName,
|
|
6994
7090
|
localShares,
|
|
6995
|
-
recordedKeygenIds
|
|
7091
|
+
recordedKeygenIds,
|
|
7092
|
+
variant: walletData.variant
|
|
6996
7093
|
});
|
|
6997
7094
|
if (fresh) return;
|
|
6998
7095
|
this.logger.warn('[storeEncryptedBackupByWallet] Stale local shares detected; refreshing local storage', {
|
|
@@ -8417,9 +8514,17 @@ class DynamicWalletClient {
|
|
|
8417
8514
|
const user = await this.getUserWithEnvCheck(dynamicRequestId);
|
|
8418
8515
|
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.filter((vc)=>vc.walletName === 'dynamicwaas');
|
|
8419
8516
|
for (const vc of waasWallets != null ? waasWallets : []){
|
|
8517
|
+
var _props_settings, _this_getWalletFromMap;
|
|
8420
8518
|
const addr = vc.address;
|
|
8421
8519
|
const props = vc.walletProperties;
|
|
8422
|
-
|
|
8520
|
+
var _props_settings_variant, _ref;
|
|
8521
|
+
// Resolve the ed25519 protocol variant: server-surfaced (walletProperties
|
|
8522
|
+
// .settings or top-level) first, then any locally-seeded value (set at raw
|
|
8523
|
+
// import). Required on a fresh session (no local seed) so recover/sign
|
|
8524
|
+
// rebuild the non-exportable Ed25519 signer for raw-scalar wallets instead
|
|
8525
|
+
// of defaulting to exportable → "Invalid discriminant".
|
|
8526
|
+
const resolvedVariant = (_ref = (_props_settings_variant = props == null ? void 0 : (_props_settings = props.settings) == null ? void 0 : _props_settings.variant) != null ? _props_settings_variant : props == null ? void 0 : props.variant) != null ? _ref : (_this_getWalletFromMap = this.getWalletFromMap(addr)) == null ? void 0 : _this_getWalletFromMap.variant;
|
|
8527
|
+
this.updateWalletMap(addr, _extends({
|
|
8423
8528
|
walletId: vc.id,
|
|
8424
8529
|
chainName: verifiedCredentialNameToChainEnum[vc.chain],
|
|
8425
8530
|
accountAddress: addr,
|
|
@@ -8432,7 +8537,9 @@ class DynamicWalletClient {
|
|
|
8432
8537
|
shareSetId: props == null ? void 0 : props.shareSetId,
|
|
8433
8538
|
shareSetType: props == null ? void 0 : props.shareSetType,
|
|
8434
8539
|
otherShareSets: props == null ? void 0 : props.otherShareSets
|
|
8435
|
-
}
|
|
8540
|
+
}, resolvedVariant ? {
|
|
8541
|
+
variant: resolvedVariant
|
|
8542
|
+
} : {}));
|
|
8436
8543
|
}
|
|
8437
8544
|
if (walletOperation !== WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
8438
8545
|
accountAddress,
|
|
@@ -8810,8 +8917,8 @@ class DynamicWalletClient {
|
|
|
8810
8917
|
this.userId = user.id;
|
|
8811
8918
|
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.filter((vc)=>vc.walletName === 'dynamicwaas');
|
|
8812
8919
|
const wallets = waasWallets.map((vc)=>{
|
|
8813
|
-
var _this_getWalletFromMap, _vc_walletProperties, _vc_walletProperties1, _vc_walletProperties2, _vc_walletProperties3, _vc_walletProperties4, _vc_walletProperties5, _vc_walletProperties6;
|
|
8814
|
-
var _this_getWalletFromMap_derivationPath;
|
|
8920
|
+
var _this_getWalletFromMap, _vc_walletProperties, _vc_walletProperties1, _vc_walletProperties2, _vc_walletProperties3, _vc_walletProperties4, _vc_walletProperties5, _vc_walletProperties6, _vc_walletProperties_settings, _vc_walletProperties7, _vc_walletProperties8, _this_getWalletFromMap1;
|
|
8921
|
+
var _this_getWalletFromMap_derivationPath, _vc_walletProperties_settings_variant, _ref;
|
|
8815
8922
|
return {
|
|
8816
8923
|
walletId: vc.id,
|
|
8817
8924
|
chainName: verifiedCredentialNameToChainEnum[vc.chain],
|
|
@@ -8829,14 +8936,18 @@ class DynamicWalletClient {
|
|
|
8829
8936
|
// On-sign-on settings (shouldRefreshOnNextSignOn / reshareOnNextSignOn /
|
|
8830
8937
|
// revokeOnNextSignOn). Surfaced so the SDK can self-drive the on-sign-on
|
|
8831
8938
|
// orchestration instead of the host reading these flags.
|
|
8832
|
-
settings: (_vc_walletProperties6 = vc.walletProperties) == null ? void 0 : _vc_walletProperties6.settings
|
|
8939
|
+
settings: (_vc_walletProperties6 = vc.walletProperties) == null ? void 0 : _vc_walletProperties6.settings,
|
|
8940
|
+
// Prefer the server-persisted variant (surfaced via walletProperties.settings),
|
|
8941
|
+
// then the locally-known value (set at raw import) so same-session
|
|
8942
|
+
// import → sign works before the server has surfaced it.
|
|
8943
|
+
variant: (_ref = (_vc_walletProperties_settings_variant = (_vc_walletProperties7 = vc.walletProperties) == null ? void 0 : (_vc_walletProperties_settings = _vc_walletProperties7.settings) == null ? void 0 : _vc_walletProperties_settings.variant) != null ? _vc_walletProperties_settings_variant : (_vc_walletProperties8 = vc.walletProperties) == null ? void 0 : _vc_walletProperties8.variant) != null ? _ref : (_this_getWalletFromMap1 = this.getWalletFromMap(vc.address)) == null ? void 0 : _this_getWalletFromMap1.variant
|
|
8833
8944
|
};
|
|
8834
8945
|
});
|
|
8835
8946
|
const existingWalletMap = this.walletMap;
|
|
8836
8947
|
this.walletMap = wallets.reduce((acc, wallet)=>{
|
|
8837
8948
|
const normalizedAddress = normalizeAddress(wallet.accountAddress);
|
|
8838
8949
|
const existingWallet = existingWalletMap[normalizedAddress];
|
|
8839
|
-
acc[normalizedAddress] = {
|
|
8950
|
+
acc[normalizedAddress] = _extends({
|
|
8840
8951
|
walletId: wallet.walletId,
|
|
8841
8952
|
chainName: wallet.chainName,
|
|
8842
8953
|
accountAddress: wallet.accountAddress,
|
|
@@ -8849,7 +8960,9 @@ class DynamicWalletClient {
|
|
|
8849
8960
|
shareSetType: wallet.shareSetType,
|
|
8850
8961
|
businessAccountId: wallet.businessAccountId,
|
|
8851
8962
|
otherShareSets: wallet.otherShareSets
|
|
8852
|
-
}
|
|
8963
|
+
}, wallet.variant ? {
|
|
8964
|
+
variant: wallet.variant
|
|
8965
|
+
} : {});
|
|
8853
8966
|
return acc;
|
|
8854
8967
|
}, {});
|
|
8855
8968
|
this.logger.info('[walletMap] getWallets: walletMap updated from API', {
|
|
@@ -9303,4 +9416,44 @@ DynamicWalletClient.roomsPersistDirty = false;
|
|
|
9303
9416
|
// rooms back into the new user's storage (TOCTOU on the create→merge gap).
|
|
9304
9417
|
DynamicWalletClient.roomsGeneration = 0;
|
|
9305
9418
|
|
|
9306
|
-
|
|
9419
|
+
/**
|
|
9420
|
+
* Derive the 32-byte ed25519 public key from a **raw** 32-byte signing scalar
|
|
9421
|
+
* (`A = s·B`).
|
|
9422
|
+
*
|
|
9423
|
+
* This is NOT the same as deriving a public key from an RFC-8032 seed: the
|
|
9424
|
+
* standard ed25519 key-generation step takes a 32-byte seed and SHA-512-expands
|
|
9425
|
+
* it (then clamps) to obtain the scalar. A scalar exported from an external MPC
|
|
9426
|
+
* system (e.g. Fireblocks Embedded Wallets) has no preimage seed, so it must be
|
|
9427
|
+
* used directly as the scalar. Using `Keypair.fromSecretKey` / `keyPairFromSeed`
|
|
9428
|
+
* on such bytes would re-expand them and produce the wrong public key/address.
|
|
9429
|
+
*
|
|
9430
|
+
* @param scalar Raw 32-byte ed25519 scalar, little-endian, as hex (with or
|
|
9431
|
+
* without a `0x` prefix) or as raw bytes.
|
|
9432
|
+
* @returns The compressed 32-byte ed25519 public key.
|
|
9433
|
+
*/ const getEd25519PublicKeyFromRawScalar = (scalar)=>{
|
|
9434
|
+
let bytes;
|
|
9435
|
+
if (typeof scalar === 'string') {
|
|
9436
|
+
const hex = scalar.replace(/^0x/, '');
|
|
9437
|
+
// Validate before hexToBytes so malformed input fails with a clear, own
|
|
9438
|
+
// error rather than an opaque/implementation-specific one from the decoder.
|
|
9439
|
+
if (!/^[0-9a-fA-F]+$/.test(hex)) {
|
|
9440
|
+
throw new Error('Invalid raw ed25519 scalar: expected a hex string');
|
|
9441
|
+
}
|
|
9442
|
+
bytes = hexToBytes(hex);
|
|
9443
|
+
} else {
|
|
9444
|
+
bytes = scalar;
|
|
9445
|
+
}
|
|
9446
|
+
if (bytes.length !== 32) {
|
|
9447
|
+
throw new Error(`Invalid raw ed25519 scalar length: ${bytes.length}, expected 32`);
|
|
9448
|
+
}
|
|
9449
|
+
// Interpret the scalar little-endian and reduce mod the curve order. We do NOT
|
|
9450
|
+
// clamp here: the caller provides the actual signing scalar `s`, and the public
|
|
9451
|
+
// key is exactly `s·B`.
|
|
9452
|
+
const reduced = bytesToNumberLE(bytes) % ed25519.CURVE.n;
|
|
9453
|
+
if (reduced === 0n) {
|
|
9454
|
+
throw new Error('Invalid raw ed25519 scalar: reduces to zero mod the curve order');
|
|
9455
|
+
}
|
|
9456
|
+
return ed25519.ExtendedPoint.BASE.multiply(reduced).toRawBytes();
|
|
9457
|
+
};
|
|
9458
|
+
|
|
9459
|
+
export { BACKUP_FILENAME, CLIENT_KEYSHARE_EXPORT_FILENAME_PREFIX, DynamicWalletClient, ENVIRONMENT_SETTINGS_STORAGE_KEY, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_EXPORT_PRIVATE_KEY, ERROR_IMPORT_PRIVATE_KEY, ERROR_INCORRECT_PASSWORD, ERROR_KEYGEN_FAILED, ERROR_MULTIPLE_WALLETS_PER_CHAIN, ERROR_NO_KEY_SHARES_BACKED_UP, ERROR_PASSWORD_MISMATCH, ERROR_PASSWORD_REQUIRED, ERROR_PASSWORD_REQUIRED_FOR_ENCRYPTED_WALLET, ERROR_PUBLIC_KEY_MISMATCH, ERROR_REFRESH_NOT_SUPPORTED_FOR_TWO_OF_THREE, ERROR_SIGN_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_VERIFY_TRANSACTION_SIGNATURE, HEAVY_QUEUE_OPERATIONS, OperationSource, RECOVER_QUEUE_OPERATIONS, ROOM_CACHE_COUNT, ROOM_EXPIRATION_TIME, SIGNED_SESSION_ID_MIN_VERSION, SIGNED_SESSION_ID_MIN_VERSION_BY_NAMESPACE, SIGNED_SESSION_REVERSE_CHANNEL_MIN_VERSION, SIGNED_SESSION_REVERSE_CHANNEL_MIN_VERSION_BY_NAMESPACE, SIGN_QUEUE_OPERATIONS, STORAGE_KEY, StaleLocalSharesError, WalletBusyError, WalletNotReadyError, cancelICloudAuth, createAddCloudProviderToExistingDelegationDistribution, createBackupData, createCloudProviderDistribution, createDelegationOnlyDistribution, createDelegationWithCloudProviderDistribution, createDynamicOnlyDistribution, deleteICloudBackup, downloadStringAsFile, extractPubkey, formatEvmMessage, formatMessage, formatTronMessage, getActiveCloudProviders, getBitcoinAddressTypeFromAddress, getBitcoinAddressTypeFromDerivationPath, getClientKeyShareBackupInfo, getClientKeyShareExportFileName, getDelegatedShareSet, getEd25519PublicKeyFromRawScalar, getGoogleOAuthAccountId, getHttpStatus, getICloudBackup, getMPCSignatureScheme, getMPCSigner, hasCloudProviderBackup, hasDelegatedBackup, hasEncryptedSharesCached, initializeCloudKit, isBrowser, isHeavyQueueOperation, isHexString, isICloudAuthenticated, isNonRetryableCeremonyError, isPublicKeyMismatchError, isRecoverQueueOperation, isRoomIdAlreadyUsedError, isSignQueueOperation, isStaleClientSharesError, listICloudBackups, markCeremonyErrorNonRetryable, readEnvironmentSettings, resolveLogLevel, retryPromise, shouldReshareToSameBackups, timeoutPromise };
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.93",
|
|
4
4
|
"license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/core": "1.0.
|
|
7
|
+
"@dynamic-labs-wallet/core": "1.0.93",
|
|
8
8
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
9
|
-
"@dynamic-labs-wallet/primitives": "1.0.
|
|
9
|
+
"@dynamic-labs-wallet/primitives": "1.0.93",
|
|
10
10
|
"@dynamic-labs/sdk-api-core": "^0.0.1093",
|
|
11
|
+
"@noble/curves": "1.8.0",
|
|
11
12
|
"argon2id": "1.0.1",
|
|
12
13
|
"axios": "1.16.0",
|
|
13
14
|
"p-queue": "9.1.0",
|