diff --git a/src/server.rs b/src/server.rs index 5e57844..bfaf0cf 100644 --- a/src/server.rs +++ b/src/server.rs @@ -211,7 +211,8 @@ impl RpcServer for RpcServerImpl { match submit_request.proof_request_type { ProofRequest::Register { .. } | ProofRequest::RegisterId { .. } - | ProofRequest::RegisterAadhaar { .. } => { + | ProofRequest::RegisterAadhaar { .. } + | ProofRequest::RegisterKyc { .. } => { if !cfg!(feature = "register") && !cfg!(feature = "cherrypick") { self.store.remove_agreement(&uuid).await; return invalid_proof_type_response; @@ -225,7 +226,8 @@ impl RpcServer for RpcServerImpl { } ProofRequest::Disclose { .. } | ProofRequest::DiscloseId { .. } - | ProofRequest::DiscloseAadhaar { .. } => { + | ProofRequest::DiscloseAadhaar { .. } + | ProofRequest::DiscloseKyc { .. } => { if !cfg!(feature = "disclose") && !cfg!(feature = "cherrypick") { self.store.remove_agreement(&uuid).await; return invalid_proof_type_response; @@ -320,6 +322,23 @@ impl RpcServer for RpcServerImpl { user_defined_data.as_str(), *version as i32, ), + ProofRequest::RegisterKyc { + endpoint_type, + endpoint, + .. + } => (endpoint_type.as_ref(), endpoint.as_ref(), "", 1), + ProofRequest::DiscloseKyc { + endpoint_type, + endpoint, + user_defined_data, + version, + .. + } => ( + Some(endpoint_type), + Some(endpoint), + user_defined_data.as_str(), + *version as i32, + ), }; if let Err(e) = create_proof_status( diff --git a/src/types.rs b/src/types.rs index 6cd5bd0..cb7f9b2 100644 --- a/src/types.rs +++ b/src/types.rs @@ -111,6 +111,22 @@ pub enum ProofRequest { #[serde(default = "default_version")] version: u32, }, + #[serde(rename_all = "camelCase")] + RegisterKyc { + circuit: Circuit, + endpoint_type: Option, + endpoint: Option, + }, + #[serde(rename_all = "camelCase")] + DiscloseKyc { + circuit: Circuit, + endpoint_type: EndpointType, + endpoint: String, + #[serde(default = "default_user_defined_data")] + user_defined_data: String, + #[serde(default = "default_version")] + version: u32, + }, } impl ProofRequest { @@ -124,6 +140,8 @@ impl ProofRequest { ProofRequest::DiscloseId { circuit, .. } => circuit, ProofRequest::RegisterAadhaar { circuit, .. } => circuit, ProofRequest::DiscloseAadhaar { circuit, .. } => circuit, + ProofRequest::RegisterKyc { circuit, .. } => circuit, + ProofRequest::DiscloseKyc { circuit, .. } => circuit, } } } @@ -138,6 +156,8 @@ pub enum ProofType { DiscloseId, RegisterAadhaar, DiscloseAadhaar, + RegisterKyc, + DiscloseKyc, } impl Into for &ProofRequest { @@ -151,6 +171,8 @@ impl Into for &ProofRequest { ProofRequest::DiscloseId { .. } => ProofType::DiscloseId, ProofRequest::RegisterAadhaar { .. } => ProofType::RegisterAadhaar, ProofRequest::DiscloseAadhaar { .. } => ProofType::DiscloseAadhaar, + ProofRequest::RegisterKyc { .. } => ProofType::RegisterKyc, + ProofRequest::DiscloseKyc { .. } => ProofType::DiscloseKyc, } } } @@ -166,6 +188,8 @@ impl std::fmt::Display for ProofType { ProofType::DiscloseId => write!(f, "disclose_id"), ProofType::RegisterAadhaar => write!(f, "register_aadhaar"), ProofType::DiscloseAadhaar => write!(f, "disclose_aadhaar"), + ProofType::RegisterKyc => write!(f, "register_kyc"), + ProofType::DiscloseKyc => write!(f, "disclose_kyc"), } } } @@ -181,6 +205,8 @@ impl Into for &ProofType { ProofType::DiscloseId => 5, ProofType::RegisterAadhaar => 6, ProofType::DiscloseAadhaar => 7, + ProofType::RegisterKyc => 8, + ProofType::DiscloseKyc => 9, } } } @@ -197,6 +223,8 @@ impl TryFrom for ProofType { 5 => Ok(ProofType::DiscloseId), 6 => Ok(ProofType::RegisterAadhaar), 7 => Ok(ProofType::DiscloseAadhaar), + 8 => Ok(ProofType::RegisterKyc), + 9 => Ok(ProofType::DiscloseKyc), _ => Err(()), } }