Skip to content

Commit a257190

Browse files
authored
feat: add more heartbeats on sapling address generation (#120)
* feat: add more heartbeats on sapling address generation * chore: bump version * chore: update snapshots
1 parent 02f68db commit a257190

File tree

12 files changed

+22
-1
lines changed

12 files changed

+22
-1
lines changed

app/Makefile.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ APPVERSION_M=4
33
# This is the minor version
44
APPVERSION_N=1
55
# This is the patch version
6-
APPVERSION_P=3
6+
APPVERSION_P=4

app/rust/src/bolos/blake2b.rs

+12
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,23 @@ pub fn blake2b_expand_v4(
241241
.hash_length(64)
242242
.personal(PRF_EXPAND_PERSONALIZATION)
243243
.to_state();
244+
crate::bolos::heartbeat();
245+
244246
blake2b_state.update(in_a);
247+
crate::bolos::heartbeat();
248+
245249
blake2b_state.update(in_b);
250+
crate::bolos::heartbeat();
251+
246252
blake2b_state.update(in_c);
253+
crate::bolos::heartbeat();
254+
247255
blake2b_state.update(in_d);
256+
crate::bolos::heartbeat();
257+
248258
blake2b_state.update(in_e);
259+
crate::bolos::heartbeat();
260+
249261
let mut hash = [0u8; 64];
250262
hash.copy_from_slice(blake2b_state.finalize().as_bytes());
251263
hash

app/rust/src/zip32.rs

+3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ fn zip32_sapling_derive_child(
263263
path_i: u32,
264264
key_bundle_i: &mut SaplingKeyBundle,
265265
) {
266+
crate::bolos::heartbeat();
267+
266268
let hardened = (path_i & 0x8000_0000) != 0;
267269
let c = path_i & 0x7FFF_FFFF;
268270

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

325328
let mut key_bundle_i = SaplingKeyBundle::new(
326329
zip32_sapling_ask_m(&ik.spending_key()),

app/rust/src/zip32_extern.rs

+6
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,25 @@ pub extern "C" fn get_pkd_from_seed(
151151
pkd_ptr: *mut [u8; 32],
152152
) {
153153
crate::bolos::heartbeat();
154+
154155
let path = [ZIP32_PURPOSE, ZIP32_COIN_TYPE, account];
155156
let start = unsafe { &mut *start_diversifier };
156157
let div_out = unsafe { &mut *div_ptr };
157158

158159
let key_bundle = zip32_sapling_derive(&path);
160+
crate::bolos::heartbeat();
161+
159162
let dk = key_bundle.dk();
163+
crate::bolos::heartbeat();
160164

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

164168
let ivk = sapling_asknsk_to_ivk(&key_bundle.ask(), &key_bundle.nsk());
165169
crate::bolos::heartbeat();
170+
166171
let tmp_pkd = zip32::pkd_default(&ivk, div_out);
172+
crate::bolos::heartbeat();
167173

168174
let pkd_out = unsafe { &mut *pkd_ptr };
169175
pkd_out.copy_from_slice(&tmp_pkd);
-281 Bytes
Loading
-6 Bytes
Loading
-6 Bytes
Loading
-12 Bytes
Loading
-12 Bytes
Loading
-204 Bytes
Loading
-12 Bytes
Loading
-12 Bytes
Loading

0 commit comments

Comments
 (0)