@toruslabs/torus.js
Advanced tools
Comparing version 11.0.3 to 11.0.4
@@ -147,2 +147,3 @@ import type { INodePub, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
node_puby: string; | ||
is_new_key: boolean; | ||
} | ||
@@ -149,0 +150,0 @@ export interface ImportedShare { |
{ | ||
"name": "@toruslabs/torus.js", | ||
"version": "11.0.3", | ||
"version": "11.0.4", | ||
"description": "Handle communication with torus nodes", | ||
@@ -5,0 +5,0 @@ "main": "dist/torusUtils.cjs.js", |
@@ -33,3 +33,3 @@ import { LEGACY_NETWORKS_ROUTE_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
import { lagrangeInterpolation } from "./langrangeInterpolatePoly"; | ||
import { decryptNodeData, getMetadata, getNonce } from "./metadataUtils"; | ||
import { decryptNodeData, getMetadata, getOrSetNonce } from "./metadataUtils"; | ||
@@ -303,3 +303,4 @@ export const GetPubKeyOrKeyAssign = async (params: { | ||
void | JRPCResponse<ShareRequestResult>, | ||
{ privateKey: BN; sessionTokenData: SessionToken[]; thresholdNonceData: GetOrSetNonceResult; nodeIndexes: BN[] } | undefined | ||
| { privateKey: BN; sessionTokenData: SessionToken[]; thresholdNonceData: GetOrSetNonceResult; nodeIndexes: BN[]; isNewKey: boolean } | ||
| undefined | ||
>(promiseArrRequest, async (shareResponses, sharedState) => { | ||
@@ -357,2 +358,3 @@ // check if threshold number of nodes have returned the same user public key | ||
const sessionTokenData: SessionToken[] = []; | ||
const isNewKeyResponses: boolean[] = []; | ||
@@ -367,4 +369,7 @@ for (let i = 0; i < completedRequests.length; i += 1) { | ||
keys, | ||
is_new_key: isNewKey, | ||
} = currentShareResponse.result; | ||
isNewKeyResponses.push(isNewKey); | ||
if (sessionTokenSigs?.length > 0) { | ||
@@ -490,4 +495,5 @@ // decrypt sessionSig if enc metadata is sent | ||
} | ||
const thresholdIsNewKey = thresholdSame(isNewKeyResponses, ~~(endpoints.length / 2) + 1); | ||
return { privateKey, sessionTokenData, thresholdNonceData, nodeIndexes }; | ||
return { privateKey, sessionTokenData, thresholdNonceData, nodeIndexes, isNewKey: thresholdIsNewKey }; | ||
} | ||
@@ -498,3 +504,3 @@ throw new Error("Invalid"); | ||
.then(async (res) => { | ||
const { privateKey, sessionTokenData, thresholdNonceData, nodeIndexes } = res; | ||
const { privateKey, sessionTokenData, thresholdNonceData, nodeIndexes, isNewKey } = res; | ||
let nonceResult = thresholdNonceData; | ||
@@ -518,3 +524,3 @@ if (!privateKey) throw new Error("Invalid private key returned"); | ||
if (enableOneKey) { | ||
nonceResult = await getNonce(legacyMetadataHost, ecCurve, serverTimeOffset, oAuthPubkeyX, oAuthPubkeyY, oAuthKey); | ||
nonceResult = await getOrSetNonce(legacyMetadataHost, ecCurve, serverTimeOffset, oAuthPubkeyX, oAuthPubkeyY, oAuthKey, !isNewKey); | ||
metadataNonce = new BN(nonceResult.nonce || "0", 16); | ||
@@ -521,0 +527,0 @@ typeOfUser = nonceResult.typeOfUser; |
@@ -149,2 +149,3 @@ import type { INodePub, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
node_puby: string; | ||
is_new_key: boolean; | ||
} | ||
@@ -151,0 +152,0 @@ |
@@ -728,6 +728,7 @@ import { INodePub, JRPCResponse, LEGACY_NETWORKS_ROUTE_MAP, SIGNER_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
if (nonceResult.typeOfUser === "v1") { | ||
nonce = await getMetadata(this.legacyMetadataHost, { pub_key_X: X, pub_key_Y: Y }); | ||
finalPubKey = this.ec | ||
.keyFromPublic({ x: X, y: Y }) | ||
.getPublic() | ||
.add(this.ec.keyFromPrivate(nonce.toString(16)).getPublic()); | ||
.add(this.ec.keyFromPrivate(nonce.toString(16, 64), "hex").getPublic()); | ||
} else if (nonceResult.typeOfUser === "v2") { | ||
@@ -734,0 +735,0 @@ finalPubKey = this.ec |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1657257
7328