Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 9f86f88

Browse files
committed
fix: verify signature before uploads
1 parent 0a0f2f3 commit 9f86f88

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

crates/storb_validator/src/upload.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ impl<'a> UploadProcessor<'a> {
242242
}
243243
};
244244

245+
let owner_account_id = SqlAccountId(account_id.clone());
246+
247+
// Verify nonce before we upload the user's file
248+
let message = {
249+
let mut msg = Vec::new();
250+
msg.extend_from_slice(&nonce);
251+
msg
252+
};
253+
debug!("Verifying signature for nonce {}", hex::encode(nonce));
254+
let verified =
255+
crabtensor::sign::verify_signature(&owner_account_id.0, &signature, &message);
256+
if !verified {
257+
error!(
258+
"Signature verification failed for nonce {}",
259+
hex::encode(message)
260+
);
261+
return Err(anyhow::anyhow!("Signature verification failed for nonce"));
262+
}
263+
245264
// Spawn consumer task
246265
let miner_uids = self.miner_uids.clone();
247266
let miner_connections = self.miner_connections.clone();
@@ -287,7 +306,7 @@ impl<'a> UploadProcessor<'a> {
287306
length: total_size,
288307
chunk_size,
289308
chunk_count: chunks_with_pieces.len() as u64,
290-
owner_account_id: SqlAccountId(account_id.clone()),
309+
owner_account_id,
291310
creation_timestamp: now,
292311
signature: KeypairSignature::from_raw([0; 64]), // Placeholder, will be signed below
293312
};

0 commit comments

Comments
 (0)