utils

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 28 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ARToWinston

func ARToWinston(a *big.Float) *big.Int

ARToWinston 1 AR = 1000000000000

func Base64Decode

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

func Base64Encode

func Base64Encode(data []byte) string

func BundleItemSignData

func BundleItemSignData(d types.BundleItem) ([]byte, error)

func ByteArrayToLong

func ByteArrayToLong(b []byte) int

func ConcatBuffer

func ConcatBuffer(buffers ...[]byte) []byte

ConcatBuffer 更好的 slice append

func ContainsInSlice

func ContainsInSlice(items []string, item string) bool

ContainsInSlice checks if a string is in a slice of strings

func DecodeBlock

func DecodeBlock(body string) (*types.Block, error)

func DecodeBundle

func DecodeBundle(bundleBinary []byte) (*types.Bundle, error)

func DecodeBundleItem

func DecodeBundleItem(itemBinary []byte) (*types.BundleItem, error)

func DecodeBundleItemStream

func DecodeBundleItemStream(itemBinary io.Reader) (*types.BundleItem, error)

func DecodeBundleStream

func DecodeBundleStream(bundleData *os.File) (*types.Bundle, error)

func DeepHash

func DeepHash(data []interface{}) [48]byte

func DeserializeTags

func DeserializeTags(data []byte) ([]types.Tag, error)

func DeserializeTags1 added in v1.6.1

func DeserializeTags1(data []byte) ([]types.Tag, error)

func GenerateChunks

func GenerateChunks(data interface{}) (types.Chunks, error)

*

  • Generates the data_root, chunks & proofs
  • needed for a transaction. *
  • This also checks if the last chunk is a zero-length
  • chunk and discards that chunk and proof if so.
  • (we do not need to upload this zero length chunk) *
  • @param data

func GenerateIndepHash

func GenerateIndepHash(b types.Block) string

func GenerateItemBinary

func GenerateItemBinary(d *types.BundleItem) (by []byte, err error)

func GenerateItemBinaryStream

func GenerateItemBinaryStream(d *types.BundleItem) (binaryReader io.Reader, err error)

func GenerateRsaKey

func GenerateRsaKey(bits int) (*rsa.PrivateKey, error)

func GetBundleItemTagsBytes

func GetBundleItemTagsBytes(itemBinary []byte) ([]byte, error)

func GetChunk

func GetChunk(tx types.Transaction, idx int, data []byte) (*types.GetChunk, error)

func GetChunkStream

func GetChunkStream(tx types.Transaction, idx int, data *os.File) (*types.GetChunk, error)

func GetSignatureData

func GetSignatureData(tx *types.Transaction) ([]byte, error)

func Hash

func Hash(data [][]byte) []byte

func ItemSignerAddr

func ItemSignerAddr(b types.BundleItem) (string, error)

func LongTo32ByteArray

func LongTo32ByteArray(long int) []byte

func LongTo8ByteArray

func LongTo8ByteArray(long int) []byte

func NewBundle

func NewBundle(items ...types.BundleItem) (*types.Bundle, error)

func NewBundleItem

func NewBundleItem(owner string, signatureType int, target, anchor string, data []byte, tags []types.Tag) (*types.BundleItem, error)

func NewBundleItemStream

func NewBundleItemStream(owner string, signatureType int, target, anchor string, data io.Reader, tags []types.Tag) (*types.BundleItem, error)

func NewBundleStream

func NewBundleStream(items ...types.BundleItem) (*types.Bundle, error)

func OwnerToAddress

func OwnerToAddress(owner string) (string, error)

func OwnerToPubKey

func OwnerToPubKey(owner string) (*rsa.PublicKey, error)

func PaddedBigBytes

func PaddedBigBytes(bigint *big.Int, n int) []byte

func PrepareChunks

func PrepareChunks(tx *types.Transaction, data interface{}, dataSize int) error

func PstTransferTags

func PstTransferTags(contractId string, target string, qty int64, warp bool) ([]types.Tag, error)

func ReadBits

func ReadBits(bigint *big.Int, buf []byte)

func SerializeTags

func SerializeTags(tags []types.Tag) ([]byte, error)

func SerializeTags1 added in v1.6.1

func SerializeTags1(tags []types.Tag) ([]byte, error)

using bundle tx, avro serialize

func ShortTo2ByteArray

func ShortTo2ByteArray(long int) []byte

func Sign

func Sign(msg []byte, prvKey *rsa.PrivateKey) ([]byte, error)

func SignTransaction

func SignTransaction(tx *types.Transaction, prvKey *rsa.PrivateKey) error

func SubmitItemToArSeed

func SubmitItemToArSeed(item types.BundleItem, currency, arseedUrl string) (*schema.RespOrder, error)

func SubmitItemToBundlr

func SubmitItemToBundlr(item types.BundleItem, bundlrUrl string) (*types.BundlrResp, error)

func SubmitItemToMU added in v1.6.1

func SubmitItemToMU(item types.BundleItem, muUrl string) ([]byte, error)

func TagsDecode

func TagsDecode(base64Tags []types.Tag) ([]types.Tag, error)

func TagsEncode

func TagsEncode(tags []types.Tag) []types.Tag

func Verify

func Verify(msg []byte, pubKey *rsa.PublicKey, sign []byte) error

func VerifyBundleItem

func VerifyBundleItem(d types.BundleItem) error

func VerifyTransaction

func VerifyTransaction(tx types.Transaction) (err error)

func WinstonToAR

func WinstonToAR(w *big.Int) *big.Float

WinstonToAR 1 Winston = 0.000000000001 AR

Types

type ValidateResult

type ValidateResult struct {
	Offset     int
	LeftBound  int
	RightBound int
	ChunkSize  int
}

func ValidatePath

func ValidatePath(id []byte, dest, leftBound, rightBound int, path []byte) (*ValidateResult, bool)

验证 merkle path

Jump to

Keyboard shortcuts

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