Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enforce useDkg to false for ed25519 #164

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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