-
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
Make ECDSA more efficient with GLV #209
Conversation
/** | ||
* GLV decomposition, named after the authors Gallant, Lambert and Vanstone who introduced it: | ||
* https://iacr.org/archive/crypto2001/21390189.pdf |
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.
this is where the magic happens!
// upper bounds for | ||
// |s0| <= 0.5 * (|v00| + |v01|) | ||
// |s1| <= 0.5 * (|v10| + |v11|) | ||
let maxS0 = ((abs(v00) + abs(v01)) >> 1n) + 1n; | ||
let maxS1 = ((abs(v10) + abs(v11)) >> 1n) + 1n; | ||
let maxBits = log2(max(maxS0, maxS1)); |
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.
it's essential that we are able to statically compute the maximum number of bits (maxBits
) that scalars have after GLV decomposition, with a reliable upper bound. Only with this knowledge can we leverage the gains of reduced bit lengths in a static circuit.
generator | ||
)); | ||
} catch (e: any) { | ||
console.log(`Warning: no endomorphism for ${name}`, e?.message); |
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.
we could also utilize console.warn
if we want - but that also sometimes gets mistaken for runtime warnings and just ignored by users :X
Companion of o1-labs/o1js#1257
endoScalar
,endoBase
, implements methods to decompose a scalar, and to do faster scalar multiplication using that decomposition ("GLV method")endoScalar
andendoBase
when they exist and are not already given as parameters (i.e. for secp256k1)