pub fn signer_from_jwk(&self, jwk: &Jwk) -> Result<EcdsaJwsSigner, JoseError> {
        (|| -> anyhow::Result<EcdsaJwsSigner> {
            match jwk.key_use() {
                Some(val) if val == "sig" => {}
                None => {}
                Some(val) => bail!("A parameter use must be sig: {}", val),
            }
            if !jwk.is_for_key_operation("sign") {
                bail!("A parameter key_ops must contains sign.");
            }
            match jwk.algorithm() {
                Some(val) if val == self.name() => {}
                Some(val) => bail!("A parameter alg must be {} but {}", self.name(), val),
                None => {}
            }
            match jwk.curve() {
                Some(val) if val == self.curve().name() => {}
                Some(val) => bail!("A parameter crv must be {} but {}", self.name(), val),
                None => bail!("A parameter crv is required."),
            }

            let key_pair = EcKeyPair::from_jwk(jwk)?;
            let private_key = key_pair.into_private_key();
            let key_id = jwk.key_id().map(|val| val.to_string());

            Ok(EcdsaJwsSigner {
                algorithm: self.clone(),
                private_key,
                key_id,
            })
        })()
        .map_err(|err| JoseError::InvalidKeyFormat(err))
    }
/// Return a signer from a private key that is formatted by a JWK of EC type.
///
/// # Arguments
/// * `jwk` - A private key that is formatted by a JWK of EC type.
Return a signer from a private key that is formatted by a JWK of EC type.
Return a signer from a private key that is formatted by a JWK of EC type .
pub fn signer_from_jwk(&self, jwk: &Jwk) -> Result<EcdsaJwsSigner, JoseError> {
        (|| -> anyhow::Result<EcdsaJwsSigner> {
            match jwk.key_use() {
                Some(val) if val == "sig" => {}
                None => {}
                Some(val) => bail!("A parameter use must be sig: {}", val),
            }
            if !jwk.is_for_key_operation("sign") {
                bail!("A parameter key_ops must contains sign.");
            }
            match jwk.algorithm() {
                Some(val) if val == self.name() => {}
                Some(val) => bail!("A parameter alg must be {} but {}", self.name(), val),
                None => {}
            }
            match jwk.curve() {
                Some(val) if val == self.curve().name() => {}
                Some(val) => bail!("A parameter crv must be {} but {}", self.name(), val),
                None => bail!("A parameter crv is required."),
            }
            let key_pair = EcKeyPair::from_jwk(jwk)?;
            let private_key = key_pair.into_private_key();
            let key_id = jwk.key_id().map(|val| val.to_string());
            Ok(EcdsaJwsSigner {
                algorithm: self.clone(),
                private_key,
                key_id,
            })
        })()
        .map_err(|err| JoseError::InvalidKeyFormat(err))
    }
pub fn signer_from_jwk ( & self , jwk : & Jwk ) -> Result < EcdsaJwsSigner , JoseError > { ( | | -> anyhow :: Result < EcdsaJwsSigner > { match jwk . key_use ( ) { Some ( val ) if val == " " => { } None => { } Some ( val ) => bail ! ( " " val ) , } if ! jwk . is_for_key_operation ( " " ) { bail ! ( " " ) ; } match jwk . algorithm ( ) { Some ( val ) if val == self . name ( ) => { } Some ( val ) => bail ! ( " " self name ( ) val ) , None => { } } match jwk . curve ( ) { Some ( val ) if val == self . curve ( ) . name ( ) => { } Some ( val ) => bail ! ( " " self name ( ) val ) , None => bail ! ( " " ) , } let key_pair = EcKeyPair :: from_jwk ( jwk ) ? ; let private_key = key_pair . into_private_key ( ) ; let key_id = jwk . key_id ( ) . map ( | val | val . to_string ( ) ) ; Ok ( EcdsaJwsSigner { algorithm : self . clone ( ) , private_key , key_id , } ) } ) ( ) . map_err ( | err | JoseError :: InvalidKeyFormat ( err ) ) }
Return a signer from a private key that is formatted by a JWK of EC type.
Return a signer from a private key that is formatted by a JWK of EC type .
&self
jwk
&Jwk
&self
jwk
&Jwk