From 5034366c72268fe12be64a41120ad260016817f8 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 21 Aug 2025 09:41:59 +0300 Subject: [PATCH] fix(hmac-sha256): compute PHash and AHash concurrently (#969) --------- Co-authored-by: th4s --- .../hmac-sha256/src/prf/function/reduced.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/components/hmac-sha256/src/prf/function/reduced.rs b/crates/components/hmac-sha256/src/prf/function/reduced.rs index 2120a8293..403d4c529 100644 --- a/crates/components/hmac-sha256/src/prf/function/reduced.rs +++ b/crates/components/hmac-sha256/src/prf/function/reduced.rs @@ -40,7 +40,6 @@ enum PrfState { inner_partial: [u32; 8], a_output: DecodeFutureTyped, }, - FinishLastP, Done, } @@ -137,16 +136,18 @@ impl PrfFunction { assign_inner_local(vm, p.inner_local, *inner_partial, &msg)?; if *iter == self.iterations { - self.state = PrfState::FinishLastP; + self.state = PrfState::Done; } else { self.state = PrfState::ComputeA { iter: *iter + 1, inner_partial: *inner_partial, msg: output.to_vec(), - } - }; + }; + // We recurse, so that this PHash and the next AHash could + // be computed in a single VM execute call. + self.flush(vm)?; + } } - PrfState::FinishLastP => self.state = PrfState::Done, _ => (), }