darklang / darklang/dark

Add Ed25519 function

Open
#4,677 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

later
Dominant language
F#
Stars
2.2k
Forks
115
Avg merge
17h 28m
Merged PRs (30d)
50

Description

Vynlar, from our discord, is looking for functions to make discord bots. Specifically, a way to verify ed5519 signatures, as indicated in https://discord.com/developers/docs/interactions/receiving-and-responding#security-and-authorization.

Suggested signature/test cases:

Possible function signature
Crypto::verifyEd25519 (bytes message, bytes signature, bytes publicKey) -> bool

Note: All values below are hex-encoded bytes

Positive case:
message = "1a2b3c"
signature = "093128FA3D47389D62C3264733F4A663F413D219EEBF276FDECC4D2D689C307140DBD093EECB7B8790986BFC839CEE458E77F7EB7A87ADE5CB8C7A5389046E0E"
publicKey = "AF154ADEAE6DE36277B91BF11F923993E1202AA0B9F192619FF47AFF0B6CC8F7"
expected output: true

Negative case:
message = "1a2b3c4d" // has been tampered with
signature = "093128FA3D47389D62C3264733F4A663F413D219EEBF276FDECC4D2D689C307140DBD093EECB7B8790986BFC839CEE458E77F7EB7A87ADE5CB8C7A5389046E0E"
publicKey = "AF154ADEAE6DE36277B91BF11F923993E1202AA0B9F192619FF47AFF0B6CC8F7"
expected output: false

Howver, @StachuDotNet points out that Ed25519 is not supported in .NET's System.Security.Cryptography, but we might be able to use https://github.com/CodesInChaos/Chaos.NaCl/blob/master/Chaos.NaCl/Ed25519.cs. Another angle is to see what's in libsodium which we already use.

We already have a function which validates data against existing public/private stuff, maybe in the X509 module. Is this the same thing or different? Do we perhaps just need a new version which supports a 4th type of cert/algorithm?

Next steps:

  • investigate whether we should just make a new version of an existing function
  • get agreement on the signature/test case to create
  • find an idiomatic .NET library to support this
  • actually write the code

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing X509 module function mentioned in the issue and compare it with Chaos.NaCl/Ed25519.cs and the libsodium option. Confirm the API and test vectors, choose an idiomatic .NET library, and consider the work done when the implementation and positive and negative verification tests are agreed and complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
cryptography
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.