identity_storage/key_storage/
jwk_storage_bbs_plus_ext.rs

1// Copyright 2020-2024 IOTA Stiftung, Fondazione Links
2// SPDX-License-Identifier: Apache-2.0
3
4use async_trait::async_trait;
5use identity_verification::jwk::Jwk;
6use jsonprooftoken::jpa::algs::ProofAlgorithm;
7
8use crate::JwkGenOutput;
9use crate::JwkStorage;
10use crate::KeyId;
11use crate::KeyStorageResult;
12use crate::KeyType;
13use crate::ProofUpdateCtx;
14
15/// Extension to the JwkStorage to handle BBS+ keys
16#[cfg_attr(not(feature = "send-sync-storage"), async_trait(?Send))]
17#[cfg_attr(feature = "send-sync-storage", async_trait)]
18pub trait JwkStorageBbsPlusExt: JwkStorage {
19  /// Generates a JWK representing a BBS+ signature
20  async fn generate_bbs(&self, key_type: KeyType, alg: ProofAlgorithm) -> KeyStorageResult<JwkGenOutput>;
21
22  /// Sign the provided `data` and `header` using the private key identified by `key_id` according to the requirements
23  /// of the corresponding `public_key` (see [`Jwk::alg`](Jwk::alg()) etc.).
24  async fn sign_bbs(
25    &self,
26    key_id: &KeyId,
27    data: &[Vec<u8>],
28    header: &[u8],
29    public_key: &Jwk,
30  ) -> KeyStorageResult<Vec<u8>>;
31
32  /// Update proof functionality for timeframe revocation mechanism
33  async fn update_signature(
34    &self,
35    key_id: &KeyId,
36    public_key: &Jwk,
37    signature: &[u8],
38    ctx: ProofUpdateCtx,
39  ) -> KeyStorageResult<Vec<u8>>;
40}