Off-by-one error in polynomial degree calculation fixed

This commit is contained in:
2024-01-14 04:05:45 +01:00
parent 1b74e60eff
commit c5d33bc5da

View File

@@ -145,7 +145,10 @@ impl Command for GenPoly {
let mut polys = Vec::with_capacity(payload.len());
for i in 0..payload.len() {
polys.push(rng.sample(UniformPoly{ intercept: GF256::from(payload[i]), degree: self.min_shares as usize}));
if i % 1000 == 0 {
eprint!("\rGenerated {i}/{}", payload.len());
}
polys.push(rng.sample(UniformPoly{ intercept: GF256::from(payload[i]), degree: self.min_shares as usize - 1}));
}
// export the poly
@@ -159,7 +162,7 @@ impl Command for GenShare {
eprintln!("Reading poly");
let mut poly: Vec<rssss::poly::Poly<GF256>> = serde_cbor::from_reader(io::stdin())?;
eprintln!("Read poly");
let mut rng = rand::rngs::JitterRng::new()?;
let mut rng = rand::rngs::OsRng::new()?;
let share = rssss::s4::Share::new((self.share_no as u8).into(), poly.as_slice());
eprintln!("{share:?}");