Merge pull request #1779 from VolodymyrBg/AE5959595959

BIP374: add subtraction operator for GE class
This commit is contained in:
Jon Atack authored and GitHub committed 2025-04-16 08:08:34 -06:00
commit 05d546d581
2 files changed
+6 -3

No files matched your search

+2 -3
View File
@@ -87,11 +87,10 @@ def dleq_verify_proof(
s = int.from_bytes(proof[32:], "big")
if s >= GE.ORDER:
return False
# TODO: implement subtraction operator (__sub__) for GE class to simplify these terms
R1 = s * G + (-e * A)
R1 = s * G - e * A
if R1.infinity:
return False
R2 = s * B + (-e * C)
R2 = s * B - e * C
if R2.infinity:
return False
if e != dleq_challenge(A, B, C, R1, R2, m, G):
+4
View File
@@ -240,6 +240,10 @@ class GE:
return self
return GE(self.x, -self.y)
def __sub__(self, a):
"""Subtract a group element from another."""
return self + (-a)
def to_bytes_compressed(self):
"""Convert a non-infinite group element to 33-byte compressed encoding."""
assert not self.infinity