FeCMove function

void FeCMove(
  1. FieldElement f,
  2. FieldElement g,
  3. int b
)

Replace (f,g) with (g,g) if b == 1; replace (f,g) with (f,g) if b == 0.

Preconditions: b in {0,1}.

Implementation

void FeCMove(FieldElement f, FieldElement g, int b) {
  b = -b;
  f[0] ^= b & (f[0] ^ g[0]);
  f[1] ^= b & (f[1] ^ g[1]);
  f[2] ^= b & (f[2] ^ g[2]);
  f[3] ^= b & (f[3] ^ g[3]);
  f[4] ^= b & (f[4] ^ g[4]);
  f[5] ^= b & (f[5] ^ g[5]);
  f[6] ^= b & (f[6] ^ g[6]);
  f[7] ^= b & (f[7] ^ g[7]);
  f[8] ^= b & (f[8] ^ g[8]);
  f[9] ^= b & (f[9] ^ g[9]);
}