-
Notifications
You must be signed in to change notification settings - Fork 23
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 interface for bls12-381 #79
base: main
Are you sure you want to change the base?
Conversation
This looks super solid to me, I think @MicroProofs has some questions about Scalar |
We haven't forgotten this PR we're just putting merging it on hold until we decide how to handle the PlutusV3 script context changes. |
Sounds good, no rush :) |
I wanted to comment on this as I have been working with BLS12381 a lot now in anticipation of V3. Would be a good idea to add in a equals function that wraps around, Consider changing how scaler works all together. Very rarely do you ever want to be working with the integer type when building BLS encrpytion algorithms. The limitation of the datum int type at 2^64-1 is too small and not secure. It is very common to use bytearrays and do a conversion, An example of this use case is given in my seed elf wallet implementation using a variation of a Schnorr signature. Having these functions from this PR in the stdlib is really going to help avoiding mixing between stdlib and builtin calls. With these addtions from this PR I will be implementing some BLS specific additions to the Assist library, specifically implementing all the algorithms from Registry type. |
ae2022f
to
b3d09b2
Compare
HI @logicalmechanism , thank you for the review!
I added them :)
I disagree that this would be a better interface as the low level operations always work over the integers (as you cannot add byte strings as integers in plutus yet (see bitwise primitives)), but how about I add a function @rvcas , can you please consider from a UI perspective if I named all function properly? |
Hello Aiken stdlib maintainers,
I'm excited to submit my first pull request, which introduces a new BLS12-381 interface to the Aiken standard library!
As a summary, I propose to add three new submodules, all under the umbrella module
bls12_381
. These are:g1.ak
: A simple interface for basic operations on G1 elements derived from builtin functions.g2.ak
: A simple interface for basic operations on G2 elements derived from builtin functions.scalar.ak
: An interface that implements the bls12-381 scalar field over the integers.I have one remark on the scalar field. Currently, taking an exponential in plutus is costly. Which means that the operations, like
scale
/recip
/div
in this module, are very costly onchain, I still added these functions for completeness.That said, most proof systems do use an exponent, but can rely on a little trick. That is, for
scalar^n
we can fix in our protocol thatn=2^k
for somek
. Which means that we can reduce the complexity of the tree created in the repeated squaring method. I called this functionpow_of_two
.Feel free to change any naming in this lib as you like to better fit the rest (I tried my best in following your standards).