/// Deserialize a Protobuf public key to a MEGaPublicKey.
Deserialize a Protobuf public key to a MEGaPublicKey.
Deserialize a Protobuf public key to a MEGaPublicKey .
fn mega_public_key_from_proto(
    proto: &PublicKeyProto,
    node_id: &NodeId,
) -> Result<MEGaPublicKey, MegaKeyFromRegistryError> {
    let curve_type = match AlgorithmIdProto::from_i32(proto.algorithm) {
        Some(AlgorithmIdProto::MegaSecp256k1) => Ok(EccCurveType::K256),
        alg_id => Err(MegaKeyFromRegistryError::UnsupportedAlgorithm {
            algorithm_id: alg_id,
        }),
    }?;
    MEGaPublicKey::deserialize(curve_type, &proto.key_value).map_err(|_| {
        MegaKeyFromRegistryError::MalformedPublicKey {
            node_id: *node_id,
            key_bytes: proto.key_value.clone(),
        }
    })
}
fn mega_public_key_from_proto ( proto : & PublicKeyProto , node_id : & NodeId , ) -> Result < MEGaPublicKey , MegaKeyFromRegistryError > { let curve_type = match AlgorithmIdProto :: from_i32 ( proto . algorithm ) { Some ( AlgorithmIdProto :: MegaSecp256k1 ) => Ok ( EccCurveType :: K256 ) , alg_id => Err ( MegaKeyFromRegistryError :: UnsupportedAlgorithm { algorithm_id : alg_id , } ) , } ? ; MEGaPublicKey :: deserialize ( curve_type , & proto . key_value ) . map_err ( | _ | { MegaKeyFromRegistryError :: MalformedPublicKey { node_id : * node_id , key_bytes : proto . key_value . clone ( ) , } } ) }
Deserialize a Protobuf public key to a MEGaPublicKey.
Deserialize a Protobuf public key to a MEGaPublicKey .
proto
&PublicKeyProto
node_id
&NodeId