dkls23/keygen/
constants.rs

1// Copyright (c) Silence Laboratories Pte. Ltd. All Rights Reserved.
2// This software is licensed under the Silence Laboratories License Agreement.
3
4//! This module defines all the constants used throughout the DKG protocol,
5//! including message tags, labels for cryptographic operations, and protocol-specific
6//! identifiers. These constants ensure consistent message handling and cryptographic
7//! operations across all protocol participants.
8
9use crate::VERSION;
10use sl_mpc_mate::message::MessageTag;
11use sl_oblivious::label::Label;
12
13/// Label used for the key generation protocol.
14/// This label is used to derive protocol-specific keys and nonces.
15pub const DKG_LABEL: Label = Label::new(VERSION, 100);
16
17/// Label used for the first commitment in the protocol.
18/// This commitment is used to ensure participants are bound to their initial values.
19pub const COMMITMENT_1_LABEL: Label = Label::new(VERSION, 101);
20
21/// Label used for the second commitment in the protocol.
22/// This commitment is used to ensure participants are bound to their final values.
23pub const COMMITMENT_2_LABEL: Label = Label::new(VERSION, 102);
24
25/// Label used for the first discrete logarithm proof.
26/// This proof ensures the validity of certain cryptographic operations.
27pub const DLOG_PROOF1_LABEL: Label = Label::new(VERSION, 103);
28
29/// Label used for the second discrete logarithm proof.
30/// This proof ensures the validity of certain cryptographic operations.
31pub const DLOG_PROOF2_LABEL: Label = Label::new(VERSION, 104);
32
33/// Label used to create a discrete logarithm session ID from the final session ID and root chain code.
34/// This is used to ensure proper session management and key derivation.
35pub const DLOG_SESSION_ID_WITH_CHAIN_CODE: Label = Label::new(VERSION, 105);
36
37/// Label used for the quorum change protocol.
38/// This label is used to derive protocol-specific keys and nonces for quorum changes.
39pub const QC_LABEL: Label = Label::new(VERSION, 106);
40
41/// Label used for the first commitment in the quorum change protocol.
42/// This commitment is used to ensure participants are bound to their initial values.
43pub const QC_COMMITMENT_1_LABEL: Label = Label::new(VERSION, 107);
44
45/// Label used for the second commitment in the quorum change protocol.
46/// This commitment is used to ensure participants are bound to their final values.
47pub const QC_COMMITMENT_2_LABEL: Label = Label::new(VERSION, 108);
48
49/// Message tag for the first round of the DKG protocol.
50/// This message contains initial commitments and setup information.
51pub const DKG_MSG_R1: MessageTag = MessageTag::tag(1);
52
53/// Message tag for the second round of the DKG protocol.
54/// This message contains responses to the initial commitments.
55pub const DKG_MSG_R2: MessageTag = MessageTag::tag(2);
56
57/// Message tag for the first round of oblivious transfer in the DKG protocol.
58/// This message is sent peer-to-peer between participants.
59pub const DKG_MSG_OT1: MessageTag = MessageTag::tag(3);
60
61/// Message tag for the third round of the DKG protocol.
62/// This message contains final commitments and proofs.
63pub const DKG_MSG_R3: MessageTag = MessageTag::tag(4);
64
65/// Message tag for the fourth round of the DKG protocol.
66/// This message contains the final key shares and verification information.
67pub const DKG_MSG_R4: MessageTag = MessageTag::tag(5);
68
69/// Message tag for the initial round of the quorum change protocol.
70/// This message contains the request to change the quorum.
71pub const QC_MSG_R0: MessageTag = MessageTag::tag(10);
72
73/// Message tag for the first round of the quorum change protocol.
74/// This message contains initial commitments for the quorum change.
75pub const QC_MSG_R1: MessageTag = MessageTag::tag(11);
76
77/// Message tag for the second round of the quorum change protocol.
78/// This message contains responses to the quorum change commitments.
79pub const QC_MSG_R2: MessageTag = MessageTag::tag(12);
80
81/// Message tag for the first peer-to-peer message in the quorum change protocol.
82/// This message is sent directly between participants.
83pub const QC_MSG_P2P_1: MessageTag = MessageTag::tag(13);
84
85/// Message tag for the second peer-to-peer message in the quorum change protocol.
86/// This message is sent directly between participants.
87pub const QC_MSG_P2P_2: MessageTag = MessageTag::tag(14);
88
89/// Message tag for the first oblivious transfer message in the quorum change protocol.
90/// This message is used for secure information exchange.
91pub const QC_MSG_OT1: MessageTag = MessageTag::tag(15);
92
93/// Message tag for the second oblivious transfer message in the quorum change protocol.
94/// This message is used for secure information exchange.
95pub const QC_MSG_OT2: MessageTag = MessageTag::tag(16);
96
97/// Message tag used to communicate the final result of a keyshare creation or update operation.
98/// This message is sent after all protocol rounds are complete.
99pub const DKG_RECONCILE: MessageTag = MessageTag::tag(u64::MAX - 1);
100
101/// First available message tag for user applications.
102///
103/// Applications should use `MessageTag::tag2(DKG_MSG_APP, app-specific-value)` to create
104/// application-specific message tags. This ensures tags don't conflict with protocol messages.
105///
106/// The value is set to `u32::MAX - 1` to avoid potential conflicts with `ABORT_MESSAGE_TAG`
107/// which is equal to `MessageTag::tag2(u32::MAX, u32::MAX)`.
108pub const DKG_MSG_APP: u32 = u32::MAX - 1;