Post
Topic
Board Development & Technical Discussion
Re: zero point of secp256k1
by
pooya87
on 26/12/2021, 12:12:31 UTC
solve this please
Code:
example input: # + and - mixed
-3942323
56456
-3
-342
-33398
683
Code:
output : #always positive value
3942323
56456
3
342
33398
683

i know abs() method returns the absolute value of a number  and √(x^2) = all value positive

i need math steps
example:
https://www.wolframalpha.com/input/?i=3942323%2F-1+*++-1
https://www.wolframalpha.com/input/?i=-3942323%2F-1+*++-1

 √(x^2) = only rootsqure alternative method maths explain please #mybad english
I'm not sure what you are asking me to solve but in modular arithmetic we aren't arbitrarily changing the sign of a negative number to positive. Instead the congruent number is computed.
For example if the modulus is 7 then -1 becomes 6 or -9 becomes 5.
Essentially we compute (a mod m) then if the result was negative we add modulus to the result.
Code:
-9%7=-2 -> -2+7=5 -> -9 ≡ -2 ≡ 5 (mod 7)

As for square root, it is also different in modular arithmetic. You have to compute r so that r2≡a (mod 9).
For secp256k1 curve we have a simple solution to compute ModPow(a, (p+1)/4, p) but in general cases where p%4 != 3 we have to use an algorithm like Tonelli–Shanks.