Skip to content

Commit

Permalink
Merge pull request #341 from ava-labs/fix/eth_msg
Browse files Browse the repository at this point in the history
Fix/eth msg
  • Loading branch information
neithanmo authored Dec 10, 2024
1 parent ac7750c commit 10a442c
Show file tree
Hide file tree
Showing 383 changed files with 531 additions and 153 deletions.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=1
# Minor
APPVERSION_N=1
# Patch
APPVERSION_P=0
APPVERSION_P=1
4 changes: 3 additions & 1 deletion app/rust/src/handlers/eth/personal_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ impl Sign {
hasher.update(len_str).map_err(|_| Error::Unknown)?;
hasher.update(buffer).map_err(|_| Error::Unknown)?;

hasher.finalize().map_err(|_| Error::Unknown)
let hash = hasher.finalize().map_err(|_| Error::Unknown)?;

Ok(hash)
}

#[inline(never)]
Expand Down
7 changes: 7 additions & 0 deletions app/rust/src/parser/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,12 @@ pub const CB58_CHECKSUM_LEN: usize = 4;
pub const U32_SIZE: usize = std::mem::size_of::<u32>();
pub const U64_SIZE: usize = std::mem::size_of::<u64>();

// The maximun lenght of a message chunk
// to be displayed on the device. each chunk
// would contain a formatted part of the original message
// this applies only in cases where the received
// message is in ASCII format
pub const MSG_MAX_CHUNK_LEN: usize = 100;

// types
pub type OutputIdx = u64;
25 changes: 11 additions & 14 deletions app/rust/src/parser/coreth/native/sign_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ use crate::{
checked_add,
handlers::handle_ui_message,
parser::{DisplayableItem, FromBytes, Message},
zlog,
};
use bolos::{pic_str, PIC};
use zemu_sys::ViewError;

const MAX_ETH_MESSAGE_SIZE: usize = 100;

#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(test, derive(Debug))]
pub struct PersonalMsg<'b>(Message<'b>);

Expand All @@ -41,7 +42,7 @@ impl<'b> FromBytes<'b> for PersonalMsg<'b> {
input: &'b [u8],
out: &mut MaybeUninit<Self>,
) -> Result<&'b [u8], nom::Err<crate::parser::ParserError>> {
crate::sys::zemu_log_stack("PersonalMessage::from_bytes_into\x00");
zlog("PersonalMessage::from_bytes_into\x00");
// read message len
let out = out.as_mut_ptr();

Expand All @@ -64,18 +65,14 @@ impl<'b> DisplayableItem for PersonalMsg<'b> {
message: &mut [u8],
page: u8,
) -> Result<u8, ViewError> {
match item_n {
0 => {
let label = pic_str!(b"Sign");
title[..label.len()].copy_from_slice(label);
let content = pic_str!("PersonalMessage");
handle_ui_message(content.as_bytes(), message, page)
}

x @ 1.. => {
let idx = x - 1;
self.0.render_item(idx, title, message, page)
}
if item_n == 0 {
let label = pic_str!(b"Sign");
title[..label.len()].copy_from_slice(label);
let content = pic_str!("PersonalMessage");
handle_ui_message(content.as_bytes(), message, page)
} else {
let idx = item_n - 1;
self.0.render_item(idx, title, message, page)
}
}
}
Expand Down
Loading

0 comments on commit 10a442c

Please sign in to comment.