Skip to main content

use_hint

Function use_hint 

Source
pub fn use_hint(h: i32, r: i32, gamma2: i32) -> i32
Expand description

Use a hint bit to recover the correct high bits.

Implements Algorithm 40 of FIPS 204 (UseHint). When h == 0, returns HighBits(r) directly. When h == 1, adjusts the high-bits value by +/-1 (modulo m = (q-1)/alpha) depending on the sign of the low bits.

  • h: hint bit (0 or 1).
  • r: the approximate value to round.
  • gamma2: decomposition parameter.

Returns the corrected high-order representative.