identity_jose/jwk/curve/
ecx.rs

1// Copyright 2020-2023 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use core::fmt::Display;
5use core::fmt::Formatter;
6use core::fmt::Result;
7
8/// Supported Elliptic Curves.
9///
10/// [More Info](https://www.iana.org/assignments/jose/jose.xhtml#web-key-elliptic-curve)
11#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
12pub enum EcxCurve {
13  /// X25519 function key pairs.
14  X25519,
15  /// X448 function key pairs.
16  X448,
17}
18
19impl EcxCurve {
20  /// Returns the name of the curve as a string slice.
21  pub const fn name(self) -> &'static str {
22    match self {
23      Self::X25519 => "X25519",
24      Self::X448 => "X448",
25    }
26  }
27}
28
29impl Display for EcxCurve {
30  fn fmt(&self, f: &mut Formatter<'_>) -> Result {
31    f.write_str(self.name())
32  }
33}