stdlib
stdlib copied to clipboard
Add interface for bls12-381
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 that n=2^k
for some k
. Which means that we can reduce the complexity of the tree created in the repeated squaring method. I called this function pow_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).