Skip to content

Commit

Permalink
Merge pull request #164 from torusresearch/fix/ed25519-use-dkg
Browse files Browse the repository at this point in the history
enforce useDkg to false for ed25519
  • Loading branch information
chaitanyapotti authored Sep 6, 2024
2 parents 4cb0c73 + 09113c1 commit 2d01fd4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/torus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions test/sapphire_devnet_ed25519.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit 2d01fd4

Please sign in to comment.