decompressPoint method

  1. @override
ECPoint decompressPoint(
  1. int yTilde,
  2. BigInt x1
)
override

Implementation

@override
ECPoint decompressPoint(int yTilde, BigInt x1) {
  var x = fromBigInteger(x1);
  var alpha = (x * ((x * x) + (a as ECFieldElement))) + (b as ECFieldElement);
  var beta = alpha.sqrt();

  //
  // if we can't find a sqrt we haven't got a point on the
  // curve - run!
  //
  if (beta == null) {
    throw ArgumentError('Invalid point compression');
  }

  var betaValue = beta.toBigInteger()!;
  var bit0 = _testBit(betaValue, 0) ? 1 : 0;

  if (bit0 != yTilde) {
    // Use the other root
    beta = fromBigInteger(q! - betaValue);
  }

  return ECPoint(this, x, beta, true);
}