@dynamic-labs-wallet/node 0.0.0-preview.114.4 → 0.0.1-paolo-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +790 -233
- package/index.esm.js +778 -195
- package/internal/core/bip340.cjs +1 -0
- package/internal/core/common.cjs +1 -0
- package/internal/core/ecdsa.cjs +1 -0
- package/internal/core/ecdsa.d.ts +1 -1
- package/internal/core/ed25519.cjs +1 -0
- package/internal/core/ed25519_exportable.cjs +1 -0
- package/internal/core/ed25519_exportable.d.ts +21 -0
- package/internal/core/index.cjs +1 -0
- package/internal/core/index.d.ts +4 -2
- package/internal/core/native.d.ts +65 -0
- package/internal/core/sr25519.cjs +1 -0
- package/internal/core/sr25519.d.ts +22 -0
- package/internal/core/types.cjs +1 -0
- package/internal/core/types.d.ts +20 -0
- package/internal/node/index.cjs +1 -0
- package/internal/node/index.d.ts +8 -2
- package/internal/node/native/libmpc_executor_linux_arm64_nodejs.node +0 -0
- package/internal/node/native/libmpc_executor_linux_x86_64_nodejs.node +0 -0
- package/internal/node/native/libmpc_executor_macos_arm64_nodejs.node +0 -0
- package/internal/node/native/libmpc_executor_macos_x86_64_nodejs.node +0 -0
- package/internal/node/native.cjs +1 -0
- package/internal/node/native.d.ts +1 -1
- package/package.json +13 -8
- package/src/backup/encryption.d.ts +42 -2
- package/src/backup/encryption.d.ts.map +1 -1
- package/src/backup/utils.d.ts +4 -0
- package/src/backup/utils.d.ts.map +1 -0
- package/src/client.d.ts +85 -30
- package/src/client.d.ts.map +1 -1
- package/src/core/createCore.d.ts +25 -0
- package/src/core/createCore.d.ts.map +1 -0
- package/src/core/types.d.ts +7 -0
- package/src/core/types.d.ts.map +1 -0
- package/src/delegatedClient/createDelegatedClient.d.ts +23 -0
- package/src/delegatedClient/createDelegatedClient.d.ts.map +1 -0
- package/src/delegatedClient/index.d.ts +7 -0
- package/src/delegatedClient/index.d.ts.map +1 -0
- package/src/delegatedClient/modules/decryptWebhookData.d.ts +18 -0
- package/src/delegatedClient/modules/decryptWebhookData.d.ts.map +1 -0
- package/src/delegatedClient/modules/revokeDelegation.d.ts +3 -0
- package/src/delegatedClient/modules/revokeDelegation.d.ts.map +1 -0
- package/src/delegatedClient/modules/sign.d.ts +31 -0
- package/src/delegatedClient/modules/sign.d.ts.map +1 -0
- package/src/index.d.ts +11 -5
- package/src/index.d.ts.map +1 -1
- package/src/mpc/index.d.ts +2 -2
- package/src/mpc/index.d.ts.map +1 -1
- package/src/mpc/mpc.d.ts +3 -4
- package/src/mpc/mpc.d.ts.map +1 -1
- package/src/mpc/types.d.ts +1 -2
- package/src/mpc/types.d.ts.map +1 -1
- package/src/types.d.ts +11 -2
- package/src/types.d.ts.map +1 -1
- package/src/utils.d.ts +5 -2
- package/src/utils.d.ts.map +1 -1
- package/internal/core/bip340.js +0 -1
- package/internal/core/common.js +0 -1
- package/internal/core/ecdsa.js +0 -1
- package/internal/core/ed25519.js +0 -1
- package/internal/core/index.js +0 -1
- package/internal/core/types.js +0 -1
- package/internal/node/index.js +0 -1
- package/internal/node/native.js +0 -1
- /package/internal/core/{native.js → native.cjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340=void 0;const _1=require("./index.cjs"),utils_1=require("@noble/hashes/utils"),common_1=require("./common.cjs");function getTweak(tweak){if("string"!=typeof tweak&&(tweak=(0,utils_1.bytesToHex)(tweak)),0!==tweak.length&&64!==tweak.length)throw new Error("Tweak must be 32 bytes long");return tweak}class BIP340{constructor(native,url){this.NATIVE=native,this.URL=url}async initKeygen(){const keygenInitKeypair=await(await this.NATIVE).initKeygen();return new _1.BIP340InitKeygenResult(keygenInitKeypair.pubkey,keygenInitKeypair.keypair)}async exportID(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).bip340GetExportID(secretShare)}async createRoom(numParties,apiKey){return(0,common_1.sanitizeNumberOfParties)(numParties),(await this.NATIVE).createRoom(this.URL,numParties,apiKey)}async keygen(roomUuid,numParties,threshold,keygenInit,keygenIds){if((0,common_1.sanitizeNumberOfParties)(numParties,threshold),keygenIds.length!==numParties-1)throw new Error(`keygenIds length must be exactly: ${numParties-1}, it is: `+keygenIds.length);const keygenResult=await(await this.NATIVE).bip340Keygen(roomUuid,this.URL,numParties,threshold,keygenInit.keygenSecret,keygenIds);if(!keygenResult.pubkey||!keygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(keygenResult.pubkey),secretShareHex=keygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}async sign(roomUuid,keygenResult,msg,derivationPath=new Uint32Array,tweak=new Uint8Array){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,signature=("string"!=typeof msg&&(msg=(0,utils_1.bytesToHex)(msg)),tweak=getTweak(tweak),await(await this.NATIVE).bip340Sign(roomUuid,this.URL,secretShare,msg,Array.from(derivationPath),tweak));return(0,utils_1.hexToBytes)(signature)}async refresh(roomUuid,keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,refreshedKeygenResult=await(await this.NATIVE).bip340Refresh(roomUuid,this.URL,secretShare);if(!refreshedKeygenResult.pubkey||!refreshedKeygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(refreshedKeygenResult.pubkey),secretShareHex=refreshedKeygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}async reshareNewParty(roomUuid,oldThreshold,newThreshold,keygenInit,keygenIds){const resharedKeygenResult=await(await this.NATIVE).bip340ReshareNewParty(roomUuid,this.URL,oldThreshold,newThreshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}async reshareRemainingParty(roomUuid,newThreshold,keygenResult,keygenIds){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,resharedKeygenResult=await(await this.NATIVE).bip340ReshareRemainingParty(roomUuid,this.URL,newThreshold,secretShare,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}async deriveTweakPubkey(keygenResult,derivationPath=new Uint32Array,tweak=new Uint8Array){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,pubkey=await(await this.NATIVE).bip340DeriveTweakPubkey(secretShare,Array.from(derivationPath),getTweak(tweak));return(0,utils_1.hexToBytes)(pubkey)}async getXpub(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).bip340GetXpub(secretShare)}async deriveTweakPubkeyFromXpub(Xpub,derivationPath=new Uint32Array,tweak=new Uint8Array){const pubkey=await(await this.NATIVE).bip340DeriveTweakPubkeyFromXpub(Xpub,Array.from(derivationPath),getTweak(tweak));return(0,utils_1.hexToBytes)(pubkey)}async exportFullPrivateKey(roomUuid,keygenResult,toExportID){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).bip340ExportFullPrivateKey(roomUuid,this.URL,secretShare,toExportID)}async derivePrivateKeyFromXpriv(xpriv,derivationPath=new Uint32Array){return(await this.NATIVE).bip340DerivePrivateKeyFromXpriv(xpriv,Array.from(derivationPath))}async offlineExportFullPrivateKey(keygenResults){const secretShares=keygenResults.map(k=>{if("string"==typeof k)return k;if(k instanceof _1.BIP340KeygenResult)return k.secretShare;throw"UnknownType"});return(await this.NATIVE).bip340OfflineExportFullPrivateKey(secretShares)}async importPrivateKeyRecipient(roomUuid,threshold,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).bip340ImportPrivateKeyRecipient(roomUuid,this.URL,threshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}async importPrivateKeyImporter(roomUuid,threshold,privateKey,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).bip340ImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}}exports.BIP340=BIP340;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function sanitizeNumberOfParties(...numberOfParties){for(var n of numberOfParties)if(!Number.isInteger(n)||n<1||65535<n)throw new RangeError(`numberOfParties should be an integer in the range: 1..65_535, instead got: ${n} `)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.sanitizeNumberOfParties=sanitizeNumberOfParties;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ecdsa=void 0;const _1=require("./index.cjs"),common_1=require("./common.cjs");class Ecdsa{constructor(native,hostUrl){this.NATIVE=native,this.URL=hostUrl}async createRoom(numParties,apiKey){return(0,common_1.sanitizeNumberOfParties)(numParties),(await this.NATIVE).createRoom(this.URL,numParties,apiKey)}async initKeygen(){const keygenInitKeypair=await(await this.NATIVE).initKeygen();return new _1.EcdsaInitKeygenResult(keygenInitKeypair.pubkey,keygenInitKeypair.keypair)}async exportID(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).ecdsaGetExportID(secretShare)}async keygen(roomUuid,numParties,threshold,keygenInit,keygenIds){if((0,common_1.sanitizeNumberOfParties)(numParties,threshold),keygenIds.length!==numParties-1)throw new Error(`keygenIds length must be exactly: ${numParties-1}, it is: `+keygenIds.length);const keygenResult=await(await this.NATIVE).ecdsaKeygen(roomUuid,this.URL,numParties,threshold,keygenInit.keygenSecret,keygenIds),pubkey=new _1.EcdsaPublicKey(keygenResult.pubkey),secretShareHex=keygenResult.secret_share;return new _1.EcdsaKeygenResult(pubkey,secretShareHex)}async sign(roomUuid,keygenResult,msgHash,derivationPath=new Uint32Array){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,expandedSignature=await(await this.NATIVE).ecdsaSign(roomUuid,this.URL,secretShare,msgHash.toHex(),Array.from(derivationPath));return _1.EcdsaSignature.fromBuffer(expandedSignature)}async refresh(roomUuid,keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,refreshedKeygenResult=await(await this.NATIVE).ecdsaRefresh(roomUuid,this.URL,secretShare),pubkey=new _1.EcdsaPublicKey(refreshedKeygenResult.pubkey),secretShareHex=refreshedKeygenResult.secret_share;return new _1.EcdsaKeygenResult(pubkey,secretShareHex)}async reshareNewParty(roomUuid,oldThreshold,newThreshold,keygenInit,keygenIds){const resharedKeygenResult=await(await this.NATIVE).ecdsaReshareNewParty(roomUuid,this.URL,oldThreshold,newThreshold,keygenInit.keygenSecret,keygenIds),pubkey=new _1.EcdsaPublicKey(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.EcdsaKeygenResult(pubkey,secretShareHex)}async reshareRemainingParty(roomUuid,newThreshold,keygenResult,keygenIds){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,resharedKeygenResult=await(await this.NATIVE).ecdsaReshareRemainingParty(roomUuid,this.URL,newThreshold,secretShare,keygenIds),pubkey=new _1.EcdsaPublicKey(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.EcdsaKeygenResult(pubkey,secretShareHex)}async derivePubkey(keygenResult,derivationPath=new Uint32Array){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,pubkey=await(await this.NATIVE).ecdsaDerivePubkey(secretShare,Array.from(derivationPath));return new _1.EcdsaPublicKey(pubkey)}async getXpub(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).ecdsaGetXpub(secretShare)}async derivePubkeyFromXpub(Xpub,derivationPath=new Uint32Array){const pubkey=await(await this.NATIVE).ecdsaDerivePubkeyFromXpub(Xpub,Array.from(derivationPath));return new _1.EcdsaPublicKey(pubkey)}async exportFullPrivateKey(roomUuid,keygenResult,toExportID){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,exported=await(await this.NATIVE).ecdsaExportFullPrivateKey(roomUuid,this.URL,secretShare,toExportID);return exported||void 0}async derivePrivateKeyFromXpriv(xpriv,derivationPath=new Uint32Array){return(await this.NATIVE).ecdsaDerivePrivateKeyFromXpriv(xpriv,Array.from(derivationPath))}async offlineExportFullPrivateKey(keygenResults){const secretShares=keygenResults.map(k=>{if("string"==typeof k)return k;if(k instanceof _1.EcdsaKeygenResult)return k.secretShare;throw"UnknownType"});return(await this.NATIVE).ecdsaOfflineExportFullPrivateKey(secretShares)}async importPrivateKeyRecipient(roomUuid,threshold,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).ecdsaImportPrivateKeyRecipient(roomUuid,this.URL,threshold,keygenInit.keygenSecret,keygenIds),pubkey=new _1.EcdsaPublicKey(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.EcdsaKeygenResult(pubkey,secretShareHex)}async importPrivateKeyImporter(roomUuid,threshold,privateKey,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).ecdsaImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds),pubkey=new _1.EcdsaPublicKey(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.EcdsaKeygenResult(pubkey,secretShareHex)}getHostUrl(path){return path||this.URL}}exports.Ecdsa=Ecdsa;
|
package/internal/core/ecdsa.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class Ecdsa {
|
|
|
16
16
|
derivePubkeyFromXpub(Xpub: string, derivationPath?: Uint32Array): Promise<EcdsaPublicKey>;
|
|
17
17
|
exportFullPrivateKey(roomUuid: string, keygenResult: EcdsaKeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
18
18
|
derivePrivateKeyFromXpriv(xpriv: string, derivationPath?: Uint32Array): Promise<string>;
|
|
19
|
-
offlineExportFullPrivateKey(keygenResults:
|
|
19
|
+
offlineExportFullPrivateKey(keygenResults: EcdsaKeygenResult[] | string[]): Promise<string>;
|
|
20
20
|
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: EcdsaInitKeygenResult, keygenIds: string[]): Promise<EcdsaKeygenResult>;
|
|
21
21
|
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: EcdsaInitKeygenResult, keygenIds: string[]): Promise<EcdsaKeygenResult>;
|
|
22
22
|
protected getHostUrl(path?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ed25519=void 0;const _1=require("./index.cjs"),utils_1=require("@noble/hashes/utils"),common_1=require("./common.cjs");class Ed25519{constructor(native,url){this.NATIVE=native,this.URL=url}async initKeygen(){const keygenInitKeypair=await(await this.NATIVE).initKeygen();return new _1.Ed25519InitKeygenResult(keygenInitKeypair.pubkey,keygenInitKeypair.keypair)}async exportID(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).ed25519GetExportID(secretShare)}async createRoom(numParties,apiKey){return(0,common_1.sanitizeNumberOfParties)(numParties),(await this.NATIVE).createRoom(this.URL,numParties,apiKey)}async keygen(roomUuid,numParties,threshold,keygenInit,keygenIds){if((0,common_1.sanitizeNumberOfParties)(numParties,threshold),keygenIds.length!==numParties-1)throw new Error(`keygenIds length must be exactly: ${numParties-1}, it is: `+keygenIds.length);const keygenResult=await(await this.NATIVE).ed25519Keygen(roomUuid,this.URL,numParties,threshold,keygenInit.keygenSecret,keygenIds);if(!keygenResult.pubkey||!keygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(keygenResult.pubkey),secretShareHex=keygenResult.secret_share;return new _1.Ed25519KeygenResult(pubkey,secretShareHex)}async sign(roomUuid,keygenResult,msg,derivationPath=new Uint32Array){"string"!=typeof msg&&(msg=(0,utils_1.bytesToHex)(msg));const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,signature=await(await this.NATIVE).ed25519Sign(roomUuid,this.URL,secretShare,msg,Array.from(derivationPath));return(0,utils_1.hexToBytes)(signature)}async refresh(roomUuid,keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,refreshedKeygenResult=await(await this.NATIVE).ed25519Refresh(roomUuid,this.URL,secretShare);if(!refreshedKeygenResult.pubkey||!refreshedKeygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(refreshedKeygenResult.pubkey),secretShareHex=refreshedKeygenResult.secret_share;return new _1.Ed25519KeygenResult(pubkey,secretShareHex)}async reshareNewParty(roomUuid,oldThreshold,newThreshold,keygenInit,keygenIds){const resharedKeygenResult=await(await this.NATIVE).ed25519ReshareNewParty(roomUuid,this.URL,oldThreshold,newThreshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.Ed25519KeygenResult(pubkey,secretShareHex)}async reshareRemainingParty(roomUuid,newThreshold,keygenResult,keygenIds){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,resharedKeygenResult=await(await this.NATIVE).ed25519ReshareRemainingParty(roomUuid,this.URL,newThreshold,secretShare,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.Ed25519KeygenResult(pubkey,secretShareHex)}async derivePubkey(keygenResult,derivationPath=new Uint32Array){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,pubkey=await(await this.NATIVE).ed25519DerivePubkey(secretShare,Array.from(derivationPath));return(0,utils_1.hexToBytes)(pubkey)}async getSpub(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).ed25519GetSpub(secretShare)}async derivePubkeyFromSpub(spub,derivation){const pubkey=await(await this.NATIVE).ed25519DerivePubkeyFromSpub(spub,Array.from(derivation));return(0,utils_1.hexToBytes)(pubkey)}async exportFullPrivateKey(roomUuid,keygenResult,toExportID){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,exported=await(await this.NATIVE).ed25519ExportFullPrivateKey(roomUuid,this.URL,secretShare,toExportID);return exported||void 0}async derivePrivateKeyFromSpriv(spriv,derivationPath=new Uint32Array){return(await this.NATIVE).ed25519DerivePrivateKeyFromSpriv(spriv,Array.from(derivationPath))}async offlineExportFullPrivateKey(keygenResults){const secretShares=keygenResults.map(k=>{if("string"==typeof k)return k;if(k instanceof _1.Ed25519KeygenResult)return k.secretShare;throw"UnknownType"});return(await this.NATIVE).ed25519OfflineExportFullPrivateKey(secretShares)}async importPrivateKeyRecipient(roomUuid,threshold,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).ed25519ImportPrivateKeyRecipient(roomUuid,this.URL,threshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.Ed25519KeygenResult(pubkey,secretShareHex)}async importPrivateKeyImporter(roomUuid,threshold,privateKey,keygenInit,keygenIds,isPrivateKeyRaw=!1){const importKeygenResult=await(await this.NATIVE).ed25519ImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds,isPrivateKeyRaw),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.Ed25519KeygenResult(pubkey,secretShareHex)}}exports.Ed25519=Ed25519;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExportableEd25519=void 0;const _1=require("./index.cjs"),utils_1=require("@noble/hashes/utils"),common_1=require("./common.cjs");class ExportableEd25519{constructor(native,url){this.NATIVE=native,this.URL=url}async initKeygen(){const keygenInitKeypair=await(await this.NATIVE).initKeygen();return new _1.ExportableEd25519InitKeygenResult(keygenInitKeypair.pubkey,keygenInitKeypair.keypair)}async exportID(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).exportableEd25519GetExportID(secretShare)}async createRoom(numParties,apiKey){return(0,common_1.sanitizeNumberOfParties)(numParties),(await this.NATIVE).createRoom(this.URL,numParties,apiKey)}async sampleKey(roomUuid,numParties,threshold,keygenInit,keygenIds){if((0,common_1.sanitizeNumberOfParties)(numParties,threshold),keygenIds.length!==numParties-1)throw new Error(`keygenIds length must be exactly: ${numParties-1}, it is: `+keygenIds.length);const keygenResult=await(await this.NATIVE).exportableEd25519SampleKey(roomUuid,this.URL,numParties,threshold,keygenInit.keygenSecret,keygenIds);if(!keygenResult.pubkey||!keygenResult.secret_share)throw new Error("Key sampling failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(keygenResult.pubkey),secretShareHex=keygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async receiveKey(roomUuid,numParties,threshold,keygenInit,keygenIds){if((0,common_1.sanitizeNumberOfParties)(numParties,threshold),keygenIds.length!==numParties-1)throw new Error(`keygenIds length must be exactly: ${numParties-1}, it is: `+keygenIds.length);const keygenResult=await(await this.NATIVE).exportableEd25519ReceiveKey(roomUuid,this.URL,numParties,threshold,keygenInit.keygenSecret,keygenIds);if(!keygenResult.pubkey||!keygenResult.secret_share)throw new Error("Key receive failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(keygenResult.pubkey),secretShareHex=keygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async sign(roomUuid,keygenResult,msg){"string"!=typeof msg&&(msg=(0,utils_1.bytesToHex)(msg));const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,signature=await(await this.NATIVE).exportableEd25519Sign(roomUuid,this.URL,secretShare,msg);return(0,utils_1.hexToBytes)(signature)}async refresh(roomUuid,keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,refreshedKeygenResult=await(await this.NATIVE).exportableEd25519Refresh(roomUuid,this.URL,secretShare);if(!refreshedKeygenResult.pubkey||!refreshedKeygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(refreshedKeygenResult.pubkey),secretShareHex=refreshedKeygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async reshareNewParty(roomUuid,oldThreshold,newThreshold,keygenInit,keygenIds){const resharedKeygenResult=await(await this.NATIVE).exportableEd25519ReshareNewParty(roomUuid,this.URL,oldThreshold,newThreshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async reshareRemainingParty(roomUuid,newThreshold,keygenResult,keygenIds){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,resharedKeygenResult=await(await this.NATIVE).exportableEd25519ReshareRemainingParty(roomUuid,this.URL,newThreshold,secretShare,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async getPrivateKey(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).exportableEd25519GetPubkey(secretShare)}async exportFullPrivateKey(roomUuid,keygenResult,toExportID){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,exported=await(await this.NATIVE).exportableEd25519ExportFullPrivateKey(roomUuid,this.URL,secretShare,toExportID);return exported||void 0}async offlineExportFullPrivateKey(keygenResults){const secretShares=keygenResults.map(k=>{if("string"==typeof k)return k;if(k instanceof _1.ExportableEd25519KeygenResult)return k.secretShare;throw new Error("UnknownType")});return(await this.NATIVE).exportableEd25519OfflineExportFullPrivateKey(secretShares)}async importPrivateKeyRecipient(roomUuid,threshold,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).exportableEd25519ImportPrivateKeyRecipient(roomUuid,this.URL,threshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async importPrivateKeyImporter(roomUuid,threshold,privateKey,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).exportableEd25519ImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.ExportableEd25519KeygenResult(pubkey,secretShareHex)}async getPubkey(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).exportableEd25519GetPubkey(secretShare)}}exports.ExportableEd25519=ExportableEd25519;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExportableEd25519InitKeygenResult, ExportableEd25519KeygenResult, DynamicNativeSdkInterface } from './';
|
|
2
|
+
export declare class ExportableEd25519 {
|
|
3
|
+
protected readonly NATIVE: Promise<DynamicNativeSdkInterface>;
|
|
4
|
+
protected readonly URL: string;
|
|
5
|
+
protected constructor(native: Promise<DynamicNativeSdkInterface>, url: string);
|
|
6
|
+
initKeygen(): Promise<ExportableEd25519InitKeygenResult>;
|
|
7
|
+
exportID(keygenResult: ExportableEd25519KeygenResult | string): Promise<string>;
|
|
8
|
+
createRoom(numParties: number, apiKey: string): Promise<string>;
|
|
9
|
+
sampleKey(roomUuid: string, numParties: number, threshold: number, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
10
|
+
receiveKey(roomUuid: string, numParties: number, threshold: number, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
11
|
+
sign(roomUuid: string, keygenResult: ExportableEd25519KeygenResult | string, msg: Uint8Array | string): Promise<Uint8Array>;
|
|
12
|
+
refresh(roomUuid: string, keygenResult: ExportableEd25519KeygenResult | string): Promise<ExportableEd25519KeygenResult>;
|
|
13
|
+
reshareNewParty(roomUuid: string, oldThreshold: number, newThreshold: number, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
14
|
+
reshareRemainingParty(roomUuid: string, newThreshold: number, keygenResult: ExportableEd25519KeygenResult | string, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
15
|
+
getPrivateKey(keygenResult: ExportableEd25519KeygenResult | string): Promise<string>;
|
|
16
|
+
exportFullPrivateKey(roomUuid: string, keygenResult: ExportableEd25519KeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
17
|
+
offlineExportFullPrivateKey(keygenResults: ExportableEd25519KeygenResult[] | string[]): Promise<string>;
|
|
18
|
+
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
19
|
+
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
20
|
+
getPubkey(keygenResult: ExportableEd25519KeygenResult | string): Promise<string>;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340=exports.Sr25519=exports.ExportableEd25519=exports.Ed25519=exports.Ecdsa=exports.MessageHash=exports.BIP340KeygenResult=exports.BIP340InitKeygenResult=exports.Sr25519KeygenResult=exports.Sr25519InitKeygenResult=exports.ExportableEd25519KeygenResult=exports.ExportableEd25519InitKeygenResult=exports.Ed25519KeygenResult=exports.Ed25519InitKeygenResult=exports.EcdsaSignature=exports.EcdsaPublicKey=exports.EcdsaKeygenResult=exports.EcdsaInitKeygenResult=void 0;const types_1=require("./types.cjs"),ecdsa_1=(Object.defineProperty(exports,"EcdsaInitKeygenResult",{value:types_1.EcdsaInitKeygenResult}),Object.defineProperty(exports,"EcdsaKeygenResult",{value:types_1.EcdsaKeygenResult}),Object.defineProperty(exports,"EcdsaPublicKey",{value:types_1.EcdsaPublicKey}),Object.defineProperty(exports,"EcdsaSignature",{value:types_1.EcdsaSignature}),Object.defineProperty(exports,"Ed25519InitKeygenResult",{value:types_1.Ed25519InitKeygenResult}),Object.defineProperty(exports,"Ed25519KeygenResult",{value:types_1.Ed25519KeygenResult}),Object.defineProperty(exports,"ExportableEd25519InitKeygenResult",{value:types_1.ExportableEd25519InitKeygenResult}),Object.defineProperty(exports,"ExportableEd25519KeygenResult",{value:types_1.ExportableEd25519KeygenResult}),Object.defineProperty(exports,"Sr25519InitKeygenResult",{value:types_1.Sr25519InitKeygenResult}),Object.defineProperty(exports,"Sr25519KeygenResult",{value:types_1.Sr25519KeygenResult}),Object.defineProperty(exports,"BIP340InitKeygenResult",{value:types_1.BIP340InitKeygenResult}),Object.defineProperty(exports,"BIP340KeygenResult",{value:types_1.BIP340KeygenResult}),Object.defineProperty(exports,"MessageHash",{value:types_1.MessageHash}),require("./ecdsa.cjs")),ed25519_1=(Object.defineProperty(exports,"Ecdsa",{value:ecdsa_1.Ecdsa}),require("./ed25519.cjs")),ed25519_exportable_1=(Object.defineProperty(exports,"Ed25519",{value:ed25519_1.Ed25519}),require("./ed25519_exportable.cjs")),sr25519_1=(Object.defineProperty(exports,"ExportableEd25519",{value:ed25519_exportable_1.ExportableEd25519}),require("./sr25519.cjs")),bip340_1=(Object.defineProperty(exports,"Sr25519",{value:sr25519_1.Sr25519}),require("./bip340.cjs"));Object.defineProperty(exports,"BIP340",{value:bip340_1.BIP340});
|
package/internal/core/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519KeygenResult, BIP340InitKeygenResult, BIP340KeygenResult, MessageHash } from './types';
|
|
1
|
+
import { EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519KeygenResult, ExportableEd25519InitKeygenResult, ExportableEd25519KeygenResult, Sr25519InitKeygenResult, Sr25519KeygenResult, BIP340InitKeygenResult, BIP340KeygenResult, MessageHash } from './types';
|
|
2
2
|
import { Ecdsa } from './ecdsa';
|
|
3
3
|
import { Ed25519 } from './ed25519';
|
|
4
|
+
import { ExportableEd25519 } from './ed25519_exportable';
|
|
5
|
+
import { Sr25519 } from './sr25519';
|
|
4
6
|
import { BIP340 } from './bip340';
|
|
5
7
|
import { DynamicNativeSdkInterface } from './native';
|
|
6
|
-
export { DynamicNativeSdkInterface, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519KeygenResult, BIP340InitKeygenResult, BIP340KeygenResult, MessageHash, Ecdsa, Ed25519, BIP340, };
|
|
8
|
+
export { DynamicNativeSdkInterface, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519KeygenResult, ExportableEd25519InitKeygenResult, ExportableEd25519KeygenResult, Sr25519InitKeygenResult, Sr25519KeygenResult, BIP340InitKeygenResult, BIP340KeygenResult, MessageHash, Ecdsa, Ed25519, ExportableEd25519, Sr25519, BIP340, };
|
|
@@ -68,6 +68,39 @@ export interface DynamicNativeSdkInterface {
|
|
|
68
68
|
pubkey: string;
|
|
69
69
|
secret_share: string;
|
|
70
70
|
}>;
|
|
71
|
+
exportableEd25519GetExportID(secretShare: string): Promise<string>;
|
|
72
|
+
exportableEd25519SampleKey(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
73
|
+
pubkey: string;
|
|
74
|
+
secret_share: string;
|
|
75
|
+
}>;
|
|
76
|
+
exportableEd25519ReceiveKey(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
77
|
+
pubkey: string;
|
|
78
|
+
secret_share: string;
|
|
79
|
+
}>;
|
|
80
|
+
exportableEd25519Sign(roomUUID: string, hostUrl: string, secretShare: string, msgHex: string): Promise<string>;
|
|
81
|
+
exportableEd25519Refresh(roomUUID: string, hostUrl: string, secretShare: string): Promise<{
|
|
82
|
+
pubkey: string;
|
|
83
|
+
secret_share: string;
|
|
84
|
+
}>;
|
|
85
|
+
exportableEd25519ReshareNewParty(roomUUID: string, hostUrl: string, oldThreshold: number, newThreshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
86
|
+
pubkey: string;
|
|
87
|
+
secret_share: string;
|
|
88
|
+
}>;
|
|
89
|
+
exportableEd25519ReshareRemainingParty(roomUUID: string, hostUrl: string, newThreshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
90
|
+
pubkey: string;
|
|
91
|
+
secret_share: string;
|
|
92
|
+
}>;
|
|
93
|
+
exportableEd25519GetPubkey(secretShare: string): Promise<string>;
|
|
94
|
+
exportableEd25519ExportFullPrivateKey(roomUUID: string, hostUrl: string, secretShare: string, toExportID: string): Promise<undefined | string>;
|
|
95
|
+
exportableEd25519OfflineExportFullPrivateKey(keygenResults: string[]): Promise<string>;
|
|
96
|
+
exportableEd25519ImportPrivateKeyRecipient(roomUUID: string, hostUrl: string, threshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
97
|
+
pubkey: string;
|
|
98
|
+
secret_share: string;
|
|
99
|
+
}>;
|
|
100
|
+
exportableEd25519ImportPrivateKeyImporter(roomUUID: string, hostUrl: string, threshold: number, privateKey: string, secretShare: string, keygenIDs: string[]): Promise<{
|
|
101
|
+
pubkey: string;
|
|
102
|
+
secret_share: string;
|
|
103
|
+
}>;
|
|
71
104
|
bip340GetExportID(secretShare: string): Promise<string>;
|
|
72
105
|
bip340Keygen(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
73
106
|
pubkey: string;
|
|
@@ -100,4 +133,36 @@ export interface DynamicNativeSdkInterface {
|
|
|
100
133
|
pubkey: string;
|
|
101
134
|
secret_share: string;
|
|
102
135
|
}>;
|
|
136
|
+
sr25519GetExportID(secretShare: string): Promise<string>;
|
|
137
|
+
sr25519Keygen(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
138
|
+
pubkey: string;
|
|
139
|
+
secret_share: string;
|
|
140
|
+
}>;
|
|
141
|
+
sr25519Sign(roomUUID: string, hostUrl: string, secretShare: string, msgHex: string, derivationPath: string[]): Promise<string>;
|
|
142
|
+
sr25519Refresh(roomUUID: string, hostUrl: string, secretShare: string): Promise<{
|
|
143
|
+
pubkey: string;
|
|
144
|
+
secret_share: string;
|
|
145
|
+
}>;
|
|
146
|
+
sr25519ReshareNewParty(roomUUID: string, hostUrl: string, oldThreshold: number, newThreshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
147
|
+
pubkey: string;
|
|
148
|
+
secret_share: string;
|
|
149
|
+
}>;
|
|
150
|
+
sr25519ReshareRemainingParty(roomUUID: string, hostUrl: string, newThreshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
151
|
+
pubkey: string;
|
|
152
|
+
secret_share: string;
|
|
153
|
+
}>;
|
|
154
|
+
sr25519DerivePubkey(secretShare: string, derivationPath: string[]): Promise<string>;
|
|
155
|
+
sr25519GetPubkey(secretShare: string): Promise<string>;
|
|
156
|
+
sr25519DerivePubkeyFromPubkey(pubkey: string, derivation: string[]): Promise<string>;
|
|
157
|
+
sr25519ExportFullPrivateKey(roomUUID: string, hostUrl: string, secretShare: string, toExportID: string): Promise<undefined | string>;
|
|
158
|
+
sr25519DerivePrivateKeyFromPrivateKey(privkey: string, derive: string[], isPrivateKeyRaw: boolean): Promise<string>;
|
|
159
|
+
sr25519OfflineExportFullPrivateKey(keygenResults: string[]): Promise<string>;
|
|
160
|
+
sr25519ImportPrivateKeyRecipient(roomUUID: string, hostUrl: string, threshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
161
|
+
pubkey: string;
|
|
162
|
+
secret_share: string;
|
|
163
|
+
}>;
|
|
164
|
+
sr25519ImportPrivateKeyImporter(roomUUID: string, hostUrl: string, threshold: number, privateKey: string, secretShare: string, keygenIDs: string[], isPrivateKeyRaw: boolean): Promise<{
|
|
165
|
+
pubkey: string;
|
|
166
|
+
secret_share: string;
|
|
167
|
+
}>;
|
|
103
168
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Sr25519=void 0;const _1=require("./index.cjs"),utils_1=require("@noble/hashes/utils"),common_1=require("./common.cjs");class Sr25519{constructor(native,url){this.NATIVE=native,this.URL=url}async initKeygen(){const keygenInitKeypair=await(await this.NATIVE).initKeygen();return new _1.Sr25519InitKeygenResult(keygenInitKeypair.pubkey,keygenInitKeypair.keypair)}async exportID(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare;return(await this.NATIVE).sr25519GetExportID(secretShare)}async createRoom(numParties,apiKey){return(0,common_1.sanitizeNumberOfParties)(numParties),(await this.NATIVE).createRoom(this.URL,numParties,apiKey)}async keygen(roomUuid,numParties,threshold,keygenInit,keygenIds){if((0,common_1.sanitizeNumberOfParties)(numParties,threshold),keygenIds.length!==numParties-1)throw new Error(`keygenIds length must be exactly: ${numParties-1}, it is: `+keygenIds.length);const keygenResult=await(await this.NATIVE).sr25519Keygen(roomUuid,this.URL,numParties,threshold,keygenInit.keygenSecret,keygenIds);if(!keygenResult.pubkey||!keygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(keygenResult.pubkey),secretShareHex=keygenResult.secret_share;return new _1.Sr25519KeygenResult(pubkey,secretShareHex)}async sign(roomUuid,keygenResult,msg,derivationPath=[]){"string"!=typeof msg&&(msg=(0,utils_1.bytesToHex)(msg));const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,signature=await(await this.NATIVE).sr25519Sign(roomUuid,this.URL,secretShare,msg,Array.from(derivationPath));return(0,utils_1.hexToBytes)(signature)}async refresh(roomUuid,keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,refreshedKeygenResult=await(await this.NATIVE).sr25519Refresh(roomUuid,this.URL,secretShare);if(!refreshedKeygenResult.pubkey||!refreshedKeygenResult.secret_share)throw new Error("Keygen failed, no public key or secret share was returned.");const pubkey=(0,utils_1.hexToBytes)(refreshedKeygenResult.pubkey),secretShareHex=refreshedKeygenResult.secret_share;return new _1.Sr25519KeygenResult(pubkey,secretShareHex)}async reshareNewParty(roomUuid,oldThreshold,newThreshold,keygenInit,keygenIds){const resharedKeygenResult=await(await this.NATIVE).sr25519ReshareNewParty(roomUuid,this.URL,oldThreshold,newThreshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.Sr25519KeygenResult(pubkey,secretShareHex)}async reshareRemainingParty(roomUuid,newThreshold,keygenResult,keygenIds){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,resharedKeygenResult=await(await this.NATIVE).sr25519ReshareRemainingParty(roomUuid,this.URL,newThreshold,secretShare,keygenIds),pubkey=(0,utils_1.hexToBytes)(resharedKeygenResult.pubkey),secretShareHex=resharedKeygenResult.secret_share;return new _1.Sr25519KeygenResult(pubkey,secretShareHex)}async derivePubkey(keygenResult,derivationPath=[]){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,derivedPubkey=await(await this.NATIVE).sr25519DerivePubkey(secretShare,Array.from(derivationPath));return(0,utils_1.hexToBytes)(derivedPubkey)}async getPubkey(keygenResult){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,pubKey=await(await this.NATIVE).sr25519GetPubkey(secretShare);return(0,utils_1.hexToBytes)(pubKey)}async derivePubkeyFromPubkey(pubkey,derivation){const derivedPubkey=await(await this.NATIVE).sr25519DerivePubkeyFromPubkey((0,utils_1.bytesToHex)(pubkey),Array.from(derivation));return(0,utils_1.hexToBytes)(derivedPubkey)}async exportFullPrivateKey(roomUuid,keygenResult,toExportID){const secretShare="string"==typeof keygenResult?keygenResult:keygenResult.secretShare,exported=await(await this.NATIVE).sr25519ExportFullPrivateKey(roomUuid,this.URL,secretShare,toExportID);return exported||void 0}async derivePrivateKeyFromPrivateKey(privkey,isPrivateKeyRaw,derivationPath=[]){return(await this.NATIVE).sr25519DerivePrivateKeyFromPrivateKey(privkey,Array.from(derivationPath),isPrivateKeyRaw)}async offlineExportFullPrivateKey(keygenResults){const secretShares=keygenResults.map(k=>{if("string"==typeof k)return k;if(k instanceof _1.Sr25519KeygenResult)return k.secretShare;throw"UnknownType"});return(await this.NATIVE).sr25519OfflineExportFullPrivateKey(secretShares)}async importPrivateKeyRecipient(roomUuid,threshold,keygenInit,keygenIds){const importKeygenResult=await(await this.NATIVE).sr25519ImportPrivateKeyRecipient(roomUuid,this.URL,threshold,keygenInit.keygenSecret,keygenIds),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.Sr25519KeygenResult(pubkey,secretShareHex)}async importPrivateKeyImporter(roomUuid,threshold,privateKey,keygenInit,keygenIds,isPrivateKeyRaw=!1){const importKeygenResult=await(await this.NATIVE).sr25519ImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds,isPrivateKeyRaw),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.Sr25519KeygenResult(pubkey,secretShareHex)}}exports.Sr25519=Sr25519;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Sr25519InitKeygenResult, Sr25519KeygenResult, DynamicNativeSdkInterface } from './';
|
|
2
|
+
export declare class Sr25519 {
|
|
3
|
+
protected readonly NATIVE: Promise<DynamicNativeSdkInterface>;
|
|
4
|
+
protected readonly URL: string;
|
|
5
|
+
protected constructor(native: Promise<DynamicNativeSdkInterface>, url: string);
|
|
6
|
+
initKeygen(): Promise<Sr25519InitKeygenResult>;
|
|
7
|
+
exportID(keygenResult: Sr25519KeygenResult | string): Promise<string>;
|
|
8
|
+
createRoom(numParties: number, apiKey: string): Promise<string>;
|
|
9
|
+
keygen(roomUuid: string, numParties: number, threshold: number, keygenInit: Sr25519InitKeygenResult, keygenIds: string[]): Promise<Sr25519KeygenResult>;
|
|
10
|
+
sign(roomUuid: string, keygenResult: Sr25519KeygenResult | string, msg: Uint8Array | string, derivationPath?: string[]): Promise<Uint8Array>;
|
|
11
|
+
refresh(roomUuid: string, keygenResult: Sr25519KeygenResult | string): Promise<Sr25519KeygenResult>;
|
|
12
|
+
reshareNewParty(roomUuid: string, oldThreshold: number, newThreshold: number, keygenInit: Sr25519InitKeygenResult, keygenIds: string[]): Promise<Sr25519KeygenResult>;
|
|
13
|
+
reshareRemainingParty(roomUuid: string, newThreshold: number, keygenResult: Sr25519KeygenResult | string, keygenIds: string[]): Promise<Sr25519KeygenResult>;
|
|
14
|
+
derivePubkey(keygenResult: Sr25519KeygenResult | string, derivationPath?: string[]): Promise<Uint8Array>;
|
|
15
|
+
getPubkey(keygenResult: Sr25519KeygenResult | string): Promise<Uint8Array>;
|
|
16
|
+
derivePubkeyFromPubkey(pubkey: Uint8Array, derivation: string[]): Promise<Uint8Array>;
|
|
17
|
+
exportFullPrivateKey(roomUuid: string, keygenResult: Sr25519KeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
18
|
+
derivePrivateKeyFromPrivateKey(privkey: string, isPrivateKeyRaw: boolean, derivationPath?: string[]): Promise<string>;
|
|
19
|
+
offlineExportFullPrivateKey(keygenResults: Sr25519KeygenResult[] | string[]): Promise<string>;
|
|
20
|
+
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: Sr25519InitKeygenResult, keygenIds: string[]): Promise<Sr25519KeygenResult>;
|
|
21
|
+
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: Sr25519InitKeygenResult, keygenIds: string[], isPrivateKeyRaw?: boolean): Promise<Sr25519KeygenResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.BIP340InitKeygenResult=exports.BIP340KeygenResult=exports.EcdsaSignature=exports.Sr25519InitKeygenResult=exports.ExportableEd25519InitKeygenResult=exports.ExportableEd25519KeygenResult=exports.Sr25519KeygenResult=exports.Ed25519InitKeygenResult=exports.Ed25519KeygenResult=exports.EcdsaInitKeygenResult=exports.EcdsaKeygenResult=exports.EcdsaPublicKey=exports.MessageHash=void 0;const utils_1=require("@noble/hashes/utils"),sha3_1=require("@noble/hashes/sha3"),sha256_1=require("@noble/hashes/sha256");class MessageHash{constructor(bytes){if(this.bytes=new Uint8Array,"string"==typeof bytes){if(bytes.length!==2*MessageHash.LENGTH)throw new Error("Invalid length for MessageHash: "+bytes.length);this.bytes=(0,utils_1.hexToBytes)(bytes)}else{if(bytes.length!==MessageHash.LENGTH)throw new Error("Invalid length for MessageHash: "+bytes.length);this.bytes=bytes}}static sha256(message){return new MessageHash((0,sha256_1.sha256)(message))}static sha256d(message){return new MessageHash((0,sha256_1.sha256)((0,sha256_1.sha256)(message)))}static keccak256(message){return new MessageHash((0,sha3_1.keccak_256)(message))}toHex(){return(0,utils_1.bytesToHex)(this.bytes)}}exports.MessageHash=MessageHash,MessageHash.LENGTH=32;class EcdsaPublicKey{constructor(pubkey){if("string"==typeof pubkey&&(pubkey=(0,utils_1.hexToBytes)(pubkey)),pubkey.length===EcdsaPublicKey.LENGTH+1)this.pubkey=pubkey.slice(1);else{if(pubkey.length!==EcdsaPublicKey.LENGTH)throw new RangeError(`Invalid ${this.constructor.name} length, expected: ${EcdsaPublicKey.LENGTH} bytes, found: `+pubkey.length);this.pubkey=pubkey}}serializeUncompressed(){return new Uint8Array([4,...this.pubkey])}serializeCompressed(){const isOdd=1&this.pubkey[63];return new Uint8Array([2+isOdd,...this.pubkey.slice(0,32)])}pubKeyAsHex(){return(0,utils_1.bytesToHex)(this.serializeUncompressed())}}exports.EcdsaPublicKey=EcdsaPublicKey,EcdsaPublicKey.LENGTH=64;class EcdsaKeygenResult{constructor(pubkey,secretShare){this.pubkey=pubkey,this.secretShare=secretShare}}exports.EcdsaKeygenResult=EcdsaKeygenResult;class EcdsaInitKeygenResult{constructor(keygenId,keygenSecret){this.keygenId=keygenId,this.keygenSecret=keygenSecret}}exports.EcdsaInitKeygenResult=EcdsaInitKeygenResult;class Ed25519KeygenResult{constructor(pubkey,secretShare){this.pubkey=pubkey,this.secretShare=secretShare}}exports.Ed25519KeygenResult=Ed25519KeygenResult;class Ed25519InitKeygenResult{constructor(keygenId,keygenSecret){this.keygenId=keygenId,this.keygenSecret=keygenSecret}}exports.Ed25519InitKeygenResult=Ed25519InitKeygenResult;class Sr25519KeygenResult{constructor(pubkey,secretShare){this.pubkey=pubkey,this.secretShare=secretShare}}exports.Sr25519KeygenResult=Sr25519KeygenResult;class ExportableEd25519KeygenResult{constructor(pubkey,secretShare){this.pubkey=pubkey,this.secretShare=secretShare}}exports.ExportableEd25519KeygenResult=ExportableEd25519KeygenResult;class ExportableEd25519InitKeygenResult{constructor(keygenId,keygenSecret){this.keygenId=keygenId,this.keygenSecret=keygenSecret}}exports.ExportableEd25519InitKeygenResult=ExportableEd25519InitKeygenResult;class Sr25519InitKeygenResult{constructor(keygenId,keygenSecret){this.keygenId=keygenId,this.keygenSecret=keygenSecret}}exports.Sr25519InitKeygenResult=Sr25519InitKeygenResult;class EcdsaSignature{static fromBuffer(expandedSignature){"string"==typeof expandedSignature&&(expandedSignature=(0,utils_1.hexToBytes)(expandedSignature));const maxSize=2*EcdsaSignature.FIELD_SIZE+EcdsaSignature.MAX_DER_LEN+1,minSize=2*EcdsaSignature.FIELD_SIZE+EcdsaSignature.MIN_DER_LEN+1;if(expandedSignature.length<minSize||expandedSignature.length>maxSize)throw new RangeError(`Invalid ${this.constructor.name} length, expected between ${minSize}..${maxSize} bytes, found: `+expandedSignature.length);const r=expandedSignature.subarray(0,EcdsaSignature.FIELD_SIZE),s=expandedSignature.subarray(EcdsaSignature.FIELD_SIZE,2*EcdsaSignature.FIELD_SIZE),v=expandedSignature[2*EcdsaSignature.FIELD_SIZE],der=expandedSignature.subarray(2*EcdsaSignature.FIELD_SIZE+1);return new EcdsaSignature(r,s,v,der)}constructor(r,s,v,DERencoding){if(s.length!==EcdsaSignature.FIELD_SIZE)throw new RangeError(`Invalid 's' length, expected: ${EcdsaSignature.FIELD_SIZE} found: `+s.length);if(r.length!==EcdsaSignature.FIELD_SIZE)throw new RangeError(`Invalid 'r' length, expected: ${EcdsaSignature.FIELD_SIZE} found: `+r.length);if(!Number.isInteger(v)||v<27||30<v)throw new RangeError("Invalid 'v' value, expected 27/28/29/30 found: "+v);if(DERencoding.length<EcdsaSignature.MIN_DER_LEN||DERencoding.length>EcdsaSignature.MAX_DER_LEN)throw new RangeError(`Invalid DER encoding, expected length: ${EcdsaSignature.MIN_DER_LEN}..${EcdsaSignature.MAX_DER_LEN} found: `+DERencoding.length);this.r=r,this.s=s,this.v=v,this.der=DERencoding}}exports.EcdsaSignature=EcdsaSignature,EcdsaSignature.FIELD_SIZE=32,EcdsaSignature.MAX_DER_LEN=72,EcdsaSignature.MIN_DER_LEN=8;class BIP340KeygenResult{constructor(pubkey,secretShare){this.pubkey=pubkey,this.secretShare=secretShare}}exports.BIP340KeygenResult=BIP340KeygenResult;class BIP340InitKeygenResult{constructor(keygenId,keygenSecret){this.keygenId=keygenId,this.keygenSecret=keygenSecret}}exports.BIP340InitKeygenResult=BIP340InitKeygenResult;
|
package/internal/core/types.d.ts
CHANGED
|
@@ -35,6 +35,26 @@ export declare class Ed25519InitKeygenResult {
|
|
|
35
35
|
keygenSecret: string;
|
|
36
36
|
constructor(keygenId: string, keygenSecret: string);
|
|
37
37
|
}
|
|
38
|
+
export declare class Sr25519KeygenResult {
|
|
39
|
+
pubkey: Uint8Array;
|
|
40
|
+
secretShare: string;
|
|
41
|
+
constructor(pubkey: Uint8Array, secretShare: string);
|
|
42
|
+
}
|
|
43
|
+
export declare class ExportableEd25519KeygenResult {
|
|
44
|
+
pubkey: Uint8Array;
|
|
45
|
+
secretShare: string;
|
|
46
|
+
constructor(pubkey: Uint8Array, secretShare: string);
|
|
47
|
+
}
|
|
48
|
+
export declare class ExportableEd25519InitKeygenResult {
|
|
49
|
+
keygenId: string;
|
|
50
|
+
keygenSecret: string;
|
|
51
|
+
constructor(keygenId: string, keygenSecret: string);
|
|
52
|
+
}
|
|
53
|
+
export declare class Sr25519InitKeygenResult {
|
|
54
|
+
keygenId: string;
|
|
55
|
+
keygenSecret: string;
|
|
56
|
+
constructor(keygenId: string, keygenSecret: string);
|
|
57
|
+
}
|
|
38
58
|
export declare class EcdsaSignature {
|
|
39
59
|
private static readonly FIELD_SIZE;
|
|
40
60
|
private static readonly MAX_DER_LEN;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Sr25519=exports.BIP340=exports.ExportableEd25519=exports.Ed25519=exports.Ecdsa=exports.BIP340InitKeygenResult=exports.BIP340KeygenResult=exports.Sr25519InitKeygenResult=exports.ExportableEd25519InitKeygenResult=exports.ExportableEd25519KeygenResult=exports.Ed25519InitKeygenResult=exports.EcdsaInitKeygenResult=exports.MessageHash=exports.Sr25519KeygenResult=exports.Ed25519KeygenResult=exports.EcdsaSignature=exports.EcdsaPublicKey=exports.EcdsaKeygenResult=void 0;const lib_mpc_internal_1=require("../core/index.cjs"),native_1=(Object.defineProperty(exports,"EcdsaInitKeygenResult",{value:lib_mpc_internal_1.EcdsaInitKeygenResult}),Object.defineProperty(exports,"EcdsaKeygenResult",{value:lib_mpc_internal_1.EcdsaKeygenResult}),Object.defineProperty(exports,"EcdsaPublicKey",{value:lib_mpc_internal_1.EcdsaPublicKey}),Object.defineProperty(exports,"EcdsaSignature",{value:lib_mpc_internal_1.EcdsaSignature}),Object.defineProperty(exports,"Ed25519InitKeygenResult",{value:lib_mpc_internal_1.Ed25519InitKeygenResult}),Object.defineProperty(exports,"Ed25519KeygenResult",{value:lib_mpc_internal_1.Ed25519KeygenResult}),Object.defineProperty(exports,"ExportableEd25519InitKeygenResult",{value:lib_mpc_internal_1.ExportableEd25519InitKeygenResult}),Object.defineProperty(exports,"ExportableEd25519KeygenResult",{value:lib_mpc_internal_1.ExportableEd25519KeygenResult}),Object.defineProperty(exports,"Sr25519InitKeygenResult",{value:lib_mpc_internal_1.Sr25519InitKeygenResult}),Object.defineProperty(exports,"Sr25519KeygenResult",{value:lib_mpc_internal_1.Sr25519KeygenResult}),Object.defineProperty(exports,"BIP340KeygenResult",{value:lib_mpc_internal_1.BIP340KeygenResult}),Object.defineProperty(exports,"BIP340InitKeygenResult",{value:lib_mpc_internal_1.BIP340InitKeygenResult}),Object.defineProperty(exports,"MessageHash",{value:lib_mpc_internal_1.MessageHash}),require("./native.cjs")),DEFAULT_RELAY_URL="relay.dynamicauth.com";class Ecdsa extends lib_mpc_internal_1.Ecdsa{constructor(hostUrl){super(Promise.resolve(native_1.NodeNativeSdk),hostUrl||DEFAULT_RELAY_URL)}}exports.Ecdsa=Ecdsa;class Ed25519 extends lib_mpc_internal_1.Ed25519{constructor(hostUrl){super(Promise.resolve(native_1.NodeNativeSdk),hostUrl||DEFAULT_RELAY_URL)}}exports.Ed25519=Ed25519;class ExportableEd25519 extends lib_mpc_internal_1.ExportableEd25519{constructor(hostUrl){super(Promise.resolve(native_1.NodeNativeSdk),hostUrl||DEFAULT_RELAY_URL)}}exports.ExportableEd25519=ExportableEd25519;class BIP340 extends lib_mpc_internal_1.BIP340{constructor(hostUrl){super(Promise.resolve(native_1.NodeNativeSdk),hostUrl||DEFAULT_RELAY_URL)}}exports.BIP340=BIP340;class Sr25519 extends lib_mpc_internal_1.Sr25519{constructor(hostUrl){super(Promise.resolve(native_1.NodeNativeSdk),hostUrl||DEFAULT_RELAY_URL)}}exports.Sr25519=Sr25519;
|
package/internal/node/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { EcdsaInitKeygenResult, Ecdsa as EcdsaInternal, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519 as Ed25519Internal, Ed25519KeygenResult, BIP340KeygenResult, BIP340InitKeygenResult, BIP340 as BIP340Internal, MessageHash } from '../core';
|
|
2
|
-
export { EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519KeygenResult, MessageHash, EcdsaInitKeygenResult, Ed25519InitKeygenResult, BIP340KeygenResult, BIP340InitKeygenResult, };
|
|
1
|
+
import { EcdsaInitKeygenResult, Ecdsa as EcdsaInternal, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519 as Ed25519Internal, Ed25519KeygenResult, ExportableEd25519InitKeygenResult, ExportableEd25519 as ExportableEd25519Internal, ExportableEd25519KeygenResult, Sr25519InitKeygenResult, Sr25519 as Sr25519Internal, Sr25519KeygenResult, BIP340KeygenResult, BIP340InitKeygenResult, BIP340 as BIP340Internal, MessageHash } from '../core/index.d.ts';
|
|
2
|
+
export { EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519KeygenResult, Sr25519KeygenResult, MessageHash, EcdsaInitKeygenResult, Ed25519InitKeygenResult, ExportableEd25519KeygenResult, ExportableEd25519InitKeygenResult, Sr25519InitKeygenResult, BIP340KeygenResult, BIP340InitKeygenResult, };
|
|
3
3
|
export declare class Ecdsa extends EcdsaInternal {
|
|
4
4
|
constructor(hostUrl?: string);
|
|
5
5
|
}
|
|
6
6
|
export declare class Ed25519 extends Ed25519Internal {
|
|
7
7
|
constructor(hostUrl?: string);
|
|
8
8
|
}
|
|
9
|
+
export declare class ExportableEd25519 extends ExportableEd25519Internal {
|
|
10
|
+
constructor(hostUrl?: string);
|
|
11
|
+
}
|
|
9
12
|
export declare class BIP340 extends BIP340Internal {
|
|
10
13
|
constructor(hostUrl?: string);
|
|
11
14
|
}
|
|
15
|
+
export declare class Sr25519 extends Sr25519Internal {
|
|
16
|
+
constructor(hostUrl?: string);
|
|
17
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.NodeNativeSdk=void 0;const target=currentTarget();function currentTarget(){switch(process.platform){case"darwin":switch(process.arch){case"x64":return"macos_x86_64";case"arm64":return"macos_arm64";default:throw new Error("Neon: unsupported macOS\\darwin architecture: "+process.arch)}case"linux":switch(process.arch){case"x64":return"linux_x86_64";case"arm64":return"linux_arm64";default:throw new Error("Neon: unsupported linux architecture: "+process.arch)}default:throw new Error(`Neon: unsupported system: ${process.platform}, only {darwin/linux} are supported}`)}}exports.NodeNativeSdk=require(`./native/libmpc_executor_${target}_nodejs.node`);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DynamicNativeSdkInterface } from '../core';
|
|
1
|
+
import { DynamicNativeSdkInterface } from '../core/index.d.ts';
|
|
2
2
|
export declare const NodeNativeSdk: DynamicNativeSdkInterface;
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-paolo-1",
|
|
4
4
|
"license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
7
|
-
"@dynamic-labs/
|
|
7
|
+
"@dynamic-labs-wallet/core": "0.0.1-paolo-1",
|
|
8
|
+
"@dynamic-labs-wallet/forward-mpc-client": "0.1.3",
|
|
9
|
+
"@dynamic-labs/logger": "^4.25.3",
|
|
10
|
+
"@dynamic-labs/sdk-api-core": "^0.0.801",
|
|
11
|
+
"uuid": "11.1.0",
|
|
12
|
+
"@noble/hashes": "1.7.1"
|
|
8
13
|
},
|
|
9
14
|
"files": [
|
|
10
15
|
"*",
|
|
11
16
|
"node_modules/**/*"
|
|
12
17
|
],
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"access": "restricted"
|
|
15
|
-
},
|
|
16
18
|
"nx": {
|
|
17
19
|
"sourceRoot": "packages/node/src",
|
|
18
20
|
"projectType": "library",
|
|
@@ -21,7 +23,6 @@
|
|
|
21
23
|
"build": {}
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
|
-
"type": "module",
|
|
25
26
|
"main": "./index.cjs.js",
|
|
26
27
|
"module": "./index.esm.js",
|
|
27
28
|
"types": "./index.esm.d.ts",
|
|
@@ -31,7 +32,11 @@
|
|
|
31
32
|
"types": "./index.esm.d.ts",
|
|
32
33
|
"import": "./index.esm.js",
|
|
33
34
|
"require": "./index.cjs.js",
|
|
34
|
-
"default": "./index.
|
|
35
|
+
"default": "./index.esm.js"
|
|
35
36
|
}
|
|
37
|
+
},
|
|
38
|
+
"imports": {
|
|
39
|
+
"#internal/node": "./internal/node/index.cjs",
|
|
40
|
+
"#internal/core": "./internal/core/index.cjs"
|
|
36
41
|
}
|
|
37
42
|
}
|
|
@@ -1,22 +1,62 @@
|
|
|
1
|
+
import type { EncryptionMetadata } from '@dynamic-labs-wallet/core';
|
|
2
|
+
export declare const ENCRYPTION_VERSION_LEGACY = "v1";
|
|
3
|
+
export declare const ENCRYPTION_VERSION_CURRENT = "v2";
|
|
1
4
|
export declare const PBKDF2_ALGORITHM = "PBKDF2";
|
|
2
|
-
export declare const PBKDF2_ITERATIONS = 100000;
|
|
3
5
|
export declare const PBKDF2_HASH_ALGORITHM = "SHA-256";
|
|
4
6
|
export declare const AES_GCM_ALGORITHM = "AES-GCM";
|
|
5
7
|
export declare const AES_GCM_LENGTH = 256;
|
|
6
|
-
export declare const
|
|
8
|
+
export declare const ENCRYPTION_VERSIONS: {
|
|
9
|
+
readonly v1: {
|
|
10
|
+
readonly version: "v1";
|
|
11
|
+
readonly algorithm: "AES-GCM";
|
|
12
|
+
readonly keyDerivation: "PBKDF2";
|
|
13
|
+
readonly iterations: 100000;
|
|
14
|
+
readonly hashAlgorithm: "SHA-256";
|
|
15
|
+
readonly algorithmLength: 256;
|
|
16
|
+
};
|
|
17
|
+
readonly v2: {
|
|
18
|
+
readonly version: "v2";
|
|
19
|
+
readonly algorithm: "AES-GCM";
|
|
20
|
+
readonly keyDerivation: "PBKDF2";
|
|
21
|
+
readonly iterations: 1000000;
|
|
22
|
+
readonly hashAlgorithm: "SHA-256";
|
|
23
|
+
readonly algorithmLength: 256;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare const PBKDF2_ITERATIONS: 1000000;
|
|
27
|
+
export declare const PBKDF2_ITERATIONS_LEGACY: 100000;
|
|
28
|
+
export type EncryptionVersion = (typeof ENCRYPTION_VERSIONS)[keyof typeof ENCRYPTION_VERSIONS];
|
|
29
|
+
/**
|
|
30
|
+
* Encrypts data using the specified encryption version.
|
|
31
|
+
* Always uses the latest encryption configuration for new encryptions by default.
|
|
32
|
+
*/
|
|
33
|
+
export declare const encryptData: ({ data, password, version, }: {
|
|
7
34
|
data: string;
|
|
8
35
|
password: string;
|
|
36
|
+
version?: string;
|
|
9
37
|
}) => Promise<{
|
|
10
38
|
salt: string;
|
|
11
39
|
iv: string;
|
|
12
40
|
cipher: string;
|
|
41
|
+
version: string;
|
|
13
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Decrypts data with version-based configuration.
|
|
45
|
+
* Uses the version field from the data to determine encryption parameters.
|
|
46
|
+
* Falls back to legacy version for backward compatibility if no version is specified.
|
|
47
|
+
*/
|
|
14
48
|
export declare const decryptData: ({ data, password, }: {
|
|
15
49
|
data: {
|
|
16
50
|
salt: string;
|
|
17
51
|
iv: string;
|
|
18
52
|
cipher: string;
|
|
53
|
+
version?: string;
|
|
19
54
|
};
|
|
20
55
|
password: string;
|
|
21
56
|
}) => Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets encryption metadata for a specific version.
|
|
59
|
+
* Used when we need to include metadata in legacy systems or APIs that require it.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getEncryptionMetadataForVersion: (version: string) => EncryptionMetadata;
|
|
22
62
|
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/backup/encryption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/backup/encryption.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAiBtB,CAAC;AAEX,eAAO,MAAM,iBAAiB,SAC8B,CAAC;AAC7D,eAAO,MAAM,wBAAwB,QACsB,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAsCjE;;;GAGG;AACH,eAAO,MAAM,WAAW,iCAIrB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;;;;;EAkCA,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,wBAGrB;IACD,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB,oBA2CA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,YACjC,MAAM,KACd,kBAcF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ServerKeyShare } from '../mpc/types.js';
|
|
2
|
+
import type { WalletProperties } from '../types.js';
|
|
3
|
+
export declare const checkIfExternalServerKeySharesAreRequired: (wallet: WalletProperties, externalServerKeyShares?: ServerKeyShare[]) => void;
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/backup/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,yCAAyC,WAC5C,gBAAgB,4BACE,cAAc,EAAE,SAkB3C,CAAC"}
|