utility

package
v0.0.0-...-3f353b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base58

type Base58 struct {
	// contains filtered or unexported fields
}

Base58 is a encode/decode utility for base58 strings.

func NewBase58

func NewBase58() Base58

NewBase58 creates a new Base58 struct, using the default alphabet.

func (Base58) Decode

func (b Base58) Decode(s string) ([]byte, error)

Decode decodes the base58 encoded string.

func (Base58) Encode

func (b Base58) Encode(bytes []byte) string

Encode encodes a byte slice to be a base58 encoded string.

type EllipticCurve

type EllipticCurve struct {
	A *big.Int
	B *big.Int
	P *big.Int
	G EllipticCurvePoint
	N *big.Int
	H *big.Int
	// contains filtered or unexported fields
}

EllipticCurve represents the parameters of a short Weierstrass equation elliptic curve.

func NewEllipticCurve

func NewEllipticCurve() EllipticCurve

NewEllipticCurve creates a new EllipticCurve struct.

func (*EllipticCurve) Add

Add computes R = P + Q on EllipticCurve ec.

func (*EllipticCurve) IsOnCurve

func (e *EllipticCurve) IsOnCurve(point EllipticCurvePoint) bool

IsOnCurve checks if point P is on EllipticCurve ec.

func (*EllipticCurve) ScalarBaseMult

func (e *EllipticCurve) ScalarBaseMult(k *big.Int) (*EllipticCurvePoint, error)

ScalarBaseMult computes Q = k * G on EllipticCurve ec.

func (*EllipticCurve) ScalarMult

ScalarMult computes Q = k * P on EllipticCurve ec.

type EllipticCurvePoint

type EllipticCurvePoint struct {
	X *big.Int
	Y *big.Int
}

EllipticCurvePoint represents a point on an elliptic curve.

func (EllipticCurvePoint) Format

func (p EllipticCurvePoint) Format() string

Format encodes the bytes of an EllipticCurvePoint for debugging.

type ModularArithmetic

type ModularArithmetic struct{}

ModularArithmetic is a set of helper functions for carrying out specialised mathematical operations in an elliptic curve.

func NewModularArithmetic

func NewModularArithmetic() ModularArithmetic

NewModularArithmetic creates a new ModularArithmetic struct.

func (ModularArithmetic) Add

func (m ModularArithmetic) Add(x *big.Int, y *big.Int, p *big.Int) *big.Int

Add computes: (x + y) % p.

func (ModularArithmetic) Exp

func (m ModularArithmetic) Exp(x *big.Int, y *big.Int, p *big.Int) *big.Int

Exp computes: (x^e) % p.

func (ModularArithmetic) Inverse

func (m ModularArithmetic) Inverse(x *big.Int, p *big.Int) *big.Int

Inverse computes: (1/x) % p.

func (ModularArithmetic) Mul

func (m ModularArithmetic) Mul(x *big.Int, y *big.Int, p *big.Int) *big.Int

Mul computes: (x * y) % p.

func (ModularArithmetic) Sqrt

func (m ModularArithmetic) Sqrt(x *big.Int, p *big.Int) (*big.Int, error)

Sqrt computes: sqrt(x) % p.

func (ModularArithmetic) Sub

func (m ModularArithmetic) Sub(x *big.Int, y *big.Int, p *big.Int) *big.Int

Sub computes: (x - y) % p.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL