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

Add Ed25519 overload for SubtleCrypto#generateKey #1594

Merged
merged 2 commits into from
Jul 12, 2023
Merged

Add Ed25519 overload for SubtleCrypto#generateKey #1594

merged 2 commits into from
Jul 12, 2023

Conversation

steveluscher
Copy link
Contributor

I find myself constantly having to do this:

const key = await crypto.subtle.generateKey('Ed25519', false, ['sign', 'verify']) as CryptoKeyPair;

This PR updates the types so as to indicate that this method always returns a keypair for the algorithm Ed25519. It further constrains the type of the KeyUsages to just sign and verify – the only ones allowed by the spec.

@github-actions
Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

@saschanaz
Copy link
Contributor

Maybe we should have KeyUsagesMap for other algorithms too?

@@ -1589,6 +1589,7 @@
"generateKey": {
"name": "generateKey",
"additionalSignatures": [
"generateKey(algorithm: \"Ed25519\", extractable: boolean, keyUsages: ReadonlyArray<Extract<KeyUsage, \"sign\" | \"verify\">>): Promise<CryptoKeyPair>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't Extract<KeyUsage, "sign" | "verify"> effectively just "sign" | "verify"? Maybe the latter can be concise.

@github-actions github-actions bot merged commit 0271c50 into microsoft:main Jul 12, 2023
3 of 4 checks passed
@github-actions
Copy link
Contributor

Merging because @saschanaz is a code-owner of all the changes - thanks!

@steveluscher steveluscher deleted the ed25519-keygen-always-keypair branch July 13, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants