Skip to content

Commit

Permalink
feat: add more heartbeats on sapling address generation (#120)
Browse files Browse the repository at this point in the history
* feat: add more heartbeats on sapling address generation

* chore: bump version

* chore: update snapshots
  • Loading branch information
emmanuelm41 committed Sep 4, 2024
1 parent 02f68db commit a257190
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 1 deletion.
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=4
# This is the minor version
APPVERSION_N=1
# This is the patch version
APPVERSION_P=3
APPVERSION_P=4
12 changes: 12 additions & 0 deletions app/rust/src/bolos/blake2b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,23 @@ pub fn blake2b_expand_v4(
.hash_length(64)
.personal(PRF_EXPAND_PERSONALIZATION)
.to_state();
crate::bolos::heartbeat();

blake2b_state.update(in_a);
crate::bolos::heartbeat();

blake2b_state.update(in_b);
crate::bolos::heartbeat();

blake2b_state.update(in_c);
crate::bolos::heartbeat();

blake2b_state.update(in_d);
crate::bolos::heartbeat();

blake2b_state.update(in_e);
crate::bolos::heartbeat();

let mut hash = [0u8; 64];
hash.copy_from_slice(blake2b_state.finalize().as_bytes());
hash
Expand Down
3 changes: 3 additions & 0 deletions app/rust/src/zip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ fn zip32_sapling_derive_child(
path_i: u32,
key_bundle_i: &mut SaplingKeyBundle,
) {
crate::bolos::heartbeat();

let hardened = (path_i & 0x8000_0000) != 0;
let c = path_i & 0x7FFF_FFFF;

Expand Down Expand Up @@ -321,6 +323,7 @@ fn zip32_sapling_derive_child(
pub fn zip32_sapling_derive(path: &Zip32Path) -> SaplingKeyBundle {
// ik as in capital I (https://zips.z.cash/zip-0032#sapling-child-key-derivation)
let mut ik = zip32_master_key_i();
crate::bolos::heartbeat();

let mut key_bundle_i = SaplingKeyBundle::new(
zip32_sapling_ask_m(&ik.spending_key()),
Expand Down
6 changes: 6 additions & 0 deletions app/rust/src/zip32_extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,25 @@ pub extern "C" fn get_pkd_from_seed(
pkd_ptr: *mut [u8; 32],
) {
crate::bolos::heartbeat();

let path = [ZIP32_PURPOSE, ZIP32_COIN_TYPE, account];
let start = unsafe { &mut *start_diversifier };
let div_out = unsafe { &mut *div_ptr };

let key_bundle = zip32_sapling_derive(&path);
crate::bolos::heartbeat();

let dk = key_bundle.dk();
crate::bolos::heartbeat();

div_out.copy_from_slice(&zip32::diversifier_find_valid(&dk, start));
crate::bolos::heartbeat();

let ivk = sapling_asknsk_to_ivk(&key_bundle.ask(), &key_bundle.nsk());
crate::bolos::heartbeat();

let tmp_pkd = zip32::pkd_default(&ivk, div_out);
crate::bolos::heartbeat();

let pkd_out = unsafe { &mut *pkd_ptr };
pkd_out.copy_from_slice(&tmp_pkd);
Expand Down
Binary file modified tests_zemu/snapshots/fl-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/st-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a257190

Please sign in to comment.