Skip to content

Commit c9e9d10

Browse files
remove the usage removal from the signature (#376)
1 parent 48459e1 commit c9e9d10

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

atoma-service/src/streamer.rs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -291,38 +291,25 @@ impl Streamer {
291291
Ok(())
292292
}
293293

294-
/// Signs the accumulated response
295-
/// This is used when the streaming is complete and we need to send the final chunk back to the client
296-
/// with the signature and response hash
294+
/// Signs the each chunk of the response
297295
///
298296
/// # Returns
299297
///
300298
/// Returns a tuple containing:
301299
/// * A base64-encoded string of the signature
302300
/// * A base64-encoded string of the response hash
303-
///
304-
/// NOTE: We remove the usage key from the chunk before signing it, as we need to send the usage key back to the client in the final chunk
305301
#[instrument(level = "debug", skip_all)]
306302
pub fn sign_chunk(&self, chunk: &Value) -> Result<(String, [u8; PAYLOAD_HASH_SIZE]), Error> {
307-
// Clone the chunk and remove usage if present
308-
let mut chunk_to_sign = chunk.clone();
309-
if let Some(obj) = chunk_to_sign.as_object_mut() {
310-
obj.remove(USAGE_KEY);
311-
}
312-
313-
// Sign the accumulated response
314303
let (response_hash, signature) =
315-
utils::sign_response_body(&chunk_to_sign, &self.keystore, self.address_index).map_err(
316-
|e| {
317-
error!(
318-
target = "atoma-service-streamer",
319-
level = "error",
320-
"Error signing response: {}",
321-
e
322-
);
323-
Error::new(format!("Error signing response: {e}"))
324-
},
325-
)?;
304+
utils::sign_response_body(chunk, &self.keystore, self.address_index).map_err(|e| {
305+
error!(
306+
target = "atoma-service-streamer",
307+
level = "error",
308+
"Error signing response: {}",
309+
e
310+
);
311+
Error::new(format!("Error signing response: {e}"))
312+
})?;
326313

327314
Ok((signature, response_hash))
328315
}

0 commit comments

Comments
 (0)