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

BLS12-381 bindings #266

Merged
merged 67 commits into from
Mar 30, 2023
Merged

BLS12-381 bindings #266

merged 67 commits into from
Mar 30, 2023

Conversation

tdammers
Copy link
Contributor

@tdammers tdammers commented Mar 10, 2022

Implements #302

Copy link
Collaborator

@iquerejeta iquerejeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great! 👍

However, as you'll see in the comments below, we should change a few things. The main points are the following:

  • We should remove the pairing check (and by consequence the two_miller_one_exp)
  • We should change the definition of "equal elements" for GT elements
  • We should check points are in the group before computing the miller loop

In a nutshell we will be doing the optimization we did in pairing_check for all operations between GT elements. i.e. we are generalizing it so that, instead of only applying the optimization when checking equality of two pairing evaluations, we can apply the optimization to an arbitrary number of pairing evaluations. Therefore, we only compute the miller loop when "computing the pairing", and when we check for equality, we do the finalcheck, which handles the final exponentiation.

To this end we should include the following test with three pairings to the library:

        (BLS.pairing (BLS.mult p a, q) * BLS.pairing (p, BLS.mult q b))
        ==
        BLS.pairing(BLS.mult p (a + b), q)

cardano-crypto-class/cbits/blst_util.c Outdated Show resolved Hide resolved
cardano-crypto-class/cbits/blst_util.c Outdated Show resolved Hide resolved
cardano-crypto-tests/src/Test/Crypto/EllipticCurve.hs Outdated Show resolved Hide resolved
cardano-crypto-tests/src/Test/Crypto/EllipticCurve.hs Outdated Show resolved Hide resolved
Copy link

@jmhrpr jmhrpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on function naming for add vs add_or_double

@arthurgreef
Copy link

Hi @tdammers, can we get an update on the PR? Also, is there a branch that exposes these bindings to dapps via Plutus?

@iquerejeta
Copy link
Collaborator

Hi @arthurgreef . This PR is still in draft, as we are waiting for benchmarks to determine whether these primitives will be usable in practice (due to the execution budget). The use-case we are currently considering is that of ATMS signatures. What are you planning on using them for?
And regarding your question, there is no branch that exposes these bindings via Plutus yet, and that most probably won't happen until we have not concluded that they can be used in practice.

btw, did you manage to solve the problem with nix you had?

@arthurgreef
Copy link

Hi @iquerejeta I still have the problem with nix-shell.

cardano-base$ nix-shell
trace: Not using IOHK default nixpkgs (use 'niv drop nixpkgs' to use default for better sharing)
building '/nix/store/mli2m3sw8jkc15pgjmxagjqxxw5rii45-git-ls-files.drv'...
error: The Nixpkgs package set does not contain the package: blst (system dependency).
       You may need to augment the system package mapping in haskell.nix so that it can be found.
(use '--show-trace' to show detailed location information)

@arthurgreef
Copy link

Hi @iquerejeta my use case is DKG.
Here is the paper. https://eprint.iacr.org/2019/985.pdf
Here is the ETH smart contract I wanted to convert to Plutus. https://github.com/PhilippSchindler/EthDKG/blob/master/contracts/ETHDKG.sol

@iquerejeta
Copy link
Collaborator

Thanks @arthurgreef . I will try to look into the nix issue soon (we've been building it directly with cabal so far). And regarding DKG, that's cool. And the intention of using pairing friendly curve is because you want to generate a key for a pairing friendly primitive? or simply because BLS curve is what is closer to be available in Plutus?

@arthurgreef
Copy link

@iquerejeta we need BLS12-381 so that organizations can issue verifiable credentials using signatures that comply with the BBS+ selective disclosure protocol. https://w3c-ccg.github.io/ldp-bbs2020/

@arthurgreef
Copy link

Hi @iquerejeta - we are need BLS12-381 for organizations that sign verifiable credentials compliant with BBS+ https://w3c-ccg.github.io/ldp-bbs2020/

@jhofp
Copy link

jhofp commented Nov 14, 2022

Hi @tdammers , thanks for all the great works from you and your team on bring BLS12-381 to Plutus.
Is there any timeline that i could expect for this to be on Plutus? thanks!

@iquerejeta iquerejeta force-pushed the bls12-381 branch 2 times, most recently from f791c4a to 43cba76 Compare November 29, 2022 18:05
@iquerejeta
Copy link
Collaborator

@arthurgreef you should be able to make it work with nix. Let me know if that is not the case.

@iquerejeta
Copy link
Collaborator

@arthurgreef , nix should work now. If that's not the case, please let me know.

@arthurgreef
Copy link

nix-shell works for me now. thank you.

angerman and others added 6 commits March 29, 2023 15:50
Now that we enforce at type level that points are part of the subgroup, the miller loop will always succeed
@iquerejeta iquerejeta merged commit 56a71b1 into master Mar 30, 2023
@iquerejeta iquerejeta deleted the bls12-381 branch March 30, 2023 13:18
lehins added a commit that referenced this pull request May 18, 2023
Bindings in Haskell for curve BLS12-381 operations. End goal is to add BLS12-381 bindings to Plutus, following [CIP-0381](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0381). Bindings based in the [blst](https://github.com/supranational/blst) library.

Co-authored-by: iquerejeta <[email protected]>
Co-authored-by: Moritz Angermann <[email protected]>
Co-authored-by: Alexey Kuleshevich <[email protected]>
lehins added a commit that referenced this pull request May 23, 2023
Bindings in Haskell for curve BLS12-381 operations. End goal is to add BLS12-381 bindings to Plutus, following [CIP-0381](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0381). Bindings based in the [blst](https://github.com/supranational/blst) library.

Co-authored-by: iquerejeta <[email protected]>
Co-authored-by: Moritz Angermann <[email protected]>
Co-authored-by: Alexey Kuleshevich <[email protected]>
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

Successfully merging this pull request may close these issues.

8 participants