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 (c1 *Point) Equal(c2 Point) bool {
22 if !bytes.Equal(c1.X.Bytes(), c2.X.Bytes()) {
23 return false
24 }
25 if !bytes.Equal(c1.Y.Bytes(), c2.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}