Skip to content

Commit

Permalink
Merge pull request #58 from nlordell/fix-ec-dbl-inline
Browse files Browse the repository at this point in the history
Fix Other Occurences of Inlined EC Dbl
  • Loading branch information
rdubois-crypto authored Jan 15, 2024
2 parents c3715de + d122b86 commit d9bb3b0
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions solidity/src/FCL_elliptic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,10 @@ function SqrtMod(uint256 self) internal view returns (uint256 result){
T3 := mulmod(X, T2, p) // S = X1*V

T1 := mulmod(T1, T2, p) // W=UV
y2 := addmod(X, zz, p) //X+ZZ
let TT1 := addmod(X, sub(p, zz), p) //X-ZZ
y2 := mulmod(y2, TT1, p) //(X-ZZ)(X+ZZ)
T4 := mulmod(3, y2, p) //M
y2 := mulmod(addmod(X, zz, p), addmod(X, sub(p, zz), p), p) //(X-ZZ)(X+ZZ)
T4 := mulmod(3, y2, p) //M=3*(X-ZZ)(X+ZZ)

zzz := mulmod(TT1, zzz, p) //zzz3=W*zzz1
zzz := mulmod(T1, zzz, p) //zzz3=W*zzz1
zz := mulmod(T2, zz, p) //zz3=V*ZZ1, V free

X := addmod(mulmod(T4, T4, p), mulmod(minus_2, T3, p), p) //X3=M^2-2S
Expand Down Expand Up @@ -755,12 +753,10 @@ function SqrtMod(uint256 self) internal view returns (uint256 result){
let T3 := mulmod(X, T2, p) // S = X1*V

T1 := mulmod(T1, T2, p) // W=UV
y2 := addmod(X, zz, p) //X+ZZ
let TT1 := addmod(X, sub(p, zz), p) //X-ZZ
y2 := mulmod(y2, TT1, p) //(X-ZZ)(X+ZZ)
let T4 := mulmod(3, y2, p) //M
y2 := mulmod(addmod(X, zz, p), addmod(X, sub(p, zz), p), p) //(X-ZZ)(X+ZZ)
let T4 := mulmod(3, y2, p) //M=3*(X-ZZ)(X+ZZ)

zzz := mulmod(TT1, zzz, p) //zzz3=W*zzz1
zzz := mulmod(T1, zzz, p) //zzz3=W*zzz1
zz := mulmod(T2, zz, p) //zz3=V*ZZ1, V free

X := addmod(mulmod(T4, T4, p), mulmod(minus_2, T3, p), p) //X3=M^2-2S
Expand Down

0 comments on commit d9bb3b0

Please sign in to comment.