Skip to content

Commit

Permalink
fix report data
Browse files Browse the repository at this point in the history
  • Loading branch information
chzyer committed Dec 5, 2024
1 parent 5906991 commit cd2f1b8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/prover/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,23 @@ impl ProverApi {

#[async_trait]
impl ProverV1ApiServer for ProverApi {
async fn generate_attestation_report(&self, req: Bytes) -> RpcResult<Bytes> {
async fn generate_attestation_report(&self, mut req: Bytes) -> RpcResult<Bytes> {
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();

Expand Down

0 comments on commit cd2f1b8

Please sign in to comment.