I know from reading another forum that a public key in bitcoin is a point P. To do P2, you multiply 12 to P where 12 is the multiplicative inverse of 2 in Zn. It is an integer that can be found using the extended Euclidean algorithm and is 57896044618658097711785492504343953926418782139537452191302581570759080747169 in the case of secp256k1.
2^-1 (mod n) = 57896044618658097711785492504343953926418782139537452191302581570759080747169
2 * 57896044618658097711785492504343953926418782139537452191302581570759080747169 = 1 (mod n)
Multiplying a point by this number will "half" the point.
My question is how would I code this in python?