TODO: double check if the function is okay affineFromJacobian reverses the Jacobian transform. See the comment at the top of the file.
(x, y, z *big.Int)
| 117 | // affineFromJacobian reverses the Jacobian transform. See the comment at the |
| 118 | // top of the file. |
| 119 | func (BitCurve *BitCurve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) { |
| 120 | zinv := new(big.Int).ModInverse(z, BitCurve.P) |
| 121 | zinvsq := new(big.Int).Mul(zinv, zinv) |
| 122 | |
| 123 | xOut = new(big.Int).Mul(x, zinvsq) |
| 124 | xOut.Mod(xOut, BitCurve.P) |
| 125 | zinvsq.Mul(zinvsq, zinv) |
| 126 | yOut = new(big.Int).Mul(y, zinvsq) |
| 127 | yOut.Mod(yOut, BitCurve.P) |
| 128 | return |
| 129 | } |
| 130 | |
| 131 | // Add returns the sum of (x1,y1) and (x2,y2). |
| 132 | func (BitCurve *BitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) { |