Skip to content

Commit dd60045

Browse files
authored
Merge branch 'main' into feat/doc-signing-logic
2 parents 2392ed5 + e251dea commit dd60045

File tree

38 files changed

+409
-154
lines changed

38 files changed

+409
-154
lines changed

docs/src/architecture/08_concepts/signed_doc/cddl/additional_meta.cddl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ additional_fields = {
55
? "reply" => ref_type,
66
? "section" => text,
77
? "collabs" => [+any],
8-
? "brand_id" => UUID, ; UUID v4
9-
? "campaign_id" => UUID, ; UUID v4
8+
? "brand_id" => ref_type,
9+
? "campaign_id" => ref_type,
1010
? "election_id" => UUID, ; UUID v4
11-
? "category_id" => UUID, ; UUID v4
11+
? "category_id" => ref_type,
1212
}
1313

1414
ref_type = UUID / [UUID, UUID] ; UUIDs v7

docs/src/architecture/08_concepts/signed_doc/meta.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,17 @@ This list can impact actions that can be performed by the `Proposal Action Docum
8888

8989
## `brand_id`
9090

91-
Unique identifier [UUID] v4, which represents a "brand" who is running the voting,
92-
e.g. Catalyst, Midnight.
91+
This is a reply to another document.
92+
The format is the same as the [CBOR] Array form of [`ref`](#ref-document-reference).
93+
94+
`brand_id` represents a "brand" who is running the voting, e.g. Catalyst, Midnight.
9395

9496
## `campaign_id`
9597

96-
Unique identifier [UUID] v4, which defines a "campaign" of voting,
97-
e.g. "treasury campaign".
98+
This is a reply to another document.
99+
The format is the same as the [CBOR] Array form of [`ref`](#ref-document-reference).
100+
101+
`campaign_id` defines a "campaign" of voting, e.g. "treasury campaign".
98102

99103
## `election_id`
100104

@@ -103,7 +107,10 @@ e.g. "Catalyst Fund 1", "Catalyst Fund 2".
103107

104108
## `category_id`
105109

106-
Unique identifier [UUID] v4 which defines a voting category as a collection of proposals,
110+
This is a reply to another document.
111+
The format is the same as the [CBOR] Array form of [`ref`](#ref-document-reference).
112+
113+
`campaign_id` defines a voting category as a collection of proposals,
107114
e.g. "Development & Infrastructure", "Products & Integrations".
108115

109116
[UUID]: https://www.rfc-editor.org/rfc/rfc9562.html

rust/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
"cbork-cddl-parser",
1111
"cbork-utils",
1212
"catalyst-voting",
13-
"catalyst-types",
13+
"catalyst-types",
1414
"immutable-ledger",
1515
"vote-tx-v1",
1616
"vote-tx-v2",
@@ -60,3 +60,4 @@ string_slice = "deny"
6060
unchecked_duration_subtraction = "deny"
6161
unreachable = "deny"
6262
missing_docs_in_private_items = "deny"
63+
arithmetic_side_effects = "deny"

rust/Earthfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.27 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.28 AS rust-ci
44

55
COPY_SRC:
66
FUNCTION

rust/c509-certificate/src/attributes/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ impl Encode<()> for Attributes {
6262
));
6363
}
6464
// The attribute type should be included in array too
65-
encode_array_len(e, "Attributes", self.0.len() as u64 * 2)?;
65+
let len = (self.0.len() as u64)
66+
.checked_mul(2)
67+
.ok_or_else(|| minicbor::encode::Error::message("Attributes length overflow"))?;
68+
encode_array_len(e, "Attributes", len)?;
6669
for attribute in &self.0 {
6770
attribute.encode(e, ctx)?;
6871
}

rust/c509-certificate/src/extensions/extension/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ impl Encode<()> for Extension {
110110
{
111111
// Determine encoded OID value based on critical flag
112112
let encoded_oid = if self.critical {
113-
-mapped_oid
113+
mapped_oid.checked_neg().ok_or_else(|| {
114+
minicbor::encode::Error::message(format!(
115+
"Invalid OID value (will overflow during negation): {mapped_oid}"
116+
))
117+
})?
114118
} else {
115119
mapped_oid
116120
};

rust/c509-certificate/src/extensions/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ impl Encode<()> for Extensions {
7070
if self.0.len() == 1 && extension.registered_oid().c509_oid().oid() == &KEY_USAGE_OID {
7171
match extension.value() {
7272
ExtensionValue::Int(value) => {
73-
let ku_value = if extension.critical() { -value } else { *value };
73+
let ku_value = if extension.critical() {
74+
value
75+
.checked_neg()
76+
.ok_or_else(|| minicbor::encode::Error::message(format!("Invalid key usage value (will overflow during negation): {value}")))?
77+
} else {
78+
*value
79+
};
7480
encode_helper(e, "Extensions KeyUsage", ctx, &ku_value)?;
7581
return Ok(());
7682
},

rust/c509-certificate/src/general_names/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ impl Encode<()> for GeneralNames {
5959
));
6060
}
6161
// The general name type should be included in array too
62-
encode_array_len(e, "General Names", self.0.len() as u64 * 2)?;
62+
let len = (self.0.len() as u64)
63+
.checked_mul(2)
64+
.ok_or_else(|| minicbor::encode::Error::message("General Names length overflow"))?;
65+
encode_array_len(e, "General Names", len)?;
6366
for gn in &self.0 {
6467
gn.encode(e, ctx)?;
6568
}

rust/c509-certificate/src/name/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,20 @@ impl Encode<()> for NameValue {
106106

107107
encode_cn_value(e, cn_value)?;
108108
} else {
109-
encode_array_len(e, "Attributes", attrs.len() as u64 * 2)?;
109+
let len = (attrs.len() as u64).checked_mul(2).ok_or_else(|| {
110+
minicbor::encode::Error::message("Attribute length overflow")
111+
})?;
112+
encode_array_len(e, "Attributes", len)?;
110113
for attribute in attrs {
111114
attribute.encode(e, ctx)?;
112115
}
113116
}
114117
} else {
115118
// If is okay if the attributes is empty
116-
encode_array_len(e, "Attributes", attrs.len() as u64 * 2)?;
119+
let len = (attrs.len() as u64).checked_mul(2).ok_or_else(|| {
120+
minicbor::encode::Error::message("Attribute length overflow")
121+
})?;
122+
encode_array_len(e, "Attributes", len)?;
117123
for attribute in attrs {
118124
attribute.encode(e, ctx)?;
119125
}

rust/cardano-blockchain-types/src/auxdata/scripts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl TryFrom<u64> for ScriptType {
100100
match value {
101101
0 => Err(anyhow!("Invalid script type: {}", value)),
102102
1 => Ok(Self::Native),
103-
_ => Ok(Self::Plutus(value - 1)),
103+
_ => Ok(Self::Plutus(value.saturating_sub(1))),
104104
}
105105
}
106106
}

0 commit comments

Comments
 (0)