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

feat: ecdsa on BabyJubJub #17

Closed
wants to merge 9 commits into from

Conversation

YashBit
Copy link
Contributor

@YashBit YashBit commented Sep 15, 2024

Implement ECDSA Signature Generation and Verification in Noir

Overview

This PR introduces a comprehensive ECDSA (Elliptic Curve Digital Signature Algorithm) implementation in Noir, utilizing the Baby JubJub curve. The implementation includes functions for signature generation, verification, and related utility operations.

Key Features

  • ECDSA signature generation and verification
  • Modular inverse calculation
  • Public key derivation from private key
  • Conversion of byte arrays to field elements

Function Definitions

calculate_signature

Generates an ESDSA signature for a given message using a private key and random nonce.

verify_signature

Verifies an ECDSA signature against a given message hash and public key.

mod_inv

Computes the modular inverse of a field element with respect to a given modulus.

field_from_bytes

Converts a byte array to a field element, supporting both big-endian and little-endian formats.

derive_public_key

Computes a public key from a private key using the Baby JubJub curve.

derive_public_key_optimized

Provides an optimized version of public key derivation using pre-computed curve parameters.

Usage

This implementation can be used for secure digital signature generation and verification in Noir projects. It's particularly useful for blockchain and cryptographic applications requiring ECDSA functionality.

Notes

  • The implementation uses the Baby JubJub curve, which is well-suited for zero-knowledge proofs.
  • Random nonce generation is not included and should be handled externally for security reasons.
  • The code includes comprehensive error checking and assertions for robustness.

Future Improvements

  • Consider adding more extensive testing, especially for edge cases.
  • Explore further optimizations for performance-critical operations.
  • Evaluate the possibility of implementing additional signature schemes.

Yash Bharti added 8 commits August 31, 2024 17:33
git commit -m "feat: skeleton code for ECDSA" --no-verify
add: calculate_signature ECDSA
…ypecasting

bug: mod_inv, calculating_signature complete, focus on typecasting
feat: ECDSA => Integration Tests
git commit -m "feat: ECDSA implementation" --no-verify
@YashBit
Copy link
Contributor Author

YashBit commented Sep 18, 2024

@signorecello

I am still working on the integration test, but the code for ECDSA is complete. Compiles without any errors. Please can you comment on the logic, etc?

@@ -0,0 +1,12 @@
mod lib;

fn main(private_key: [u8; 32], message: [u8; 32], random_nonce: [u8; 32]) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have a test and a proper README with instructions on how to use, import, test, and with a benchmark? Seems like this library would benefit from using noir-edwards too.

A lot of this code is AI-generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On it.

Yes, AI Generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optimised version of BabyJubJub already implements noir-edwards I believe.

@signorecello
Copy link
Collaborator

Closing this PR as we have significant evidence of you asking community members to do the remaining work on your behalf.

@YashBit
Copy link
Contributor Author

YashBit commented Sep 20, 2024

@signorecello

Hi,

Implementing ECDSA was not a part of the work for the grant that I received. So I have not asked people to complete work that is "on my behalf", but I wanted to collaborate further with the community and add value.

Moreover, I merely asked you to comment on the logic. Hence, I believe closing this PR signals poor judgement.

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