Skip to content
Merged

Dev #360

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=2
# Patch
APPVERSION_P=0
APPVERSION_P=1
134 changes: 126 additions & 8 deletions app/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions app/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ banff = []
#debugging features
dev = []
derive-debug = []
blind-sign-togle = []
blind-sign-toggle = []
fuzzing = []

[dependencies]
no-std-compat = { version = "0.4" }
Expand All @@ -49,7 +50,7 @@ arrayvec = { version = "0.7", default-features = false }
arrayref = "0.3.6"
nom = { version = "7.1.1", default-features = false }
bytemuck = { version = "1.15.0" }
educe = "0.4.19"
educe = "0.6.0"
byteorder = { version = "1.4.3", default-features = false }
itoa = { version = "1.0.1", default-features = false }
bolos = { path = "../../deps/ledger-rust/bolos" }
Expand All @@ -67,10 +68,10 @@ hex = "0.4.3"
arrayvec = { version = "0.7" }
time = { version = "0.3.15", features = ["formatting"] }
k256 = { version = "0.13.0", features = ["ecdsa"] }
rand = "0.8.5"
rand = "0.9.0"
insta = { version = "1", features = ["glob"] }
serde_json = "1.0.85"
itertools = "0.10.4"
itertools = "0.14.0"
proptest = "1.1.0"
zuit = { path = "../../deps/ledger-rust/zuit" }

Expand Down
20 changes: 6 additions & 14 deletions app/rust/src/handlers/eth/utils/u256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl u256 {
#[inline]
pub fn as_u32(&self) -> u32 {
let u256(arr) = self;
if !self.fits_word() || arr[0] > u32::max_value() as u64 {
if !self.fits_word() || arr[0] > u32::MAX as u64 {
panic!("Integer overflow when casting to u32");
}
self.as_u64() as u32
Expand Down Expand Up @@ -162,7 +162,7 @@ impl u256 {
#[inline]
pub fn as_usize(&self) -> usize {
let u256(arr) = self;
if !self.fits_word() || arr[0] > usize::max_value() as u64 {
if !self.fits_word() || arr[0] > usize::MAX as u64 {
panic!("Integer overflow when casting to usize");
}
arr[0] as usize
Expand Down Expand Up @@ -366,7 +366,7 @@ impl u256 {
}
q_hat
} else {
u64::max_value()
u64::MAX
};
let q_hat_v = v.full_mul_u64(q_hat);
let c = Self::sub_slice(&mut u[j..], &q_hat_v[..n + 1]);
Expand Down Expand Up @@ -517,11 +517,7 @@ impl u256 {
let mut ret = [0u64; 4];
let ret_ptr = &mut ret as *mut [u64; 4] as *mut u64;
let mut carry = 0u64;
#[allow(unknown_lints, clippy::eq_op)]
const _: [(); 0 - !{
const ASSERT: bool = core::isize::MAX as usize / core::mem::size_of::<u64>() > 4;
ASSERT
} as usize] = [];
const ASSERT: bool = isize::MAX as usize / core::mem::size_of::<u64>() > 4;

{
const i: usize = 0;
Expand Down Expand Up @@ -607,11 +603,7 @@ impl u256 {
let mut ret = [0u64; 4];
let ret_ptr = &mut ret as *mut [u64; 4] as *mut u64;
let mut carry = 0u64;
#[allow(unknown_lints, clippy::eq_op)]
const _: [(); 0 - !{
const ASSERT: bool = core::isize::MAX as usize / core::mem::size_of::<u64>() > 4;
ASSERT
} as usize] = [];
const ASSERT: bool = isize::MAX as usize / core::mem::size_of::<u64>() > 4;

{
const i: usize = 0;
Expand Down Expand Up @@ -1645,7 +1637,7 @@ impl u256 {
/// To make sure there are enough bytes, use a buffer of size [`Self::FORMATTED_SIZE_DECIMAL`]
pub fn to_lexical(mut self, bytes: &mut [u8]) -> &mut [u8] {
//this is equivalent to Self::from(10)
const TEN: &u256 = &Self([10, 0, 0, 0]);
const TEN: &u256 = &u256([10, 0, 0, 0]);

let ten = *PIC::new(TEN).into_inner();

Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use handlers::ZPacketType as PacketType;
mod crypto;

cfg_if::cfg_if! {
if #[cfg(fuzzing)] {
if #[cfg(feature = "fuzzing")] {
pub use dispatcher::handle_apdu;
} else {
use dispatcher::handle_apdu;
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/outputs/nft_mint_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct NFTMintOutput<'b> {
impl<'b> NFTMintOutput<'b> {
pub const TYPE_ID: u32 = 0x0000000a;

pub fn get_address_at(&'b self, idx: usize) -> Option<Address> {
pub fn get_address_at(&'b self, idx: usize) -> Option<Address<'b>> {
let data = self.addresses.get(idx)?;
let mut addr = MaybeUninit::uninit();
Address::from_bytes_into(data, &mut addr)
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/outputs/nft_transfer_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct NFTTransferOutput<'b> {
impl<'b> NFTTransferOutput<'b> {
pub const TYPE_ID: u32 = 0x0000000b;

pub fn get_address_at(&'b self, idx: usize) -> Option<Address> {
pub fn get_address_at(&'b self, idx: usize) -> Option<Address<'b>> {
let data = self.addresses.get(idx)?;
let mut addr = MaybeUninit::uninit();
Address::from_bytes_into(data, &mut addr)
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/outputs/secp_mint_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct SECPMintOutput<'b> {
impl<'b> SECPMintOutput<'b> {
pub const TYPE_ID: u32 = 0x00000006;

pub fn get_address_at(&'b self, idx: usize) -> Option<Address> {
pub fn get_address_at(&'b self, idx: usize) -> Option<Address<'b>> {
let data = self.addresses.get(idx)?;
let mut addr = MaybeUninit::uninit();
Address::from_bytes_into(data, &mut addr)
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/outputs/secp_output_owners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct SECPOutputOwners<'b> {
impl<'b> SECPOutputOwners<'b> {
pub const TYPE_ID: u32 = 0x0000000b;

pub fn get_address_at(&'b self, idx: usize) -> Option<Address> {
pub fn get_address_at(&'b self, idx: usize) -> Option<Address<'b>> {
let data = self.addresses.get(idx)?;
let mut addr = MaybeUninit::uninit();
Address::from_bytes_into(data, &mut addr)
Expand Down
Loading
Loading