← Back to Bitcoin Improvement Proposals
BIPinformational

BIP374: add subtraction operator for GE class

This commit implements the subtraction operator (__sub__) for the GE (Group Element) class in the secp256k1.py file as requested in the TODO comment in reference.py. The implementation is straightforward, leveraging the existing __neg__ method to define subtraction as addition with the negated element: self + (-a). After implementing the operator, the code in reference.py was simplified by replacing expressions like: s * G + (-e * A) with s * G - e * A This makes the code more readable and di

No reviews
VolodymyrBg·Updated Apr 16, 2025·0 reviews·0 attestations·View source
Collections:BIPs — Merged

Specification

This commit implements the subtraction operator (sub) for the GE (Group Element) class in the secp256k1.py file as requested in the TODO comment in reference.py.

The implementation is straightforward, leveraging the existing neg method to define subtraction as addition with the negated element: self + (-a).

After implementing the operator, the code in reference.py was simplified by replacing expressions like: s * G + (-e * A) with s * G - e * A

This makes the code more readable and directly matches the mathematical notation used in the BIP-0374 specification.

Discussion (0 threads)

Loading discussions...