-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support Secp256r1 #310
Support Secp256r1 #310
Conversation
@Trivo25 can you get me the necessary reviewers for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left two observations, other than that looks good
@@ -15,6 +15,18 @@ const secp256k1Params: CurveParams = { | |||
}, | |||
}; | |||
|
|||
const secp256r1Params: CurveParams = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@@ -26,6 +26,10 @@ let exampleFields = { | |||
f25519: createField(p25519), | |||
secp256k1: createField(pSecp256k1), | |||
secq256k1: createField(pSecq256k1), | |||
secp256r1: | |||
createField( | |||
0xffffffff00000001000000000000000000000000ffffffffffffffffffffffffn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@@ -530,14 +623,12 @@ function createCurveAffine({ | |||
endoScalar, | |||
endoBase, | |||
}: CurveParams) { | |||
// TODO: lift this limitation by using other formulas (in projectiveScale) for a != 0 | |||
if (a !== 0n) throw Error('createCurveAffine only supports a = 0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this check implies you allow any a
? In createCurveProjective
you removed the check and called createProjectiveDouble
where there's a check that a
is 0 or -3. But what about here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point, I mean we do support general a
now in all the purely affine methods like affineAdd
, affineDouble
. the only place which doesn't support general a is projectiveDouble
, which is used here by methods like scale()
and isInSubgroup()
so I think we can accept general a
here at this point and only when using certain unsupported methods users would hit the error.
companion of o1-labs/o1js#1885
a
in most elliptic curve methodsa
parametera = -3
in projective curve doublinga
. thanks to the other changes here, it would now be very simple to add the generala
case as well, but for testing we would need a concrete curve with generala
, and I'm skipping the work of finding one since I'm not interested in general curves here