Skip to main content

confium_pkcs11_server/
token.rs

1//! PKCS#11 token model.
2
3use crate::slot::SlotId;
4use serde::{Deserialize, Serialize};
5
6/// Token info (per PKCS#11 `CK_TOKEN_INFO`).
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct TokenInfo {
9    /// Slot this token is in.
10    pub slot: SlotId,
11    /// Token label (32 bytes in real PKCS#11).
12    pub label: String,
13    /// Threshold quorum size.
14    pub threshold: u32,
15    /// Total parties N.
16    pub num_parties: u32,
17    /// Signing algorithm.
18    pub signing_algorithm: String,
19    /// Quorum coordinator URL.
20    pub coordinator: String,
21}
22
23impl TokenInfo {
24    /// Construct for a Confium-backed quorum.
25    pub fn for_quorum(
26        slot: SlotId,
27        quorum_id: &str,
28        threshold: u32,
29        num_parties: u32,
30        signing_algorithm: &str,
31        coordinator: &str,
32    ) -> Self {
33        Self {
34            slot,
35            label: format!("Confium/{quorum_id}"),
36            threshold,
37            num_parties,
38            signing_algorithm: signing_algorithm.into(),
39            coordinator: coordinator.into(),
40        }
41    }
42}