sp_crypto_ec_utils/lib.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! This crate offers elliptic curves types which are compatible with the
19//! [Arkworks](https://github.com/arkworks-rs) library functionalities.
20//!
21//! The implementation has been primarily designed to be used in slow hosted
22//! targets (e.g. wasm32) and offloads the most computationally expensive
23//! operations to the host by leveraging the
24//! [arkworks-extensions](https://github.com/paritytech/arkworks-extensions)
25//! library and Substrate's host functions.
26//!
27//! The exported types are organized and named in a way that mirrors the structure
28//! of the types in the original Arkworks library. This design choice aims to make
29//! it easier for users already familiar with the library to understand and utilize
30//! the exported types effectively.
31
32#![warn(missing_docs)]
33#![cfg_attr(not(feature = "std"), no_std)]
34
35extern crate alloc;
36
37#[cfg(feature = "bls12-377")]
38pub mod bls12_377;
39#[cfg(feature = "bls12-381")]
40pub mod bls12_381;
41#[cfg(feature = "bw6-761")]
42pub mod bw6_761;
43#[cfg(feature = "ed-on-bls12-377")]
44pub mod ed_on_bls12_377;
45#[cfg(feature = "ed-on-bls12-381-bandersnatch")]
46pub mod ed_on_bls12_381_bandersnatch;
47#[cfg(feature = "pallas")]
48pub mod pallas;
49#[cfg(feature = "vesta")]
50pub mod vesta;
51
52#[cfg(any(
53 feature = "bls12-377",
54 feature = "bls12-381",
55 feature = "bw6-761",
56 feature = "ed-on-bls12-377",
57 feature = "ed-on-bls12-381-bandersnatch",
58 feature = "pallas",
59 feature = "vesta",
60))]
61mod utils;
62
63/// Host functions to speed up Elliptic Curve math.
64///
65/// Provides: BLS12-381, Ed-on-BLS12-381-Bandersnatch, Pallas, Vesta.
66///
67/// As ratified by [RFC-0163](https://github.com/polkadot-fellows/RFCs/pull/163).
68#[cfg(feature = "rfc163")]
69pub type HostFunctionsRfc163 = (
70 bls12_381::host_calls::HostFunctions,
71 ed_on_bls12_381_bandersnatch::host_calls::HostFunctions,
72 pallas::host_calls::HostFunctions,
73 vesta::host_calls::HostFunctions,
74);