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 sign-verify example #247

Merged
merged 8 commits into from
Feb 27, 2024
Merged

Conversation

guest271314
Copy link
Contributor

@bsmth bsmth self-assigned this Jan 25, 2024
@bsmth
Copy link
Member

bsmth commented Jan 25, 2024

Thanks for the submission. This doesn't work for me using Chrome Canary / Beta:

image

  • ❌ Version 123.0.6264.0 (Official Build) canary (arm64)
  • ❌ Version 122.0.6261.6 (Official Build) beta (arm64)

I don't see any preferences / flags to enable.

The following works in node:

async function generateAndSignKey() {
  const algorithm = { name: "Ed25519" };
  const encoder = new TextEncoder();
  const cryptoKey = await crypto.subtle.generateKey(
    algorithm,
    true,
    ["sign", "verify"]
  );

  console.log(
    await crypto.subtle.sign(
      algorithm,
      cryptoKey.privateKey,
      new Uint8Array([255])
    )
  );
}

generateAndSignKey();

With an exp warning:

(node:27247) ExperimentalWarning: The Ed25519 Web Crypto API algorithm is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
ArrayBuffer {
  [Uint8Contents]: <bd 47 7d 05 81 ff e2 98 02 6e 16 4e cd 49 9a 1c 9f 5b 6d 5c 49 a0 f6 98 eb 29 3c 0c 4d 3e 28 43 b7 9a dd c2 df ef 4b ca 80 de 2e 04 59 02 7e 08 95 c5 c8 5c 3d d9 4c aa 65 20 0d 00 2e 1c 2e 0b>,
  byteLength: 64
}
...
node --version
v20.11.0

@guest271314
Copy link
Contributor Author

Launch Chrome or Chromium with --enable-experimental-web-platform-features command-line switch (updated with link in index.html).

E.g., for testing

~/chrome-linux/chrome --user-data-dir=$HOME/test --password-store=basic --enable-experimental-web-platform-features file:///home/user/sign-verify/index.html

Screenshot_2024-01-25_18-26-11

@bsmth
Copy link
Member

bsmth commented Jan 26, 2024

Confirmed this is working, also possible via chrome://flags/#enable-experimental-web-platform-features as an alternative to command-line arg. See;

@bsmth bsmth closed this Jan 26, 2024
@bsmth bsmth reopened this Jan 26, 2024
@bsmth
Copy link
Member

bsmth commented Jan 26, 2024

Closed by mistake, please ignore

web-crypto/sign-verify/ed25519.js Outdated Show resolved Hide resolved
web-crypto/sign-verify/ed25519.js Outdated Show resolved Hide resolved
web-crypto/sign-verify/ed25519.js Outdated Show resolved Hide resolved
web-crypto/sign-verify/index.html Outdated Show resolved Hide resolved
Copy link
Member

@bsmth bsmth left a comment

Choose a reason for hiding this comment

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

Leaving a +1 on this, thank you!

@bsmth
Copy link
Member

bsmth commented Feb 26, 2024

Thanks a lot for your review @twiss, I've incorporated your feedback and I'm happy to merge in the current state unless you have any objections!

@bsmth bsmth requested a review from twiss February 26, 2024 10:38
web-crypto/sign-verify/index.html Outdated Show resolved Hide resolved
Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
@bsmth bsmth merged commit 9189afb into mdn:main Feb 27, 2024
3 checks passed
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.

None yet

3 participants