Skip to content

Commit 2574df9

Browse files
authored
Merge pull request #186 from LedgerHQ/y333/remove_friction_blind_signing_ngl
Remove warning message when performing blind signing (NBGL)
2 parents 48062b8 + ea9ec8f commit 2574df9

File tree

5 files changed

+47
-63
lines changed

5 files changed

+47
-63
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ledger_device_sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_device_sdk"
3-
version = "1.15.4"
3+
version = "1.15.5"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true

ledger_device_sdk/src/nbgl.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use alloc::ffi::CString;
66
use alloc::vec::Vec;
77
use core::ffi::{c_char, c_int};
88
use core::mem::transmute;
9-
use include_gif::include_gif;
109
use ledger_secure_sdk_sys::*;
1110

1211
#[no_mangle]
@@ -210,15 +209,12 @@ trait ToMessage {
210209
}
211210

212211
impl TransactionType {
213-
pub fn to_c_type(&self, blind: bool, skippable: bool) -> nbgl_operationType_t {
212+
fn to_c_type(&self, skippable: bool) -> nbgl_operationType_t {
214213
let mut tx_type = match self {
215214
TransactionType::Transaction => TYPE_TRANSACTION.into(),
216215
TransactionType::Message => TYPE_MESSAGE.into(),
217216
TransactionType::Operation => TYPE_OPERATION.into(),
218217
};
219-
if blind {
220-
tx_type |= BLIND_OPERATION;
221-
}
222218
if skippable {
223219
tx_type |= SKIPPABLE_OPERATION;
224220
}
@@ -267,35 +263,6 @@ pub fn init_comm(comm: &mut Comm) {
267263
}
268264
}
269265

270-
/// Private helper function to display a warning screen when a transaction
271-
/// is reviewed in "blind" mode. The user can choose to go back to safety
272-
/// or review the risk. If the user chooses to review the risk, a second screen
273-
/// is displayed with the option to accept the risk or reject the transaction.
274-
/// Used in NbglReview and NbglStreamingReview.
275-
fn show_blind_warning() -> bool {
276-
const WARNING: NbglGlyph =
277-
NbglGlyph::from_include(include_gif!("icons/Warning_64px.gif", NBGL));
278-
279-
let back_to_safety = NbglChoice::new().glyph(&WARNING).show(
280-
"Security risk detected",
281-
"It may not be safe to sign this transaction. To continue, you'll need to review the risk.",
282-
"Back to safety",
283-
"Review risk",
284-
);
285-
286-
if !back_to_safety {
287-
NbglChoice::new()
288-
.show(
289-
"The transaction cannot be trusted",
290-
"Your Ledger cannot decode this transaction. If you sign it, you could be authorizing malicious actions that can drain your wallet.\n\nLearn more: ledger.com/e8",
291-
"I accept the risk",
292-
"Reject transaction"
293-
)
294-
} else {
295-
false
296-
}
297-
}
298-
299266
#[derive(Copy, Clone)]
300267
pub enum TuneIndex {
301268
Reserved,

ledger_device_sdk/src/nbgl/nbgl_review.rs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,33 @@ impl<'a> NbglReview<'a> {
9090
None => nbgl_icon_details_t::default(),
9191
};
9292

93-
if self.blind {
94-
if !show_blind_warning() {
95-
return false;
96-
}
97-
}
98-
9993
// Show the review on the device.
10094
self.ux_sync_init();
101-
nbgl_useCaseReview(
102-
self.tx_type.to_c_type(self.blind, false),
103-
&tag_value_list as *const nbgl_contentTagValueList_t,
104-
&icon as *const nbgl_icon_details_t,
105-
self.title.as_ptr() as *const c_char,
106-
self.subtitle.as_ptr() as *const c_char,
107-
self.finish_title.as_ptr() as *const c_char,
108-
Some(choice_callback),
109-
);
95+
match self.blind {
96+
true => {
97+
nbgl_useCaseReviewBlindSigning(
98+
self.tx_type.to_c_type(false),
99+
&tag_value_list as *const nbgl_contentTagValueList_t,
100+
&icon as *const nbgl_icon_details_t,
101+
self.title.as_ptr() as *const c_char,
102+
self.subtitle.as_ptr() as *const c_char,
103+
self.finish_title.as_ptr() as *const c_char,
104+
core::ptr::null(),
105+
Some(choice_callback),
106+
);
107+
}
108+
false => {
109+
nbgl_useCaseReview(
110+
self.tx_type.to_c_type(false),
111+
&tag_value_list as *const nbgl_contentTagValueList_t,
112+
&icon as *const nbgl_icon_details_t,
113+
self.title.as_ptr() as *const c_char,
114+
self.subtitle.as_ptr() as *const c_char,
115+
self.finish_title.as_ptr() as *const c_char,
116+
Some(choice_callback),
117+
);
118+
}
119+
}
110120
let sync_ret = self.ux_sync_wait(false);
111121

112122
// Return true if the user approved the transaction, false otherwise.

ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,27 @@ impl NbglStreamingReview {
4242
let title = CString::new(title).unwrap();
4343
let subtitle = CString::new(subtitle).unwrap();
4444

45-
if self.blind {
46-
if !show_blind_warning() {
47-
return false;
45+
self.ux_sync_init();
46+
match self.blind {
47+
true => {
48+
nbgl_useCaseReviewStreamingBlindSigningStart(
49+
self.tx_type.to_c_type(false),
50+
&self.icon as *const nbgl_icon_details_t,
51+
title.as_ptr() as *const c_char,
52+
subtitle.as_ptr() as *const c_char,
53+
Some(choice_callback),
54+
);
55+
}
56+
false => {
57+
nbgl_useCaseReviewStreamingStart(
58+
self.tx_type.to_c_type(false),
59+
&self.icon as *const nbgl_icon_details_t,
60+
title.as_ptr() as *const c_char,
61+
subtitle.as_ptr() as *const c_char,
62+
Some(choice_callback),
63+
);
4864
}
4965
}
50-
51-
self.ux_sync_init();
52-
nbgl_useCaseReviewStreamingStart(
53-
self.tx_type.to_c_type(self.blind, false),
54-
&self.icon as *const nbgl_icon_details_t,
55-
title.as_ptr() as *const c_char,
56-
subtitle.as_ptr() as *const c_char,
57-
Some(choice_callback),
58-
);
5966
let sync_ret = self.ux_sync_wait(false);
6067

6168
// Return true if the user approved the transaction, false otherwise.

0 commit comments

Comments
 (0)