From bd29feead7a08925302f4352a07bc0f1ca589371 Mon Sep 17 00:00:00 2001 From: kukkok3 <93382903+kukkok3@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:46:55 +0200 Subject: [PATCH 1/3] fix: lock cargo chef version --- Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index 1851d8cbcc..2dd536da32 100644 --- a/Earthfile +++ b/Earthfile @@ -8,7 +8,7 @@ rust-toolchain: # Installs Cargo chef install-chef: FROM +rust-toolchain - RUN cargo install --debug cargo-chef + RUN cargo install --debug --version 0.1.59 cargo-chef --locked # Prepares the local cache prepare-cache: From 2631ff3e68d472ccd05e44a141442c28a4d3517c Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 19 Jun 2024 12:40:25 +0700 Subject: [PATCH 2/3] fix(voting-tools-rs): Cap Registration Nonce at the Slot# of the Registration Transaction to fix Yoroi nonce eclipsing issue. --- src/voting-tools-rs/src/data/mod.rs | 11 ++++++++--- src/voting-tools-rs/src/verification/verify.rs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/voting-tools-rs/src/data/mod.rs b/src/voting-tools-rs/src/data/mod.rs index 0dd1555bdc..8e8c9998c3 100644 --- a/src/voting-tools-rs/src/data/mod.rs +++ b/src/voting-tools-rs/src/data/mod.rs @@ -225,6 +225,7 @@ impl RawRegistration { &self, cddl_config: &CddlConfig, network_id: NetworkId, + slot_no: SlotNo ) -> Result> { // validate cddl: 61284 validate_reg_cddl(&self.bin_reg, cddl_config)?; @@ -232,7 +233,7 @@ impl RawRegistration { // validate cddl: 61285 validate_sig_cddl(&self.bin_sig, cddl_config)?; - let registration = self.raw_reg_conversion(network_id)?; + let registration = self.raw_reg_conversion(network_id, slot_no)?; let signature = self.raw_sig_conversion()?; @@ -245,7 +246,7 @@ impl RawRegistration { }) } - fn raw_reg_conversion(&self, network_id: NetworkId) -> Result> { + fn raw_reg_conversion(&self, network_id: NetworkId, slot_no: SlotNo) -> Result> { let decoded: ciborium::value::Value = ciborium::de::from_reader(Cursor::new(&self.bin_reg))?; @@ -283,7 +284,11 @@ impl RawRegistration { // A nonce that identifies that most recent delegation let nonce = match inspect_nonce(metamap) { - Ok(value) => value, + Ok(value) => if value.0 < slot_no.0 { // Don't allow nonce > slot number + value + } else { + Nonce(slot_no.0) + }, Err(value) => return value, }; diff --git a/src/voting-tools-rs/src/verification/verify.rs b/src/voting-tools-rs/src/verification/verify.rs index 3f88a894b7..d2cfa8feb9 100644 --- a/src/voting-tools-rs/src/verification/verify.rs +++ b/src/voting-tools-rs/src/verification/verify.rs @@ -100,7 +100,7 @@ pub fn filter_registrations( }; // deserialize the raw Binary CBOR. - let reg = match rawreg.to_signed(&cddl, network_id) { + let reg = match rawreg.to_signed(&cddl, network_id, SlotNo(slot as u64)) { Err(err) => { invalids.push(InvalidRegistration { spec_61284: Some(prefix_hex(&rawreg.bin_reg)), From 29a328ba8079578674b0aaa331540fc80c34e65b Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Fri, 13 Sep 2024 12:24:50 +0700 Subject: [PATCH 3/3] fix(voting-tools-rs): code format --- src/voting-tools-rs/src/data/mod.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/voting-tools-rs/src/data/mod.rs b/src/voting-tools-rs/src/data/mod.rs index 8e8c9998c3..8115187bfa 100644 --- a/src/voting-tools-rs/src/data/mod.rs +++ b/src/voting-tools-rs/src/data/mod.rs @@ -225,7 +225,7 @@ impl RawRegistration { &self, cddl_config: &CddlConfig, network_id: NetworkId, - slot_no: SlotNo + slot_no: SlotNo, ) -> Result> { // validate cddl: 61284 validate_reg_cddl(&self.bin_reg, cddl_config)?; @@ -246,7 +246,11 @@ impl RawRegistration { }) } - fn raw_reg_conversion(&self, network_id: NetworkId, slot_no: SlotNo) -> Result> { + fn raw_reg_conversion( + &self, + network_id: NetworkId, + slot_no: SlotNo, + ) -> Result> { let decoded: ciborium::value::Value = ciborium::de::from_reader(Cursor::new(&self.bin_reg))?; @@ -284,11 +288,14 @@ impl RawRegistration { // A nonce that identifies that most recent delegation let nonce = match inspect_nonce(metamap) { - Ok(value) => if value.0 < slot_no.0 { // Don't allow nonce > slot number - value - } else { - Nonce(slot_no.0) - }, + Ok(value) => { + if value.0 < slot_no.0 { + // Don't allow nonce > slot number + value + } else { + Nonce(slot_no.0) + } + } Err(value) => return value, };