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 schnorr signature and tests for bip 340 #385

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

guha-rahul
Copy link
Contributor

addresses #274

}

/// Signs a message using Schnorr signature scheme
fn sign(private_key: felt252, message: felt252) -> SchnorrSignature {
Copy link
Member

Choose a reason for hiding this comment

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

We need a function to sign Nostr event like the Struct below, or how convert a Struct Nostr Event as a felt or ByteArray, it's the main used Struct in our repo and to sign Nostr Social event, we need this struct:

    let request = SocialRequest {
        public_key: recipient_public_key,
        created_at: 1716285235_u64,
        kind: 1_u16,
        tags: "[]",
        content: claim,
        sig: Signature {
            r: 0xf1dac3f8d0d19767805ca85933bdf0e744594aeee04058eedaa29e26de087be9_u256,
            s: 0x144c4636083c7d0e3b8186c8c0bc6fa38bd9c6a629ec6e2ce5e437797a6e911c_u256
        }
    };

}

/// Verifies a Schnorr signature
fn verify_sig(public_key: EcPoint, message: felt252, signature: SchnorrSignature) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

We need also a conversion between this two types of Signature, like present in the others bip340 implement in our repo, and used in Nostr event:

sig: Signature {
r: 0xf1dac3f8d0d19767805ca85933bdf0e744594aeee04058eedaa29e26de087be9_u256,
s: 0x144c4636083c7d0e3b8186c8c0bc6fa38bd9c6a629ec6e2ce5e437797a6e911c_u256
}

Copy link
Member

@MSghais MSghais left a comment

Choose a reason for hiding this comment

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

lfg! Let's change after the ODHack:

  • Sign with ByteArray to sign Nostr event deseriliazed
  • Add the VRF for the generate private key

@guha-rahul

@MSghais MSghais merged commit 6fae362 into AFK-AlignedFamKernel:main Dec 22, 2024
3 of 5 checks passed
@guha-rahul guha-rahul mentioned this pull request Jan 4, 2025
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