Skip to main content

confium_tc_cmp20/
scheme.rs

1//! CMP20 scheme registration.
2//!
3//! Two logical operations — DKG and signing — exposed as two scheme
4//! names so the framework's single-name/single-kind `TcScheme` trait
5//! can route each.
6//!
7//! | Name                    | Kind        | Produces                          |
8//! |------------------------|-------------|-----------------------------------|
9//! | `CMP20-ECDSA-P256`       | `Dkg`       | per-party `Cmp20Share` + pubkey    |
10//! | `CMP20-ECDSA-P256-SIGN`  | `Signature` | 64-byte `(r, s)` ECDSA signature  |
11
12use confium_tc::Result;
13use confium_tc::registry::{SessionImpl, TcScheme, TcSchemeKind};
14use confium_tc::session::SessionParams;
15
16use crate::keygen::Cmp20DkgP256;
17use crate::sign::Cmp20SignP256;
18
19/// CMP20 DKG scheme (registered as `CMP20-ECDSA-P256`).
20pub struct Cmp20EcdsaP256;
21
22impl TcScheme for Cmp20EcdsaP256 {
23    fn name(&self) -> &'static str {
24        crate::DKG_SCHEME_NAME
25    }
26    fn kind(&self) -> TcSchemeKind {
27        TcSchemeKind::Dkg
28    }
29    fn create_session(&self, params: &SessionParams) -> Result<Box<dyn SessionImpl>> {
30        Cmp20DkgP256::build_session(params)
31    }
32}
33
34/// CMP20 signing scheme (registered as `CMP20-ECDSA-P256-SIGN`).
35pub struct Cmp20EcdsaP256Sign;
36
37impl TcScheme for Cmp20EcdsaP256Sign {
38    fn name(&self) -> &'static str {
39        crate::SIGN_SCHEME_NAME
40    }
41    fn kind(&self) -> TcSchemeKind {
42        TcSchemeKind::Signature
43    }
44    fn create_session(&self, params: &SessionParams) -> Result<Box<dyn SessionImpl>> {
45        Cmp20SignP256::build_session(params)
46    }
47}
48
49confium_tc::register_tc_scheme!(Cmp20EcdsaP256);
50confium_tc::register_tc_scheme!(Cmp20EcdsaP256Sign);