1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct SignGenericRequest {
4 #[prost(string, tag = "1")]
6 pub public_key_g1: ::prost::alloc::string::String,
7 #[prost(bytes = "vec", tag = "2")]
9 pub data: ::prost::alloc::vec::Vec<u8>,
10 #[prost(string, tag = "3")]
12 pub password: ::prost::alloc::string::String,
13}
14#[allow(clippy::derive_partial_eq_without_eq)]
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct SignGenericResponse {
17 #[prost(bytes = "vec", tag = "1")]
19 pub signature: ::prost::alloc::vec::Vec<u8>,
20}
21#[allow(clippy::derive_partial_eq_without_eq)]
22#[derive(Clone, PartialEq, ::prost::Message)]
23pub struct SignG1Request {
24 #[prost(string, tag = "1")]
26 pub public_key_g1: ::prost::alloc::string::String,
27 #[prost(bytes = "vec", tag = "2")]
30 pub data: ::prost::alloc::vec::Vec<u8>,
31 #[prost(string, tag = "3")]
33 pub password: ::prost::alloc::string::String,
34}
35#[allow(clippy::derive_partial_eq_without_eq)]
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct SignG1Response {
38 #[prost(bytes = "vec", tag = "1")]
40 pub signature: ::prost::alloc::vec::Vec<u8>,
41}
42pub mod signer_client {
44 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
45 use tonic::codegen::*;
46 use tonic::codegen::http::Uri;
47 #[derive(Debug, Clone)]
48 pub struct SignerClient<T> {
49 inner: tonic::client::Grpc<T>,
50 }
51 impl SignerClient<tonic::transport::Channel> {
52 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
54 where
55 D: TryInto<tonic::transport::Endpoint>,
56 D::Error: Into<StdError>,
57 {
58 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
59 Ok(Self::new(conn))
60 }
61 }
62 impl<T> SignerClient<T>
63 where
64 T: tonic::client::GrpcService<tonic::body::BoxBody>,
65 T::Error: Into<StdError>,
66 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
67 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
68 {
69 pub fn new(inner: T) -> Self {
70 let inner = tonic::client::Grpc::new(inner);
71 Self { inner }
72 }
73 pub fn with_origin(inner: T, origin: Uri) -> Self {
74 let inner = tonic::client::Grpc::with_origin(inner, origin);
75 Self { inner }
76 }
77 pub fn with_interceptor<F>(
78 inner: T,
79 interceptor: F,
80 ) -> SignerClient<InterceptedService<T, F>>
81 where
82 F: tonic::service::Interceptor,
83 T::ResponseBody: Default,
84 T: tonic::codegen::Service<
85 http::Request<tonic::body::BoxBody>,
86 Response = http::Response<
87 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
88 >,
89 >,
90 <T as tonic::codegen::Service<
91 http::Request<tonic::body::BoxBody>,
92 >>::Error: Into<StdError> + Send + Sync,
93 {
94 SignerClient::new(InterceptedService::new(inner, interceptor))
95 }
96 #[must_use]
101 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
102 self.inner = self.inner.send_compressed(encoding);
103 self
104 }
105 #[must_use]
107 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
108 self.inner = self.inner.accept_compressed(encoding);
109 self
110 }
111 #[must_use]
115 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
116 self.inner = self.inner.max_decoding_message_size(limit);
117 self
118 }
119 #[must_use]
123 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
124 self.inner = self.inner.max_encoding_message_size(limit);
125 self
126 }
127 pub async fn sign_generic(
128 &mut self,
129 request: impl tonic::IntoRequest<super::SignGenericRequest>,
130 ) -> std::result::Result<
131 tonic::Response<super::SignGenericResponse>,
132 tonic::Status,
133 > {
134 self.inner
135 .ready()
136 .await
137 .map_err(|e| {
138 tonic::Status::new(
139 tonic::Code::Unknown,
140 format!("Service was not ready: {}", e.into()),
141 )
142 })?;
143 let codec = tonic::codec::ProstCodec::default();
144 let path = http::uri::PathAndQuery::from_static(
145 "/signer.v1.Signer/SignGeneric",
146 );
147 let mut req = request.into_request();
148 req.extensions_mut()
149 .insert(GrpcMethod::new("signer.v1.Signer", "SignGeneric"));
150 self.inner.unary(req, path, codec).await
151 }
152 pub async fn sign_g1(
153 &mut self,
154 request: impl tonic::IntoRequest<super::SignG1Request>,
155 ) -> std::result::Result<tonic::Response<super::SignG1Response>, tonic::Status> {
156 self.inner
157 .ready()
158 .await
159 .map_err(|e| {
160 tonic::Status::new(
161 tonic::Code::Unknown,
162 format!("Service was not ready: {}", e.into()),
163 )
164 })?;
165 let codec = tonic::codec::ProstCodec::default();
166 let path = http::uri::PathAndQuery::from_static("/signer.v1.Signer/SignG1");
167 let mut req = request.into_request();
168 req.extensions_mut().insert(GrpcMethod::new("signer.v1.Signer", "SignG1"));
169 self.inner.unary(req, path, codec).await
170 }
171 }
172}
173pub mod signer_server {
175 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
176 use tonic::codegen::*;
177 #[async_trait]
179 pub trait Signer: Send + Sync + 'static {
180 async fn sign_generic(
181 &self,
182 request: tonic::Request<super::SignGenericRequest>,
183 ) -> std::result::Result<
184 tonic::Response<super::SignGenericResponse>,
185 tonic::Status,
186 >;
187 async fn sign_g1(
188 &self,
189 request: tonic::Request<super::SignG1Request>,
190 ) -> std::result::Result<tonic::Response<super::SignG1Response>, tonic::Status>;
191 }
192 #[derive(Debug)]
193 pub struct SignerServer<T: Signer> {
194 inner: _Inner<T>,
195 accept_compression_encodings: EnabledCompressionEncodings,
196 send_compression_encodings: EnabledCompressionEncodings,
197 max_decoding_message_size: Option<usize>,
198 max_encoding_message_size: Option<usize>,
199 }
200 struct _Inner<T>(Arc<T>);
201 impl<T: Signer> SignerServer<T> {
202 pub fn new(inner: T) -> Self {
203 Self::from_arc(Arc::new(inner))
204 }
205 pub fn from_arc(inner: Arc<T>) -> Self {
206 let inner = _Inner(inner);
207 Self {
208 inner,
209 accept_compression_encodings: Default::default(),
210 send_compression_encodings: Default::default(),
211 max_decoding_message_size: None,
212 max_encoding_message_size: None,
213 }
214 }
215 pub fn with_interceptor<F>(
216 inner: T,
217 interceptor: F,
218 ) -> InterceptedService<Self, F>
219 where
220 F: tonic::service::Interceptor,
221 {
222 InterceptedService::new(Self::new(inner), interceptor)
223 }
224 #[must_use]
226 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
227 self.accept_compression_encodings.enable(encoding);
228 self
229 }
230 #[must_use]
232 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
233 self.send_compression_encodings.enable(encoding);
234 self
235 }
236 #[must_use]
240 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
241 self.max_decoding_message_size = Some(limit);
242 self
243 }
244 #[must_use]
248 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
249 self.max_encoding_message_size = Some(limit);
250 self
251 }
252 }
253 impl<T, B> tonic::codegen::Service<http::Request<B>> for SignerServer<T>
254 where
255 T: Signer,
256 B: Body + Send + 'static,
257 B::Error: Into<StdError> + Send + 'static,
258 {
259 type Response = http::Response<tonic::body::BoxBody>;
260 type Error = std::convert::Infallible;
261 type Future = BoxFuture<Self::Response, Self::Error>;
262 fn poll_ready(
263 &mut self,
264 _cx: &mut Context<'_>,
265 ) -> Poll<std::result::Result<(), Self::Error>> {
266 Poll::Ready(Ok(()))
267 }
268 fn call(&mut self, req: http::Request<B>) -> Self::Future {
269 let inner = self.inner.clone();
270 match req.uri().path() {
271 "/signer.v1.Signer/SignGeneric" => {
272 #[allow(non_camel_case_types)]
273 struct SignGenericSvc<T: Signer>(pub Arc<T>);
274 impl<
275 T: Signer,
276 > tonic::server::UnaryService<super::SignGenericRequest>
277 for SignGenericSvc<T> {
278 type Response = super::SignGenericResponse;
279 type Future = BoxFuture<
280 tonic::Response<Self::Response>,
281 tonic::Status,
282 >;
283 fn call(
284 &mut self,
285 request: tonic::Request<super::SignGenericRequest>,
286 ) -> Self::Future {
287 let inner = Arc::clone(&self.0);
288 let fut = async move {
289 (*inner).sign_generic(request).await
290 };
291 Box::pin(fut)
292 }
293 }
294 let accept_compression_encodings = self.accept_compression_encodings;
295 let send_compression_encodings = self.send_compression_encodings;
296 let max_decoding_message_size = self.max_decoding_message_size;
297 let max_encoding_message_size = self.max_encoding_message_size;
298 let inner = self.inner.clone();
299 let fut = async move {
300 let inner = inner.0;
301 let method = SignGenericSvc(inner);
302 let codec = tonic::codec::ProstCodec::default();
303 let mut grpc = tonic::server::Grpc::new(codec)
304 .apply_compression_config(
305 accept_compression_encodings,
306 send_compression_encodings,
307 )
308 .apply_max_message_size_config(
309 max_decoding_message_size,
310 max_encoding_message_size,
311 );
312 let res = grpc.unary(method, req).await;
313 Ok(res)
314 };
315 Box::pin(fut)
316 }
317 "/signer.v1.Signer/SignG1" => {
318 #[allow(non_camel_case_types)]
319 struct SignG1Svc<T: Signer>(pub Arc<T>);
320 impl<T: Signer> tonic::server::UnaryService<super::SignG1Request>
321 for SignG1Svc<T> {
322 type Response = super::SignG1Response;
323 type Future = BoxFuture<
324 tonic::Response<Self::Response>,
325 tonic::Status,
326 >;
327 fn call(
328 &mut self,
329 request: tonic::Request<super::SignG1Request>,
330 ) -> Self::Future {
331 let inner = Arc::clone(&self.0);
332 let fut = async move { (*inner).sign_g1(request).await };
333 Box::pin(fut)
334 }
335 }
336 let accept_compression_encodings = self.accept_compression_encodings;
337 let send_compression_encodings = self.send_compression_encodings;
338 let max_decoding_message_size = self.max_decoding_message_size;
339 let max_encoding_message_size = self.max_encoding_message_size;
340 let inner = self.inner.clone();
341 let fut = async move {
342 let inner = inner.0;
343 let method = SignG1Svc(inner);
344 let codec = tonic::codec::ProstCodec::default();
345 let mut grpc = tonic::server::Grpc::new(codec)
346 .apply_compression_config(
347 accept_compression_encodings,
348 send_compression_encodings,
349 )
350 .apply_max_message_size_config(
351 max_decoding_message_size,
352 max_encoding_message_size,
353 );
354 let res = grpc.unary(method, req).await;
355 Ok(res)
356 };
357 Box::pin(fut)
358 }
359 _ => {
360 Box::pin(async move {
361 Ok(
362 http::Response::builder()
363 .status(200)
364 .header("grpc-status", "12")
365 .header("content-type", "application/grpc")
366 .body(empty_body())
367 .unwrap(),
368 )
369 })
370 }
371 }
372 }
373 }
374 impl<T: Signer> Clone for SignerServer<T> {
375 fn clone(&self) -> Self {
376 let inner = self.inner.clone();
377 Self {
378 inner,
379 accept_compression_encodings: self.accept_compression_encodings,
380 send_compression_encodings: self.send_compression_encodings,
381 max_decoding_message_size: self.max_decoding_message_size,
382 max_encoding_message_size: self.max_encoding_message_size,
383 }
384 }
385 }
386 impl<T: Signer> Clone for _Inner<T> {
387 fn clone(&self) -> Self {
388 Self(Arc::clone(&self.0))
389 }
390 }
391 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
392 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
393 write!(f, "{:?}", self.0)
394 }
395 }
396 impl<T: Signer> tonic::server::NamedService for SignerServer<T> {
397 const NAME: &'static str = "signer.v1.Signer";
398 }
399}