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