pg_core/
api.rs

1//! Definitions of the PostGuard protocol REST API.
2
3use crate::{artifacts::SigningKeyExt, identity::Attribute};
4use alloc::vec::Vec;
5use irma::{ProofStatus, SessionStatus};
6use serde::{Deserialize, Serialize};
7
8/// The public parameters of the Private Key Generator (PKG).
9#[derive(Debug, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct Parameters<T> {
12    /// The formatting version of the Master Public Key.
13    pub format_version: u8,
14
15    /// The Master Public Key.
16    pub public_key: T,
17}
18
19/// An authentication request for a IRMA identity.
20#[derive(Debug, Serialize, Deserialize)]
21pub struct IrmaAuthRequest {
22    /// The conjunction of [`Attribute`].
23    pub con: Vec<Attribute>,
24    #[serde(skip_serializing_if = "Option::is_none")]
25    /// The validity (in seconds) of the JWT response.
26    pub validity: Option<u64>,
27}
28
29/// The key response from the Private Key Generator (PKG).
30#[derive(Debug, Serialize, Deserialize)]
31#[serde(rename_all = "camelCase")]
32pub struct KeyResponse<T> {
33    /// The status of the session.
34    pub status: SessionStatus,
35
36    /// The status of the IRMA proof.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub proof_status: Option<ProofStatus>,
39
40    /// The key will remain `None` until the status is `Done` and the proof is `Valid`.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub key: Option<T>,
43}
44
45/// The request Signing key request body.
46#[derive(Debug, Serialize, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct SigningKeyRequest {
49    /// The public signing identity.
50    pub pub_sign_id: Vec<Attribute>,
51
52    /// The private signing identity.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub priv_sign_id: Option<Vec<Attribute>>,
55}
56
57/// The signing key response from the Private Key Generator (PKG).
58#[derive(Debug, Serialize, Deserialize)]
59#[serde(rename_all = "camelCase")]
60pub struct SigningKeyResponse {
61    /// The status of the session.
62    pub status: SessionStatus,
63
64    /// The status of the IRMA proof.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub proof_status: Option<ProofStatus>,
67
68    /// The public signing key.
69    /// The key will remain `None` until the status is `Done` and the proof is `Valid`.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub pub_sign_key: Option<SigningKeyExt>,
72
73    /// This private signing key.
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub priv_sign_key: Option<SigningKeyExt>,
76}