1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
Copyright Michael Lodder. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
//! Extra Rust Crypto elliptic-curve adaptors, functions, and macros
//!
//! There are some methods that can be applied to many different elliptic curves
//! fields and groups.
//!
//! This crate provides multi-exponentiation functions
//! and `serde` serialization for different types of scalars and groups,
//! including fixed-size array, `Vec`, and `Box<[_]>` collections.
//! These require the `alloc` or `std` feature.
//!
//! Curves still on the `group`/`ff` 0.13 traits (curve25519-dalek, ed448-goldilocks,
//! bls12-381 forks, ...) can use these functions through the `legacy` feature and its
//! `legacy` module.
//!
//! To permit serializing a [`PrimeField`](elliptic_curve::PrimeField)
//!
//! ```
//! use elliptic_curve_tools::prime_field;
//! use elliptic_curve::PrimeField;
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Serialize, Deserialize)]
//! pub struct PrimeFieldWrapper<F: PrimeField>( #[serde(with = "prime_field")] F);
//! ```
//!
//! To permit serializing a [`Group`](elliptic_curve::Group)
//!
//! ```
//! use elliptic_curve_tools::group;
//! use elliptic_curve::{Group, group::GroupEncoding};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Serialize, Deserialize)]
//! pub struct GroupWrapper<G: Group + GroupEncoding>( #[serde(with = "group")] G);
//! ```
//!
//! Other collections can also be serialized like
//! - Fixed sized arrays like `[PrimeField; 32]` or `[Group + GroupEncoding; 32]`
//!
// `serdes` relies on `serde` and `serdect`'s alloc-backed helpers, both of which are
// only enabled through the `alloc`/`std` features; gate the module to match so the
// crate still builds with `--no-default-features`.
extern crate alloc;
extern crate std;
use ;
use ;
pub use ;
pub use *;
pub use *;