identity_storage/key_storage/
jwk_storage_pqc.rs

1// Copyright 2020-2025 IOTA Stiftung, Fondazione Links
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::key_storage::KeyId;
5use crate::key_storage::KeyType;
6use async_trait::async_trait;
7use identity_verification::jose::jws::JwsAlgorithm;
8use identity_verification::jwk::PostQuantumJwk;
9
10use super::jwk_gen_output::JwkGenOutput;
11use super::JwkStorage;
12use super::KeyStorageResult;
13
14/// Extension to the JwkStorage to handle post-quantum keys.
15#[cfg_attr(not(feature = "send-sync-storage"), async_trait(?Send))]
16#[cfg_attr(feature = "send-sync-storage", async_trait)]
17pub trait JwkStoragePQ: JwkStorage {
18  /// Generates a JWK representing a PQ key.
19  async fn generate_pq_key(&self, key_type: KeyType, alg: JwsAlgorithm) -> KeyStorageResult<JwkGenOutput>;
20
21  /// Sign the provided `data` using a PQ algorithm, ctx is optional for the ctx paramter of the algorithm ML-DSA.
22  async fn pq_sign(
23    &self,
24    key_id: &KeyId,
25    data: &[u8],
26    public_key: &PostQuantumJwk,
27    ctx: Option<&[u8]>,
28  ) -> KeyStorageResult<Vec<u8>>;
29}