mymath

package
v0.0.0-...-03677bc Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2012 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASCII2Hex

func ASCII2Hex(s string) []byte

TODO: test

func ASCII2HexRev

func ASCII2HexRev(s string) []byte

func AddByte

func AddByte(one []byte, two byte) []byte

func AreHexesEqual

func AreHexesEqual(one, two []byte) bool

func AreStringsEqual

func AreStringsEqual(one, two string) bool

func Base582Hex

func Base582Hex(b string) []byte

convert base58 to hex bytes

func Big2Hex

func Big2Hex(b *big.Int) []byte

TODO: test

func Big2HexPadded

func Big2HexPadded(b *big.Int, paddingSize int) []byte

func Big2HexRev

func Big2HexRev(b *big.Int) []byte

TODO: test

func Bits2Difficulty

func Bits2Difficulty(bits uint32) (float64, error)

TODO: test and add to tests

func Bits2Target

func Bits2Target(bits uint32) *big.Int

TODO: test and add to tests

func Bits2TargetHex

func Bits2TargetHex(bits uint32) []byte

TODO: test and add to tests

func Bits2TargetHexRev

func Bits2TargetHexRev(bits uint32) []byte

TODO: test and add to tests

func BitsRev2TargetHexRev

func BitsRev2TargetHexRev(bits uint32) []byte

TODO: test and add to tests

func BitsString2TargetHexRev

func BitsString2TargetHexRev(bits string) []byte

func Byte2String

func Byte2String(b []byte) string

func CalculateBitMidstate

func CalculateBitMidstate(data []byte) []byte

TODO: test and add to tests

func CheckAddressStringValidity

func CheckAddressStringValidity(addr string) bool

func CheckAddressValidity

func CheckAddressValidity(addr Base58) bool

func CheckSolution

func CheckSolution(pubKey, solution, pattern string, netByte byte) (string, string)

func CombinePrivateKeys

func CombinePrivateKeys(one, two string) *big.Int

func CombinePublicKeys

func CombinePublicKeys(one, two string) (*big.Int, *big.Int)

func ConcatBytes

func ConcatBytes(list ...[]byte) []byte

func DoubleDoubleSHA

func DoubleDoubleSHA(a []byte, b []byte) []byte

TODO: test and add to tests double hash input bytes, double hash their concatanation

func DoubleSHA

func DoubleSHA(b []byte) []byte

TODO: test and add to tests double SHA-256 hashing of a single byte array

func DoubleSHAPair

func DoubleSHAPair(a []byte, b []byte) []byte

TODO: test and add to tests double SHA-256 hash of a concatenation of the two inputs

func DoubleSHAPairRev

func DoubleSHAPairRev(a []byte, b []byte) []byte

TODO: test and add to tests double SHA-256 hash of a concatenation of the reverse of two inputs

func DoubleSHARev

func DoubleSHARev(b []byte) []byte

TODO: test and add to tests reverse double SHA-256 hashing of a single byte array

func Float642Str

func Float642Str(f float64) string

func Float642String

func Float642String(f float64) string

func GenerateMerkleRoot

func GenerateMerkleRoot(leafs [][]byte) []byte

TODO: test and add to tests

func GenerateMerkleTree

func GenerateMerkleTree(leafs [][]byte) [][]byte

TODO: test and add to tests

func GenerateMerkleTreeFromString

func GenerateMerkleTreeFromString(leafs []string) []string

TODO: test and add to tests

func Hex2Base58Str

func Hex2Base58Str(val []byte) string

func Hex2Base58String

func Hex2Base58String(val []byte) string

func Hex2Big

func Hex2Big(b []byte) *big.Int

func Hex2Int

func Hex2Int(b []byte) int

func Hex2Int64

func Hex2Int64(b []byte) int64

func Hex2Str

func Hex2Str(b []byte) string

func Hex2String

func Hex2String(b []byte) string

func Hex2Uint32

func Hex2Uint32(b []byte) uint32

func Hex2Uint64

func Hex2Uint64(b []byte) uint64

func HexRev2Big

func HexRev2Big(rev []byte) *big.Int

func HexRev2Str

func HexRev2Str(b []byte) string

func HexRev2String

func HexRev2String(b []byte) string

func HexRev2Uint32

func HexRev2Uint32(b []byte) uint32

