From cd2f1b819d9590b9ed342d8b4e26868ae7c8f7fd Mon Sep 17 00:00:00 2001 From: ChenYe Date: Thu, 5 Dec 2024 17:46:10 +0800 Subject: [PATCH] fix report data --- crates/prover/src/api.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/prover/src/api.rs b/crates/prover/src/api.rs index 85c6317..8b35875 100644 --- a/crates/prover/src/api.rs +++ b/crates/prover/src/api.rs @@ -186,15 +186,23 @@ impl ProverApi { #[async_trait] impl ProverV1ApiServer for ProverApi { - async fn generate_attestation_report(&self, req: Bytes) -> RpcResult { + async fn generate_attestation_report(&self, mut req: Bytes) -> RpcResult { let mut data = [0_u8; 64]; + const ZERO: [u8; 32] = [0_u8; 32]; + if req.len() == 64 { + if ZERO.eq(&req[0..32]) { + req = req.slice(32..); + } + } + if req.len() > 32 { - return Err(self.err(14002, "invalid report data")); + return Err(self.err(14002, "invalid report data (too long)")); } - data[32 - req.len()..].copy_from_slice(&req); + data[64 - req.len()..].copy_from_slice(&req); data[12..32].copy_from_slice(self.keypair.address().as_slice()); - log::info!("report data: {:?}", data); + + log::info!("report data: {:?}", Bytes::copy_from_slice(&data)); let start = Instant::now();