Skip to main content

quantize_gradient

Function quantize_gradient 

Source
pub fn quantize_gradient(
    gradient: &Array1<f64>,
    scale: f64,
    modulus: i64,
) -> Result<Vec<i64>>
Expand description

Quantise a real-valued gradient into the additive modular group Z_p.

The mapping is q_k = round(g_k * scale) mod modulus. Negative post-rounding values are folded into [0, modulus) via rem_euclid, which guarantees the canonical non-negative representative used everywhere in the protocol.