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

Any easy way to verify secp256r1 (NIST P256) ECDSA signature? #1724

Open
xomexh opened this issue Jul 5, 2024 · 3 comments
Open

Any easy way to verify secp256r1 (NIST P256) ECDSA signature? #1724

xomexh opened this issue Jul 5, 2024 · 3 comments

Comments

@xomexh
Copy link

xomexh commented Jul 5, 2024

The custom curve params for the NIST curve does not seem to work. Anyway/any work around as to how a P256 ECDSA signature?
Using curve params as:

const secp256r1Params: CurveParams = {
   name: 'secp256r1',
   modulus: 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFn,
   order: 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551n,
   a: -3n,
   b: 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604Bn,
   generator: {
     x: 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296n,
     y: 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5n,
   },
};```
@Trivo25
Copy link
Member

Trivo25 commented Jul 6, 2024

Hey! Unfortunately, we currently only support foreign curves with curve parameter a !== 0, and here a = -3

https://github.com/o1-labs/o1js-bindings/blob/df8c87ed6804465f79196fdff84e5147ae71e92d/crypto/elliptic-curve.ts#L531-L532

To support curves with a = 0, we would have to implement the a = 0 case in the code base

@xomexh
Copy link
Author

xomexh commented Jul 6, 2024

Thank you for the reply, I would see I'd see for myself if I could do something about this.

Also another completely unrelated issue/doubt, is there an easy way to pass a composite struct having string data inside to a zkProgram?

This inherently doesn't give any errors, but the values of sig and msg are not accessible inside prove-able code (inside the methods of zkProgram) i.e I get no value from these fields of sig and msg.

Example:

class P256_Signature_Field extends Struct({
    sig: String,
    msg: String
}){
    constructor(value:{sig:string, msg:string}){
        super(value)
    }
}


@Trivo25
Copy link
Member

Trivo25 commented Jul 6, 2024

Also another completely unrelated issue/doubt, is there an easy way to pass a composite struct having string data inside to a zkProgram?

You can't work with strings inside provable code, you would have to convert your strings into Field elements using an encoding

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

No branches or pull requests

2 participants