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

[Core Add] Add support to Ed25519 #3507

Open
wants to merge 18 commits into
base: HF_Echidna
Choose a base branch
from
Open

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Oct 2, 2024

Description

This pr adds support to Ed25519 as is suggested in #3506

Tested with test vectors from RFC 8032 (https://datatracker.ietf.org/doc/html/rfc8032)

Fixes # #3506

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • TestGenerateKeyPair
  • TestGetPublicKey
  • TestSignAndVerify
  • TestInvalidPrivateKeySize
  • TestInvalidSignatureSize
  • TestInvalidPublicKeySize
  • TestVectorCase1
  • TestVectorCase2
  • TestVectorCase3

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Jim8y Jim8y changed the base branch from master to HF_Echidna October 2, 2024 12:51
@Jim8y Jim8y marked this pull request as draft October 2, 2024 12:59
@Jim8y Jim8y marked this pull request as ready for review October 2, 2024 13:01
@Jim8y Jim8y requested review from vncoelho and a team October 2, 2024 13:01
@Jim8y
Copy link
Contributor Author

Jim8y commented Oct 2, 2024

@EdgeDLT

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

Add ut for false verification?

/// <param name="publicKey">The public key to be used.</param>
/// <returns><see langword="true"/> if the signature is valid; otherwise, <see langword="false"/>.</returns>
[ContractMethod(Hardfork.HF_Echidna, CpuFee = 1 << 15)]
public static bool VerifyWithEd25519(byte[] message, byte[] signature, byte[] publicKey)
Copy link
Member

Choose a reason for hiding this comment

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

Message, pubkey, signature? As in VerifyWithEcdsa

@Jim8y
Copy link
Contributor Author

Jim8y commented Oct 3, 2024

Add ut for false verification?

sure

verifier.BlockUpdate(message, 0, message.Length);
return verifier.VerifySignature(signature);
}
catch (Exception)
Copy link
Member

Choose a reason for hiding this comment

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

Well, I was talking only about ArgumentException, e.g. only about input data of invalid length and some other ArgumentException thrown by this part of code. However, catching any exception is a valid solution as far.

@roman-khimov, what do you think about cases when we should return true/false or FAULT VM?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can be both ways, but we need to know all of the exceptions that can happen in this block. Some are likely OK to be converted to false result (invalid signature), some may not (verifier constructor failure?). I'd expect some symmetry to ECDSA verification function. Like what happens if the key is wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants