From 09113c103326adf73910522d553ac4859fce1c89 Mon Sep 17 00:00:00 2001 From: himanshu Date: Fri, 6 Sep 2024 12:40:09 +0530 Subject: [PATCH] enforce useDkg to false for ed25519 --- src/torus.ts | 2 +- test/sapphire_devnet_ed25519.test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/torus.ts b/src/torus.ts index 08fe50c..a8bc551 100644 --- a/src/torus.ts +++ b/src/torus.ts @@ -131,7 +131,7 @@ class Torus { if (useDkg === false && LEGACY_NETWORKS_ROUTE_MAP[this.network as TORUS_LEGACY_NETWORK_TYPE]) { throw new Error(`useDkg cannot be false for legacy network; ${this.network}`); } - shouldUseDkg = useDkg; + shouldUseDkg = this.keyType === KEY_TYPE.ED25519 ? false : useDkg; } else if (this.keyType === KEY_TYPE.ED25519) { shouldUseDkg = false; } else { diff --git a/test/sapphire_devnet_ed25519.test.ts b/test/sapphire_devnet_ed25519.test.ts index 884a3be..164cfb6 100644 --- a/test/sapphire_devnet_ed25519.test.ts +++ b/test/sapphire_devnet_ed25519.test.ts @@ -213,6 +213,30 @@ describe("torus utils ed25519 sapphire devnet", function () { expect(result.finalKeyData.X).eql(publicResult.finalKeyData.X); }); + it("should be able to login a new user with use dkg flag is true", async function () { + const email = `${faker.internet.email()}`; + const token = generateIdToken(email, "ES256"); + const verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: email }; + const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails); + const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints; + const result = await torus.retrieveShares( + getRetrieveSharesParams( + torusNodeEndpoints, + nodeDetails.torusIndexes, + TORUS_TEST_VERIFIER, + { verifier_id: email }, + token, + nodeDetails.torusNodePub, + {}, + true + ) + ); + + const publicResult = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails); + + expect(result.finalKeyData.X).eql(publicResult.finalKeyData.X); + }); + it("should be able to login even when node is down", async function () { const token = generateIdToken(TORUS_TEST_EMAIL, "ES256"); const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails({ verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL });