Skip to content
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
12 changes: 8 additions & 4 deletions cc/algorithms/numerical-mechanisms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ int64_t LaplaceMechanism::AddInt64Noise(int64_t result) {
granularity = granularity_cast_result.value;
}

return RoundToNearestInt64Multiple(result, granularity) +
noise_cast_result.value;
SafeOpResult<int64_t> add_result =
SafeAdd(RoundToNearestInt64Multiple(result, granularity),
noise_cast_result.value);
return add_result.value;
}

absl::StatusOr<std::unique_ptr<NumericalMechanism>>
Expand Down Expand Up @@ -411,8 +413,10 @@ int64_t GaussianMechanism::AddInt64Noise(int64_t result) {
granularity = granularity_cast_result.value;
}

return RoundToNearestInt64Multiple(result, granularity) +
noise_cast_result.value;
SafeOpResult<int64_t> add_result =
SafeAdd(RoundToNearestInt64Multiple(result, granularity),
noise_cast_result.value);
return add_result.value;
}

} // namespace differential_privacy
Loading