1use ssi_jwk::{Algorithm, JWK};
2
3use crate::sidetree::Sidetree;
4
5#[derive(Default, Clone)]
6pub struct ION;
7
8impl Sidetree for ION {
9 fn generate_key() -> JWK {
10 JWK::generate_secp256k1()
11 }
12
13 fn validate_key(key: &JWK) -> bool {
14 is_secp256k1(key)
15 }
16
17 const SIGNATURE_ALGORITHM: Algorithm = Algorithm::ES256K;
18 const METHOD: &'static str = "ion";
19 const NETWORK: Option<&'static str> = None;
20}
21
22pub fn is_secp256k1(jwk: &JWK) -> bool {
24 matches!(jwk, JWK {params: ssi_jwk::Params::EC(ssi_jwk::ECParams { curve: Some(curve), ..}), ..} if curve == "secp256k1")
25}