Merge pull request 'Expose observed BM1370 work ID correlation' (#7) from feature/bm1370-work-id into next
next-build / build (push) Canceled after 0s
next-build / build (push) Canceled after 0s
This commit was merged in pull request #7.
This commit is contained in:
+20
-3
@@ -20,6 +20,14 @@ pub struct NonceReport {
|
||||
pub trailer: u8,
|
||||
}
|
||||
|
||||
impl NonceReport {
|
||||
/// Work ID observed in the Braiins S21 Pro capture. Chip and version
|
||||
/// attribution remain unknown, and this has no accepted-share proof.
|
||||
pub fn observed_work_id(&self) -> u8 {
|
||||
(self.byte7 & 0xf0) >> 1
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ReportError {
|
||||
Length,
|
||||
@@ -41,9 +49,9 @@ pub fn encode_job(job: &Job) -> Option<[u8; JOB_BYTES]> {
|
||||
Some(frame)
|
||||
}
|
||||
|
||||
/// Keep the five trailing bytes raw until work-ID and version-roll mapping is
|
||||
/// validated against silicon. The marker bit distinguishes nonce reports from
|
||||
/// register replies in the observed capture.
|
||||
/// Keep the five trailing bytes raw. The work-ID expression is correlated with
|
||||
/// same-UART jobs in one capture; chip and version mapping remain unverified.
|
||||
/// The marker bit distinguishes nonce reports from register replies.
|
||||
pub fn decode_nonce_report(frame: &[u8]) -> Result<NonceReport, ReportError> {
|
||||
if frame.len() != REPORT_BYTES {
|
||||
return Err(ReportError::Length);
|
||||
@@ -152,6 +160,15 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn observed_work_id_matches_same_uart_job() {
|
||||
// c2-steady.strace lines 1287 and 1352: job byte 4 is 0x10.
|
||||
let frame = captured_bytes::<REPORT_BYTES>("aa554a3488c70022013291");
|
||||
let report = decode_nonce_report(&frame).unwrap();
|
||||
assert_eq!(report.observed_work_id(), 0x10);
|
||||
assert_eq!(report.byte7, 0x22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_report_fails_closed() {
|
||||
let mut frame = captured_bytes::<REPORT_BYTES>("aa555804a92a041e133e86");
|
||||
|
||||
Reference in New Issue
Block a user