Implementation pairing operation over elliptic curves from the following "families" with parameters such as base field, extension tower structure, coefficients defined in runtime:

  • BLS12
  • BN
  • MNT4/6 (Ate pairing)

I want to learn about BN128 curve in substrate


Does substrate support BN128 curve?

3 Answers 3


Yes you can implement logic using this curve in Substrate. It is not supported natively as a key type, but that doesn't really matter if I had to guess what your use case is.

One way to do this is to use Arkworks. The Arkworks ecosystem has a library that exposes the BN128 curve among many others and compiles into WASM compatible code. You can do so by importing the relevant packages you need for your application and using default-features = false in your Cargo.toml of your pallet.

We've effectively used this route on Webb's Substrate Protocol. You can see an example of it in the links below. I will describe what is going on here so that it avoids any confusion hopefully.

We've generalized our pallets to provide some arbitrary functionality like hashing or verifying zero-knowledge proofs (Groth16 proofs/Plonk proofs over a specified curve in our runtime).

  1. We define the actual curve-specific hashing logic in the runtime.
  2. The curve specific logic lives in a no-std compatible library, for example our BN128 Poseidon hashing logic.

You can define arbitrary no-std compatible curves and functionality anywhere you want really in your runtime. You could even implement it directly in the pallet's logic, since this code all executes there anyway.

  • thank you very much,sir
    – bun
    Commented Sep 4, 2022 at 3:02

Substrate supports ECDSA, ED25519 and SR25519 as listed here https://docs.rs/sp-core.
You can open an issue if you feel that Substrate is lacking important features.
Or if you are experienced you can implement it and try to integrate it into Substrate by opening a Merge Request.


There is a WIP PR for arkworks-rs integration: https://github.com/paritytech/substrate/pull/13031 It adds host-funciton calls for BLS12_381.

The curves are living in this repo: https://github.com/achimcc/ark-substrate.

You might want to check out https://github.com/achimcc/substrate-groth16 which verifys a groth16 proof using arkworks library and the PR.

  • 1
    Excellent! Thank you for your answer. I also have implemented these including the zk verify(groth16) pallet in the last year. We can use the existing curve to adapt the substrate. That's right!
    – bun
    Commented Mar 1, 2023 at 15:29
  • You are welcome! Feel free to flag my post as answer ;)
    – Achim
    Commented Mar 2, 2023 at 10:06
  • We have also a more up to date repo now, which contains example implementations for all curves: github.com/achimcc/substrate-arkworks-examples. It also has a comparison of various benchmarking results: github.com/achimcc/substrate-arkworks-examples/blob/main/…
    – Achim
    Commented Mar 2, 2023 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.