Skip to content

Commit

Permalink
fix CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed Oct 5, 2023
1 parent bd7ec8b commit 71030f1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lto = true
curve = ["secp256k1"]
path = ["m/2645'"]
flags = "0"
name = "staRknet"
name = "Starknet"

[package.metadata.ledger.nanos]
icon = "crab.gif"
Expand Down
8 changes: 7 additions & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
28 changes: 12 additions & 16 deletions src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CryptoError> for Reply {
Expand All @@ -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),
}
}

Expand Down Expand Up @@ -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),
}
}

Expand All @@ -84,11 +84,7 @@ enum ConvertError<const R: usize, const S: usize> {
/// 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
Expand Down Expand Up @@ -127,11 +123,11 @@ fn convert_der_to_rs<const R: usize, const S: usize>(
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
Expand Down
10 changes: 4 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ extern "C" fn sample_pending() {
ui::SingleMessage::new("Pending").show();

loop {
match comm.next_event::<Ins>() {
io::Event::Button(ButtonEvent::RightButtonRelease) => break,
_ => (),
if let io::Event::Button(ButtonEvent::RightButtonRelease) = comm.next_event::<Ins>() {
break;
}
}
ui::SingleMessage::new("Ledger review").show();
loop {
match comm.next_event::<Ins>() {
io::Event::Button(ButtonEvent::BothButtonsRelease) => break,
_ => (),
if let io::Event::Button(ButtonEvent::RightButtonRelease) = comm.next_event::<Ins>() {
break;
}
}
}
Expand Down

0 comments on commit 71030f1

Please sign in to comment.