func HexRev2Uint64

func HexRev2Uint64(b []byte) uint64

func Int2BitHex

func Int2BitHex(i int) []byte

TODO: test

func Int2Hex

func Int2Hex(i int) []byte

func Int2Str

func Int2Str(i int) string

func Int2String

func Int2String(i int) string

func Int642Hex

func Int642Hex(i64 int64) []byte

func Int642Str

func Int642Str(i int64) string

func Int642String

func Int642String(i int64) string

func Makesecp256k1

func Makesecp256k1()

TODO: test and add to tests

func PointCoordinatesToPublicKey

func PointCoordinatesToPublicKey(x, y *big.Int) string

func PublicKeyToPointCoordinates

func PublicKeyToPointCoordinates(pubKey string) (*big.Int, *big.Int)

func RandomHex

func RandomHex(length int) []byte

func Randuint64

func Randuint64() []byte

func Randuint64Rev

func Randuint64Rev() []byte

func Rev

func Rev(b []byte) []byte

TODO: use this function to reverse some of the below functions?

func RevTest

func RevTest() bool

func RevWords

func RevWords(b []byte) []byte

func RevWords2

func RevWords2(b []byte) []byte

func RevWords2Str

func RevWords2Str(b string) string

func RevWordsStr

func RevWordsStr(b string) string

func ReverseByteOrder

func ReverseByteOrder(b []byte) []byte

TODO: test

func Ripemd

func Ripemd(b []byte) []byte

TODO: test and add to tests RIPEMD-160 operation for bitcoin address hashing

func RipemdRev

func RipemdRev(b []byte) []byte

TODO: test and add to tests reverse RIPEMD-160 hash

func SHARipemd

func SHARipemd(b []byte) []byte

TODO: test and add to tests SHA-256 RIPEMD-160 operation for bitcoin address hashing

func SHARipemdRev

func SHARipemdRev(b []byte) []byte

TODO: test and add to tests reverse SHA-256 RIPEMD-160 hash

func SingleSHA

func SingleSHA(b []byte) []byte

TODO: test and add to tests Single SHA-256 hashing of a single byte array

func SingleSHA1

func SingleSHA1(b []byte) []byte

TODO: test and add to tests Single SHA-1 hashing of a single byte array

func SingleSHA1Rev

func SingleSHA1Rev(b []byte) []byte

Reversed SHA-1 hashing of a single byte array TODO: test and add to tests

func SingleSHARev

func SingleSHARev(b []byte) []byte

TODO: test and add to tests Reversed single SHA-256 hashing of a single byte array

func SplitStrings

func SplitStrings(str, separator string) []string

func Str2Big

func Str2Big(s string) *big.Int

TODO: test

func Str2BigBase

func Str2BigBase(s string, base int) *big.Int

TODO: test

func Str2Float

func Str2Float(s string) float64

func Str2Hex

func Str2Hex(s string) []byte

func Str2HexRev

func Str2HexRev(s string) []byte

func Str2Int64

func Str2Int64(s string) int64

func Str2Uint32

func Str2Uint32(s string) uint32

func String2Big

func String2Big(s string) *big.Int

TODO: test

func String2BigBase

func String2BigBase(s string, base int) *big.Int

TODO: test

func String2Float

func String2Float(s string) float64

func String2Hex

func String2Hex(s string) []byte

func String2Hex32

func String2Hex32(s string) [32]byte

func String2HexRev

func String2HexRev(s string) []byte

func Target2Bits

func Target2Bits(target *big.Int) uint32

TODO: test and add to tests

func Target2Difficulty

func Target2Difficulty(target *big.Int) (float64, error)

TODO: test and add to tests

func TestBase58

func TestBase58()

TODO: do and test everything

func TestBitAddress

func TestBitAddress()

func TestBitsTargetDifficultyConversions

func TestBitsTargetDifficultyConversions() bool

TODO: expand and add to tests

func TestCompile

func TestCompile() bool

func TestEverything

func TestEverything() bool

TODO: do

func TestEverythingBitmath

func TestEverythingBitmath() bool

func TestGenerateMerkleTree

func TestGenerateMerkleTree() bool

func TestLen

func TestLen() bool

func TestVarInt

func TestVarInt() bool

func TestVarInt2Hex

func TestVarInt2Hex() bool

