You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
701 B

  1. package ecc
  2. import (
  3. "bytes"
  4. "math/big"
  5. )
  6. var (
  7. BigZero = big.NewInt(int64(0))
  8. BigOne = big.NewInt(int64(1))
  9. ZeroPoint = Point{BigZero, BigZero}
  10. )
  11. // Point is the data structure for a point, containing the X and Y coordinates
  12. type Point struct {
  13. X *big.Int
  14. Y *big.Int
  15. }
  16. // Equal compares the X and Y coord of a Point and returns true if are the same
  17. func (p1 *Point) Equal(p2 Point) bool {
  18. if !bytes.Equal(p1.X.Bytes(), p2.X.Bytes()) {
  19. return false
  20. }
  21. if !bytes.Equal(p1.Y.Bytes(), p2.Y.Bytes()) {
  22. return false
  23. }
  24. return true
  25. }
  26. // String returns the components of the point in a string
  27. func (p *Point) String() string {
  28. return "(" + p.X.String() + ", " + p.Y.String() + ")"
  29. }