1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct GenerateKeyPairRequest {
4 #[prost(string, tag = "1")]
7 pub password: ::prost::alloc::string::String,
8}
9#[allow(clippy::derive_partial_eq_without_eq)]
10#[derive(Clone, PartialEq, ::prost::Message)]
11pub struct GenerateKeyPairResponse {
12 #[prost(string, tag = "1")]
14 pub public_key_g1: ::prost::alloc::string::String,
15 #[prost(string, tag = "2")]
17 pub private_key: ::prost::alloc::string::String,
18 #[prost(string, tag = "3")]
20 pub mnemonic: ::prost::alloc::string::String,
21 #[prost(string, tag = "4")]
23 pub public_key_g2: ::prost::alloc::string::String,
24 #[prost(string, tag = "5")]
26 pub api_key: ::prost::alloc::string::String,
27}
28#[allow(clippy::derive_partial_eq_without_eq)]
29#[derive(Clone, PartialEq, ::prost::Message)]
30pub struct ImportKeyRequest {
31 #[prost(string, tag = "1")]
33 pub private_key: ::prost::alloc::string::String,
34 #[prost(string, tag = "2")]
36 pub mnemonic: ::prost::alloc::string::String,
37 #[prost(string, tag = "3")]
39 pub password: ::prost::alloc::string::String,
40}
41#[allow(clippy::derive_partial_eq_without_eq)]
42#[derive(Clone, PartialEq, ::prost::Message)]
43pub struct ImportKeyResponse {
44 #[prost(string, tag = "1")]
46 pub public_key_g1: ::prost::alloc::string::String,
47 #[prost(string, tag = "2")]
49 pub public_key_g2: ::prost::alloc::string::String,
50 #[prost(string, tag = "3")]
52 pub api_key: ::prost::alloc::string::String,
53}
54#[allow(clippy::derive_partial_eq_without_eq)]
55#[derive(Clone, PartialEq, ::prost::Message)]
56pub struct PublicKey {
57 #[prost(string, tag = "1")]
59 pub public_key_g1: ::prost::alloc::string::String,
60 #[prost(string, tag = "2")]
62 pub public_key_g2: ::prost::alloc::string::String,
63}
64#[allow(clippy::derive_partial_eq_without_eq)]
65#[derive(Clone, PartialEq, ::prost::Message)]
66pub struct ListKeysRequest {}
67#[allow(clippy::derive_partial_eq_without_eq)]
68#[derive(Clone, PartialEq, ::prost::Message)]
69pub struct ListKeysResponse {
70 #[prost(message, repeated, tag = "1")]
72 pub public_keys: ::prost::alloc::vec::Vec<PublicKey>,
73}
74#[allow(clippy::derive_partial_eq_without_eq)]
75#[derive(Clone, PartialEq, ::prost::Message)]
76pub struct GetKeyMetadataRequest {
77 #[prost(string, tag = "1")]
79 pub public_key_g1: ::prost::alloc::string::String,
80}
81#[allow(clippy::derive_partial_eq_without_eq)]
82#[derive(Clone, PartialEq, ::prost::Message)]
83pub struct GetKeyMetadataResponse {
84 #[prost(string, tag = "1")]
86 pub public_key_g1: ::prost::alloc::string::String,
87 #[prost(string, tag = "2")]
89 pub public_key_g2: ::prost::alloc::string::String,
90 #[prost(int64, tag = "3")]
92 pub created_at: i64,
93 #[prost(int64, tag = "4")]
95 pub updated_at: i64,
96}
97pub mod key_manager_client {
99 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
100 use tonic::codegen::*;
101 use tonic::codegen::http::Uri;
102 #[derive(Debug, Clone)]
103 pub struct KeyManagerClient<T> {
104 inner: tonic::client::Grpc<T>,
105 }
106 impl KeyManagerClient<tonic::transport::Channel> {
107 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
109 where
110 D: TryInto<tonic::transport::Endpoint>,
111 D::Error: Into<StdError>,
112 {
113 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
114 Ok(Self::new(conn))
115 }
116 }
117 impl<T> KeyManagerClient<T>
118 where
119 T: tonic::client::GrpcService<tonic::body::BoxBody>,
120 T::Error: Into<StdError>,
121 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
122 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
123 {
124 pub fn new(inner: T) -> Self {
125 let inner = tonic::client::Grpc::new(inner);
126 Self { inner }
127 }
128 pub fn with_origin(inner: T, origin: Uri) -> Self {
129 let inner = tonic::client::Grpc::with_origin(inner, origin);
130 Self { inner }
131 }
132 pub fn with_interceptor<F>(
133 inner: T,
134 interceptor: F,
135 ) -> KeyManagerClient<InterceptedService<T, F>>
136 where
137 F: tonic::service::Interceptor,
138 T::ResponseBody: Default,
139 T: tonic::codegen::Service<
140 http::Request<tonic::body::BoxBody>,
141 Response = http::Response<
142 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
143 >,
144 >,
145 <T as tonic::codegen::Service<
146 http::Request<tonic::body::BoxBody>,
147 >>::Error: Into<StdError> + Send + Sync,
148 {
149 KeyManagerClient::new(InterceptedService::new(inner, interceptor))
150 }
151 #[must_use]
156 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
157 self.inner = self.inner.send_compressed(encoding);
158 self
159 }
160 #[must_use]
162 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
163 self.inner = self.inner.accept_compressed(encoding);
164 self
165 }
166 #[must_use]
170 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
171 self.inner = self.inner.max_decoding_message_size(limit);
172 self
173 }
174 #[must_use]
178 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
179 self.inner = self.inner.max_encoding_message_size(limit);
180 self
181 }
182 pub async fn generate_key_pair(
183 &mut self,
184 request: impl tonic::IntoRequest<super::GenerateKeyPairRequest>,
185 ) -> std::result::Result<
186 tonic::Response<super::GenerateKeyPairResponse>,
187 tonic::Status,
188 > {
189 self.inner
190 .ready()
191 .await
192 .map_err(|e| {
193 tonic::Status::new(
194 tonic::Code::Unknown,
195 format!("Service was not ready: {}", e.into()),
196 )
197 })?;
198 let codec = tonic::codec::ProstCodec::default();
199 let path = http::uri::PathAndQuery::from_static(
200 "/keymanager.v1.KeyManager/GenerateKeyPair",
201 );
202 let mut req = request.into_request();
203 req.extensions_mut()
204 .insert(GrpcMethod::new("keymanager.v1.KeyManager", "GenerateKeyPair"));
205 self.inner.unary(req, path, codec).await
206 }
207 pub async fn import_key(
208 &mut self,
209 request: impl tonic::IntoRequest<super::ImportKeyRequest>,
210 ) -> std::result::Result<
211 tonic::Response<super::ImportKeyResponse>,
212 tonic::Status,
213 > {
214 self.inner
215 .ready()
216 .await
217 .map_err(|e| {
218 tonic::Status::new(
219 tonic::Code::Unknown,
220 format!("Service was not ready: {}", e.into()),
221 )
222 })?;
223 let codec = tonic::codec::ProstCodec::default();
224 let path = http::uri::PathAndQuery::from_static(
225 "/keymanager.v1.KeyManager/ImportKey",
226 );
227 let mut req = request.into_request();
228 req.extensions_mut()
229 .insert(GrpcMethod::new("keymanager.v1.KeyManager", "ImportKey"));
230 self.inner.unary(req, path, codec).await
231 }
232 pub async fn list_keys(
233 &mut self,
234 request: impl tonic::IntoRequest<super::ListKeysRequest>,
235 ) -> std::result::Result<
236 tonic::Response<super::ListKeysResponse>,
237 tonic::Status,
238 > {
239 self.inner
240 .ready()
241 .await
242 .map_err(|e| {
243 tonic::Status::new(
244 tonic::Code::Unknown,
245 format!("Service was not ready: {}", e.into()),
246 )
247 })?;
248 let codec = tonic::codec::ProstCodec::default();
249 let path = http::uri::PathAndQuery::from_static(
250 "/keymanager.v1.KeyManager/ListKeys",
251 );
252 let mut req = request.into_request();
253 req.extensions_mut()
254 .insert(GrpcMethod::new("keymanager.v1.KeyManager", "ListKeys"));
255 self.inner.unary(req, path, codec).await
256 }
257 pub async fn get_key_metadata(
258 &mut self,
259 request: impl tonic::IntoRequest<super::GetKeyMetadataRequest>,
260 ) -> std::result::Result<
261 tonic::Response<super::GetKeyMetadataResponse>,
262 tonic::Status,
263 > {
264 self.inner
265 .ready()
266 .await
267 .map_err(|e| {
268 tonic::Status::new(
269 tonic::Code::Unknown,
270 format!("Service was not ready: {}", e.into()),
271 )
272 })?;
273 let codec = tonic::codec::ProstCodec::default();
274 let path = http::uri::PathAndQuery::from_static(
275 "/keymanager.v1.KeyManager/GetKeyMetadata",
276 );
277 let mut req = request.into_request();
278 req.extensions_mut()
279 .insert(GrpcMethod::new("keymanager.v1.KeyManager", "GetKeyMetadata"));
280 self.inner.unary(req, path, codec).await
281 }
282 }
283}
284pub mod key_manager_server {
286 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
287 use tonic::codegen::*;
288 #[async_trait]
290 pub trait KeyManager: Send + Sync + 'static {
291 async fn generate_key_pair(
292 &self,
293 request: tonic::Request<super::GenerateKeyPairRequest>,
294 ) -> std::result::Result<
295 tonic::Response<super::GenerateKeyPairResponse>,
296 tonic::Status,
297 >;
298 async fn import_key(
299 &self,
300 request: tonic::Request<super::ImportKeyRequest>,
301 ) -> std::result::Result<
302 tonic::Response<super::ImportKeyResponse>,
303 tonic::Status,
304 >;
305 async fn list_keys(
306 &self,
307 request: tonic::Request<super::ListKeysRequest>,
308 ) -> std::result::Result<
309 tonic::Response<super::ListKeysResponse>,
310 tonic::Status,
311 >;
312 async fn get_key_metadata(
313 &self,
314 request: tonic::Request<super::GetKeyMetadataRequest>,
315 ) -> std::result::Result<
316 tonic::Response<super::GetKeyMetadataResponse>,
317 tonic::Status,
318 >;
319 }
320 #[derive(Debug)]
321 pub struct KeyManagerServer<T: KeyManager> {
322 inner: _Inner<T>,
323 accept_compression_encodings: EnabledCompressionEncodings,
324 send_compression_encodings: EnabledCompressionEncodings,
325 max_decoding_message_size: Option<usize>,
326 max_encoding_message_size: Option<usize>,
327 }
328 struct _Inner<T>(Arc<T>);
329 impl<T: KeyManager> KeyManagerServer<T> {
330 pub fn new(inner: T) -> Self {
331 Self::from_arc(Arc::new(inner))
332 }
333 pub fn from_arc(inner: Arc<T>) -> Self {
334 let inner = _Inner(inner);
335 Self {
336 inner,
337 accept_compression_encodings: Default::default(),
338 send_compression_encodings: Default::default(),
339 max_decoding_message_size: None,
340 max_encoding_message_size: None,
341 }
342 }
343 pub fn with_interceptor<F>(
344 inner: T,
345 interceptor: F,
346 ) -> InterceptedService<Self, F>
347 where
348 F: tonic::service::Interceptor,
349 {
350 InterceptedService::new(Self::new(inner), interceptor)
351 }
352 #[must_use]
354 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
355 self.accept_compression_encodings.enable(encoding);
356 self
357 }
358 #[must_use]
360 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
361 self.send_compression_encodings.enable(encoding);
362 self
363 }
364 #[must_use]
368 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
369 self.max_decoding_message_size = Some(limit);
370 self
371 }
372 #[must_use]
376 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
377 self.max_encoding_message_size = Some(limit);
378 self
379 }
380 }
381 impl<T, B> tonic::codegen::Service<http::Request<B>> for KeyManagerServer<T>
382 where
383 T: KeyManager,
384 B: Body + Send + 'static,
385 B::Error: Into<StdError> + Send + 'static,
386 {
387 type Response = http::Response<tonic::body::BoxBody>;
388 type Error = std::convert::Infallible;
389 type Future = BoxFuture<Self::Response, Self::Error>;
390 fn poll_ready(
391 &mut self,
392 _cx: &mut Context<'_>,
393 ) -> Poll<std::result::Result<(), Self::Error>> {
394 Poll::Ready(Ok(()))
395 }
396 fn call(&mut self, req: http::Request<B>) -> Self::Future {
397 let inner = self.inner.clone();
398 match req.uri().path() {
399 "/keymanager.v1.KeyManager/GenerateKeyPair" => {
400 #[allow(non_camel_case_types)]
401 struct GenerateKeyPairSvc<T: KeyManager>(pub Arc<T>);
402 impl<
403 T: KeyManager,
404 > tonic::server::UnaryService<super::GenerateKeyPairRequest>
405 for GenerateKeyPairSvc<T> {
406 type Response = super::GenerateKeyPairResponse;
407 type Future = BoxFuture<
408 tonic::Response<Self::Response>,
409 tonic::Status,
410 >;
411 fn call(
412 &mut self,
413 request: tonic::Request<super::GenerateKeyPairRequest>,
414 ) -> Self::Future {
415 let inner = Arc::clone(&self.0);
416 let fut = async move {
417 (*inner).generate_key_pair(request).await
418 };
419 Box::pin(fut)
420 }
421 }
422 let accept_compression_encodings = self.accept_compression_encodings;
423 let send_compression_encodings = self.send_compression_encodings;
424 let max_decoding_message_size = self.max_decoding_message_size;
425 let max_encoding_message_size = self.max_encoding_message_size;
426 let inner = self.inner.clone();
427 let fut = async move {
428 let inner = inner.0;
429 let method = GenerateKeyPairSvc(inner);
430 let codec = tonic::codec::ProstCodec::default();
431 let mut grpc = tonic::server::Grpc::new(codec)
432 .apply_compression_config(
433 accept_compression_encodings,
434 send_compression_encodings,
435 )
436 .apply_max_message_size_config(
437 max_decoding_message_size,
438 max_encoding_message_size,
439 );
440 let res = grpc.unary(method, req).await;
441 Ok(res)
442 };
443 Box::pin(fut)
444 }
445 "/keymanager.v1.KeyManager/ImportKey" => {
446 #[allow(non_camel_case_types)]
447 struct ImportKeySvc<T: KeyManager>(pub Arc<T>);
448 impl<
449 T: KeyManager,
450 > tonic::server::UnaryService<super::ImportKeyRequest>
451 for ImportKeySvc<T> {
452 type Response = super::ImportKeyResponse;
453 type Future = BoxFuture<
454 tonic::Response<Self::Response>,
455 tonic::Status,
456 >;
457 fn call(
458 &mut self,
459 request: tonic::Request<super::ImportKeyRequest>,
460 ) -> Self::Future {
461 let inner = Arc::clone(&self.0);
462 let fut = async move { (*inner).import_key(request).await };
463 Box::pin(fut)
464 }
465 }
466 let accept_compression_encodings = self.accept_compression_encodings;
467 let send_compression_encodings = self.send_compression_encodings;
468 let max_decoding_message_size = self.max_decoding_message_size;
469 let max_encoding_message_size = self.max_encoding_message_size;
470 let inner = self.inner.clone();
471 let fut = async move {
472 let inner = inner.0;
473 let method = ImportKeySvc(inner);
474 let codec = tonic::codec::ProstCodec::default();
475 let mut grpc = tonic::server::Grpc::new(codec)
476 .apply_compression_config(
477 accept_compression_encodings,
478 send_compression_encodings,
479 )
480 .apply_max_message_size_config(
481 max_decoding_message_size,
482 max_encoding_message_size,
483 );
484 let res = grpc.unary(method, req).await;
485 Ok(res)
486 };
487 Box::pin(fut)
488 }
489 "/keymanager.v1.KeyManager/ListKeys" => {
490 #[allow(non_camel_case_types)]
491 struct ListKeysSvc<T: KeyManager>(pub Arc<T>);
492 impl<
493 T: KeyManager,
494 > tonic::server::UnaryService<super::ListKeysRequest>
495 for ListKeysSvc<T> {
496 type Response = super::ListKeysResponse;
497 type Future = BoxFuture<
498 tonic::Response<Self::Response>,
499 tonic::Status,
500 >;
501 fn call(
502 &mut self,
503 request: tonic::Request<super::ListKeysRequest>,
504 ) -> Self::Future {
505 let inner = Arc::clone(&self.0);
506 let fut = async move { (*inner).list_keys(request).await };
507 Box::pin(fut)
508 }
509 }
510 let accept_compression_encodings = self.accept_compression_encodings;
511 let send_compression_encodings = self.send_compression_encodings;
512 let max_decoding_message_size = self.max_decoding_message_size;
513 let max_encoding_message_size = self.max_encoding_message_size;
514 let inner = self.inner.clone();
515 let fut = async move {
516 let inner = inner.0;
517 let method = ListKeysSvc(inner);
518 let codec = tonic::codec::ProstCodec::default();
519 let mut grpc = tonic::server::Grpc::new(codec)
520 .apply_compression_config(
521 accept_compression_encodings,
522 send_compression_encodings,
523 )
524 .apply_max_message_size_config(
525 max_decoding_message_size,
526 max_encoding_message_size,
527 );
528 let res = grpc.unary(method, req).await;
529 Ok(res)
530 };
531 Box::pin(fut)
532 }
533 "/keymanager.v1.KeyManager/GetKeyMetadata" => {
534 #[allow(non_camel_case_types)]
535 struct GetKeyMetadataSvc<T: KeyManager>(pub Arc<T>);
536 impl<
537 T: KeyManager,
538 > tonic::server::UnaryService<super::GetKeyMetadataRequest>
539 for GetKeyMetadataSvc<T> {
540 type Response = super::GetKeyMetadataResponse;
541 type Future = BoxFuture<
542 tonic::Response<Self::Response>,
543 tonic::Status,
544 >;
545 fn call(
546 &mut self,
547 request: tonic::Request<super::GetKeyMetadataRequest>,
548 ) -> Self::Future {
549 let inner = Arc::clone(&self.0);
550 let fut = async move {
551 (*inner).get_key_metadata(request).await
552 };
553 Box::pin(fut)
554 }
555 }
556 let accept_compression_encodings = self.accept_compression_encodings;
557 let send_compression_encodings = self.send_compression_encodings;
558 let max_decoding_message_size = self.max_decoding_message_size;
559 let max_encoding_message_size = self.max_encoding_message_size;
560 let inner = self.inner.clone();
561 let fut = async move {
562 let inner = inner.0;
563 let method = GetKeyMetadataSvc(inner);
564 let codec = tonic::codec::ProstCodec::default();
565 let mut grpc = tonic::server::Grpc::new(codec)
566 .apply_compression_config(
567 accept_compression_encodings,
568 send_compression_encodings,
569 )
570 .apply_max_message_size_config(
571 max_decoding_message_size,
572 max_encoding_message_size,
573 );
574 let res = grpc.unary(method, req).await;
575 Ok(res)
576 };
577 Box::pin(fut)
578 }
579 _ => {
580 Box::pin(async move {
581 Ok(
582 http::Response::builder()
583 .status(200)
584 .header("grpc-status", "12")
585 .header("content-type", "application/grpc")
586 .body(empty_body())
587 .unwrap(),
588 )
589 })
590 }
591 }
592 }
593 }
594 impl<T: KeyManager> Clone for KeyManagerServer<T> {
595 fn clone(&self) -> Self {
596 let inner = self.inner.clone();
597 Self {
598 inner,
599 accept_compression_encodings: self.accept_compression_encodings,
600 send_compression_encodings: self.send_compression_encodings,
601 max_decoding_message_size: self.max_decoding_message_size,
602 max_encoding_message_size: self.max_encoding_message_size,
603 }
604 }
605 }
606 impl<T: KeyManager> Clone for _Inner<T> {
607 fn clone(&self) -> Self {
608 Self(Arc::clone(&self.0))
609 }
610 }
611 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
612 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
613 write!(f, "{:?}", self.0)
614 }
615 }
616 impl<T: KeyManager> tonic::server::NamedService for KeyManagerServer<T> {
617 const NAME: &'static str = "keymanager.v1.KeyManager";
618 }
619}