Add verification at beginning of second phase

This commit is contained in:
Christopher Berner 2019-02-03 13:21:20 -08:00
parent 3a3c22db5b
commit 4eb8340bbb

@ -382,6 +382,7 @@ impl IntermediateSymbolDecoder {
// Second phase (section 5.4.2.3)
#[allow(non_snake_case)]
fn second_phase(&mut self) -> bool {
self.second_phase_verify();
let rows_to_discard = self.i..self.X.len();
let cols_to_discard = self.i..self.X[0].len();
self.X.drain(rows_to_discard);
@ -402,6 +403,15 @@ impl IntermediateSymbolDecoder {
return true;
}
// Verifies that X is lower triangular. See section 5.4.2.3
fn second_phase_verify(&self) {
for row in 0..self.i {
for col in (row + 1)..self.i {
assert_eq!(Octet::zero(), self.X[row][col]);
}
}
}
// Third phase (section 5.4.2.4)
#[allow(non_snake_case)]
fn third_phase(&mut self) {