crypto

package
v0.0.0-...-438f3b5 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(crypted, key []byte) ([]byte, error)

AESDecrypt decrypts the encrypted source with the given key.

func AESDecryptV2

func AESDecryptV2(src, key string) string

AESDecryptV2 decode by AES output string

func AESEncrypt

func AESEncrypt(src, key []byte) ([]byte, error)

AESEncrypt encrypts the key with the given source.

func AESEncryptV2

func AESEncryptV2(src, key string) string

AESEncryptV2 encode by AES output string

func Base58CheckDecode

func Base58CheckDecode(s string) (b []byte, err error)

Base58CheckDecode decodes the given string.

func Base58CheckEncode

func Base58CheckEncode(b []byte) string

Base58checkEncode encodes b into a base-58 check encoded string.

func Base58Decode

func Base58Decode(s string) ([]byte, error)

Base58Decode decodes the base58 encoded string.

func Base58Encode

func Base58Encode(bytes []byte) string

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

Types

type ECPoint

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

ECPoint represents a point on the EllipticCurve.

func ECPointFromReader

func ECPointFromReader(r io.Reader) (point ECPoint, err error)

ECPointFromReader return a new point from the given reader. f == 4, 6 or 7 are not implemented.

func RandomECPoint

func RandomECPoint() ECPoint

RandomECPoint returns a random generated ECPoint, mostly used for testing.

func (ECPoint) EncodeBinary

func (p ECPoint) EncodeBinary(w io.Writer) error

EncodeBinary encodes the point to the given io.Writer.

func (*ECPoint) IsInfinity

func (p *ECPoint) IsInfinity() bool

IsInfinity checks if point P is infinity on EllipticCurve ec.

func (*ECPoint) String

func (p *ECPoint) String() string

String implements the Stringer interface.

type EllipticCurve

type EllipticCurve struct {
	A *big.Int
	B *big.Int
	P *big.Int
	G ECPoint
	N *big.Int
	H *big.Int
}

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

func NewEllipticCurve

func NewEllipticCurve() EllipticCurve

NewEllipticCurve returns a ready to use EllipticCurve with preconfigured fields for the NEO protocol.

func (*EllipticCurve) Add

func (c *EllipticCurve) Add(P, Q ECPoint) (R ECPoint)

Add computes R = P + Q on EllipticCurve ec.

func (*EllipticCurve) Decompress

func (c *EllipticCurve) Decompress(x *big.Int, ylsb uint) (P ECPoint, err error)

Decompress decompresses coordinate x and ylsb (y's least significant bit) into a ECPoint P on EllipticCurve ec.

func (*EllipticCurve) IsInfinity

func (c *EllipticCurve) IsInfinity(P ECPoint) bool

IsInfinity checks if point P is infinity on EllipticCurve ec.

func (*EllipticCurve) IsOnCurve

func (c *EllipticCurve) IsOnCurve(P ECPoint) bool

IsOnCurve checks if point P is on EllipticCurve ec.

func (*EllipticCurve) ScalarBaseMult

func (c *EllipticCurve) ScalarBaseMult(k *big.Int) (Q ECPoint)

ScalarBaseMult computes Q = k * G on EllipticCurve ec.

func (*EllipticCurve) ScalarMult

func (c *EllipticCurve) ScalarMult(k *big.Int, P ECPoint) (Q ECPoint)

ScalarMult computes Q = k * P on EllipticCurve ec.

Jump to

Keyboard shortcuts

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