Skip to content

Commit b105a4a

Browse files
committed
Improve documentation of cardano modules and structures.
1 parent 2596a7f commit b105a4a

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

mithril-common/src/crypto_helper/cardano/codec.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
//! Module to provide functions to (de)serialise JSON data structures as used in Shelley,
2+
//! which have the following format:
3+
//! ```json
4+
//! {
5+
//! "type": <NAME OF SERIALISED STRUCTURE>,
6+
//! "description": <DESCRIPTION OF SERIALISED STRUCTURE>,
7+
//! "cborHex": <CBOR HEX REPRESENTATION OF SERIALISED STRUCTURE>
8+
//! }
9+
//! ```
10+
//!
11+
//! The trait `SerDeShelleyFileFormat` can be implemented for any structure that implements
12+
//! `Serialize` and `Deserialize`.
13+
114
use hex::FromHex;
215
use kes_summed_ed25519::kes::Sum6Kes;
316
use serde::de::DeserializeOwned;

mithril-common/src/crypto_helper/cardano/key_certification.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
//! API for mithril key certification.
2-
//! Includes the wrappers for StmInitializer and KeyReg, and ProtocolRegistrationErrorWrapper.
1+
//! API for mithril key certification.
2+
//! Includes the wrappers for StmInitializer and KeyReg, and ProtocolRegistrationErrorWrapper.
3+
//! These wrappers allows keeping mithril-core agnostic to Cardano, while providing some
4+
//! guarantees that mithril-core will not be misused in the context of Cardano.
35
46
use crate::crypto_helper::cardano::{OpCert, ParseError, SerDeShelleyFileFormat};
57
use crate::crypto_helper::types::{
@@ -63,15 +65,21 @@ pub enum ProtocolRegistrationErrorWrapper {
6365
CoreRegister(#[from] RegisterError),
6466
}
6567

66-
// Wrapper structures to reduce library misuse in the Cardano context
6768
/// Wrapper structure for [MithrilCore:StmInitializer](https://mithril.network/mithril-core/doc/mithril/stm/struct.StmInitializer.html).
69+
/// It now obtains a KES signature over the Mithril key. This allows the signers prove
70+
/// their correct identity with respect to a Cardano PoolID.
6871
#[derive(Debug, Clone, Serialize, Deserialize)]
6972
pub struct StmInitializerWrapper {
7073
stm_initializer: StmInitializer,
7174
kes_signature: Option<ProtocolSignerVerificationKeySignature>, // todo: The option is ONLY for a smooth transition. We have to remove this.
7275
}
7376

7477
/// Wrapper structure for [MithrilCore:KeyReg](https://mithril.network/mithril-core/doc/mithril/key_reg/struct.KeyReg.html).
78+
/// The wrapper not only contains a map between `Mithril vkey <-> Stake`, but also
79+
/// a map `PoolID <-> Stake`. This information is recovered from the node state, and
80+
/// is used to verify the identity of a Mithril signer. Furthermore, the `register` function
81+
/// of the wrapper forces the registrar to check that the KES signature over the Mithril key
82+
/// is valid with respect to the PoolID.
7583
#[derive(Debug, Clone)]
7684
pub struct KeyRegWrapper {
7785
stm_key_reg: KeyReg,

mithril-common/src/crypto_helper/cardano/opcert.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Module to (de)serialise, OpCert using the same structure as used in Cardano.
2+
13
use super::SerDeShelleyFileFormat;
24
use crate::crypto_helper::cardano::ProtocolRegistrationErrorWrapper;
35
use crate::crypto_helper::ProtocolPartyId;

0 commit comments

Comments
 (0)