identity_jose/jwk/curve/
ed.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 EdCurve {
13  /// Ed25519 signature algorithm key pairs.
14  Ed25519,
15  /// Ed448 signature algorithm key pairs.
16  Ed448,
17}
18
19impl EdCurve {
20  /// Returns the name of the curve as a string slice.
21  pub const fn name(self) -> &'static str {
22    match self {
23      Self::Ed25519 => "Ed25519",
24      Self::Ed448 => "Ed448",
25    }
26  }
27}
28
29impl Display for EdCurve {
30  fn fmt(&self, f: &mut Formatter<'_>) -> Result {
31    f.write_str(self.name())
32  }
33}