FeSquare2 function Null safety

void FeSquare2(
  1. FieldElement h,
  2. FieldElement f
)

FeSquare2 sets h = 2 * f * f

Can overlap h with f.

Preconditions: |f| bounded by 1.652^26,1.652^25,1.652^26,1.652^25,etc.

Postconditions: |h| bounded by 1.012^25,1.012^24,1.012^25,1.012^24,etc. See fe_mul.c for discussion of implementation strategy.

Implementation

void FeSquare2(FieldElement h, FieldElement f) {
  var fs = feSquare(f);
  var h0 = fs[0]!;
  var h1 = fs[1]!;
  var h2 = fs[2]!;
  var h3 = fs[3]!;
  var h4 = fs[4]!;
  var h5 = fs[5]!;
  var h6 = fs[6]!;
  var h7 = fs[7]!;
  var h8 = fs[8]!;
  var h9 = fs[9]!;

  h0 += h0;
  h1 += h1;
  h2 += h2;
  h3 += h3;
  h4 += h4;
  h5 += h5;
  h6 += h6;
  h7 += h7;
  h8 += h8;
  h9 += h9;

  FeCombine(h, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9);
}