feCmov static method

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

Implementation

static void feCmov(FieldElement f, FieldElement g, int b) {
  assert(b == 0 || b == 1, "b should be either 0 or 1.");
  int f0 = f.h[0];
  int f1 = f.h[1];
  int f2 = f.h[2];
  int f3 = f.h[3];
  int f4 = f.h[4];
  int f5 = f.h[5];
  int f6 = f.h[6];
  int f7 = f.h[7];
  int f8 = f.h[8];
  int f9 = f.h[9];
  int g0 = g.h[0];
  int g1 = g.h[1];
  int g2 = g.h[2];
  int g3 = g.h[3];
  int g4 = g.h[4];
  int g5 = g.h[5];
  int g6 = g.h[6];
  int g7 = g.h[7];
  int g8 = g.h[8];
  int g9 = g.h[9];
  int x0 = f0 ^ g0;
  int x1 = f1 ^ g1;
  int x2 = f2 ^ g2;
  int x3 = f3 ^ g3;
  int x4 = f4 ^ g4;
  int x5 = f5 ^ g5;
  int x6 = f6 ^ g6;
  int x7 = f7 ^ g7;
  int x8 = f8 ^ g8;
  int x9 = f9 ^ g9;
  b = -b;
  x0 &= b;
  x1 &= b;
  x2 &= b;
  x3 &= b;
  x4 &= b;
  x5 &= b;
  x6 &= b;
  x7 &= b;
  x8 &= b;
  x9 &= b;
  f.h[0] = _xor32(f0, x0);
  f.h[1] = _xor32(f1, x1);
  f.h[2] = _xor32(f2, x2);
  f.h[3] = _xor32(f3, x3);
  f.h[4] = _xor32(f4, x4);
  f.h[5] = _xor32(f5, x5);
  f.h[6] = _xor32(f6, x6);
  f.h[7] = _xor32(f7, x7);
  f.h[8] = _xor32(f8, x8);
  f.h[9] = _xor32(f9, x9);
}