Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent panicking each time the computed sum is zero #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions protocol/src/pjc/partner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use common::timer;

use num_bigint::BigUint;
use num_traits::One;
use num_traits::Zero;

use std::path::Path;
use std::sync::Arc;
Expand Down Expand Up @@ -173,9 +174,13 @@ impl PartnerPJCProtocol for PartnerPjc {
assert_eq!(encrypted_sum.len(), 1);
let z = ((self.he_cipher.decrypt_vec(encrypted_sum))[0]).clone();
let sum = {
let v = (z % &max_val).to_u64_digits();
assert_eq!(v.len(), 1);
v[0]
if z.is_zero() {
0
} else {
let v = (z % &max_val).to_u64_digits();
assert_eq!(v.len(), 1);
v[0]
}
};
info!("Feature: {}, Sum {}", feature_index, sum);

Expand Down