解释以下代码:@staticmethod def multiply(a, n, N, A, P): return SM2Key.fromJacobian(SM2Key.jacobianMultiply(SM2Key.toJacobian(a), n, N, A, P), P) @staticmethod def add(a, b, A, P): return SM2Key.fromJacobian(SM2Key.jacobianAdd(SM2Key.toJacobian(a), SM2Key.toJacobian(b), A, P), P) @staticmethod def inv(a, n): if a == 0: return 0 lm, hm = 1, 0 low, high = a % n, n while low > 1: r = high // low nm, new = hm - lm * r, high - low * r lm, low, hm, high = nm, new, lm, low return lm % n @staticmethod def toJacobian(Xp_Yp): Xp, Yp = Xp_Yp return Xp, Yp, 1 @staticmethod def fromJacobian(Xp_Yp_Zp, P): Xp, Yp, Zp = Xp_Yp_Zp z = SM2Key.inv(Zp, P) return (Xp * z ** 2) % P, (Yp * z ** 3) % P @staticmethod def jacobianDouble(Xp_Yp_Zp, A, P): Xp, Yp, Zp = Xp_Yp_Zp if not Yp: return 0, 0, 0 ysq = (Yp ** 2) % P S = (4 * Xp * ysq) % P M = (3 * Xp ** 2 + A * Zp ** 4) % P nx = (M ** 2 - 2 * S) % P ny = (M * (S - nx) - 8 * ysq ** 2) % P nz = (2 * Yp * Zp) % P return nx, ny, nz @staticmethod def jacobianAdd(Xp_Yp_Zp, Xq_Yq_Zq, A, P): Xp, Yp, Zp = Xp_Yp_Zp Xq, Yq, Zq = Xq_Yq_Zq if not Yp: return Xq, Yq, Zq if not Yq: return Xp, Yp, Zp U1 = (Xp * Zq ** 2) % P U2 = (Xq * Zp ** 2) % P S1 = (Yp * Zq ** 3) % P S2 = (Yq * Zp ** 3) % P if U1 == U2: if S1 != S2: return 0, 0, 1 return SM2Key.jacobianDouble((Xp, Yp, Zp), A, P) H = U2 - U1 R = S2 - S1 H2 = (H * H) % P H3 = (H * H2) % P U1H2 = (U1 * H2) % P nx = (R ** 2 - H3 - 2 * U1H2) % P ny = (R * (U1H2 - nx) - S1 * H3) % P nz = (H * Zp * Zq) % P return nx, ny, nz @staticmethod def jacobianMultiply(Xp_Yp_Zp, n, N, A, P): Xp, Yp, Zp = Xp_Yp_Zp if Yp == 0 or n == 0: return (0, 0, 1) if n == 1: return (Xp, Yp, Zp) if n < 0 or n >= N: return SM2Key.jacobianMultiply((Xp, Yp, Zp), n % N, N, A, P) if (n % 2) == 0: return SM2Key.jacobianDouble(SM2Key.jacobianMultiply((Xp, Yp, Zp), n // 2, N, A, P), A, P) if (n % 2) == 1: mv = SM2Key.jacobianMultiply((Xp, Yp, Zp), n // 2, N, A, P) return SM2Key.jacobianAdd(SM2Key.jacobianDouble(mv, A, P), (Xp, Yp, Zp), A, P)