modred fix failures
This commit is contained in:
parent
853c28a4d5
commit
08fcef7079
|
@ -26,21 +26,19 @@ pub fn modred(mut poly: u64, relation: u64, verbose: bool) -> Result<u64, String
|
||||||
println!("polynomial:\t0x{:x}\t", poly);
|
println!("polynomial:\t0x{:x}\t", poly);
|
||||||
println!("=======================================================================");
|
println!("=======================================================================");
|
||||||
}
|
}
|
||||||
while relation.leading_zeros() - poly.leading_zeros() != 0 {
|
if relation > poly {
|
||||||
diffrence = relation.leading_zeros() - poly.leading_zeros();
|
|
||||||
poly = poly ^ (relation << diffrence);
|
|
||||||
if verbose {
|
if verbose {
|
||||||
println!("{index}:\tpoly: 0x{:x}\t", poly);
|
println!("relation is longer than polynom, nothing to do.");
|
||||||
//println!("{index}:\tpoly: 0b{:b}\t", poly);
|
}
|
||||||
}
|
return Ok(poly);
|
||||||
index += 1;
|
}
|
||||||
}
|
while poly > relation {
|
||||||
// one more time!
|
diffrence = relation.leading_zeros() - poly.leading_zeros();
|
||||||
diffrence = relation.leading_zeros() - poly.leading_zeros();
|
poly = poly ^ (relation << diffrence);
|
||||||
poly = poly ^ (relation << diffrence);
|
if verbose {
|
||||||
if verbose {
|
println!("{index}:\tpoly: 0x{:x}\t 0b{:b}", poly, poly);
|
||||||
println!("{index}:\tpoly: 0x{:x}\t", poly);
|
}
|
||||||
//println!("{index}:\tpoly: 0b{:b}\t", poly);
|
index += 1;
|
||||||
}
|
}
|
||||||
return Ok(poly);
|
return Ok(poly);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue