From 08fcef707995bfa884d8fe841c7d820408db89d4 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 16 May 2023 14:23:05 +0200 Subject: [PATCH] modred fix failures --- src/math/modred.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/math/modred.rs b/src/math/modred.rs index f496b95..07d9024 100644 --- a/src/math/modred.rs +++ b/src/math/modred.rs @@ -26,21 +26,19 @@ pub fn modred(mut poly: u64, relation: u64, verbose: bool) -> Result poly { + if verbose { + println!("relation is longer than polynom, nothing to do."); + } + return Ok(poly); + } + while poly > relation { diffrence = relation.leading_zeros() - poly.leading_zeros(); poly = poly ^ (relation << diffrence); if verbose { - println!("{index}:\tpoly: 0x{:x}\t", poly); - //println!("{index}:\tpoly: 0b{:b}\t", poly); + println!("{index}:\tpoly: 0x{:x}\t 0b{:b}", poly, poly); } index += 1; } - // one more time! - diffrence = relation.leading_zeros() - poly.leading_zeros(); - poly = poly ^ (relation << diffrence); - if verbose { - println!("{index}:\tpoly: 0x{:x}\t", poly); - //println!("{index}:\tpoly: 0b{:b}\t", poly); - } return Ok(poly); }