func TestVarInt2HexRev

func TestVarInt2HexRev() bool

func TestVarStr

func TestVarStr() bool

func ToLower

func ToLower(s string) string

func ToUpper

func ToUpper(s string) string

func Uint162Hex

func Uint162Hex(ui uint16) []byte

func Uint162HexRev

func Uint162HexRev(ui uint16) []byte

func Uint2Hex

func Uint2Hex(ui uint) []byte

TODO: test

func Uint322Hex

func Uint322Hex(ui uint32) []byte

func Uint322HexRev

func Uint322HexRev(ui uint32) []byte

func Uint642Hex

func Uint642Hex(ui uint64) []byte

func Uint642HexRev

func Uint642HexRev(ui uint64) []byte

Types

type Base58

type Base58 string

type to hold the Base58 string

func Big2Base58

func Big2Base58(val *big.Int) Base58

encodes big.Int to base58 string

func Hex2Base58

func Hex2Base58(val []byte) Base58

encodes hex bytes into base58

func Int2Base58

func Int2Base58(val int) Base58

encodes int to base58 string

func Str2Hex58

func Str2Hex58(val string) Base58

func StrHex2Base58

func StrHex2Base58(val string) Base58

func String2Base58

func String2Base58(val string) Base58

func StringHex2Base58

func StringHex2Base58(val string) Base58

encodes string stored hex bytes into base58

func (Base58) Base582Big

func (b Base58) Base582Big() *big.Int

func (Base58) Base582Int

func (b Base58) Base582Int() int

convert base58 to int

func (Base58) BitHex

func (b Base58) BitHex() []byte

convert base58 to hexes used by Bitcoins (keeping the zeroes on the front, 25 bytes long)

func (Base58) ToBig

func (b Base58) ToBig() *big.Int

Convert base58 to big.Int

func (Base58) ToHex

func (b Base58) ToHex() []byte

convert base58 to hex bytes

func (Base58) ToInt

func (b Base58) ToInt() int

convert base58 to int

type BitAddress

type BitAddress struct {
	PrivateKey []byte //private key, can be encrypted
	Encrypted  bool   //checked if the private key is encrypted
	PublicKey  []byte //public key
	Hash160    []byte //RIPEMD hash
	Hash       []byte //RIPEMD with network bit and checksum
	Base       Base58 //base58 encoded address
}

structure to keep different encodings of the bitcoin adress

func NewAddressFromPrivateKey

func NewAddressFromPrivateKey(privateKey []byte) (*BitAddress, error)

func NewAddressFromPrivateKeyOtherNets

func NewAddressFromPrivateKeyOtherNets(netByte byte, privateKey []byte) (*BitAddress, error)

func NewFromBase

func NewFromBase(b Base58) *BitAddress

creates the structure to hold the base58 address

func NewFromBaseString

func NewFromBaseString(s string) *BitAddress

func NewFromPublicKey

func NewFromPublicKey(netbyte byte, key []byte) *BitAddress

TODO: do something for TESTnet? TODO: update and revise creates a bitcoin address from the public key

func NewFromPublicKeyString

func NewFromPublicKeyString(netByte byte, s string) *BitAddress

creates a new bitcoin address from a string representing a public key

func NewRandomAddress

func NewRandomAddress() (*BitAddress, error)

func NewRandomAddressOtherNets

func NewRandomAddressOtherNets(netByte byte) (*BitAddress, error)

func (BitAddress) CheckValidity

func (ba BitAddress) CheckValidity() bool

TODO: do check validity of bitcoin address

type VarInt

type VarInt uint64

func DecodeVarInt

func DecodeVarInt(b []byte) VarInt

TODO: test

func DecodeVarIntGiveRest

func DecodeVarIntGiveRest(b []byte) (VarInt, []byte)

TODO: check and add to tests

func (VarInt) Compile

func (vi VarInt) Compile() []byte

func (VarInt) Len

func (vi VarInt) Len() int

type VarStr

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

func (*VarStr) Compile

func (vs *VarStr) Compile() []byte

func (*VarStr) Len

func (vs *VarStr) Len() int

func (*VarStr) Read

func (vs *VarStr) Read() string

func (*VarStr) Set

func (vs *VarStr) Set(newString string)

Jump to

Keyboard shortcuts

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