crypto

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
View Source
const PREFIX rune = '1'

Variables

View Source
var P256 = elliptic.P256()

Functions

func AESDecrypt

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

AESDecrypt decrypts the encrypted source with the given key.

func AESEncrypt

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

AESEncrypt encrypts the key with the given source.

func AddressToScriptHash

func AddressToScriptHash(address string, version byte) (*helper.UInt160, error)

func Base58CheckDecode

func Base58CheckDecode(input string) ([]byte, error)

Base58CheckDecode ...

func Base58CheckEncode

func Base58CheckEncode(input []byte) string

Base58CheckEncode ...

func Base64Decode

func Base64Decode(input string) ([]byte, error)

func Base64Encode

func Base64Encode(input []byte) string

func BytesToScriptHash

func BytesToScriptHash(script []byte) *helper.UInt160

func Decode

func Decode(input string) ([]byte, error)

Decode...

func Encode

func Encode(input []byte) string

Encode ... ref: neo/Cryptography/Base58.cs

func ExpectedECPointLength

func ExpectedECPointLength(curve *elliptic.Curve) int

ExpectedECPointLength return the expected byte array length

func Hash160

func Hash160(ba []byte) []byte

Hash160 first calculate SHA-256 hash result of ba, then RIPEMD-160 hash of the result

func Hash256

func Hash256(ba []byte) []byte

Hash256 gets the twice SHA-256 hash value of ba

func ScriptHashToAddress

func ScriptHashToAddress(scriptHash *helper.UInt160, version byte) string

func Sha256

func Sha256(b []byte) []byte

Sha256 gets the SHA-256 hash value of b

Types

type ECPoint

type ECPoint struct {
	X, Y  *big.Int
	Curve elliptic.Curve
	// contains filtered or unexported fields
}

func CreateECPoint

func CreateECPoint(x *big.Int, y *big.Int, curve *elliptic.Curve) (*ECPoint, error)

CreateECPoint creates an Elliptic Curve Point using the given (x,y) value and the given curve. Only use this method if you know what you are doing.

func DecodePoint

func DecodePoint(encoded []byte, curve *elliptic.Curve) (*ECPoint, error)

func DeserializeFrom

func DeserializeFrom(br *io.BinaryReader, curve *elliptic.Curve) (*ECPoint, error)

DeserializeFrom deserializes an ECPoint from the given io.Reader and curve.

func FromBytes

func FromBytes(data []byte, curve *elliptic.Curve) (*ECPoint, error)

func NewECPoint

func NewECPoint() (*ECPoint, error)

func NewECPointFromBytes

func NewECPointFromBytes(data []byte) (*ECPoint, error)

NewECPointFromBytes return a public key created from the given []byte.

func NewECPointFromString

func NewECPointFromString(s string) (*ECPoint, error)

NewECPointFromString return a public key created from the given hex string.

func Parse

func Parse(value string, curve *elliptic.Curve) (*ECPoint, error)

Parse checks if the string is an ECPoint on the give curve.

func (*ECPoint) CompareTo

func (p *ECPoint) CompareTo(other *ECPoint) int

CompareTo Compares two points

func (*ECPoint) Deserialize

func (p *ECPoint) Deserialize(br *io.BinaryReader)

Deserialize an ECPoint from the given io.Reader.

func (*ECPoint) EncodePoint

func (p *ECPoint) EncodePoint(compressed bool) []byte

EncodePoint encodes the point to a byte array

func (*ECPoint) Equals

func (p *ECPoint) Equals(other *ECPoint) bool

func (*ECPoint) ExistsIn

func (p *ECPoint) ExistsIn(points []ECPoint) bool

func (*ECPoint) GetSize added in v1.2.0

func (p *ECPoint) GetSize() int

GetSize return the byte size of this point

func (*ECPoint) IsInfinity

func (p *ECPoint) IsInfinity() bool

IsInfinity checks if point P is infinity on EllipticCurve ec.

func (*ECPoint) IsOnCurve

func (p *ECPoint) IsOnCurve() bool

IsOnCurve checks if this point is on the specified curve

func (*ECPoint) Serialize

func (p *ECPoint) Serialize(bw *io.BinaryWriter)

Serialize encodes a PublicKey to the given io.Writer.

func (*ECPoint) String

func (p *ECPoint) String() string

String implements the Stringer interface.

func (*ECPoint) ToECDsa

func (p *ECPoint) ToECDsa() *ecdsa.PublicKey

ToECDsa returns a ecdsa.PublicKey

type PublicKeySlice

type PublicKeySlice []*ECPoint

PublicKeySlice is an array of public keys.

func (PublicKeySlice) GetVarSize

func (keys PublicKeySlice) GetVarSize() int

func (PublicKeySlice) Len

func (keys PublicKeySlice) Len() int

func (PublicKeySlice) Less

func (keys PublicKeySlice) Less(i, j int) bool

func (PublicKeySlice) Swap

func (keys PublicKeySlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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