You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.6 KiB

4 years ago
4 years ago
4 years ago
  1. #![cfg_attr(not(feature = "std"), no_std)]
  2. #![deny(
  3. warnings,
  4. unused,
  5. future_incompatible,
  6. nonstandard_style,
  7. rust_2018_idioms
  8. )]
  9. #![forbid(unsafe_code)]
  10. //! This library implements the BN254 curve that was sampled as part of the [\[BCTV14\]](https://eprint.iacr.org/2013/879.pdf) paper .
  11. //! The name denotes that it is a Barreto--Naehrig curve of embedding degree 12,
  12. //! defined over a 254-bit (prime) field. The scalar field is highly 2-adic.
  13. //!
  14. //! This curve is also implemented in [libff](https://github.com/scipr-lab/libff/tree/master/libff/algebra/curves/alt_bn128) under the name `bn128`.
  15. //! It is the same as the `bn256` curve used in Ethereum (eg: [go-ethereum](https://github.com/ethereum/go-ethereum/tree/master/crypto/bn254/cloudflare)).
  16. //!
  17. //! #CAUTION
  18. //! **This curve does not satisfy the 128-bit security level anymore.**
  19. //!
  20. //!
  21. //! Curve information:
  22. //! * Base field: q = 21888242871839275222246405745257275088696311157297823662689037894645226208583
  23. //! * Scalar field: r = 21888242871839275222246405745257275088548364400416034343698204186575808495617
  24. //! * valuation(q - 1, 2) = 1
  25. //! * valuation(r - 1, 2) = 28
  26. //! * G1 curve equation: y^2 = x^3 + 3
  27. //! * G2 curve equation: y^2 = x^3 + B, where
  28. //! * B = 3/(u+9) where Fq2 is represented as Fq\[u\]/(u^2+1)
  29. //! = Fq2(19485874751759354771024239261021720505790618469301721065564631296452457478373, 266929791119991161246907387137283842545076965332900288569378510910307636690)
  30. #[cfg(feature = "curve")]
  31. mod curves;
  32. mod fields;
  33. #[cfg(feature = "curve")]
  34. pub use curves::*;
  35. pub use fields::*;