Documentation ¶
Overview ¶
Package eccutil contains various utility functions to implement protocols over ecc
Index ¶
- Constants
- Variables
- func BytesToInt(b []byte) *big.Int
- func ManyAdd(a ...*big.Int) *big.Int
- func ManyMult(a ...*big.Int) *big.Int
- func PointEqual(a, b *Point) bool
- func Sha1Hash(b []byte) []byte
- type Curve
- func (curve Curve) AddPoints(a, b *Point) *Point
- func (curve Curve) ExtractR(p *Point) (*big.Int, error)
- func (curve Curve) GenHash(msg []byte) *big.Int
- func (curve Curve) GenNV() (nv []byte, err error)
- func (curve Curve) GenNVint() (nvi *big.Int, err error)
- func (curve Curve) GenerateKey() (priv []byte, pub *Point, err error)
- func (curve Curve) Mod(a *big.Int) *big.Int
- func (curve Curve) ModInverse(a *big.Int) (*big.Int, error)
- func (curve Curve) RandomElement() (*big.Int, error)
- func (curve Curve) ScalarBaseMult(k []byte) *Point
- func (curve Curve) ScalarMult(p *Point, k []byte) *Point
- func (curve Curve) TestCoordinate(i *big.Int) (bool, error)
- func (curve Curve) TestInverse(a, b *big.Int) bool
- func (curve Curve) TestParams(a ...*big.Int) (bool, error)
- func (curve Curve) TestPoint(x1, y1, x2, y2 *big.Int) (bool, error)
- func (curve Curve) WithinRange(i *big.Int) bool
- type Point
Constants ¶
const MaxLoopCount = 1000
MaxLoopCount is the maximum number of tries we do for parameter search
Variables ¶
var ( // ErrMsgShort is returned when the message is too short ErrMsgShort = errors.New("singhdas: Message too short") // ErrBadCoordinate is returned if a coordinate is an illegal value ErrBadCoordinate = errors.New("singhdas: Coordinate illegal value") // ErrCoordinateBase is returned if a coordinate is in the base point ErrCoordinateBase = errors.New("singhdas: Coordinate illegal value (basepoint,reflection,inverse)") // ErrMaxLoop is returned if we cannot find parameters in time, should only happen during testing ErrMaxLoop = errors.New("singhdas: Cannot find parameters") // ErrNotRelPrime is returned if two numbers must be relative prime but are not ErrNotRelPrime = errors.New("singhdas: Not relative prime") // ErrParamReuse is returned if blinding parameters are used again ErrParamReuse = errors.New("singhdas: Do not reuse blinding parameters") // ErrBadBlindParam is returned if the blinding parameter is unusable ErrBadBlindParam = errors.New("singhdas: Blinding parameter unusable") // ErrHashDif is returned if the hash of the message diffs from the signature ErrHashDif = errors.New("singhdas: Hash does not match signature") // ErrSigWrong is returned if the signature does not verify for the message and public key of signer ErrSigWrong = errors.New("singhdas: Signature does not verify") )
Functions ¶
func BytesToInt ¶
BytesToInt is a helper function to convert bytes into Int the quick way
func PointEqual ¶
PointEqual returns true if the points a and b are the same
Types ¶
type Curve ¶
type Curve struct { Curve elliptic.Curve Rand io.Reader Params *elliptic.CurveParams Nminus *big.Int Hash func([]byte) []byte }
Curve encapsulates an elliptic curve
func (Curve) GenNV ¶
GenNV generates the signature blind/nonce. Copied from src/crypto/elliptic/elliptic.go GenerateKey
func (Curve) GenerateKey ¶
GenerateKey returns a new keypair
func (Curve) ModInverse ¶
ModInverse calculates the modular inverse of a over P
func (Curve) RandomElement ¶
RandomElement returns a random element within (1,N-1)
func (Curve) ScalarBaseMult ¶
ScalarBaseMult returns the result of a scalar multiplication
func (Curve) ScalarMult ¶
ScalarMult returns the result of a scalar multiplication
func (Curve) TestCoordinate ¶
TestCoordinate verifies that a number is not the coordinate of the base point of the curve nor that it is zero or one
func (Curve) TestInverse ¶
TestInverse verifies that a number is the multiplicative inverse over P of another number
func (Curve) TestParams ¶
TestParams runs tests on parameters to make sure they do not form a dangerous combination