github.com/LagrangeDev/LagrangeGo@v0.0.0-20240512064304-ad4a85e10cb4/utils/crypto/ecdh/point.go (about)

     1  package ecdh
     2  
     3  /*
     4  
     5  import "math/big"
     6  
     7  type ep struct {
     8  	x, y *big.Int
     9  }
    10  
    11  func newEllipticPoint(x, y *big.Int) *ep {
    12  	return &ep{x: x, y: y}
    13  }
    14  
    15  func (p *ep) Equals(other *ep) bool {
    16  	// return p.x == other.x && p.y == other.y
    17  	return (p.x.Cmp(other.x) == 0) && (p.y.Cmp(other.y) == 0)
    18  }
    19  
    20  func (p *ep) Negate() *ep {
    21  	// return &EllipticPoint{-p.x, -p.y}
    22  	return &ep{
    23  		x: new(big.Int).Neg(p.x),
    24  		y: new(big.Int).Neg(p.y),
    25  	}
    26  }
    27  
    28  func (p *ep) IsDefault() bool {
    29  	// return p.x == 0 && p.y == 0
    30  	return (p.x.Cmp(big.NewInt(0)) == 0) && (p.y.Cmp(big.NewInt(0)) == 0)
    31  }
    32  
    33  */