@dynamic-labs-wallet/btc-utils 0.0.0-pr658.0
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.d.ts +1 -0
- package/index.cjs.js +1309 -0
- package/index.esm.d.ts +1 -0
- package/index.esm.js +1271 -0
- package/internal/core/bip340.cjs +1 -0
- package/internal/core/bip340.d.ts +22 -0
- package/internal/core/common.cjs +1 -0
- package/internal/core/common.d.ts +2 -0
- package/internal/core/ecdsa.cjs +1 -0
- package/internal/core/ecdsa.d.ts +23 -0
- package/internal/core/ed25519.cjs +1 -0
- package/internal/core/ed25519.d.ts +22 -0
- package/internal/core/ed25519_exportable.cjs +1 -0
- package/internal/core/ed25519_exportable.d.ts +20 -0
- package/internal/core/index.cjs +1 -0
- package/internal/core/index.d.ts +8 -0
- package/internal/core/native.cjs +1 -0
- package/internal/core/native.d.ts +168 -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 +78 -0
- package/package.json +40 -0
- package/src/calculateBip322Hash/calculateBip322Hash.d.ts +16 -0
- package/src/calculateBip322Hash/calculateBip322Hash.d.ts.map +1 -0
- package/src/calculateBip322Hash/index.d.ts +2 -0
- package/src/calculateBip322Hash/index.d.ts.map +1 -0
- package/src/calculateTaprootTweak/calculateTaprootTweak.d.ts +7 -0
- package/src/calculateTaprootTweak/calculateTaprootTweak.d.ts.map +1 -0
- package/src/calculateTaprootTweak/index.d.ts +2 -0
- package/src/calculateTaprootTweak/index.d.ts.map +1 -0
- package/src/collectPSBTInputData/collectPSBTInputData.d.ts +13 -0
- package/src/collectPSBTInputData/collectPSBTInputData.d.ts.map +1 -0
- package/src/collectPSBTInputData/index.d.ts +2 -0
- package/src/collectPSBTInputData/index.d.ts.map +1 -0
- package/src/convertPublicKeyToBuffer/convertPublicKeyToBuffer.d.ts +15 -0
- package/src/convertPublicKeyToBuffer/convertPublicKeyToBuffer.d.ts.map +1 -0
- package/src/convertPublicKeyToBuffer/index.d.ts +2 -0
- package/src/convertPublicKeyToBuffer/index.d.ts.map +1 -0
- package/src/convertSignatureToDER/convertSignatureToDER.d.ts +9 -0
- package/src/convertSignatureToDER/convertSignatureToDER.d.ts.map +1 -0
- package/src/convertSignatureToDER/index.d.ts +2 -0
- package/src/convertSignatureToDER/index.d.ts.map +1 -0
- package/src/convertSignatureToTaprootBuffer/convertSignatureToTaprootBuffer.d.ts +9 -0
- package/src/convertSignatureToTaprootBuffer/convertSignatureToTaprootBuffer.d.ts.map +1 -0
- package/src/convertSignatureToTaprootBuffer/index.d.ts +2 -0
- package/src/convertSignatureToTaprootBuffer/index.d.ts.map +1 -0
- package/src/createLegacyAddress/createLegacyAddress.d.ts +10 -0
- package/src/createLegacyAddress/createLegacyAddress.d.ts.map +1 -0
- package/src/createLegacyAddress/index.d.ts +2 -0
- package/src/createLegacyAddress/index.d.ts.map +1 -0
- package/src/createNativeSegWitAddress/createNativeSegWitAddress.d.ts +11 -0
- package/src/createNativeSegWitAddress/createNativeSegWitAddress.d.ts.map +1 -0
- package/src/createNativeSegWitAddress/index.d.ts +2 -0
- package/src/createNativeSegWitAddress/index.d.ts.map +1 -0
- package/src/createSegWitAddress/createSegWitAddress.d.ts +10 -0
- package/src/createSegWitAddress/createSegWitAddress.d.ts.map +1 -0
- package/src/createSegWitAddress/index.d.ts +2 -0
- package/src/createSegWitAddress/index.d.ts.map +1 -0
- package/src/createTaprootAddress/createTaprootAddress.d.ts +11 -0
- package/src/createTaprootAddress/createTaprootAddress.d.ts.map +1 -0
- package/src/createTaprootAddress/index.d.ts +2 -0
- package/src/createTaprootAddress/index.d.ts.map +1 -0
- package/src/doesInputBelongToAddress/doesInputBelongToAddress.d.ts +11 -0
- package/src/doesInputBelongToAddress/doesInputBelongToAddress.d.ts.map +1 -0
- package/src/doesInputBelongToAddress/index.d.ts +2 -0
- package/src/doesInputBelongToAddress/index.d.ts.map +1 -0
- package/src/encodeBip322Signature/encodeBip322Signature.d.ts +13 -0
- package/src/encodeBip322Signature/encodeBip322Signature.d.ts.map +1 -0
- package/src/encodeBip322Signature/index.d.ts +2 -0
- package/src/encodeBip322Signature/index.d.ts.map +1 -0
- package/src/getAddressTypeFromDerivationPath/getAddressTypeFromDerivationPath.d.ts +9 -0
- package/src/getAddressTypeFromDerivationPath/getAddressTypeFromDerivationPath.d.ts.map +1 -0
- package/src/getAddressTypeFromDerivationPath/index.d.ts +2 -0
- package/src/getAddressTypeFromDerivationPath/index.d.ts.map +1 -0
- package/src/getBitcoinNetwork/getBitcoinNetwork.d.ts +10 -0
- package/src/getBitcoinNetwork/getBitcoinNetwork.d.ts.map +1 -0
- package/src/getBitcoinNetwork/index.d.ts +2 -0
- package/src/getBitcoinNetwork/index.d.ts.map +1 -0
- package/src/getDefaultRpcUrl/getDefaultRpcUrl.d.ts +9 -0
- package/src/getDefaultRpcUrl/getDefaultRpcUrl.d.ts.map +1 -0
- package/src/getDefaultRpcUrl/index.d.ts +2 -0
- package/src/getDefaultRpcUrl/index.d.ts.map +1 -0
- package/src/getFeeRates/getFeeRates.d.ts +18 -0
- package/src/getFeeRates/getFeeRates.d.ts.map +1 -0
- package/src/getFeeRates/index.d.ts +2 -0
- package/src/getFeeRates/index.d.ts.map +1 -0
- package/src/getPublicKeyFromPrivateKey/getPublicKeyFromPrivateKey.d.ts +13 -0
- package/src/getPublicKeyFromPrivateKey/getPublicKeyFromPrivateKey.d.ts.map +1 -0
- package/src/getPublicKeyFromPrivateKey/index.d.ts +2 -0
- package/src/getPublicKeyFromPrivateKey/index.d.ts.map +1 -0
- package/src/getUTXOs/getUTXOs.d.ts +16 -0
- package/src/getUTXOs/getUTXOs.d.ts.map +1 -0
- package/src/getUTXOs/index.d.ts +2 -0
- package/src/getUTXOs/index.d.ts.map +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.d.ts.map +1 -0
- package/src/initEccLib/index.d.ts +2 -0
- package/src/initEccLib/index.d.ts.map +1 -0
- package/src/initEccLib/initEccLib.d.ts +7 -0
- package/src/initEccLib/initEccLib.d.ts.map +1 -0
- package/src/normalizeForCompressed/index.d.ts +2 -0
- package/src/normalizeForCompressed/index.d.ts.map +1 -0
- package/src/normalizeForCompressed/normalizeForCompressed.d.ts +9 -0
- package/src/normalizeForCompressed/normalizeForCompressed.d.ts.map +1 -0
- package/src/normalizeForTaproot/index.d.ts +2 -0
- package/src/normalizeForTaproot/index.d.ts.map +1 -0
- package/src/normalizeForTaproot/normalizeForTaproot.d.ts +9 -0
- package/src/normalizeForTaproot/normalizeForTaproot.d.ts.map +1 -0
- package/src/normalizePublicKey/index.d.ts +2 -0
- package/src/normalizePublicKey/index.d.ts.map +1 -0
- package/src/normalizePublicKey/normalizePublicKey.d.ts +19 -0
- package/src/normalizePublicKey/normalizePublicKey.d.ts.map +1 -0
- package/src/privateKeyToWIF/index.d.ts +2 -0
- package/src/privateKeyToWIF/index.d.ts.map +1 -0
- package/src/privateKeyToWIF/privateKeyToWIF.d.ts +24 -0
- package/src/privateKeyToWIF/privateKeyToWIF.d.ts.map +1 -0
- package/src/publicKeyToBitcoinAddress/index.d.ts +2 -0
- package/src/publicKeyToBitcoinAddress/index.d.ts.map +1 -0
- package/src/publicKeyToBitcoinAddress/publicKeyToBitcoinAddress.d.ts +12 -0
- package/src/publicKeyToBitcoinAddress/publicKeyToBitcoinAddress.d.ts.map +1 -0
- package/src/selectUTXOs/index.d.ts +2 -0
- package/src/selectUTXOs/index.d.ts.map +1 -0
- package/src/selectUTXOs/selectUTXOs.d.ts +19 -0
- package/src/selectUTXOs/selectUTXOs.d.ts.map +1 -0
- package/src/toBuffer/index.d.ts +2 -0
- package/src/toBuffer/index.d.ts.map +1 -0
- package/src/toBuffer/toBuffer.d.ts +8 -0
- package/src/toBuffer/toBuffer.d.ts.map +1 -0
- package/src/types.d.ts +35 -0
- package/src/types.d.ts.map +1 -0
- package/src/wifToPrivateKey/index.d.ts +2 -0
- package/src/wifToPrivateKey/index.d.ts.map +1 -0
- package/src/wifToPrivateKey/wifToPrivateKey.d.ts +19 -0
- package/src/wifToPrivateKey/wifToPrivateKey.d.ts.map +1 -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");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=(0,common_1.getHex32Bytes)(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),(0,common_1.getHex32Bytes)(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),(0,common_1.getHex32Bytes)(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,chaincode=new Uint8Array){const importKeygenResult=await(await this.NATIVE).bip340ImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds,(0,common_1.getHex32Bytes)(chaincode)),pubkey=(0,utils_1.hexToBytes)(importKeygenResult.pubkey),secretShareHex=importKeygenResult.secret_share;return new _1.BIP340KeygenResult(pubkey,secretShareHex)}}exports.BIP340=BIP340;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BIP340InitKeygenResult, BIP340KeygenResult, DynamicNativeSdkInterface } from '.';
|
|
2
|
+
export declare class BIP340 {
|
|
3
|
+
protected readonly NATIVE: Promise<DynamicNativeSdkInterface>;
|
|
4
|
+
protected readonly URL: string;
|
|
5
|
+
protected constructor(native: Promise<DynamicNativeSdkInterface>, url: string);
|
|
6
|
+
initKeygen(): Promise<BIP340InitKeygenResult>;
|
|
7
|
+
exportID(keygenResult: BIP340KeygenResult | string): Promise<string>;
|
|
8
|
+
createRoom(numParties: number, apiKey: string): Promise<string>;
|
|
9
|
+
keygen(roomUuid: string, numParties: number, threshold: number, keygenInit: BIP340InitKeygenResult, keygenIds: string[]): Promise<BIP340KeygenResult>;
|
|
10
|
+
sign(roomUuid: string, keygenResult: BIP340KeygenResult | string, msg: Uint8Array | string, derivationPath?: Uint32Array, tweak?: Uint8Array | string): Promise<Uint8Array>;
|
|
11
|
+
refresh(roomUuid: string, keygenResult: BIP340KeygenResult | string): Promise<BIP340KeygenResult>;
|
|
12
|
+
reshareNewParty(roomUuid: string, oldThreshold: number, newThreshold: number, keygenInit: BIP340InitKeygenResult, keygenIds: string[]): Promise<BIP340KeygenResult>;
|
|
13
|
+
reshareRemainingParty(roomUuid: string, newThreshold: number, keygenResult: BIP340KeygenResult | string, keygenIds: string[]): Promise<BIP340KeygenResult>;
|
|
14
|
+
deriveTweakPubkey(keygenResult: BIP340KeygenResult | string, derivationPath?: Uint32Array, tweak?: Uint8Array | string): Promise<Uint8Array>;
|
|
15
|
+
getXpub(keygenResult: BIP340KeygenResult | string): Promise<string>;
|
|
16
|
+
deriveTweakPubkeyFromXpub(Xpub: string, derivationPath?: Uint32Array, tweak?: Uint8Array | string): Promise<Uint8Array>;
|
|
17
|
+
exportFullPrivateKey(roomUuid: string, keygenResult: BIP340KeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
18
|
+
derivePrivateKeyFromXpriv(xpriv: string, derivationPath?: Uint32Array): Promise<string>;
|
|
19
|
+
offlineExportFullPrivateKey(keygenResults: BIP340KeygenResult[] | string[]): Promise<string>;
|
|
20
|
+
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: BIP340InitKeygenResult, keygenIds: string[]): Promise<BIP340KeygenResult>;
|
|
21
|
+
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: BIP340InitKeygenResult, keygenIds: string[], chaincode?: Uint8Array | string): Promise<BIP340KeygenResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.sanitizeNumberOfParties=sanitizeNumberOfParties,exports.getHex32Bytes=getHex32Bytes;const utils_1=require("@noble/hashes/utils");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} `)}function getHex32Bytes(strOrArr){if("string"!=typeof strOrArr&&(strOrArr=(0,utils_1.bytesToHex)(strOrArr)),0!==strOrArr.length&&64!==strOrArr.length)throw new Error("Tweak must be 32 bytes long");return strOrArr}
|
|
@@ -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,chaincode=new Uint8Array){const importKeygenResult=await(await this.NATIVE).ecdsaImportPrivateKeyImporter(roomUuid,this.URL,threshold,privateKey,keygenInit.keygenSecret,keygenIds,(0,common_1.getHex32Bytes)(chaincode)),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;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, MessageHash, DynamicNativeSdkInterface } from './';
|
|
2
|
+
export declare class Ecdsa {
|
|
3
|
+
protected readonly NATIVE: Promise<DynamicNativeSdkInterface>;
|
|
4
|
+
protected readonly URL: string;
|
|
5
|
+
protected constructor(native: Promise<DynamicNativeSdkInterface>, hostUrl: string);
|
|
6
|
+
createRoom(numParties: number, apiKey: string): Promise<string>;
|
|
7
|
+
initKeygen(): Promise<EcdsaInitKeygenResult>;
|
|
8
|
+
exportID(keygenResult: EcdsaKeygenResult | string): Promise<string>;
|
|
9
|
+
keygen(roomUuid: string, numParties: number, threshold: number, keygenInit: EcdsaInitKeygenResult, keygenIds: string[]): Promise<EcdsaKeygenResult>;
|
|
10
|
+
sign(roomUuid: string, keygenResult: EcdsaKeygenResult | string, msgHash: MessageHash, derivationPath?: Uint32Array): Promise<EcdsaSignature>;
|
|
11
|
+
refresh(roomUuid: string, keygenResult: EcdsaKeygenResult | string): Promise<EcdsaKeygenResult>;
|
|
12
|
+
reshareNewParty(roomUuid: string, oldThreshold: number, newThreshold: number, keygenInit: EcdsaInitKeygenResult, keygenIds: string[]): Promise<EcdsaKeygenResult>;
|
|
13
|
+
reshareRemainingParty(roomUuid: string, newThreshold: number, keygenResult: EcdsaKeygenResult | string, keygenIds: string[]): Promise<EcdsaKeygenResult>;
|
|
14
|
+
derivePubkey(keygenResult: EcdsaKeygenResult | string, derivationPath?: Uint32Array): Promise<EcdsaPublicKey>;
|
|
15
|
+
getXpub(keygenResult: EcdsaKeygenResult | string): Promise<string>;
|
|
16
|
+
derivePubkeyFromXpub(Xpub: string, derivationPath?: Uint32Array): Promise<EcdsaPublicKey>;
|
|
17
|
+
exportFullPrivateKey(roomUuid: string, keygenResult: EcdsaKeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
18
|
+
derivePrivateKeyFromXpriv(xpriv: string, derivationPath?: Uint32Array): Promise<string>;
|
|
19
|
+
offlineExportFullPrivateKey(keygenResults: EcdsaKeygenResult[] | string[]): Promise<string>;
|
|
20
|
+
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: EcdsaInitKeygenResult, keygenIds: string[]): Promise<EcdsaKeygenResult>;
|
|
21
|
+
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: EcdsaInitKeygenResult, keygenIds: string[], chaincode?: Uint8Array | string): Promise<EcdsaKeygenResult>;
|
|
22
|
+
protected getHostUrl(path?: string): string;
|
|
23
|
+
}
|
|
@@ -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,22 @@
|
|
|
1
|
+
import { Ed25519InitKeygenResult, Ed25519KeygenResult, DynamicNativeSdkInterface } from './';
|
|
2
|
+
export declare class Ed25519 {
|
|
3
|
+
protected readonly NATIVE: Promise<DynamicNativeSdkInterface>;
|
|
4
|
+
protected readonly URL: string;
|
|
5
|
+
protected constructor(native: Promise<DynamicNativeSdkInterface>, url: string);
|
|
6
|
+
initKeygen(): Promise<Ed25519InitKeygenResult>;
|
|
7
|
+
exportID(keygenResult: Ed25519KeygenResult | string): Promise<string>;
|
|
8
|
+
createRoom(numParties: number, apiKey: string): Promise<string>;
|
|
9
|
+
keygen(roomUuid: string, numParties: number, threshold: number, keygenInit: Ed25519InitKeygenResult, keygenIds: string[]): Promise<Ed25519KeygenResult>;
|
|
10
|
+
sign(roomUuid: string, keygenResult: Ed25519KeygenResult | string, msg: Uint8Array | string, derivationPath?: Uint32Array): Promise<Uint8Array>;
|
|
11
|
+
refresh(roomUuid: string, keygenResult: Ed25519KeygenResult | string): Promise<Ed25519KeygenResult>;
|
|
12
|
+
reshareNewParty(roomUuid: string, oldThreshold: number, newThreshold: number, keygenInit: Ed25519InitKeygenResult, keygenIds: string[]): Promise<Ed25519KeygenResult>;
|
|
13
|
+
reshareRemainingParty(roomUuid: string, newThreshold: number, keygenResult: Ed25519KeygenResult | string, keygenIds: string[]): Promise<Ed25519KeygenResult>;
|
|
14
|
+
derivePubkey(keygenResult: Ed25519KeygenResult | string, derivationPath?: Uint32Array): Promise<Uint8Array>;
|
|
15
|
+
getSpub(keygenResult: Ed25519KeygenResult | string): Promise<string>;
|
|
16
|
+
derivePubkeyFromSpub(spub: string, derivation: Uint32Array): Promise<Uint8Array>;
|
|
17
|
+
exportFullPrivateKey(roomUuid: string, keygenResult: Ed25519KeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
18
|
+
derivePrivateKeyFromSpriv(spriv: string, derivationPath?: Uint32Array): Promise<string>;
|
|
19
|
+
offlineExportFullPrivateKey(keygenResults: Ed25519KeygenResult[] | string[]): Promise<string>;
|
|
20
|
+
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: Ed25519InitKeygenResult, keygenIds: string[]): Promise<Ed25519KeygenResult>;
|
|
21
|
+
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: Ed25519InitKeygenResult, keygenIds: string[], isPrivateKeyRaw?: boolean): Promise<Ed25519KeygenResult>;
|
|
22
|
+
}
|
|
@@ -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 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,20 @@
|
|
|
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
|
+
exportFullPrivateKey(roomUuid: string, keygenResult: ExportableEd25519KeygenResult | string, toExportID: string): Promise<string | undefined>;
|
|
16
|
+
offlineExportFullPrivateKey(keygenResults: ExportableEd25519KeygenResult[] | string[]): Promise<string>;
|
|
17
|
+
importPrivateKeyRecipient(roomUuid: string, threshold: number, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
18
|
+
importPrivateKeyImporter(roomUuid: string, threshold: number, privateKey: string, keygenInit: ExportableEd25519InitKeygenResult, keygenIds: string[]): Promise<ExportableEd25519KeygenResult>;
|
|
19
|
+
getPubkey(keygenResult: ExportableEd25519KeygenResult | string): Promise<string>;
|
|
20
|
+
}
|
|
@@ -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});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519KeygenResult, ExportableEd25519InitKeygenResult, ExportableEd25519KeygenResult, Sr25519InitKeygenResult, Sr25519KeygenResult, BIP340InitKeygenResult, BIP340KeygenResult, MessageHash } from './types';
|
|
2
|
+
import { Ecdsa } from './ecdsa';
|
|
3
|
+
import { Ed25519 } from './ed25519';
|
|
4
|
+
import { ExportableEd25519 } from './ed25519_exportable';
|
|
5
|
+
import { Sr25519 } from './sr25519';
|
|
6
|
+
import { BIP340 } from './bip340';
|
|
7
|
+
import { DynamicNativeSdkInterface } from './native';
|
|
8
|
+
export { DynamicNativeSdkInterface, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519InitKeygenResult, Ed25519KeygenResult, ExportableEd25519InitKeygenResult, ExportableEd25519KeygenResult, Sr25519InitKeygenResult, Sr25519KeygenResult, BIP340InitKeygenResult, BIP340KeygenResult, MessageHash, Ecdsa, Ed25519, ExportableEd25519, Sr25519, BIP340, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
export interface DynamicNativeSdkInterface {
|
|
2
|
+
initKeygen(): Promise<{
|
|
3
|
+
pubkey: string;
|
|
4
|
+
keypair: string;
|
|
5
|
+
}>;
|
|
6
|
+
createRoom(hostUrl: string, numParties: number, apiKey: string): Promise<string>;
|
|
7
|
+
ecdsaGetExportID(secretShare: string): Promise<string>;
|
|
8
|
+
ecdsaKeygen(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
9
|
+
pubkey: string;
|
|
10
|
+
secret_share: string;
|
|
11
|
+
}>;
|
|
12
|
+
ecdsaSign(roomUUID: string, hostUrl: string, secretShare: string, msgHex: string, derivationPath: number[]): Promise<string>;
|
|
13
|
+
ecdsaRefresh(roomUUID: string, hostUrl: string, secretShare: string): Promise<{
|
|
14
|
+
pubkey: string;
|
|
15
|
+
secret_share: string;
|
|
16
|
+
}>;
|
|
17
|
+
ecdsaReshareNewParty(roomUUID: string, hostUrl: string, oldThreshold: number, newThreshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
18
|
+
pubkey: string;
|
|
19
|
+
secret_share: string;
|
|
20
|
+
}>;
|
|
21
|
+
ecdsaReshareRemainingParty(roomUUID: string, hostUrl: string, newThreshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
22
|
+
pubkey: string;
|
|
23
|
+
secret_share: string;
|
|
24
|
+
}>;
|
|
25
|
+
ecdsaDerivePubkey(secretShare: string, derive: number[]): Promise<string>;
|
|
26
|
+
ecdsaGetXpub(secretShare: string): Promise<string>;
|
|
27
|
+
ecdsaDerivePubkeyFromXpub(xpub: string, derivation: number[]): Promise<string>;
|
|
28
|
+
ecdsaExportFullPrivateKey(roomUUID: string, hostUrl: string, secretShare: string, toExportID: string): Promise<undefined | string>;
|
|
29
|
+
ecdsaDerivePrivateKeyFromXpriv(xpriv: string, derive: number[]): Promise<string>;
|
|
30
|
+
ecdsaOfflineExportFullPrivateKey(keygenResults: string[]): Promise<string>;
|
|
31
|
+
ecdsaImportPrivateKeyRecipient(roomUUID: string, hostUrl: string, threshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
32
|
+
pubkey: string;
|
|
33
|
+
secret_share: string;
|
|
34
|
+
}>;
|
|
35
|
+
ecdsaImportPrivateKeyImporter(roomUUID: string, hostUrl: string, threshold: number, privateKey: string, secretShare: string, keygenIDs: string[], chaincode: Uint8Array | string): Promise<{
|
|
36
|
+
pubkey: string;
|
|
37
|
+
secret_share: string;
|
|
38
|
+
}>;
|
|
39
|
+
ed25519GetExportID(secretShare: string): Promise<string>;
|
|
40
|
+
ed25519Keygen(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
41
|
+
pubkey: string;
|
|
42
|
+
secret_share: string;
|
|
43
|
+
}>;
|
|
44
|
+
ed25519Sign(roomUUID: string, hostUrl: string, secretShare: string, msgHex: string, derivationPath: number[]): Promise<string>;
|
|
45
|
+
ed25519Refresh(roomUUID: string, hostUrl: string, secretShare: string): Promise<{
|
|
46
|
+
pubkey: string;
|
|
47
|
+
secret_share: string;
|
|
48
|
+
}>;
|
|
49
|
+
ed25519ReshareNewParty(roomUUID: string, hostUrl: string, oldThreshold: number, newThreshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
50
|
+
pubkey: string;
|
|
51
|
+
secret_share: string;
|
|
52
|
+
}>;
|
|
53
|
+
ed25519ReshareRemainingParty(roomUUID: string, hostUrl: string, newThreshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
54
|
+
pubkey: string;
|
|
55
|
+
secret_share: string;
|
|
56
|
+
}>;
|
|
57
|
+
ed25519DerivePubkey(secretShare: string, derive: number[]): Promise<string>;
|
|
58
|
+
ed25519GetSpub(secretShare: string): Promise<string>;
|
|
59
|
+
ed25519DerivePubkeyFromSpub(spub: string, derivation: number[]): Promise<string>;
|
|
60
|
+
ed25519ExportFullPrivateKey(roomUUID: string, hostUrl: string, secretShare: string, toExportID: string): Promise<undefined | string>;
|
|
61
|
+
ed25519DerivePrivateKeyFromSpriv(spriv: string, derive: number[]): Promise<string>;
|
|
62
|
+
ed25519OfflineExportFullPrivateKey(keygenResults: string[]): Promise<string>;
|
|
63
|
+
ed25519ImportPrivateKeyRecipient(roomUUID: string, hostUrl: string, threshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
64
|
+
pubkey: string;
|
|
65
|
+
secret_share: string;
|
|
66
|
+
}>;
|
|
67
|
+
ed25519ImportPrivateKeyImporter(roomUUID: string, hostUrl: string, threshold: number, privateKey: string, secretShare: string, keygenIDs: string[], isPrivateKeyRaw: boolean): Promise<{
|
|
68
|
+
pubkey: string;
|
|
69
|
+
secret_share: string;
|
|
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
|
+
}>;
|
|
104
|
+
bip340GetExportID(secretShare: string): Promise<string>;
|
|
105
|
+
bip340Keygen(roomUUID: string, hostUrl: string, numParties: number, threshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
106
|
+
pubkey: string;
|
|
107
|
+
secret_share: string;
|
|
108
|
+
}>;
|
|
109
|
+
bip340Sign(roomUUID: string, hostUrl: string, secretShare: string, msgHex: string, derivationPath: number[], tweak: string): Promise<string>;
|
|
110
|
+
bip340Refresh(roomUUID: string, hostUrl: string, secretShare: string): Promise<{
|
|
111
|
+
pubkey: string;
|
|
112
|
+
secret_share: string;
|
|
113
|
+
}>;
|
|
114
|
+
bip340ReshareNewParty(roomUUID: string, hostUrl: string, oldThreshold: number, newThreshold: number, keygenSecret: string, keygenIDs: string[]): Promise<{
|
|
115
|
+
pubkey: string;
|
|
116
|
+
secret_share: string;
|
|
117
|
+
}>;
|
|
118
|
+
bip340ReshareRemainingParty(roomUUID: string, hostUrl: string, newThreshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
119
|
+
pubkey: string;
|
|
120
|
+
secret_share: string;
|
|
121
|
+
}>;
|
|
122
|
+
bip340DeriveTweakPubkey(secretShare: string, derive: number[], tweak: string): Promise<string>;
|
|
123
|
+
bip340GetXpub(secretShare: string): Promise<string>;
|
|
124
|
+
bip340DeriveTweakPubkeyFromXpub(xpub: string, derivation: number[], optTweak: string): Promise<string>;
|
|
125
|
+
bip340ExportFullPrivateKey(roomUUID: string, hostUrl: string, secretShare: string, toExportID: string): Promise<undefined | string>;
|
|
126
|
+
bip340DerivePrivateKeyFromXpriv(xpriv: string, derive: number[]): Promise<string>;
|
|
127
|
+
bip340OfflineExportFullPrivateKey(keygenResults: string[]): Promise<string>;
|
|
128
|
+
bip340ImportPrivateKeyRecipient(roomUUID: string, hostUrl: string, threshold: number, secretShare: string, keygenIDs: string[]): Promise<{
|
|
129
|
+
pubkey: string;
|
|
130
|
+
secret_share: string;
|
|
131
|
+
}>;
|
|
132
|
+
bip340ImportPrivateKeyImporter(roomUUID: string, hostUrl: string, threshold: number, privateKey: string, secretShare: string, keygenIDs: string[], chaincode: Uint8Array | string): Promise<{
|
|
133
|
+
pubkey: string;
|
|
134
|
+
secret_share: string;
|
|
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
|
+
}>;
|
|
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;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export declare class MessageHash {
|
|
2
|
+
static readonly LENGTH = 32;
|
|
3
|
+
readonly bytes: Uint8Array;
|
|
4
|
+
constructor(bytes: Uint8Array | string);
|
|
5
|
+
static sha256(message: Uint8Array | string): MessageHash;
|
|
6
|
+
static sha256d(message: Uint8Array | string): MessageHash;
|
|
7
|
+
static keccak256(message: Uint8Array | string): MessageHash;
|
|
8
|
+
toHex(): string;
|
|
9
|
+
}
|
|
10
|
+
export declare class EcdsaPublicKey {
|
|
11
|
+
private static readonly LENGTH;
|
|
12
|
+
private readonly pubkey;
|
|
13
|
+
constructor(pubkey: Uint8Array | string);
|
|
14
|
+
serializeUncompressed(): Uint8Array;
|
|
15
|
+
serializeCompressed(): Uint8Array;
|
|
16
|
+
pubKeyAsHex(): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class EcdsaKeygenResult {
|
|
19
|
+
pubkey: EcdsaPublicKey;
|
|
20
|
+
secretShare: string;
|
|
21
|
+
constructor(pubkey: EcdsaPublicKey, secretShare: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class EcdsaInitKeygenResult {
|
|
24
|
+
keygenId: string;
|
|
25
|
+
keygenSecret: string;
|
|
26
|
+
constructor(keygenId: string, keygenSecret: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class Ed25519KeygenResult {
|
|
29
|
+
pubkey: Uint8Array;
|
|
30
|
+
secretShare: string;
|
|
31
|
+
constructor(pubkey: Uint8Array, secretShare: string);
|
|
32
|
+
}
|
|
33
|
+
export declare class Ed25519InitKeygenResult {
|
|
34
|
+
keygenId: string;
|
|
35
|
+
keygenSecret: string;
|
|
36
|
+
constructor(keygenId: string, keygenSecret: string);
|
|
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
|
+
}
|
|
58
|
+
export declare class EcdsaSignature {
|
|
59
|
+
private static readonly FIELD_SIZE;
|
|
60
|
+
private static readonly MAX_DER_LEN;
|
|
61
|
+
private static readonly MIN_DER_LEN;
|
|
62
|
+
readonly r: Uint8Array;
|
|
63
|
+
readonly s: Uint8Array;
|
|
64
|
+
readonly v: number;
|
|
65
|
+
readonly der: Uint8Array;
|
|
66
|
+
static fromBuffer(expandedSignature: Uint8Array | string): EcdsaSignature;
|
|
67
|
+
constructor(r: Uint8Array, s: Uint8Array, v: number, DERencoding: Uint8Array);
|
|
68
|
+
}
|
|
69
|
+
export declare class BIP340KeygenResult {
|
|
70
|
+
pubkey: Uint8Array;
|
|
71
|
+
secretShare: string;
|
|
72
|
+
constructor(pubkey: Uint8Array, secretShare: string);
|
|
73
|
+
}
|
|
74
|
+
export declare class BIP340InitKeygenResult {
|
|
75
|
+
keygenId: string;
|
|
76
|
+
keygenSecret: string;
|
|
77
|
+
constructor(keygenId: string, keygenSecret: string);
|
|
78
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs-wallet/btc-utils",
|
|
3
|
+
"version": "0.0.0-pr658.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@dynamic-labs-wallet/core": "0.0.0-pr658.0",
|
|
9
|
+
"bitcoinjs-lib": "^7.0.0",
|
|
10
|
+
"bip322-js": "^3.0.0",
|
|
11
|
+
"@noble/hashes": "1.7.1",
|
|
12
|
+
"bs58": "^6.0.0"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"nx": {
|
|
18
|
+
"sourceRoot": "packages/btc-utils/src",
|
|
19
|
+
"projectType": "library",
|
|
20
|
+
"name": "btc-utils",
|
|
21
|
+
"targets": {
|
|
22
|
+
"build": {}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"main": "./index.cjs.js",
|
|
26
|
+
"module": "./index.esm.js",
|
|
27
|
+
"types": "./index.esm.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./index.esm.d.ts",
|
|
32
|
+
"import": "./index.esm.js",
|
|
33
|
+
"require": "./index.cjs.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.0.0",
|
|
38
|
+
"@types/node": "^20.0.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BitcoinAddressType, BitcoinNetwork } from '@dynamic-labs-wallet/core';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the hash to be signed for a BIP-322 message verification
|
|
4
|
+
*
|
|
5
|
+
* @param message - The message to sign
|
|
6
|
+
* @param pubKey - The public key of the signer
|
|
7
|
+
* @param addressType - The address type (e.g. TAPROOT, SEGWIT)
|
|
8
|
+
* @param network - The Bitcoin network
|
|
9
|
+
* @param ecc - The ECC library instance (required for first call)
|
|
10
|
+
* @returns The formatted message hash and the PSBT to be signed
|
|
11
|
+
*/
|
|
12
|
+
export declare const calculateBip322Hash: (message: string, pubKey: any, addressType: BitcoinAddressType, network: BitcoinNetwork, ecc?: any) => {
|
|
13
|
+
formattedMessage: Uint8Array;
|
|
14
|
+
toSignPsbt: any;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=calculateBip322Hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateBip322Hash.d.ts","sourceRoot":"","sources":["../../src/calculateBip322Hash/calculateBip322Hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI/E;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,YACrB,MAAM,UACP,GAAG,eACE,kBAAkB,WACtB,cAAc,QACjB,GAAG,KACR;IAAE,gBAAgB,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,GAAG,CAAA;CAgEjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/calculateBip322Hash/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the Taproot tweak hash for BIP340 signing
|
|
3
|
+
* @param pubKey - The normalized public key (32-byte x-only for Taproot)
|
|
4
|
+
* @returns The tweak hash as a hex string (64 hex chars = 32 bytes)
|
|
5
|
+
*/
|
|
6
|
+
export declare const calculateTaprootTweak: (pubKey: Uint8Array | Buffer) => string;
|
|
7
|
+
//# sourceMappingURL=calculateTaprootTweak.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateTaprootTweak.d.ts","sourceRoot":"","sources":["../../src/calculateTaprootTweak/calculateTaprootTweak.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAY,UAAU,GAAG,MAAM,KAAG,MAMnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/calculateTaprootTweak/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Psbt } from 'bitcoinjs-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Collects prevOutScripts and values from all PSBT inputs
|
|
4
|
+
* Required for Taproot (BIP-341) hashForWitnessV1 calculation
|
|
5
|
+
* @param psbt - The PSBT to collect input data from
|
|
6
|
+
* @returns An object containing arrays of prevOutScripts and values
|
|
7
|
+
* @throws Error if any input is missing witnessUtxo
|
|
8
|
+
*/
|
|
9
|
+
export declare const collectPSBTInputData: (psbt: Psbt) => {
|
|
10
|
+
prevOutScripts: Buffer[];
|
|
11
|
+
values: bigint[];
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=collectPSBTInputData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectPSBTInputData.d.ts","sourceRoot":"","sources":["../../src/collectPSBTInputData/collectPSBTInputData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,SAAU,IAAI,KAAG;IAChD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAmBlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collectPSBTInputData/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
|