From 71030f12e047cbacfa0d55d40f81950cb255addb Mon Sep 17 00:00:00 2001 From: yogh333 Date: Thu, 5 Oct 2023 15:23:00 +0200 Subject: [PATCH] fix CI issues --- Cargo.toml | 2 +- src/context.rs | 8 +++++++- src/crypto.rs | 28 ++++++++++++---------------- src/main.rs | 10 ++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index beb117d..36e3bc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ lto = true curve = ["secp256k1"] path = ["m/2645'"] flags = "0" -name = "staRknet" +name = "Starknet" [package.metadata.ledger.nanos] icon = "crab.gif" diff --git a/src/context.rs b/src/context.rs index 6a60c65..32c171f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -23,11 +23,17 @@ impl FieldElement { } } +impl Default for FieldElement { + fn default() -> Self { + Self::new() + } +} + impl From<&[u8]> for FieldElement { fn from(data: &[u8]) -> Self { let mut value: [u8; 32] = [0; 32]; value.copy_from_slice(data); - Self { value: value } + Self { value } } } diff --git a/src/crypto.rs b/src/crypto.rs index 0b7954a..7201743 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -11,9 +11,9 @@ const EIP2645_PATH_PREFIX: u32 = 0x80000A55; #[derive(Debug)] pub enum CryptoError { - UnvalidPathPrefixError = 0xFF00, - UnvalidPathLengthError = 0xFF01, - SignError = 0xFF02, + UnvalidPathPrefix = 0xFF00, + UnvalidPathLength = 0xFF01, + Sign = 0xFF02, } impl From for Reply { @@ -33,7 +33,7 @@ pub fn sign_hash(ctx: &mut Ctx) -> Result<(), CryptoError> { ctx.hash_info.v = s.2 as u8; Ok(()) } - Err(_) => Err(CryptoError::SignError), + Err(_) => Err(CryptoError::Sign), } } @@ -62,10 +62,10 @@ pub fn set_derivation_path(buf: &mut &[u8], ctx: &mut Ctx) -> Result<(), CryptoE match ctx.bip32_path[0] { EIP2645_PATH_PREFIX => Ok(()), - _ => Err(CryptoError::UnvalidPathPrefixError), + _ => Err(CryptoError::UnvalidPathPrefix), } } - _ => Err(CryptoError::UnvalidPathLengthError), + _ => Err(CryptoError::UnvalidPathLength), } } @@ -84,11 +84,7 @@ enum ConvertError { /// Passed signature was too short to be read properly TooShort, /// Passed signature encoded payload len was not in the expected range - InvalidPayloadLen { - min: usize, - payload: usize, - max: usize, - }, + InvalidPayloadLen(usize, usize, usize), } /// Converts a DER encoded signature into a (r, s) encoded signture @@ -127,11 +123,11 @@ fn convert_der_to_rs( let min_payload_len = 2 + MINPAYLOADLEN + 2 + MINPAYLOADLEN; let max_payload_len = 2 + MAXPAYLOADLEN + 2 + MAXPAYLOADLEN; if payload_len < min_payload_len || payload_len > max_payload_len { - return Err(ConvertError::InvalidPayloadLen { - min: min_payload_len, - payload: payload_len, - max: max_payload_len, - }); + return Err(ConvertError::InvalidPayloadLen( + min_payload_len, + payload_len, + max_payload_len, + )); } //check that the input slice is at least as long as the encoded len diff --git a/src/main.rs b/src/main.rs index 063030a..e257724 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,16 +23,14 @@ extern "C" fn sample_pending() { ui::SingleMessage::new("Pending").show(); loop { - match comm.next_event::() { - io::Event::Button(ButtonEvent::RightButtonRelease) => break, - _ => (), + if let io::Event::Button(ButtonEvent::RightButtonRelease) = comm.next_event::() { + break; } } ui::SingleMessage::new("Ledger review").show(); loop { - match comm.next_event::() { - io::Event::Button(ButtonEvent::BothButtonsRelease) => break, - _ => (), + if let io::Event::Button(ButtonEvent::RightButtonRelease) = comm.next_event::() { + break; } } }