@dynamic-labs-wallet/browser 0.0.17 → 0.0.19
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.js +115 -71
- package/index.esm.js +89 -45
- package/node_modules/@internal/core/dist/bip340.js +1 -0
- package/node_modules/@internal/core/dist/common.js +1 -0
- package/node_modules/@internal/core/dist/ecdsa.js +1 -0
- package/node_modules/@internal/core/dist/ed25519.js +1 -0
- package/node_modules/@internal/core/dist/index.js +1 -0
- package/node_modules/@internal/core/dist/native.js +1 -0
- package/node_modules/@internal/core/dist/types.js +1 -0
- package/node_modules/@internal/core/package.json +19 -0
- package/node_modules/@internal/web/dist/generated/libmpc_executor.js +2 -0
- package/node_modules/@internal/web/dist/generated/libmpc_executor_bg.wasm +0 -0
- package/node_modules/@internal/web/dist/index.js +1 -0
- package/node_modules/@internal/web/package.json +19 -0
- package/package.json +10 -5
- package/src/client.d.ts +31 -8
- package/src/client.d.ts.map +1 -1
- package/src/mpc/index.d.ts +1 -1
- package/src/mpc/index.d.ts.map +1 -1
- package/src/mpc/mpc.d.ts +1 -1
- package/src/mpc/mpc.d.ts.map +1 -1
- package/src/mpc/types.d.ts +2 -2
- package/src/mpc/types.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@dynamic-labs-wallet/core');
|
|
4
|
-
var
|
|
4
|
+
var web = require('@internal/web');
|
|
5
5
|
var logger$1 = require('@dynamic-labs/logger');
|
|
6
6
|
|
|
7
7
|
function _extends() {
|
|
@@ -18,11 +18,11 @@ function _extends() {
|
|
|
18
18
|
const getMPCSignatureScheme = ({ signingAlgorithm, baseRelayUrl = core.MPC_RELAY_PROD_API_URL })=>{
|
|
19
19
|
switch(signingAlgorithm){
|
|
20
20
|
case core.SigningAlgorithm.ECDSA:
|
|
21
|
-
return new
|
|
21
|
+
return new web.Ecdsa(baseRelayUrl);
|
|
22
22
|
case core.SigningAlgorithm.ED25519:
|
|
23
|
-
return new
|
|
23
|
+
return new web.Ed25519(baseRelayUrl);
|
|
24
24
|
case core.SigningAlgorithm.BIP340:
|
|
25
|
-
return new
|
|
25
|
+
return new web.BIP340(baseRelayUrl);
|
|
26
26
|
default:
|
|
27
27
|
throw new Error(`Unsupported signing algorithm: ${signingAlgorithm}`);
|
|
28
28
|
}
|
|
@@ -295,7 +295,7 @@ class DynamicWalletClient {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
async serverInitializeKeyGen({ chainName, clientKeygenIds, thresholdSignatureScheme }) {
|
|
298
|
-
//
|
|
298
|
+
// Initialize keygen, create room, and create the wallet account on the server
|
|
299
299
|
const data = await this.apiClient.createWalletAccount({
|
|
300
300
|
chainName,
|
|
301
301
|
clientKeygenIds,
|
|
@@ -320,9 +320,9 @@ class DynamicWalletClient {
|
|
|
320
320
|
});
|
|
321
321
|
const chainConfig = core.getMPCChainConfig(chainName);
|
|
322
322
|
let publicKey;
|
|
323
|
-
if (mpcSigner instanceof
|
|
323
|
+
if (mpcSigner instanceof web.Ecdsa) {
|
|
324
324
|
publicKey = await mpcSigner.derivePubkey(keyShare, new Uint32Array(chainConfig.derivationPath));
|
|
325
|
-
} else if (mpcSigner instanceof
|
|
325
|
+
} else if (mpcSigner instanceof web.Ed25519) {
|
|
326
326
|
publicKey = await mpcSigner.derivePubkey(keyShare, new Uint32Array(chainConfig.derivationPath));
|
|
327
327
|
}
|
|
328
328
|
return publicKey;
|
|
@@ -406,11 +406,11 @@ class DynamicWalletClient {
|
|
|
406
406
|
const derivationPath = new Uint32Array(chainConfig.derivationPath);
|
|
407
407
|
let formattedMessage;
|
|
408
408
|
//note: Ecdsa can also be used by bitcoin, but only keccak256 is used by ethereum
|
|
409
|
-
if (mpcSigner instanceof
|
|
410
|
-
formattedMessage =
|
|
411
|
-
} else if (mpcSigner instanceof
|
|
409
|
+
if (mpcSigner instanceof web.Ecdsa) {
|
|
410
|
+
formattedMessage = web.MessageHash.keccak256(message);
|
|
411
|
+
} else if (mpcSigner instanceof web.Ed25519 && typeof message === 'string') {
|
|
412
412
|
formattedMessage = new TextEncoder().encode(message);
|
|
413
|
-
} else if (mpcSigner instanceof
|
|
413
|
+
} else if (mpcSigner instanceof web.BIP340 && typeof message === 'string') {
|
|
414
414
|
formattedMessage = new TextEncoder().encode(message);
|
|
415
415
|
} else {
|
|
416
416
|
throw new Error('Unsupported signer type');
|
|
@@ -464,13 +464,6 @@ class DynamicWalletClient {
|
|
|
464
464
|
});
|
|
465
465
|
return refreshResults;
|
|
466
466
|
}
|
|
467
|
-
async serverReshareRemainingParty({ walletId, clientKeygenIds }) {
|
|
468
|
-
const data = await this.apiClient.reshareRemainingParty({
|
|
469
|
-
walletId,
|
|
470
|
-
clientKeygenIds
|
|
471
|
-
});
|
|
472
|
-
return data;
|
|
473
|
-
}
|
|
474
467
|
async getExportId({ chainName, clientKeyShare }) {
|
|
475
468
|
const mpcSigner = getMPCSigner({
|
|
476
469
|
chainName,
|
|
@@ -479,48 +472,94 @@ class DynamicWalletClient {
|
|
|
479
472
|
const exportId = await mpcSigner.exportID(clientKeyShare);
|
|
480
473
|
return exportId;
|
|
481
474
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
475
|
+
/**
|
|
476
|
+
* Helper function to create client shares required to complete a reshare ceremony.
|
|
477
|
+
* @param {string} chainName - The chain to create shares for
|
|
478
|
+
* @param {WalletProperties} wallet - The wallet to reshare
|
|
479
|
+
* @param {ThresholdSignatureScheme} oldThresholdSignatureScheme - The current threshold signature scheme
|
|
480
|
+
* @param {ThresholdSignatureScheme} newThresholdSignatureScheme - The target threshold signature scheme
|
|
481
|
+
* @returns {Promise<{
|
|
482
|
+
* newClientInitKeygenResults: ClientInitKeygenResult[],
|
|
483
|
+
* newClientKeygenIds: string[],
|
|
484
|
+
* existingClientKeygenIds: string[],
|
|
485
|
+
* existingClientKeyShares: ClientKeyShare[]
|
|
486
|
+
* }>} Object containing new and existing client keygen results, IDs and shares
|
|
487
|
+
* @todo Support higher to lower reshare strategies
|
|
488
|
+
*/ async reshareStrategy({ chainName, wallet, oldThresholdSignatureScheme, newThresholdSignatureScheme }) {
|
|
487
489
|
const mpcSigner = getMPCSigner({
|
|
488
490
|
chainName,
|
|
489
491
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
490
492
|
});
|
|
491
|
-
//
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
493
|
+
// Determine share counts based on threshold signature schemes
|
|
494
|
+
const { newClientShareCount, existingClientShareCount } = core.getReshareConfig({
|
|
495
|
+
oldThresholdSignatureScheme,
|
|
496
|
+
newThresholdSignatureScheme
|
|
497
|
+
});
|
|
498
|
+
// Create new client shares
|
|
499
|
+
const newClientInitKeygenResults = await Promise.all(Array.from({
|
|
500
|
+
length: newClientShareCount
|
|
501
|
+
}, ()=>mpcSigner.initKeygen()));
|
|
502
|
+
const newClientKeygenIds = newClientInitKeygenResults.map((result)=>result.keygenId);
|
|
503
|
+
// Get existing client shares
|
|
504
|
+
const existingClientKeyShares = wallet.clientKeyShares.slice(0, existingClientShareCount);
|
|
505
|
+
const existingClientKeygenIds = await Promise.all(existingClientKeyShares.map(async (keyShare)=>await this.getExportId({
|
|
506
|
+
chainName,
|
|
507
|
+
clientKeyShare: keyShare
|
|
508
|
+
})));
|
|
509
|
+
return {
|
|
510
|
+
newClientInitKeygenResults,
|
|
511
|
+
newClientKeygenIds,
|
|
512
|
+
existingClientKeygenIds,
|
|
513
|
+
existingClientKeyShares
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme }) {
|
|
517
|
+
const wallet = await this.getWallet({
|
|
518
|
+
accountAddress
|
|
519
|
+
});
|
|
520
|
+
console.log(`Resharing from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
|
|
521
|
+
const { newClientInitKeygenResults, newClientKeygenIds, existingClientKeygenIds, existingClientKeyShares } = await this.reshareStrategy({
|
|
495
522
|
chainName,
|
|
496
|
-
|
|
523
|
+
wallet,
|
|
524
|
+
oldThresholdSignatureScheme,
|
|
525
|
+
newThresholdSignatureScheme
|
|
497
526
|
});
|
|
498
|
-
|
|
499
|
-
|
|
527
|
+
const clientKeygenIds = [
|
|
528
|
+
...newClientKeygenIds,
|
|
529
|
+
...existingClientKeygenIds
|
|
530
|
+
];
|
|
531
|
+
// Server to create the room and complete the server reshare logics
|
|
532
|
+
const data = await this.apiClient.reshare({
|
|
500
533
|
walletId: wallet.walletId,
|
|
501
|
-
clientKeygenIds:
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
]
|
|
534
|
+
clientKeygenIds: clientKeygenIds,
|
|
535
|
+
oldThresholdSignatureScheme,
|
|
536
|
+
newThresholdSignatureScheme
|
|
505
537
|
});
|
|
506
|
-
const roomId = data
|
|
538
|
+
const { roomId, serverKeygenIds, newServerKeygenIds } = data;
|
|
507
539
|
// Get the MPC config for the threshold signature scheme
|
|
508
|
-
const
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
|
|
540
|
+
const oldMpcConfig = core.MPC_CONFIG[oldThresholdSignatureScheme];
|
|
541
|
+
const newMpcConfig = core.MPC_CONFIG[newThresholdSignatureScheme];
|
|
542
|
+
const allPartyKeygenIds = [
|
|
543
|
+
...clientKeygenIds,
|
|
544
|
+
...serverKeygenIds,
|
|
545
|
+
...newServerKeygenIds
|
|
512
546
|
];
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
mpcSigner.reshareNewParty(roomId, mpcConfig.threshold, mpcConfig.threshold, newPartyInitKeygen, newClientPrimaryKeygenIds),
|
|
521
|
-
mpcSigner.reshareRemainingParty(roomId, mpcConfig.threshold, wallet.clientKeyShares[1], clientSecondaryKeygenIds)
|
|
547
|
+
const mpcSigner = getMPCSigner({
|
|
548
|
+
chainName,
|
|
549
|
+
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
550
|
+
});
|
|
551
|
+
const reshareResults = await Promise.all([
|
|
552
|
+
...newClientInitKeygenResults.map((keygenResult)=>mpcSigner.reshareNewParty(roomId, oldMpcConfig.threshold, newMpcConfig.threshold, keygenResult, allPartyKeygenIds)),
|
|
553
|
+
...existingClientKeyShares.map((keyShare)=>mpcSigner.reshareRemainingParty(roomId, newMpcConfig.threshold, keyShare, allPartyKeygenIds))
|
|
522
554
|
]);
|
|
523
|
-
|
|
555
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
556
|
+
clientKeyShares: reshareResults
|
|
557
|
+
});
|
|
558
|
+
await this.storeEncryptedBackupByWallet({
|
|
559
|
+
accountAddress,
|
|
560
|
+
password: undefined
|
|
561
|
+
});
|
|
562
|
+
return reshareResults;
|
|
524
563
|
}
|
|
525
564
|
async exportKey({ accountAddress, chainName }) {
|
|
526
565
|
const wallet = await this.getWallet({
|
|
@@ -545,11 +584,11 @@ class DynamicWalletClient {
|
|
|
545
584
|
}
|
|
546
585
|
const derivationPath = new Uint32Array(chainConfig.derivationPath);
|
|
547
586
|
let derivedPrivateKey;
|
|
548
|
-
if (mpcSigner instanceof
|
|
587
|
+
if (mpcSigner instanceof web.Ecdsa) {
|
|
549
588
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
550
|
-
} else if (mpcSigner instanceof
|
|
589
|
+
} else if (mpcSigner instanceof web.Ed25519) {
|
|
551
590
|
derivedPrivateKey = keyExportRaw;
|
|
552
|
-
} else if (mpcSigner instanceof
|
|
591
|
+
} else if (mpcSigner instanceof web.BIP340) {
|
|
553
592
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
554
593
|
}
|
|
555
594
|
return {
|
|
@@ -566,7 +605,7 @@ class DynamicWalletClient {
|
|
|
566
605
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
567
606
|
});
|
|
568
607
|
const walletKeyShares = keyShares.map((keyShare)=>{
|
|
569
|
-
return mpcSigner instanceof
|
|
608
|
+
return mpcSigner instanceof web.Ecdsa ? new web.EcdsaKeygenResult(keyShare.pubkey, keyShare.secretShare) : mpcSigner instanceof web.Ed25519 ? new web.Ed25519KeygenResult(keyShare.pubkey, keyShare.secretShare) : new web.BIP340KeygenResult(keyShare.pubkey, keyShare.secretShare);
|
|
570
609
|
});
|
|
571
610
|
const keyExportRaw = await mpcSigner.offlineExportFullPrivateKey(walletKeyShares);
|
|
572
611
|
if (!keyExportRaw) {
|
|
@@ -575,11 +614,11 @@ class DynamicWalletClient {
|
|
|
575
614
|
const chainConfig = core.getMPCChainConfig(chainName);
|
|
576
615
|
const derivationPath = new Uint32Array(chainConfig.derivationPath);
|
|
577
616
|
let derivedPrivateKey;
|
|
578
|
-
if (mpcSigner instanceof
|
|
617
|
+
if (mpcSigner instanceof web.Ecdsa) {
|
|
579
618
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
580
|
-
} else if (mpcSigner instanceof
|
|
619
|
+
} else if (mpcSigner instanceof web.Ed25519) {
|
|
581
620
|
derivedPrivateKey = keyExportRaw;
|
|
582
|
-
} else if (mpcSigner instanceof
|
|
621
|
+
} else if (mpcSigner instanceof web.BIP340) {
|
|
583
622
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
584
623
|
}
|
|
585
624
|
return {
|
|
@@ -659,7 +698,7 @@ class DynamicWalletClient {
|
|
|
659
698
|
chainName,
|
|
660
699
|
accountAddress,
|
|
661
700
|
clientKeyShares: [
|
|
662
|
-
...((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ?
|
|
701
|
+
...((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.clientKeyShares) || [],
|
|
663
702
|
keyShare
|
|
664
703
|
],
|
|
665
704
|
thresholdSignatureScheme
|
|
@@ -767,7 +806,7 @@ class DynamicWalletClient {
|
|
|
767
806
|
} else {
|
|
768
807
|
var _user_verifiedCredentials;
|
|
769
808
|
const user = await this.apiClient.getUser();
|
|
770
|
-
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ?
|
|
809
|
+
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address === accountAddress);
|
|
771
810
|
this.logger.debug('need to restore wallet', wallet);
|
|
772
811
|
console.log('need to restore wallet', wallet);
|
|
773
812
|
const clientShares = wallet.walletProperties.keyShares.filter((ks)=>ks.backupLocation === 'dynamic');
|
|
@@ -777,6 +816,11 @@ class DynamicWalletClient {
|
|
|
777
816
|
accountAddress,
|
|
778
817
|
password: this.environmentId
|
|
779
818
|
});
|
|
819
|
+
// update threshold signature scheme
|
|
820
|
+
const thresholdSignatureScheme = wallet.walletProperties.thresholdSignatureScheme;
|
|
821
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
822
|
+
thresholdSignatureScheme
|
|
823
|
+
});
|
|
780
824
|
//todo: check to see if their are other backups ie google drive, etc
|
|
781
825
|
this.logger.debug('recovery decryptedKeyShares', decryptedKeyShares);
|
|
782
826
|
}
|
|
@@ -798,7 +842,7 @@ class DynamicWalletClient {
|
|
|
798
842
|
async getWallets() {
|
|
799
843
|
var _user_verifiedCredentials;
|
|
800
844
|
const user = await this.apiClient.getUser();
|
|
801
|
-
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ?
|
|
845
|
+
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.filter((vc)=>vc.walletName === 'dynamicwaas');
|
|
802
846
|
const wallets = waasWallets.map((vc)=>({
|
|
803
847
|
walletId: vc.id,
|
|
804
848
|
chainName: vc.chain,
|
|
@@ -846,51 +890,51 @@ class DynamicWalletClient {
|
|
|
846
890
|
|
|
847
891
|
Object.defineProperty(exports, "BIP340", {
|
|
848
892
|
enumerable: true,
|
|
849
|
-
get: function () { return
|
|
893
|
+
get: function () { return web.BIP340; }
|
|
850
894
|
});
|
|
851
895
|
Object.defineProperty(exports, "BIP340InitKeygenResult", {
|
|
852
896
|
enumerable: true,
|
|
853
|
-
get: function () { return
|
|
897
|
+
get: function () { return web.BIP340InitKeygenResult; }
|
|
854
898
|
});
|
|
855
899
|
Object.defineProperty(exports, "BIP340KeygenResult", {
|
|
856
900
|
enumerable: true,
|
|
857
|
-
get: function () { return
|
|
901
|
+
get: function () { return web.BIP340KeygenResult; }
|
|
858
902
|
});
|
|
859
903
|
Object.defineProperty(exports, "Ecdsa", {
|
|
860
904
|
enumerable: true,
|
|
861
|
-
get: function () { return
|
|
905
|
+
get: function () { return web.Ecdsa; }
|
|
862
906
|
});
|
|
863
907
|
Object.defineProperty(exports, "EcdsaInitKeygenResult", {
|
|
864
908
|
enumerable: true,
|
|
865
|
-
get: function () { return
|
|
909
|
+
get: function () { return web.EcdsaInitKeygenResult; }
|
|
866
910
|
});
|
|
867
911
|
Object.defineProperty(exports, "EcdsaKeygenResult", {
|
|
868
912
|
enumerable: true,
|
|
869
|
-
get: function () { return
|
|
913
|
+
get: function () { return web.EcdsaKeygenResult; }
|
|
870
914
|
});
|
|
871
915
|
Object.defineProperty(exports, "EcdsaPublicKey", {
|
|
872
916
|
enumerable: true,
|
|
873
|
-
get: function () { return
|
|
917
|
+
get: function () { return web.EcdsaPublicKey; }
|
|
874
918
|
});
|
|
875
919
|
Object.defineProperty(exports, "EcdsaSignature", {
|
|
876
920
|
enumerable: true,
|
|
877
|
-
get: function () { return
|
|
921
|
+
get: function () { return web.EcdsaSignature; }
|
|
878
922
|
});
|
|
879
923
|
Object.defineProperty(exports, "Ed25519", {
|
|
880
924
|
enumerable: true,
|
|
881
|
-
get: function () { return
|
|
925
|
+
get: function () { return web.Ed25519; }
|
|
882
926
|
});
|
|
883
927
|
Object.defineProperty(exports, "Ed25519InitKeygenResult", {
|
|
884
928
|
enumerable: true,
|
|
885
|
-
get: function () { return
|
|
929
|
+
get: function () { return web.Ed25519InitKeygenResult; }
|
|
886
930
|
});
|
|
887
931
|
Object.defineProperty(exports, "Ed25519KeygenResult", {
|
|
888
932
|
enumerable: true,
|
|
889
|
-
get: function () { return
|
|
933
|
+
get: function () { return web.Ed25519KeygenResult; }
|
|
890
934
|
});
|
|
891
935
|
Object.defineProperty(exports, "MessageHash", {
|
|
892
936
|
enumerable: true,
|
|
893
|
-
get: function () { return
|
|
937
|
+
get: function () { return web.MessageHash; }
|
|
894
938
|
});
|
|
895
939
|
exports.DynamicWalletClient = DynamicWalletClient;
|
|
896
940
|
exports.getMPCSignatureScheme = getMPCSignatureScheme;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, getClientThreshold, MPC_CONFIG, getTSSConfig, DynamicApiClient } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, getClientThreshold, MPC_CONFIG, getReshareConfig, getTSSConfig, DynamicApiClient } from '@dynamic-labs-wallet/core';
|
|
2
2
|
export * from '@dynamic-labs-wallet/core';
|
|
3
|
-
import { BIP340, Ed25519, Ecdsa, MessageHash, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult } from '@
|
|
4
|
-
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519, Ed25519InitKeygenResult, Ed25519KeygenResult, MessageHash } from '@
|
|
3
|
+
import { BIP340, Ed25519, Ecdsa, MessageHash, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult } from '@internal/web';
|
|
4
|
+
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519, Ed25519InitKeygenResult, Ed25519KeygenResult, MessageHash } from '@internal/web';
|
|
5
5
|
import { Logger } from '@dynamic-labs/logger';
|
|
6
6
|
|
|
7
7
|
function _extends() {
|
|
@@ -295,7 +295,7 @@ class DynamicWalletClient {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
async serverInitializeKeyGen({ chainName, clientKeygenIds, thresholdSignatureScheme }) {
|
|
298
|
-
//
|
|
298
|
+
// Initialize keygen, create room, and create the wallet account on the server
|
|
299
299
|
const data = await this.apiClient.createWalletAccount({
|
|
300
300
|
chainName,
|
|
301
301
|
clientKeygenIds,
|
|
@@ -464,13 +464,6 @@ class DynamicWalletClient {
|
|
|
464
464
|
});
|
|
465
465
|
return refreshResults;
|
|
466
466
|
}
|
|
467
|
-
async serverReshareRemainingParty({ walletId, clientKeygenIds }) {
|
|
468
|
-
const data = await this.apiClient.reshareRemainingParty({
|
|
469
|
-
walletId,
|
|
470
|
-
clientKeygenIds
|
|
471
|
-
});
|
|
472
|
-
return data;
|
|
473
|
-
}
|
|
474
467
|
async getExportId({ chainName, clientKeyShare }) {
|
|
475
468
|
const mpcSigner = getMPCSigner({
|
|
476
469
|
chainName,
|
|
@@ -479,48 +472,94 @@ class DynamicWalletClient {
|
|
|
479
472
|
const exportId = await mpcSigner.exportID(clientKeyShare);
|
|
480
473
|
return exportId;
|
|
481
474
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
475
|
+
/**
|
|
476
|
+
* Helper function to create client shares required to complete a reshare ceremony.
|
|
477
|
+
* @param {string} chainName - The chain to create shares for
|
|
478
|
+
* @param {WalletProperties} wallet - The wallet to reshare
|
|
479
|
+
* @param {ThresholdSignatureScheme} oldThresholdSignatureScheme - The current threshold signature scheme
|
|
480
|
+
* @param {ThresholdSignatureScheme} newThresholdSignatureScheme - The target threshold signature scheme
|
|
481
|
+
* @returns {Promise<{
|
|
482
|
+
* newClientInitKeygenResults: ClientInitKeygenResult[],
|
|
483
|
+
* newClientKeygenIds: string[],
|
|
484
|
+
* existingClientKeygenIds: string[],
|
|
485
|
+
* existingClientKeyShares: ClientKeyShare[]
|
|
486
|
+
* }>} Object containing new and existing client keygen results, IDs and shares
|
|
487
|
+
* @todo Support higher to lower reshare strategies
|
|
488
|
+
*/ async reshareStrategy({ chainName, wallet, oldThresholdSignatureScheme, newThresholdSignatureScheme }) {
|
|
487
489
|
const mpcSigner = getMPCSigner({
|
|
488
490
|
chainName,
|
|
489
491
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
490
492
|
});
|
|
491
|
-
//
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
493
|
+
// Determine share counts based on threshold signature schemes
|
|
494
|
+
const { newClientShareCount, existingClientShareCount } = getReshareConfig({
|
|
495
|
+
oldThresholdSignatureScheme,
|
|
496
|
+
newThresholdSignatureScheme
|
|
497
|
+
});
|
|
498
|
+
// Create new client shares
|
|
499
|
+
const newClientInitKeygenResults = await Promise.all(Array.from({
|
|
500
|
+
length: newClientShareCount
|
|
501
|
+
}, ()=>mpcSigner.initKeygen()));
|
|
502
|
+
const newClientKeygenIds = newClientInitKeygenResults.map((result)=>result.keygenId);
|
|
503
|
+
// Get existing client shares
|
|
504
|
+
const existingClientKeyShares = wallet.clientKeyShares.slice(0, existingClientShareCount);
|
|
505
|
+
const existingClientKeygenIds = await Promise.all(existingClientKeyShares.map(async (keyShare)=>await this.getExportId({
|
|
506
|
+
chainName,
|
|
507
|
+
clientKeyShare: keyShare
|
|
508
|
+
})));
|
|
509
|
+
return {
|
|
510
|
+
newClientInitKeygenResults,
|
|
511
|
+
newClientKeygenIds,
|
|
512
|
+
existingClientKeygenIds,
|
|
513
|
+
existingClientKeyShares
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme }) {
|
|
517
|
+
const wallet = await this.getWallet({
|
|
518
|
+
accountAddress
|
|
519
|
+
});
|
|
520
|
+
console.log(`Resharing from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
|
|
521
|
+
const { newClientInitKeygenResults, newClientKeygenIds, existingClientKeygenIds, existingClientKeyShares } = await this.reshareStrategy({
|
|
495
522
|
chainName,
|
|
496
|
-
|
|
523
|
+
wallet,
|
|
524
|
+
oldThresholdSignatureScheme,
|
|
525
|
+
newThresholdSignatureScheme
|
|
497
526
|
});
|
|
498
|
-
|
|
499
|
-
|
|
527
|
+
const clientKeygenIds = [
|
|
528
|
+
...newClientKeygenIds,
|
|
529
|
+
...existingClientKeygenIds
|
|
530
|
+
];
|
|
531
|
+
// Server to create the room and complete the server reshare logics
|
|
532
|
+
const data = await this.apiClient.reshare({
|
|
500
533
|
walletId: wallet.walletId,
|
|
501
|
-
clientKeygenIds:
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
]
|
|
534
|
+
clientKeygenIds: clientKeygenIds,
|
|
535
|
+
oldThresholdSignatureScheme,
|
|
536
|
+
newThresholdSignatureScheme
|
|
505
537
|
});
|
|
506
|
-
const roomId = data
|
|
538
|
+
const { roomId, serverKeygenIds, newServerKeygenIds } = data;
|
|
507
539
|
// Get the MPC config for the threshold signature scheme
|
|
508
|
-
const
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
|
|
540
|
+
const oldMpcConfig = MPC_CONFIG[oldThresholdSignatureScheme];
|
|
541
|
+
const newMpcConfig = MPC_CONFIG[newThresholdSignatureScheme];
|
|
542
|
+
const allPartyKeygenIds = [
|
|
543
|
+
...clientKeygenIds,
|
|
544
|
+
...serverKeygenIds,
|
|
545
|
+
...newServerKeygenIds
|
|
512
546
|
];
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
mpcSigner.reshareNewParty(roomId, mpcConfig.threshold, mpcConfig.threshold, newPartyInitKeygen, newClientPrimaryKeygenIds),
|
|
521
|
-
mpcSigner.reshareRemainingParty(roomId, mpcConfig.threshold, wallet.clientKeyShares[1], clientSecondaryKeygenIds)
|
|
547
|
+
const mpcSigner = getMPCSigner({
|
|
548
|
+
chainName,
|
|
549
|
+
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
550
|
+
});
|
|
551
|
+
const reshareResults = await Promise.all([
|
|
552
|
+
...newClientInitKeygenResults.map((keygenResult)=>mpcSigner.reshareNewParty(roomId, oldMpcConfig.threshold, newMpcConfig.threshold, keygenResult, allPartyKeygenIds)),
|
|
553
|
+
...existingClientKeyShares.map((keyShare)=>mpcSigner.reshareRemainingParty(roomId, newMpcConfig.threshold, keyShare, allPartyKeygenIds))
|
|
522
554
|
]);
|
|
523
|
-
|
|
555
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
556
|
+
clientKeyShares: reshareResults
|
|
557
|
+
});
|
|
558
|
+
await this.storeEncryptedBackupByWallet({
|
|
559
|
+
accountAddress,
|
|
560
|
+
password: undefined
|
|
561
|
+
});
|
|
562
|
+
return reshareResults;
|
|
524
563
|
}
|
|
525
564
|
async exportKey({ accountAddress, chainName }) {
|
|
526
565
|
const wallet = await this.getWallet({
|
|
@@ -659,7 +698,7 @@ class DynamicWalletClient {
|
|
|
659
698
|
chainName,
|
|
660
699
|
accountAddress,
|
|
661
700
|
clientKeyShares: [
|
|
662
|
-
...((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ?
|
|
701
|
+
...((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.clientKeyShares) || [],
|
|
663
702
|
keyShare
|
|
664
703
|
],
|
|
665
704
|
thresholdSignatureScheme
|
|
@@ -767,7 +806,7 @@ class DynamicWalletClient {
|
|
|
767
806
|
} else {
|
|
768
807
|
var _user_verifiedCredentials;
|
|
769
808
|
const user = await this.apiClient.getUser();
|
|
770
|
-
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ?
|
|
809
|
+
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address === accountAddress);
|
|
771
810
|
this.logger.debug('need to restore wallet', wallet);
|
|
772
811
|
console.log('need to restore wallet', wallet);
|
|
773
812
|
const clientShares = wallet.walletProperties.keyShares.filter((ks)=>ks.backupLocation === 'dynamic');
|
|
@@ -777,6 +816,11 @@ class DynamicWalletClient {
|
|
|
777
816
|
accountAddress,
|
|
778
817
|
password: this.environmentId
|
|
779
818
|
});
|
|
819
|
+
// update threshold signature scheme
|
|
820
|
+
const thresholdSignatureScheme = wallet.walletProperties.thresholdSignatureScheme;
|
|
821
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
822
|
+
thresholdSignatureScheme
|
|
823
|
+
});
|
|
780
824
|
//todo: check to see if their are other backups ie google drive, etc
|
|
781
825
|
this.logger.debug('recovery decryptedKeyShares', decryptedKeyShares);
|
|
782
826
|
}
|
|
@@ -798,7 +842,7 @@ class DynamicWalletClient {
|
|
|
798
842
|
async getWallets() {
|
|
799
843
|
var _user_verifiedCredentials;
|
|
800
844
|
const user = await this.apiClient.getUser();
|
|
801
|
-
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ?
|
|
845
|
+
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.filter((vc)=>vc.walletName === 'dynamicwaas');
|
|
802
846
|
const wallets = waasWallets.map((vc)=>({
|
|
803
847
|
walletId: vc.id,
|
|
804
848
|
chainName: vc.chain,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340=void 0;let _1=require("."),utils_1=require("@noble/hashes/utils"),common_1=require("./common");function getTweak(e){if(0!==(e="string"!=typeof e?(0,utils_1.bytesToHex)(e):e).length&&64!==e.length)throw new Error("Tweak must be 32 bytes long");return e}class BIP340{constructor(e,t){this.NATIVE=e,this.URL=t}async initKeygen(){var e=await(await this.NATIVE).initKeygen();return new _1.BIP340InitKeygenResult(e.pubkey,e.keypair)}async exportID(e){e="string"==typeof e?e:e.secretShare;return(await this.NATIVE).bip340GetExportID(e)}async createRoom(e,t){return(0,common_1.sanitizeNumberOfParties)(e),(await this.NATIVE).createRoom(this.URL,e,t)}async keygen(e,t,r,i,a){if((0,common_1.sanitizeNumberOfParties)(t,r),a.length!==t-1)throw new Error(`keygenIds length must be exactly: ${t-1}, it is: `+a.length);e=await(await this.NATIVE).bip340Keygen(e,this.URL,t,r,i.keygenSecret,a);if(e.pubkey&&e.secret_share)return t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share,new _1.BIP340KeygenResult(t,r);throw new Error("Keygen failed, no public key or secret share was returned.")}async sign(e,t,r,i=new Uint32Array,a=new Uint8Array){t="string"==typeof t?t:t.secretShare,"string"!=typeof r&&(r=(0,utils_1.bytesToHex)(r)),a=getTweak(a),e=await(await this.NATIVE).bip340Sign(e,this.URL,t,r,Array.from(i),a);return(0,utils_1.hexToBytes)(e)}async refresh(e,t){var t="string"==typeof t?t:t.secretShare,e=await(await this.NATIVE).bip340Refresh(e,this.URL,t);if(e.pubkey&&e.secret_share)return t=(0,utils_1.hexToBytes)(e.pubkey),e=e.secret_share,new _1.BIP340KeygenResult(t,e);throw new Error("Keygen failed, no public key or secret share was returned.")}async reshareNewParty(e,t,r,i,a){e=await(await this.NATIVE).bip340ReshareNewParty(e,this.URL,t,r,i.keygenSecret,a),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.BIP340KeygenResult(t,r)}async reshareRemainingParty(e,t,r,i){r="string"==typeof r?r:r.secretShare,e=await(await this.NATIVE).bip340ReshareRemainingParty(e,this.URL,t,r,i),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.BIP340KeygenResult(t,r)}async deriveTweakPubkey(e,t=new Uint32Array,r=new Uint8Array){e="string"==typeof e?e:e.secretShare,e=await(await this.NATIVE).bip340DeriveTweakPubkey(e,Array.from(t),getTweak(r));return(0,utils_1.hexToBytes)(e)}async getXpub(e){e="string"==typeof e?e:e.secretShare;return(await this.NATIVE).bip340GetXpub(e)}async deriveTweakPubkeyFromXpub(e,t=new Uint32Array,r=new Uint8Array){e=await(await this.NATIVE).bip340DeriveTweakPubkeyFromXpub(e,Array.from(t),getTweak(r));return(0,utils_1.hexToBytes)(e)}async exportFullPrivateKey(e,t,r){t="string"==typeof t?t:t.secretShare;return(await this.NATIVE).bip340ExportFullPrivateKey(e,this.URL,t,r)}async derivePrivateKeyFromXpriv(e,t=new Uint32Array){return(await this.NATIVE).bip340DerivePrivateKeyFromXpriv(e,Array.from(t))}async offlineExportFullPrivateKey(e){e=e.map(e=>{if("string"==typeof e)return e;if(e instanceof _1.BIP340KeygenResult)return e.secretShare;throw"UnknownType"});return(await this.NATIVE).bip340OfflineExportFullPrivateKey(e)}async importPrivateKeyRecipient(e,t,r,i){e=await(await this.NATIVE).bip340ImportPrivateKeyRecipient(e,this.URL,t,r.keygenSecret,i),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.BIP340KeygenResult(t,r)}async importPrivateKeyImporter(e,t,r,i,a){e=await(await this.NATIVE).bip340ImportPrivateKeyImporter(e,this.URL,t,r,i.keygenSecret,a),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.BIP340KeygenResult(t,r)}}exports.BIP340=BIP340;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function sanitizeNumberOfParties(...e){for(var r of e)if(!Number.isInteger(r)||r<1||65535<r)throw new RangeError(`numberOfParties should be an integer in the range: 1..65_535, instead got: ${r} `)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.sanitizeNumberOfParties=sanitizeNumberOfParties;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ecdsa=void 0;let _1=require("./"),common_1=require("./common");class Ecdsa{constructor(e,t){this.NATIVE=e,this.URL=t}async createRoom(e,t){return(0,common_1.sanitizeNumberOfParties)(e),(await this.NATIVE).createRoom(this.URL,e,t)}async initKeygen(){var e=await(await this.NATIVE).initKeygen();return new _1.EcdsaInitKeygenResult(e.pubkey,e.keypair)}async exportID(e){e="string"==typeof e?e:e.secretShare;return(await this.NATIVE).ecdsaGetExportID(e)}async keygen(e,t,r,a,s){if((0,common_1.sanitizeNumberOfParties)(t,r),s.length!==t-1)throw new Error(`keygenIds length must be exactly: ${t-1}, it is: `+s.length);e=await(await this.NATIVE).ecdsaKeygen(e,this.URL,t,r,a.keygenSecret,s),t=new _1.EcdsaPublicKey(e.pubkey),r=e.secret_share;return new _1.EcdsaKeygenResult(t,r)}async sign(e,t,r,a=new Uint32Array){t="string"==typeof t?t:t.secretShare,e=await(await this.NATIVE).ecdsaSign(e,this.URL,t,r.toHex(),Array.from(a));return _1.EcdsaSignature.fromBuffer(e)}async refresh(e,t){t="string"==typeof t?t:t.secretShare,e=await(await this.NATIVE).ecdsaRefresh(e,this.URL,t),t=new _1.EcdsaPublicKey(e.pubkey),e=e.secret_share;return new _1.EcdsaKeygenResult(t,e)}async reshareNewParty(e,t,r,a,s){e=await(await this.NATIVE).ecdsaReshareNewParty(e,this.URL,t,r,a.keygenSecret,s),t=new _1.EcdsaPublicKey(e.pubkey),r=e.secret_share;return new _1.EcdsaKeygenResult(t,r)}async reshareRemainingParty(e,t,r,a){r="string"==typeof r?r:r.secretShare,e=await(await this.NATIVE).ecdsaReshareRemainingParty(e,this.URL,t,r,a),t=new _1.EcdsaPublicKey(e.pubkey),r=e.secret_share;return new _1.EcdsaKeygenResult(t,r)}async derivePubkey(e,t=new Uint32Array){e="string"==typeof e?e:e.secretShare,e=await(await this.NATIVE).ecdsaDerivePubkey(e,Array.from(t));return new _1.EcdsaPublicKey(e)}async getXpub(e){e="string"==typeof e?e:e.secretShare;return(await this.NATIVE).ecdsaGetXpub(e)}async derivePubkeyFromXpub(e,t=new Uint32Array){e=await(await this.NATIVE).ecdsaDerivePubkeyFromXpub(e,Array.from(t));return new _1.EcdsaPublicKey(e)}async exportFullPrivateKey(e,t,r){t="string"==typeof t?t:t.secretShare;return(await this.NATIVE).ecdsaExportFullPrivateKey(e,this.URL,t,r)}async derivePrivateKeyFromXpriv(e,t=new Uint32Array){return(await this.NATIVE).ecdsaDerivePrivateKeyFromXpriv(e,Array.from(t))}async offlineExportFullPrivateKey(e){e=e.map(e=>{if("string"==typeof e)return e;if(e instanceof _1.EcdsaKeygenResult)return e.secretShare;throw"UnknownType"});return(await this.NATIVE).ecdsaOfflineExportFullPrivateKey(e)}async importPrivateKeyRecipient(e,t,r,a){e=await(await this.NATIVE).ecdsaImportPrivateKeyRecipient(e,this.URL,t,r.keygenSecret,a),t=new _1.EcdsaPublicKey(e.pubkey),r=e.secret_share;return new _1.EcdsaKeygenResult(t,r)}async importPrivateKeyImporter(e,t,r,a,s){e=await(await this.NATIVE).ecdsaImportPrivateKeyImporter(e,this.URL,t,r,a.keygenSecret,s),t=new _1.EcdsaPublicKey(e.pubkey),r=e.secret_share;return new _1.EcdsaKeygenResult(t,r)}getHostUrl(e){return e||this.URL}}exports.Ecdsa=Ecdsa;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ed25519=void 0;let _1=require("./"),utils_1=require("@noble/hashes/utils"),common_1=require("./common");class Ed25519{constructor(e,t){this.NATIVE=e,this.URL=t}async initKeygen(){var e=await(await this.NATIVE).initKeygen();return new _1.Ed25519InitKeygenResult(e.pubkey,e.keypair)}async exportID(e){e="string"==typeof e?e:e.secretShare;return(await this.NATIVE).ed25519GetExportID(e)}async createRoom(e,t){return(0,common_1.sanitizeNumberOfParties)(e),(await this.NATIVE).createRoom(this.URL,e,t)}async keygen(e,t,r,i,s){if((0,common_1.sanitizeNumberOfParties)(t,r),s.length!==t-1)throw new Error(`keygenIds length must be exactly: ${t-1}, it is: `+s.length);e=await(await this.NATIVE).ed25519Keygen(e,this.URL,t,r,i.keygenSecret,s);if(e.pubkey&&e.secret_share)return t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share,new _1.Ed25519KeygenResult(t,r);throw new Error("Keygen failed, no public key or secret share was returned.")}async sign(e,t,r,i=new Uint32Array){"string"!=typeof r&&(r=(0,utils_1.bytesToHex)(r));t="string"==typeof t?t:t.secretShare,e=await(await this.NATIVE).ed25519Sign(e,this.URL,t,r,Array.from(i));return(0,utils_1.hexToBytes)(e)}async refresh(e,t){var t="string"==typeof t?t:t.secretShare,e=await(await this.NATIVE).ed25519Refresh(e,this.URL,t);if(e.pubkey&&e.secret_share)return t=(0,utils_1.hexToBytes)(e.pubkey),e=e.secret_share,new _1.Ed25519KeygenResult(t,e);throw new Error("Keygen failed, no public key or secret share was returned.")}async reshareNewParty(e,t,r,i,s){e=await(await this.NATIVE).ed25519ReshareNewParty(e,this.URL,t,r,i.keygenSecret,s),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.Ed25519KeygenResult(t,r)}async reshareRemainingParty(e,t,r,i){r="string"==typeof r?r:r.secretShare,e=await(await this.NATIVE).ed25519ReshareRemainingParty(e,this.URL,t,r,i),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.Ed25519KeygenResult(t,r)}async derivePubkey(e,t=new Uint32Array){e="string"==typeof e?e:e.secretShare,e=await(await this.NATIVE).ed25519DerivePubkey(e,Array.from(t));return(0,utils_1.hexToBytes)(e)}async getSpub(e){e="string"==typeof e?e:e.secretShare;return(await this.NATIVE).ed25519GetSpub(e)}async derivePubkeyFromSpub(e,t){e=await(await this.NATIVE).ed25519DerivePubkeyFromSpub(e,Array.from(t));return(0,utils_1.hexToBytes)(e)}async exportFullPrivateKey(e,t,r){t="string"==typeof t?t:t.secretShare;return(await this.NATIVE).ed25519ExportFullPrivateKey(e,this.URL,t,r)}async derivePrivateKeyFromSpriv(e,t=new Uint32Array){return(await this.NATIVE).ed25519DerivePrivateKeyFromSpriv(e,Array.from(t))}async offlineExportFullPrivateKey(e){e=e.map(e=>{if("string"==typeof e)return e;if(e instanceof _1.Ed25519KeygenResult)return e.secretShare;throw"UnknownType"});return(await this.NATIVE).ed25519OfflineExportFullPrivateKey(e)}async importPrivateKeyRecipient(e,t,r,i){e=await(await this.NATIVE).ed25519ImportPrivateKeyRecipient(e,this.URL,t,r.keygenSecret,i),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.Ed25519KeygenResult(t,r)}async importPrivateKeyImporter(e,t,r,i,s,a=!1){e=await(await this.NATIVE).ed25519ImportPrivateKeyImporter(e,this.URL,t,r,i.keygenSecret,s,a),t=(0,utils_1.hexToBytes)(e.pubkey),r=e.secret_share;return new _1.Ed25519KeygenResult(t,r)}}exports.Ed25519=Ed25519;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340=exports.Ed25519=exports.Ecdsa=exports.MessageHash=exports.BIP340KeygenResult=exports.BIP340InitKeygenResult=exports.Ed25519KeygenResult=exports.Ed25519InitKeygenResult=exports.EcdsaSignature=exports.EcdsaPublicKey=exports.EcdsaKeygenResult=exports.EcdsaInitKeygenResult=void 0;let types_1=require("./types"),ecdsa_1=(Object.defineProperty(exports,"EcdsaInitKeygenResult",{enumerable:!0,get:function(){return types_1.EcdsaInitKeygenResult}}),Object.defineProperty(exports,"EcdsaKeygenResult",{enumerable:!0,get:function(){return types_1.EcdsaKeygenResult}}),Object.defineProperty(exports,"EcdsaPublicKey",{enumerable:!0,get:function(){return types_1.EcdsaPublicKey}}),Object.defineProperty(exports,"EcdsaSignature",{enumerable:!0,get:function(){return types_1.EcdsaSignature}}),Object.defineProperty(exports,"Ed25519InitKeygenResult",{enumerable:!0,get:function(){return types_1.Ed25519InitKeygenResult}}),Object.defineProperty(exports,"Ed25519KeygenResult",{enumerable:!0,get:function(){return types_1.Ed25519KeygenResult}}),Object.defineProperty(exports,"BIP340InitKeygenResult",{enumerable:!0,get:function(){return types_1.BIP340InitKeygenResult}}),Object.defineProperty(exports,"BIP340KeygenResult",{enumerable:!0,get:function(){return types_1.BIP340KeygenResult}}),Object.defineProperty(exports,"MessageHash",{enumerable:!0,get:function(){return types_1.MessageHash}}),require("./ecdsa")),ed25519_1=(Object.defineProperty(exports,"Ecdsa",{enumerable:!0,get:function(){return ecdsa_1.Ecdsa}}),require("./ed25519")),bip340_1=(Object.defineProperty(exports,"Ed25519",{enumerable:!0,get:function(){return ed25519_1.Ed25519}}),require("./bip340"));Object.defineProperty(exports,"BIP340",{enumerable:!0,get:function(){return bip340_1.BIP340}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340InitKeygenResult=exports.BIP340KeygenResult=exports.EcdsaSignature=exports.Ed25519InitKeygenResult=exports.Ed25519KeygenResult=exports.EcdsaInitKeygenResult=exports.EcdsaKeygenResult=exports.EcdsaPublicKey=exports.MessageHash=void 0;let utils_1=require("@noble/hashes/utils"),sha3_1=require("@noble/hashes/sha3"),sha256_1=require("@noble/hashes/sha256");class MessageHash{constructor(e){if(this.bytes=new Uint8Array,"string"==typeof e){if(e.length!==2*MessageHash.LENGTH)throw new Error("Invalid length for MessageHash: "+e.length);this.bytes=(0,utils_1.hexToBytes)(e)}else{if(e.length!==MessageHash.LENGTH)throw new Error("Invalid length for MessageHash: "+e.length);this.bytes=e}}static sha256(e){return new MessageHash((0,sha256_1.sha256)(e))}static sha256d(e){return new MessageHash((0,sha256_1.sha256)((0,sha256_1.sha256)(e)))}static keccak256(e){return new MessageHash((0,sha3_1.keccak_256)(e))}toHex(){return(0,utils_1.bytesToHex)(this.bytes)}}(exports.MessageHash=MessageHash).LENGTH=32;class EcdsaPublicKey{constructor(e){if((e="string"==typeof e?(0,utils_1.hexToBytes)(e):e).length===EcdsaPublicKey.LENGTH+1)this.pubkey=e.slice(1);else{if(e.length!==EcdsaPublicKey.LENGTH)throw new RangeError(`Invalid ${this.constructor.name} length, expected: ${EcdsaPublicKey.LENGTH} bytes, found: `+e.length);this.pubkey=e}}serializeUncompressed(){return new Uint8Array([4,...this.pubkey])}serializeCompressed(){var e=1&this.pubkey[63];return new Uint8Array([2+e,...this.pubkey.slice(0,32)])}pubKeyAsHex(){return(0,utils_1.bytesToHex)(this.serializeUncompressed())}}(exports.EcdsaPublicKey=EcdsaPublicKey).LENGTH=64;class EcdsaKeygenResult{constructor(e,s){this.pubkey=e,this.secretShare=s}}exports.EcdsaKeygenResult=EcdsaKeygenResult;class EcdsaInitKeygenResult{constructor(e,s){this.keygenId=e,this.keygenSecret=s}}exports.EcdsaInitKeygenResult=EcdsaInitKeygenResult;class Ed25519KeygenResult{constructor(e,s){this.pubkey=e,this.secretShare=s}}exports.Ed25519KeygenResult=Ed25519KeygenResult;class Ed25519InitKeygenResult{constructor(e,s){this.keygenId=e,this.keygenSecret=s}}exports.Ed25519InitKeygenResult=Ed25519InitKeygenResult;class EcdsaSignature{static fromBuffer(e){"string"==typeof e&&(e=(0,utils_1.hexToBytes)(e));var s=2*EcdsaSignature.FIELD_SIZE+EcdsaSignature.MAX_DER_LEN+1,t=2*EcdsaSignature.FIELD_SIZE+EcdsaSignature.MIN_DER_LEN+1;if(e.length<t||e.length>s)throw new RangeError(`Invalid ${this.constructor.name} length, expected between ${t}..${s} bytes, found: `+e.length);var t=e.subarray(0,EcdsaSignature.FIELD_SIZE),s=e.subarray(EcdsaSignature.FIELD_SIZE,2*EcdsaSignature.FIELD_SIZE),r=e[2*EcdsaSignature.FIELD_SIZE],e=e.subarray(2*EcdsaSignature.FIELD_SIZE+1);return new EcdsaSignature(t,s,r,e)}constructor(e,s,t,r){if(s.length!==EcdsaSignature.FIELD_SIZE)throw new RangeError(`Invalid 's' length, expected: ${EcdsaSignature.FIELD_SIZE} found: `+s.length);if(e.length!==EcdsaSignature.FIELD_SIZE)throw new RangeError(`Invalid 'r' length, expected: ${EcdsaSignature.FIELD_SIZE} found: `+e.length);if(!Number.isInteger(t)||t<27||30<t)throw new RangeError("Invalid 'v' value, expected 27/28/29/30 found: "+t);if(r.length<EcdsaSignature.MIN_DER_LEN||r.length>EcdsaSignature.MAX_DER_LEN)throw new RangeError(`Invalid DER encoding, expected length: ${EcdsaSignature.MIN_DER_LEN}..${EcdsaSignature.MAX_DER_LEN} found: `+r.length);this.r=e,this.s=s,this.v=t,this.der=r}}(exports.EcdsaSignature=EcdsaSignature).FIELD_SIZE=32,EcdsaSignature.MAX_DER_LEN=72,EcdsaSignature.MIN_DER_LEN=8;class BIP340KeygenResult{constructor(e,s){this.pubkey=e,this.secretShare=s}}exports.BIP340KeygenResult=BIP340KeygenResult;class BIP340InitKeygenResult{constructor(e,s){this.keygenId=e,this.keygenSecret=s}}exports.BIP340InitKeygenResult=BIP340InitKeygenResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@internal/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./package.json": "./package.json",
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@noble/hashes": "^1.3.2"
|
|
17
|
+
},
|
|
18
|
+
"private": true
|
|
19
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let wasm,heap=new Array(128).fill(void 0);function getObject(e){return heap[e]}heap.push(void 0,null,!0,!1);let heap_next=heap.length;function dropObject(e){e<132||(heap[e]=heap_next,heap_next=e)}function takeObject(e){var _=getObject(e);return dropObject(e),_}let cachedTextDecoder="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}},cachedUint8ArrayMemory0=("undefined"!=typeof TextDecoder&&cachedTextDecoder.decode(),null);function getUint8ArrayMemory0(){return cachedUint8ArrayMemory0=null!==cachedUint8ArrayMemory0&&0!==cachedUint8ArrayMemory0.byteLength?cachedUint8ArrayMemory0:new Uint8Array(wasm.memory.buffer)}function getStringFromWasm0(e,_){return e>>>=0,cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(e,e+_))}function addHeapObject(e){heap_next===heap.length&&heap.push(heap.length+1);var _=heap_next;return heap_next=heap[_],heap[_]=e,_}let WASM_VECTOR_LEN=0,cachedTextEncoder="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},encodeString="function"==typeof cachedTextEncoder.encodeInto?function(e,_){return cachedTextEncoder.encodeInto(e,_)}:function(e,_){var t=cachedTextEncoder.encode(e);return _.set(t),{read:e.length,written:t.length}};function passStringToWasm0(_,t,e){if(void 0===e){var n=cachedTextEncoder.encode(_);let e=t(n.length,1)>>>0;return getUint8ArrayMemory0().subarray(e,e+n.length).set(n),WASM_VECTOR_LEN=n.length,e}let r=_.length,a=t(r,1)>>>0;var i=getUint8ArrayMemory0();let s=0;for(;s<r;s++){var o=_.charCodeAt(s);if(127<o)break;i[a+s]=o}return s!==r&&(0!==s&&(_=_.slice(s)),a=e(a,r,r=s+3*_.length,1)>>>0,n=getUint8ArrayMemory0().subarray(a+s,a+r),t=encodeString(_,n),s+=t.written,a=e(a,r,s,1)>>>0),WASM_VECTOR_LEN=s,a}function isLikeNone(e){return null==e}let cachedDataViewMemory0=null;function getDataViewMemory0(){return cachedDataViewMemory0=null===cachedDataViewMemory0||!0===cachedDataViewMemory0.buffer.detached||void 0===cachedDataViewMemory0.buffer.detached&&cachedDataViewMemory0.buffer!==wasm.memory.buffer?new DataView(wasm.memory.buffer):cachedDataViewMemory0}function debugString(t){var e,_=typeof t;if("number"==_||"boolean"==_||null==t)return""+t;if("string"==_)return`"${t}"`;if("symbol"==_)return null==(e=t.description)?"Symbol":`Symbol(${e})`;if("function"==_)return"string"==typeof(e=t.name)&&0<e.length?`Function(${e})`:"Function";if(Array.isArray(t)){var n=t.length;let _="[";0<n&&(_+=debugString(t[0]));for(let e=1;e<n;e++)_+=", "+debugString(t[e]);return _+="]"}_=/\[object ([^\]]+)\]/.exec(toString.call(t));let r;if(!(1<_.length))return toString.call(t);if("Object"==(r=_[1]))try{return"Object("+JSON.stringify(t)+")"}catch(e){return"Object"}return t instanceof Error?t.name+`: ${t.message}
|
|
2
|
+
`+t.stack:r}let CLOSURE_DTORS="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>{wasm.__wbindgen_export_2.get(e.dtor)(e.a,e.b)});function makeMutClosure(e,_,t,n){let r={a:e,b:_,cnt:1,dtor:t};e=(...e)=>{r.cnt++;var _=r.a;r.a=0;try{return n(_,r.b,...e)}finally{0==--r.cnt?(wasm.__wbindgen_export_2.get(r.dtor)(_,r.b),CLOSURE_DTORS.unregister(r)):r.a=_}};return e.original=r,CLOSURE_DTORS.register(e,r,r),e}function __wbg_adapter_28(e,_){wasm.__wbindgen_export_3(e,_)}function makeClosure(e,_,t,n){let r={a:e,b:_,cnt:1,dtor:t};e=(...e)=>{r.cnt++;try{return n(r.a,r.b,...e)}finally{0==--r.cnt&&(wasm.__wbindgen_export_2.get(r.dtor)(r.a,r.b),r.a=0,CLOSURE_DTORS.unregister(r))}};return e.original=r,CLOSURE_DTORS.register(e,r,r),e}function __wbg_adapter_31(e,_,t){wasm.__wbindgen_export_4(e,_,addHeapObject(t))}function __wbg_adapter_38(e,_,t){wasm.__wbindgen_export_5(e,_,addHeapObject(t))}function handleError(e,_){try{return e.apply(this,_)}catch(e){wasm.__wbindgen_export_6(addHeapObject(e))}}function __wbg_adapter_83(e,_,t,n){wasm.__wbindgen_export_7(e,_,addHeapObject(t),addHeapObject(n))}function initKeygen(){return takeObject(wasm.initKeygen())}function createRoom(e,_,t){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN;return takeObject(wasm.createRoom(e,n,_,t,r))}function passArrayJsValueToWasm0(_,e){var t=e(4*_.length,4)>>>0,n=getDataViewMemory0();for(let e=0;e<_.length;e++)n.setUint32(t+4*e,addHeapObject(_[e]),!0);return WASM_VECTOR_LEN=_.length,t}function ecdsaKeygen(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaKeygen(e,i,_,s,t,n,r,o,a,b))}let cachedUint32ArrayMemory0=null;function getUint32ArrayMemory0(){return cachedUint32ArrayMemory0=null!==cachedUint32ArrayMemory0&&0!==cachedUint32ArrayMemory0.byteLength?cachedUint32ArrayMemory0:new Uint32Array(wasm.memory.buffer)}function passArray32ToWasm0(e,_){_=_(4*e.length,4)>>>0;return getUint32ArrayMemory0().set(e,_/4),WASM_VECTOR_LEN=e.length,_}function ecdsaSign(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,r=passArray32ToWasm0(r,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaSign(e,a,_,i,t,s,n,o,r,b))}function ecdsaRefresh(e,_,t){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaRefresh(e,n,_,r,t,a))}function ecdsaReshareNewParty(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaReshareNewParty(e,i,_,s,t,n,r,o,a,b))}function ecdsaReshareRemainingParty(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passArrayJsValueToWasm0(r,wasm.__wbindgen_export_0),o=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaReshareRemainingParty(e,a,_,i,t,n,s,r,o))}function ecdsaDerivePubkey(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaDerivePubkey(e,t,_,n))}function ecdsaGetXpub(e){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),_=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaGetXpub(e,_))}function ecdsaDerivePubkeyFromXpub(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaDerivePubkeyFromXpub(e,t,_,n))}function ecdsaGetExportID(e){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),_=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaGetExportID(e,_))}function ecdsaExportFullPrivateKey(e,_,t,n){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaExportFullPrivateKey(e,r,_,a,t,i,n,s))}function ecdsaOfflineExportFullPrivateKey(e){var e=passArrayJsValueToWasm0(e,wasm.__wbindgen_export_0),_=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaOfflineExportFullPrivateKey(e,_))}function ecdsaDerivePrivateKeyFromXpriv(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaDerivePrivateKeyFromXpriv(e,t,_,n))}function ecdsaImportPrivateKeyRecipient(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passArrayJsValueToWasm0(r,wasm.__wbindgen_export_0),o=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaImportPrivateKeyRecipient(e,a,_,i,t,n,s,r,o))}function ecdsaImportPrivateKeyImporter(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),b=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),w=WASM_VECTOR_LEN;return takeObject(wasm.ecdsaImportPrivateKeyImporter(e,i,_,s,t,n,o,r,b,a,w))}function ed25519Keygen(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.ed25519Keygen(e,i,_,s,t,n,r,o,a,b))}function ed25519Sign(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,r=passArray32ToWasm0(r,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.ed25519Sign(e,a,_,i,t,s,n,o,r,b))}function ed25519Refresh(e,_,t){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN;return takeObject(wasm.ed25519Refresh(e,n,_,r,t,a))}function ed25519ReshareNewParty(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.ed25519ReshareNewParty(e,i,_,s,t,n,r,o,a,b))}function ed25519ReshareRemainingParty(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passArrayJsValueToWasm0(r,wasm.__wbindgen_export_0),o=WASM_VECTOR_LEN;return takeObject(wasm.ed25519ReshareRemainingParty(e,a,_,i,t,n,s,r,o))}function ed25519DerivePubkey(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.ed25519DerivePubkey(e,t,_,n))}function ed25519GetSpub(e){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),_=WASM_VECTOR_LEN;return takeObject(wasm.ed25519GetSpub(e,_))}function ed25519DerivePubkeyFromSpub(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.ed25519DerivePubkeyFromSpub(e,t,_,n))}function ed25519GetExportID(e){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),_=WASM_VECTOR_LEN;return takeObject(wasm.ed25519GetExportID(e,_))}function ed25519ExportFullPrivateKey(e,_,t,n){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN;return takeObject(wasm.ed25519ExportFullPrivateKey(e,r,_,a,t,i,n,s))}function ed25519OfflineExportFullPrivateKey(e){var e=passArrayJsValueToWasm0(e,wasm.__wbindgen_export_0),_=WASM_VECTOR_LEN;return takeObject(wasm.ed25519OfflineExportFullPrivateKey(e,_))}function ed25519DerivePrivateKeyFromSpriv(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.ed25519DerivePrivateKeyFromSpriv(e,t,_,n))}function ed25519ImportPrivateKeyRecipient(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passArrayJsValueToWasm0(r,wasm.__wbindgen_export_0),o=WASM_VECTOR_LEN;return takeObject(wasm.ed25519ImportPrivateKeyRecipient(e,a,_,i,t,n,s,r,o))}function ed25519ImportPrivateKeyImporter(e,_,t,n,r,a,i){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),b=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),w=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),g=WASM_VECTOR_LEN;return takeObject(wasm.ed25519ImportPrivateKeyImporter(e,s,_,o,t,n,b,r,w,a,g,i))}function bip340Keygen(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.bip340Keygen(e,i,_,s,t,n,r,o,a,b))}function bip340Sign(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),b=WASM_VECTOR_LEN,r=passArray32ToWasm0(r,wasm.__wbindgen_export_0),w=WASM_VECTOR_LEN,a=passStringToWasm0(a,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),g=WASM_VECTOR_LEN;return takeObject(wasm.bip340Sign(e,i,_,s,t,o,n,b,r,w,a,g))}function bip340Refresh(e,_,t){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN;return takeObject(wasm.bip340Refresh(e,n,_,r,t,a))}function bip340ReshareNewParty(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),b=WASM_VECTOR_LEN;return takeObject(wasm.bip340ReshareNewParty(e,i,_,s,t,n,r,o,a,b))}function bip340ReshareRemainingParty(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passArrayJsValueToWasm0(r,wasm.__wbindgen_export_0),o=WASM_VECTOR_LEN;return takeObject(wasm.bip340ReshareRemainingParty(e,a,_,i,t,n,s,r,o))}function bip340DeriveTweakPubkey(e,_,t){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),r=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN;return takeObject(wasm.bip340DeriveTweakPubkey(e,n,_,r,t,a))}function bip340GetXpub(e){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),_=WASM_VECTOR_LEN;return takeObject(wasm.bip340GetXpub(e,_))}function bip340DeriveTweakPubkeyFromXpub(e,_,t){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),r=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN;return takeObject(wasm.bip340DeriveTweakPubkeyFromXpub(e,n,_,r,t,a))}function bip340GetExportID(e){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),_=WASM_VECTOR_LEN;return takeObject(wasm.bip340GetExportID(e,_))}function bip340ExportFullPrivateKey(e,_,t,n){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),r=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,t=passStringToWasm0(t,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN;return takeObject(wasm.bip340ExportFullPrivateKey(e,r,_,a,t,i,n,s))}function bip340OfflineExportFullPrivateKey(e){var e=passArrayJsValueToWasm0(e,wasm.__wbindgen_export_0),_=WASM_VECTOR_LEN;return takeObject(wasm.bip340OfflineExportFullPrivateKey(e,_))}function bip340DerivePrivateKeyFromXpriv(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passArray32ToWasm0(_,wasm.__wbindgen_export_0),n=WASM_VECTOR_LEN;return takeObject(wasm.bip340DerivePrivateKeyFromXpriv(e,t,_,n))}function bip340ImportPrivateKeyRecipient(e,_,t,n,r){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),a=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,r=passArrayJsValueToWasm0(r,wasm.__wbindgen_export_0),o=WASM_VECTOR_LEN;return takeObject(wasm.bip340ImportPrivateKeyRecipient(e,a,_,i,t,n,s,r,o))}function bip340ImportPrivateKeyImporter(e,_,t,n,r,a){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),i=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),s=WASM_VECTOR_LEN,n=passStringToWasm0(n,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),o=WASM_VECTOR_LEN,r=passStringToWasm0(r,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),b=WASM_VECTOR_LEN,a=passArrayJsValueToWasm0(a,wasm.__wbindgen_export_0),w=WASM_VECTOR_LEN;return takeObject(wasm.bip340ImportPrivateKeyImporter(e,i,_,s,t,n,o,r,b,a,w))}function start(){wasm.start()}function getArrayU8FromWasm0(e,_){return e>>>=0,getUint8ArrayMemory0().subarray(+e,+e+_)}let KeygenInitFinalization="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>wasm.__wbg_keygeninit_free(e>>>0,1));class KeygenInit{static __wrap(e){e>>>=0;var _=Object.create(KeygenInit.prototype);return _.__wbg_ptr=e,KeygenInitFinalization.register(_,_.__wbg_ptr,_),_}__destroy_into_raw(){var e=this.__wbg_ptr;return this.__wbg_ptr=0,KeygenInitFinalization.unregister(this),e}free(){var e=this.__destroy_into_raw();wasm.__wbg_keygeninit_free(e,0)}get keypair(){let e,_;try{var t=wasm.__wbindgen_add_to_stack_pointer(-16),n=(wasm.__wbg_get_keygeninit_keypair(t,this.__wbg_ptr),getDataViewMemory0().getInt32(t+0,!0)),r=getDataViewMemory0().getInt32(t+4,!0);return getStringFromWasm0(e=n,_=r)}finally{wasm.__wbindgen_add_to_stack_pointer(16),wasm.__wbindgen_export_8(e,_,1)}}get pubkey(){let e,_;try{var t=wasm.__wbindgen_add_to_stack_pointer(-16),n=(wasm.__wbg_get_keygeninit_pubkey(t,this.__wbg_ptr),getDataViewMemory0().getInt32(t+0,!0)),r=getDataViewMemory0().getInt32(t+4,!0);return getStringFromWasm0(e=n,_=r)}finally{wasm.__wbindgen_add_to_stack_pointer(16),wasm.__wbindgen_export_8(e,_,1)}}constructor(e,_){var e=passStringToWasm0(e,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN,_=passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),n=WASM_VECTOR_LEN,e=wasm.keygeninit_new(e,t,_,n);return this.__wbg_ptr=e>>>0,KeygenInitFinalization.register(this,this.__wbg_ptr,this),this}}let KeygenResultFinalization="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>wasm.__wbg_keygenresult_free(e>>>0,1));class KeygenResult{static __wrap(e){e>>>=0;var _=Object.create(KeygenResult.prototype);return _.__wbg_ptr=e,KeygenResultFinalization.register(_,_.__wbg_ptr,_),_}__destroy_into_raw(){var e=this.__wbg_ptr;return this.__wbg_ptr=0,KeygenResultFinalization.unregister(this),e}free(){var e=this.__destroy_into_raw();wasm.__wbg_keygenresult_free(e,0)}get secret_share(){let e,_;try{var t=wasm.__wbindgen_add_to_stack_pointer(-16),n=(wasm.__wbg_get_keygeninit_keypair(t,this.__wbg_ptr),getDataViewMemory0().getInt32(t+0,!0)),r=getDataViewMemory0().getInt32(t+4,!0);return getStringFromWasm0(e=n,_=r)}finally{wasm.__wbindgen_add_to_stack_pointer(16),wasm.__wbindgen_export_8(e,_,1)}}get pubkey(){let e,_;try{var t=wasm.__wbindgen_add_to_stack_pointer(-16),n=(wasm.__wbg_get_keygeninit_pubkey(t,this.__wbg_ptr),getDataViewMemory0().getInt32(t+0,!0)),r=getDataViewMemory0().getInt32(t+4,!0);return getStringFromWasm0(e=n,_=r)}finally{wasm.__wbindgen_add_to_stack_pointer(16),wasm.__wbindgen_export_8(e,_,1)}}}async function __wbg_load(_,e){if("function"==typeof Response&&_ instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(_,e)}catch(e){if("application/wasm"==_.headers.get("Content-Type"))throw e;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",e)}var t=await _.arrayBuffer();return WebAssembly.instantiate(t,e)}return(t=await WebAssembly.instantiate(_,e))instanceof WebAssembly.Instance?{instance:t,module:_}:t}function __wbg_get_imports(){var e={wbg:{}};return e.wbg.__wbindgen_object_drop_ref=function(e){takeObject(e)},e.wbg.__wbg_crypto_1d1f22824a6a080c=function(e){return addHeapObject(getObject(e).crypto)},e.wbg.__wbindgen_is_object=function(e){e=getObject(e);return"object"==typeof e&&null!==e},e.wbg.__wbg_process_4a72847cc503995b=function(e){return addHeapObject(getObject(e).process)},e.wbg.__wbg_versions_f686565e586dd935=function(e){return addHeapObject(getObject(e).versions)},e.wbg.__wbg_node_104a2ff8d6ea03a2=function(e){return addHeapObject(getObject(e).node)},e.wbg.__wbindgen_is_string=function(e){return"string"==typeof getObject(e)},e.wbg.__wbg_require_cca90b1a94a0255b=function(){return handleError(function(){return addHeapObject(module.require)},arguments)},e.wbg.__wbindgen_is_function=function(e){return"function"==typeof getObject(e)},e.wbg.__wbindgen_string_new=function(e,_){return addHeapObject(getStringFromWasm0(e,_))},e.wbg.__wbg_msCrypto_eb05e62b530a1508=function(e){return addHeapObject(getObject(e).msCrypto)},e.wbg.__wbg_newwithlength_ec548f448387c968=function(e){return addHeapObject(new Uint8Array(e>>>0))},e.wbg.__wbg_setTimeout_75cb9b6991a4031d=function(){return handleError(function(e,_){return addHeapObject(setTimeout(getObject(e),_))},arguments)},e.wbg.__wbg_next_f9cb570345655b9a=function(){return handleError(function(e){return addHeapObject(getObject(e).next())},arguments)},e.wbg.__wbg_done_bfda7aa8f252b39f=function(e){return getObject(e).done},e.wbg.__wbg_value_6d39332ab4788d86=function(e){return addHeapObject(getObject(e).value)},e.wbg.__wbg_iterator_888179a48810a9fe=function(){return addHeapObject(Symbol.iterator)},e.wbg.__wbg_get_224d16597dbbfd96=function(){return handleError(function(e,_){return addHeapObject(Reflect.get(getObject(e),getObject(_)))},arguments)},e.wbg.__wbg_next_de3e9db4440638b2=function(e){return addHeapObject(getObject(e).next)},e.wbg.__wbg_call_1084a111329e68ce=function(){return handleError(function(e,_){return addHeapObject(getObject(e).call(getObject(_)))},arguments)},e.wbg.__wbindgen_object_clone_ref=function(e){return addHeapObject(getObject(e))},e.wbg.__wbg_call_89af060b4e1523f2=function(){return handleError(function(e,_,t){return addHeapObject(getObject(e).call(getObject(_),getObject(t)))},arguments)},e.wbg.__wbindgen_memory=function(){return addHeapObject(wasm.memory)},e.wbg.__wbg_buffer_b7b08af79b0b0974=function(e){return addHeapObject(getObject(e).buffer)},e.wbg.__wbg_new_ea1883e1e5e86686=function(e){return addHeapObject(new Uint8Array(getObject(e)))},e.wbg.__wbg_set_d1e79e2388520f18=function(e,_,t){getObject(e).set(getObject(_),t>>>0)},e.wbg.__wbg_self_3093d5d1f7bcb682=function(){return handleError(function(){return addHeapObject(self.self)},arguments)},e.wbg.__wbg_window_3bcfc4d31bc012f8=function(){return handleError(function(){return addHeapObject(window.window)},arguments)},e.wbg.__wbg_globalThis_86b222e13bdf32ed=function(){return handleError(function(){return addHeapObject(globalThis.globalThis)},arguments)},e.wbg.__wbg_global_e5a3fe56f8be9485=function(){return handleError(function(){return addHeapObject(global.global)},arguments)},e.wbg.__wbindgen_is_undefined=function(e){return void 0===getObject(e)},e.wbg.__wbg_newnoargs_76313bd6ff35d0f2=function(e,_){return addHeapObject(new Function(getStringFromWasm0(e,_)))},e.wbg.__wbindgen_string_get=function(e,_){var _=getObject(_),_="string"==typeof _?_:void 0,_=isLikeNone(_)?0:passStringToWasm0(_,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(e+4,t,!0),getDataViewMemory0().setInt32(e+0,_,!0)},e.wbg.__wbg_stringify_bbf45426c92a6bf5=function(){return handleError(function(e){return addHeapObject(JSON.stringify(getObject(e)))},arguments)},e.wbg.__wbg_newwithbyteoffsetandlength_8a2cb9ca96b27ec9=function(e,_,t){return addHeapObject(new Uint8Array(getObject(e),_>>>0,t>>>0))},e.wbg.__wbg_randomFillSync_5c9c955aa56b6049=function(){return handleError(function(e,_){getObject(e).randomFillSync(takeObject(_))},arguments)},e.wbg.__wbg_subarray_7c2e3576afe181d1=function(e,_,t){return addHeapObject(getObject(e).subarray(_>>>0,t>>>0))},e.wbg.__wbg_getRandomValues_3aa56aa6edec874c=function(){return handleError(function(e,_){getObject(e).getRandomValues(getObject(_))},arguments)},e.wbg.__wbg_has_4bfbc01db38743f7=function(){return handleError(function(e,_){return Reflect.has(getObject(e),getObject(_))},arguments)},e.wbg.__wbg_fetch_25e3a297f7b04639=function(e){return addHeapObject(fetch(getObject(e)))},e.wbg.__wbg_fetch_ba7fe179e527d942=function(e,_){return addHeapObject(getObject(e).fetch(getObject(_)))},e.wbg.__wbg_new_ebf2727385ee825c=function(){return handleError(function(){return addHeapObject(new AbortController)},arguments)},e.wbg.__wbg_abort_8659d889a7877ae3=function(e){getObject(e).abort()},e.wbg.__wbg_new_525245e2b9901204=function(){return addHeapObject(new Object)},e.wbg.__wbg_setmethod_dc68a742c2db5c6a=function(e,_,t){getObject(e).method=getStringFromWasm0(_,t)},e.wbg.__wbg_setheaders_be10a5ab566fd06f=function(e,_){getObject(e).headers=getObject(_)},e.wbg.__wbg_setmode_a781aae2bd3df202=function(e,_){getObject(e).mode=["same-origin","no-cors","cors","navigate"][_]},e.wbg.__wbg_setcredentials_2b67800db3f7b621=function(e,_){getObject(e).credentials=["omit","same-origin","include"][_]},e.wbg.__wbg_setbody_734cb3d7ee8e6e96=function(e,_){getObject(e).body=getObject(_)},e.wbg.__wbg_signal_41e46ccad44bb5e2=function(e){return addHeapObject(getObject(e).signal)},e.wbg.__wbg_setsignal_91c4e8ebd04eb935=function(e,_){getObject(e).signal=getObject(_)},e.wbg.__wbg_instanceof_Response_e91b7eb7c611a9ae=function(e){let _;try{_=getObject(e)instanceof Response}catch(e){_=!1}return _},e.wbg.__wbg_status_ae8de515694c5c7c=function(e){return getObject(e).status},e.wbg.__wbg_url_1bf85c8abeb8c92d=function(e,_){var _=passStringToWasm0(getObject(_).url,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(e+4,t,!0),getDataViewMemory0().setInt32(e+0,_,!0)},e.wbg.__wbg_headers_5e283e8345689121=function(e){return addHeapObject(getObject(e).headers)},e.wbg.__wbindgen_error_new=function(e,_){return addHeapObject(new Error(getStringFromWasm0(e,_)))},e.wbg.__wbg_keygeninit_new=function(e){return addHeapObject(KeygenInit.__wrap(e))},e.wbg.__wbg_message_fde1ade05259137c=function(e,_){var _=passStringToWasm0(getObject(_).message,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(e+4,t,!0),getDataViewMemory0().setInt32(e+0,_,!0)},e.wbg.__wbg_clearTimeout_76877dbc010e786d=function(e){return addHeapObject(clearTimeout(takeObject(e)))},e.wbg.__wbindgen_cb_drop=function(e){e=takeObject(e).original;return 1==e.cnt--&&!(e.a=0)},e.wbg.__wbg_readyState_7237e2b1adac03a6=function(e){return getObject(e).readyState},e.wbg.__wbg_send_82b52e2f9f8946d9=function(){return handleError(function(e,_,t){getObject(e).send(getStringFromWasm0(_,t))},arguments)},e.wbg.__wbg_send_1b333b26681a902d=function(){return handleError(function(e,_,t){getObject(e).send(getArrayU8FromWasm0(_,t))},arguments)},e.wbg.__wbg_close_0a0cd79519b11318=function(){return handleError(function(e,_,t,n){getObject(e).close(_,getStringFromWasm0(t,n))},arguments)},e.wbg.__wbg_new_0bf4a5b0632517ed=function(){return handleError(function(e,_){return addHeapObject(new WebSocket(getStringFromWasm0(e,_)))},arguments)},e.wbg.__wbg_setonmessage_b670c12ea34acd8b=function(e,_){getObject(e).onmessage=getObject(_)},e.wbg.__wbg_setonclose_40f935717ad6ffcd=function(e,_){getObject(e).onclose=getObject(_)},e.wbg.__wbg_setbinaryType_d164a0be4c212c9c=function(e,_){getObject(e).binaryType=["blob","arraybuffer"][_]},e.wbg.__wbg_setonopen_7e770c87269cae90=function(e,_){getObject(e).onopen=getObject(_)},e.wbg.__wbg_setonerror_5ec4625df3060159=function(e,_){getObject(e).onerror=getObject(_)},e.wbg.__wbg_wasClean_e83dfad67198c1c4=function(e){return getObject(e).wasClean},e.wbg.__wbg_code_eae09136895f8ffa=function(e){return getObject(e).code},e.wbg.__wbg_reason_8a32e6ed703d6382=function(e,_){var _=passStringToWasm0(getObject(_).reason,wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(e+4,t,!0),getDataViewMemory0().setInt32(e+0,_,!0)},e.wbg.__wbg_data_5c47a6985fefc490=function(e){return addHeapObject(getObject(e).data)},e.wbg.__wbg_instanceof_ArrayBuffer_61dfc3198373c902=function(e){let _;try{_=getObject(e)instanceof ArrayBuffer}catch(e){_=!1}return _},e.wbg.__wbg_length_8339fcf5d8ecd12e=function(e){return getObject(e).length},e.wbg.__wbg_new_b85e72ed1bfd57f9=function(e,_){try{var n={a:e,b:_};return addHeapObject(new Promise((e,_)=>{var t=n.a;n.a=0;try{return __wbg_adapter_83(t,n.b,e,_)}finally{n.a=t}}))}finally{n.a=n.b=0}},e.wbg.__wbg_keygenresult_new=function(e){return addHeapObject(KeygenResult.__wrap(e))},e.wbg.__wbindgen_throw=function(e,_){throw new Error(getStringFromWasm0(e,_))},e.wbg.__wbindgen_debug_string=function(e,_){var _=passStringToWasm0(debugString(getObject(_)),wasm.__wbindgen_export_0,wasm.__wbindgen_export_1),t=WASM_VECTOR_LEN;getDataViewMemory0().setInt32(e+4,t,!0),getDataViewMemory0().setInt32(e+0,_,!0)},e.wbg.__wbg_queueMicrotask_48421b3cc9052b68=function(e){return addHeapObject(getObject(e).queueMicrotask)},e.wbg.__wbg_resolve_570458cb99d56a43=function(e){return addHeapObject(Promise.resolve(getObject(e)))},e.wbg.__wbg_then_876bb3c633745cc6=function(e,_,t){return addHeapObject(getObject(e).then(getObject(_),getObject(t)))},e.wbg.__wbg_then_95e6edc0f89b73b1=function(e,_){return addHeapObject(getObject(e).then(getObject(_)))},e.wbg.__wbg_queueMicrotask_12a30234db4045d3=function(e){queueMicrotask(getObject(e))},e.wbg.__wbg_newwithstrandinit_a31c69e4cc337183=function(){return handleError(function(e,_,t){return addHeapObject(new Request(getStringFromWasm0(e,_),getObject(t)))},arguments)},e.wbg.__wbg_close_99bb12a22f16f79c=function(){return handleError(function(e){getObject(e).close()},arguments)},e.wbg.__wbg_new_e27c93803e1acc42=function(){return handleError(function(){return addHeapObject(new Headers)},arguments)},e.wbg.__wbg_append_f3a4426bb50622c5=function(){return handleError(function(e,_,t,n,r){getObject(e).append(getStringFromWasm0(_,t),getStringFromWasm0(n,r))},arguments)},e.wbg.__wbg_text_a94b91ea8700357a=function(){return handleError(function(e){return addHeapObject(getObject(e).text())},arguments)},e.wbg.__wbindgen_closure_wrapper1070=function(e,_,t){return addHeapObject(makeMutClosure(e,_,45,__wbg_adapter_28))},e.wbg.__wbindgen_closure_wrapper2610=function(e,_,t){return addHeapObject(makeClosure(e,_,45,__wbg_adapter_31))},e.wbg.__wbindgen_closure_wrapper2611=function(e,_,t){return addHeapObject(makeClosure(e,_,45,__wbg_adapter_31))},e.wbg.__wbindgen_closure_wrapper2612=function(e,_,t){return addHeapObject(makeClosure(e,_,45,__wbg_adapter_31))},e.wbg.__wbindgen_closure_wrapper2613=function(e,_,t){return addHeapObject(makeMutClosure(e,_,45,__wbg_adapter_38))},e.wbg.__wbindgen_closure_wrapper2614=function(e,_,t){return addHeapObject(makeMutClosure(e,_,45,__wbg_adapter_38))},e.wbg.__wbindgen_closure_wrapper3411=function(e,_,t){return addHeapObject(makeMutClosure(e,_,45,__wbg_adapter_38))},e}function __wbg_init_memory(e,_){}function __wbg_finalize_init(e,_){return wasm=e.exports,__wbg_init.__wbindgen_wasm_module=_,cachedDataViewMemory0=null,cachedUint32ArrayMemory0=null,cachedUint8ArrayMemory0=null,wasm.__wbindgen_start(),wasm}function initSync(e){if(void 0!==wasm)return wasm;void 0!==e&&Object.getPrototypeOf(e)===Object.prototype?e=e.module:console.warn("using deprecated parameters for `initSync()`; pass a single object instead");var _=__wbg_get_imports(),_=(__wbg_init_memory(_),e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),new WebAssembly.Instance(e,_));return __wbg_finalize_init(_,e)}async function __wbg_init(e){if(void 0!==wasm)return wasm;void 0!==e&&Object.getPrototypeOf(e)===Object.prototype?e=e.module_or_path:console.warn("using deprecated parameters for the initialization function; pass a single object instead"),void 0===e&&(e=new URL("libmpc_executor_bg.wasm",import.meta.url));var _=__wbg_get_imports(),{instance:e,module:_}=(("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e)),__wbg_init_memory(_),await __wbg_load(await e,_));return __wbg_finalize_init(e,_)}export default __wbg_init;export{initKeygen,createRoom,ecdsaKeygen,ecdsaSign,ecdsaRefresh,ecdsaReshareNewParty,ecdsaReshareRemainingParty,ecdsaDerivePubkey,ecdsaGetXpub,ecdsaDerivePubkeyFromXpub,ecdsaGetExportID,ecdsaExportFullPrivateKey,ecdsaOfflineExportFullPrivateKey,ecdsaDerivePrivateKeyFromXpriv,ecdsaImportPrivateKeyRecipient,ecdsaImportPrivateKeyImporter,ed25519Keygen,ed25519Sign,ed25519Refresh,ed25519ReshareNewParty,ed25519ReshareRemainingParty,ed25519DerivePubkey,ed25519GetSpub,ed25519DerivePubkeyFromSpub,ed25519GetExportID,ed25519ExportFullPrivateKey,ed25519OfflineExportFullPrivateKey,ed25519DerivePrivateKeyFromSpriv,ed25519ImportPrivateKeyRecipient,ed25519ImportPrivateKeyImporter,bip340Keygen,bip340Sign,bip340Refresh,bip340ReshareNewParty,bip340ReshareRemainingParty,bip340DeriveTweakPubkey,bip340GetXpub,bip340DeriveTweakPubkeyFromXpub,bip340GetExportID,bip340ExportFullPrivateKey,bip340OfflineExportFullPrivateKey,bip340DerivePrivateKeyFromXpriv,bip340ImportPrivateKeyRecipient,bip340ImportPrivateKeyImporter,start,KeygenInit,KeygenResult,initSync};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var n=Object.getOwnPropertyDescriptor(r,t);n&&("get"in n?r.__esModule:!n.writable&&!n.configurable)||(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,n)}:function(e,r,t,i){e[i=void 0===i?t:i]=r[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&__createBinding(r,e,t);return __setModuleDefault(r,e),r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340=exports.Ed25519=exports.Ecdsa=exports.BIP340KeygenResult=exports.BIP340InitKeygenResult=exports.Ed25519InitKeygenResult=exports.EcdsaInitKeygenResult=exports.MessageHash=exports.Ed25519KeygenResult=exports.EcdsaSignature=exports.EcdsaPublicKey=exports.EcdsaKeygenResult=void 0;let lib_mpc_internal_1=require("@internal/core"),libmpc_executor_1=(Object.defineProperty(exports,"EcdsaInitKeygenResult",{enumerable:!0,get:function(){return lib_mpc_internal_1.EcdsaInitKeygenResult}}),Object.defineProperty(exports,"EcdsaKeygenResult",{enumerable:!0,get:function(){return lib_mpc_internal_1.EcdsaKeygenResult}}),Object.defineProperty(exports,"EcdsaPublicKey",{enumerable:!0,get:function(){return lib_mpc_internal_1.EcdsaPublicKey}}),Object.defineProperty(exports,"EcdsaSignature",{enumerable:!0,get:function(){return lib_mpc_internal_1.EcdsaSignature}}),Object.defineProperty(exports,"Ed25519InitKeygenResult",{enumerable:!0,get:function(){return lib_mpc_internal_1.Ed25519InitKeygenResult}}),Object.defineProperty(exports,"Ed25519KeygenResult",{enumerable:!0,get:function(){return lib_mpc_internal_1.Ed25519KeygenResult}}),Object.defineProperty(exports,"BIP340InitKeygenResult",{enumerable:!0,get:function(){return lib_mpc_internal_1.BIP340InitKeygenResult}}),Object.defineProperty(exports,"BIP340KeygenResult",{enumerable:!0,get:function(){return lib_mpc_internal_1.BIP340KeygenResult}}),Object.defineProperty(exports,"MessageHash",{enumerable:!0,get:function(){return lib_mpc_internal_1.MessageHash}}),__importStar(require("./generated/libmpc_executor"))),sdkAPI=libmpc_executor_1,DEFAULT_RELAY_URL="relay.dynamicauth.com",sdkPromise=(0,libmpc_executor_1.default)().then(()=>({initKeygen:sdkAPI.initKeygen,createRoom:sdkAPI.createRoom,ecdsaGetExportID:sdkAPI.ecdsaGetExportID,ecdsaKeygen:sdkAPI.ecdsaKeygen,ecdsaSign:(e,r,t,i,n)=>sdkAPI.ecdsaSign(e,r,t,i,new Uint32Array(n)),ecdsaRefresh:sdkAPI.ecdsaRefresh,ecdsaReshareNewParty:sdkAPI.ecdsaReshareNewParty,ecdsaReshareRemainingParty:sdkAPI.ecdsaReshareRemainingParty,ecdsaDerivePubkey:(e,r)=>sdkAPI.ecdsaDerivePubkey(e,new Uint32Array(r)),ecdsaGetXpub:sdkAPI.ecdsaGetXpub,ecdsaDerivePubkeyFromXpub:async(e,r)=>sdkAPI.ecdsaDerivePubkeyFromXpub(e,new Uint32Array(r)),ecdsaExportFullPrivateKey:sdkAPI.ecdsaExportFullPrivateKey,ecdsaOfflineExportFullPrivateKey:sdkAPI.ecdsaOfflineExportFullPrivateKey,ecdsaDerivePrivateKeyFromXpriv:async(e,r)=>sdkAPI.ecdsaDerivePrivateKeyFromXpriv(e,new Uint32Array(r)),ecdsaImportPrivateKeyRecipient:sdkAPI.ecdsaImportPrivateKeyRecipient,ecdsaImportPrivateKeyImporter:sdkAPI.ecdsaImportPrivateKeyImporter,ed25519GetExportID:sdkAPI.ed25519GetExportID,ed25519Keygen:sdkAPI.ed25519Keygen,ed25519Sign:(e,r,t,i,n)=>sdkAPI.ed25519Sign(e,r,t,i,new Uint32Array(n)),ed25519Refresh:sdkAPI.ed25519Refresh,ed25519ReshareNewParty:sdkAPI.ed25519ReshareNewParty,ed25519ReshareRemainingParty:sdkAPI.ed25519ReshareRemainingParty,ed25519DerivePubkey:(e,r)=>sdkAPI.ed25519DerivePubkey(e,new Uint32Array(r)),ed25519GetSpub:sdkAPI.ed25519GetSpub,ed25519DerivePubkeyFromSpub:async(e,r)=>sdkAPI.ed25519DerivePubkeyFromSpub(e,new Uint32Array(r)),ed25519ExportFullPrivateKey:sdkAPI.ed25519ExportFullPrivateKey,ed25519OfflineExportFullPrivateKey:sdkAPI.ed25519OfflineExportFullPrivateKey,ed25519DerivePrivateKeyFromSpriv:async(e,r)=>sdkAPI.ed25519DerivePrivateKeyFromSpriv(e,new Uint32Array(r)),ed25519ImportPrivateKeyRecipient:sdkAPI.ed25519ImportPrivateKeyRecipient,ed25519ImportPrivateKeyImporter:sdkAPI.ed25519ImportPrivateKeyImporter,bip340GetExportID:sdkAPI.bip340GetExportID,bip340Keygen:sdkAPI.bip340Keygen,bip340Sign:async(e,r,t,i,n,s)=>sdkAPI.bip340Sign(e,r,t,i,new Uint32Array(n),s),bip340Refresh:sdkAPI.bip340Refresh,bip340ReshareNewParty:sdkAPI.bip340ReshareNewParty,bip340ReshareRemainingParty:sdkAPI.bip340ReshareRemainingParty,bip340DeriveTweakPubkey:async(e,r,t)=>sdkAPI.bip340DeriveTweakPubkey(e,new Uint32Array(r),t),bip340GetXpub:sdkAPI.bip340GetXpub,bip340DeriveTweakPubkeyFromXpub:async(e,r,t)=>sdkAPI.bip340DeriveTweakPubkeyFromXpub(e,new Uint32Array(r),t),bip340ExportFullPrivateKey:sdkAPI.bip340ExportFullPrivateKey,bip340DerivePrivateKeyFromXpriv:async(e,r)=>sdkAPI.bip340DerivePrivateKeyFromXpriv(e,new Uint32Array(r)),bip340OfflineExportFullPrivateKey:sdkAPI.bip340OfflineExportFullPrivateKey,bip340ImportPrivateKeyRecipient:sdkAPI.bip340ImportPrivateKeyRecipient,bip340ImportPrivateKeyImporter:sdkAPI.bip340ImportPrivateKeyImporter}));class Ecdsa extends lib_mpc_internal_1.Ecdsa{constructor(e){super(sdkPromise,e||DEFAULT_RELAY_URL)}}exports.Ecdsa=Ecdsa;class Ed25519 extends lib_mpc_internal_1.Ed25519{constructor(e){super(sdkPromise,e||DEFAULT_RELAY_URL)}}exports.Ed25519=Ed25519;class BIP340 extends lib_mpc_internal_1.BIP340{constructor(e){super(sdkPromise,e||DEFAULT_RELAY_URL)}}exports.BIP340=BIP340;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@internal/web",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./package.json": "./package.json",
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@internal/core": "file:../lib-mpc-core"
|
|
17
|
+
},
|
|
18
|
+
"private": true
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
6
|
-
"@dynamic-labs-wallet/lib-mpc-web": "0.0.17",
|
|
5
|
+
"@dynamic-labs-wallet/core": "0.0.19",
|
|
7
6
|
"@dynamic-labs/logger": "^4.5.1"
|
|
8
7
|
},
|
|
8
|
+
"files": [
|
|
9
|
+
"*",
|
|
10
|
+
"node_modules/**/*"
|
|
11
|
+
],
|
|
9
12
|
"nx": {
|
|
10
13
|
"sourceRoot": "packages/browser/src",
|
|
11
14
|
"projectType": "library",
|
|
12
|
-
"name": "browser"
|
|
15
|
+
"name": "browser",
|
|
16
|
+
"targets": {
|
|
17
|
+
"build": {}
|
|
18
|
+
}
|
|
13
19
|
},
|
|
14
|
-
"type": "module",
|
|
15
20
|
"main": "./index.cjs.js",
|
|
16
21
|
"module": "./index.esm.js",
|
|
17
22
|
"types": "./index.esm.d.ts",
|
package/src/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThresholdSignatureScheme, DynamicApiClient } from '@dynamic-labs-wallet/core';
|
|
2
|
-
import { EcdsaPublicKey, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult, EcdsaSignature } from '@
|
|
2
|
+
import { EcdsaPublicKey, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult, EcdsaSignature } from '@internal/web';
|
|
3
3
|
import { ClientInitKeygenResult, ClientKeyShare } from './mpc/types';
|
|
4
4
|
import { SupportedStorage } from './services/localStorage';
|
|
5
5
|
import { DynamicWalletClientProps, InitializeResult, WalletProperties } from './types';
|
|
@@ -71,18 +71,41 @@ export declare class DynamicWalletClient {
|
|
|
71
71
|
accountAddress: string;
|
|
72
72
|
chainName: string;
|
|
73
73
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
74
|
-
serverReshareRemainingParty({ walletId, clientKeygenIds, }: {
|
|
75
|
-
walletId: string;
|
|
76
|
-
clientKeygenIds: string[];
|
|
77
|
-
}): Promise<any>;
|
|
78
74
|
getExportId({ chainName, clientKeyShare, }: {
|
|
79
75
|
chainName: string;
|
|
80
76
|
clientKeyShare: EcdsaKeygenResult | Ed25519KeygenResult | BIP340KeygenResult;
|
|
81
77
|
}): Promise<string>;
|
|
82
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Helper function to create client shares required to complete a reshare ceremony.
|
|
80
|
+
* @param {string} chainName - The chain to create shares for
|
|
81
|
+
* @param {WalletProperties} wallet - The wallet to reshare
|
|
82
|
+
* @param {ThresholdSignatureScheme} oldThresholdSignatureScheme - The current threshold signature scheme
|
|
83
|
+
* @param {ThresholdSignatureScheme} newThresholdSignatureScheme - The target threshold signature scheme
|
|
84
|
+
* @returns {Promise<{
|
|
85
|
+
* newClientInitKeygenResults: ClientInitKeygenResult[],
|
|
86
|
+
* newClientKeygenIds: string[],
|
|
87
|
+
* existingClientKeygenIds: string[],
|
|
88
|
+
* existingClientKeyShares: ClientKeyShare[]
|
|
89
|
+
* }>} Object containing new and existing client keygen results, IDs and shares
|
|
90
|
+
* @todo Support higher to lower reshare strategies
|
|
91
|
+
*/
|
|
92
|
+
reshareStrategy({ chainName, wallet, oldThresholdSignatureScheme, newThresholdSignatureScheme, }: {
|
|
93
|
+
chainName: string;
|
|
94
|
+
wallet: WalletProperties;
|
|
95
|
+
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
96
|
+
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
newClientInitKeygenResults: ClientInitKeygenResult[];
|
|
99
|
+
newClientKeygenIds: string[];
|
|
100
|
+
existingClientKeygenIds: string[];
|
|
101
|
+
existingClientKeyShares: ClientKeyShare[];
|
|
102
|
+
}>;
|
|
103
|
+
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, }: {
|
|
104
|
+
chainName: string;
|
|
83
105
|
accountAddress: string;
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
107
|
+
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
108
|
+
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
86
109
|
exportKey({ accountAddress, chainName, }: {
|
|
87
110
|
accountAddress: string;
|
|
88
111
|
chainName: string;
|
package/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EACxB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"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"}
|
package/src/mpc/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ecdsa, Ed25519, BIP340, BIP340KeygenResult, EcdsaPublicKey, Ed25519KeygenResult, EcdsaKeygenResult, MessageHash, EcdsaInitKeygenResult, Ed25519InitKeygenResult, BIP340InitKeygenResult, EcdsaSignature } from '@
|
|
1
|
+
import { Ecdsa, Ed25519, BIP340, BIP340KeygenResult, EcdsaPublicKey, Ed25519KeygenResult, EcdsaKeygenResult, MessageHash, EcdsaInitKeygenResult, Ed25519InitKeygenResult, BIP340InitKeygenResult, EcdsaSignature } from '@internal/web';
|
|
2
2
|
export { Ecdsa, Ed25519, BIP340, EcdsaPublicKey, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult, MessageHash, EcdsaInitKeygenResult, Ed25519InitKeygenResult, BIP340InitKeygenResult, EcdsaSignature, };
|
|
3
3
|
export * from './mpc';
|
|
4
4
|
export * from './types';
|
package/src/mpc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACf,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,CAAC;AAEF,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
package/src/mpc/mpc.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
|
|
2
|
-
import { Ecdsa, Ed25519, BIP340 } from '@
|
|
2
|
+
import { Ecdsa, Ed25519, BIP340 } from '@internal/web';
|
|
3
3
|
export declare const getMPCSignatureScheme: ({ signingAlgorithm, baseRelayUrl, }: {
|
|
4
4
|
signingAlgorithm: SigningAlgorithm;
|
|
5
5
|
baseRelayUrl?: string;
|
package/src/mpc/mpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpc.d.ts","sourceRoot":"","sources":["../../src/mpc/mpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mpc.d.ts","sourceRoot":"","sources":["../../src/mpc/mpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvD,eAAO,MAAM,qBAAqB,wCAG/B;IACD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,6BAWA,CAAC;AAEF,eAAO,MAAM,YAAY,iCAGtB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,6BAOA,CAAC"}
|
package/src/mpc/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BIP340InitKeygenResult, BIP340KeygenResult, Ed25519InitKeygenResult, EcdsaInitKeygenResult, EcdsaKeygenResult, Ed25519KeygenResult } from '@
|
|
1
|
+
import type { BIP340InitKeygenResult, BIP340KeygenResult, Ed25519InitKeygenResult, EcdsaInitKeygenResult, EcdsaKeygenResult, Ed25519KeygenResult } from '@internal/web';
|
|
2
2
|
export type ClientInitKeygenResult = EcdsaInitKeygenResult | Ed25519InitKeygenResult | BIP340InitKeygenResult;
|
|
3
3
|
export type ClientKeyShare = EcdsaKeygenResult | Ed25519KeygenResult | BIP340KeygenResult;
|
|
4
|
-
export type { Ecdsa, Ed25519, BIP340, EcdsaPublicKey, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult, MessageHash, EcdsaSignature, } from '@
|
|
4
|
+
export type { Ecdsa, Ed25519, BIP340, EcdsaPublicKey, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult, MessageHash, EcdsaSignature, } from '@internal/web';
|
|
5
5
|
//# sourceMappingURL=types.d.ts.map
|
package/src/mpc/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mpc/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mpc/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,sBAAsB,GAC9B,qBAAqB,GACrB,uBAAuB,GACvB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,CAAC;AAGrB,YAAY,EACV,KAAK,EACL,OAAO,EACP,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,cAAc,GACf,MAAM,eAAe,CAAC"}
|