iota.lib.go: Index | Files | Directories

package giota

import ""


Package Files

api.go bigint.go bundle.go constants.go curl.go curl_transform.go kerl.go pow_c.go pow_go.go pow_sse.go sign.go transaction.go transfer.go trinary.go


const (
    TryteAlphabet             = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    MinTryteValue             = -13
    MaxTryteValue             = 13
    SignatureSize             = 6561
    HashSize                  = 243
    Depth                     = 3
    Radix                     = 3
    DefaultMinWeightMagnitude = 14

Various constants for giota.

const (
    Ki  = 1000
    Mi  = 1000000
    Gi  = 1000000000
    Ti  = 1000000000000
    Pi  = 1000000000000000

Units for iota token.

const (
    SignatureMessageFragmentTrinaryOffset = 0
    SignatureMessageFragmentTrinarySize   = 6561
    AddressTrinaryOffset                  = SignatureMessageFragmentTrinaryOffset + SignatureMessageFragmentTrinarySize
    AddressTrinarySize                    = 243
    ValueTrinaryOffset                    = AddressTrinaryOffset + AddressTrinarySize
    ValueTrinarySize                      = 81
    ObsoleteTagTrinaryOffset              = ValueTrinaryOffset + ValueTrinarySize
    ObsoleteTagTrinarySize                = 81
    TimestampTrinaryOffset                = ObsoleteTagTrinaryOffset + ObsoleteTagTrinarySize
    TimestampTrinarySize                  = 27
    CurrentIndexTrinaryOffset             = TimestampTrinaryOffset + TimestampTrinarySize
    CurrentIndexTrinarySize               = 27
    LastIndexTrinaryOffset                = CurrentIndexTrinaryOffset + CurrentIndexTrinarySize
    LastIndexTrinarySize                  = 27
    BundleTrinaryOffset                   = LastIndexTrinaryOffset + LastIndexTrinarySize
    BundleTrinarySize                     = 243
    TrunkTransactionTrinaryOffset         = BundleTrinaryOffset + BundleTrinarySize
    TrunkTransactionTrinarySize           = 243
    BranchTransactionTrinaryOffset        = TrunkTransactionTrinaryOffset + TrunkTransactionTrinarySize
    BranchTransactionTrinarySize          = 243
    TagTrinaryOffset                      = BranchTransactionTrinaryOffset + BranchTransactionTrinarySize
    TagTrinarySize                        = 81
    AttachmentTimestampTrinaryOffset      = TagTrinaryOffset + TagTrinarySize
    AttachmentTimestampTrinarySize        = 27

    AttachmentTimestampLowerBoundTrinaryOffset = AttachmentTimestampTrinaryOffset + AttachmentTimestampTrinarySize
    AttachmentTimestampLowerBoundTrinarySize   = 27
    AttachmentTimestampUpperBoundTrinaryOffset = AttachmentTimestampLowerBoundTrinaryOffset + AttachmentTimestampLowerBoundTrinarySize
    AttachmentTimestampUpperBoundTrinarySize   = 27
    NonceTrinaryOffset                         = AttachmentTimestampUpperBoundTrinaryOffset + AttachmentTimestampUpperBoundTrinarySize
    NonceTrinarySize                           = 81

Trinary sizes and offsets of a transaction

const (
    ByteLength     = 48
    TritHashLength = 243
    IntLength      = ByteLength / 4

constants regarding byte and trit lengths

const DefaultNumberOfWalks = 5

Number of random walks to perform. Currently IRI defaults to a range of 5 to 27


var (

    // EmptyHash represents an empty hash.
    EmptyHash Trytes = "999999999999999999999999999999999999999999999999999999999999999999999999999999999"
    // EmptyAddress represents an empty address.
    EmptyAddress Address = "999999999999999999999999999999999999999999999999999999999999999999999999999999999"
var (
    ErrSeedTritsLength  = errors.New("seed trit slice should be HashSize entries long")
    ErrSeedTrytesLength = errors.New("seed string needs to be HashSize / 3 characters long")
    ErrKeyTritsLength   = errors.New("key trit slice should be a multiple of HashSize*27 entries long")

errors used in sign

var (
    ErrInvalidAddressTrytes = errors.New("addresses without checksum are 81 trytes in length")
    ErrInvalidAddressTrits  = errors.New("addresses without checksum are 243 trits in length")

Error types for address

var (
    ErrInvalidTransactionType = errors.New("invalid transaction type")
    ErrInvalidTransactionHash = errors.New("invalid transaction hash")
    ErrInvalidTransaction     = errors.New("malformed transaction")

errors for tx

var (

    // PowProcs is number of concurrent processes (default is NumCPU()-1)
    PowProcs int
var (
    PublicNodes = []string{

PublicNodes is a list of known public nodes from

func GetBestPoW Uses

func GetBestPoW() (string, PowFunc)

GetBestPoW returns most preferable PoW func.

func IsValidSig Uses

func IsValidSig(expectedAddress Address, signatureFragments []Trytes, bundleHash Trytes) bool

IsValidSig validates signatureFragment.

func IsValidTrit Uses

func IsValidTrit(t int8) error

IsValidTrit returns true if t is a valid trit.

func IsValidTryte Uses

func IsValidTryte(t rune) error

IsValidTryte returns the validity of a tryte( must be rune A-Z or 9 )

func Promote Uses

func Promote(api *API, tail Trytes, depth int64, trytes []Transaction, mwm int64, pow PowFunc) error

Promote sends transanction using tail as reference (promotes the tail transaction)

func RandomNode Uses

func RandomNode() string

RandomNode returns a random node from PublicNodes. If local IRI exists, return localhost address.

func SendTrytes Uses

func SendTrytes(api *API, depth int64, trytes []Transaction, mwm int64, pow PowFunc) error

SendTrytes does attachToTangle and finally, it broadcasts the transactions.

type API Uses

type API struct {
    // contains filtered or unexported fields

API is for calling APIs.

func NewAPI Uses

func NewAPI(endpoint string, c *http.Client) *API

NewAPI takes an (optional) endpoint and optional http.Client and returns an API struct. If an empty endpoint is supplied, then "http://localhost:14265" is used.

func (*API) AddNeighbors Uses

func (api *API) AddNeighbors(uris []string) (*AddNeighborsResponse, error)

AddNeighbors calls AddNeighbors API.

func (*API) AttachToTangle Uses

func (api *API) AttachToTangle(att *AttachToTangleRequest) (*AttachToTangleResponse, error)

AttachToTangle calls AttachToTangle API.

func (*API) Balances Uses

func (api *API) Balances(adr []Address) (Balances, error)

Balances call GetBalances API and returns address-balance pair struct.

func (*API) BroadcastTransactions Uses

func (api *API) BroadcastTransactions(trytes []Transaction) error

BroadcastTransactions calls BroadcastTransactions API.

func (*API) CheckConsistency Uses

func (api *API) CheckConsistency(tails []Trytes) (*CheckConsistencyResponse, error)

CheckConsistency calls CheckConsistency API which returns true if confirming the specified tails would result in a consistent ledger state.

func (*API) FindTransactions Uses

func (api *API) FindTransactions(ft *FindTransactionsRequest) (*FindTransactionsResponse, error)

FindTransactions calls FindTransactions API.

func (*API) GetBalances Uses

func (api *API) GetBalances(adr []Address, threshold int64) (*GetBalancesResponse, error)

GetBalances calls GetBalances API.

func (*API) GetInclusionStates Uses

func (api *API) GetInclusionStates(tx []Trytes, tips []Trytes) (*GetInclusionStatesResponse, error)

GetInclusionStates calls GetInclusionStates API.

func (*API) GetLatestInclusion Uses

func (api *API) GetLatestInclusion(hash []Trytes) ([]bool, error)

GetLatestInclusion takes the most recent solid milestone as returned by getNodeInfo and uses it to get the inclusion states of a list of transaction hashes

func (*API) GetNeighbors Uses

func (api *API) GetNeighbors() (*GetNeighborsResponse, error)

GetNeighbors calls GetNeighbors API.

func (*API) GetNodeInfo Uses

func (api *API) GetNodeInfo() (*GetNodeInfoResponse, error)

GetNodeInfo calls GetNodeInfo API.

func (*API) GetTips Uses

func (api *API) GetTips() (*GetTipsResponse, error)

GetTips calls GetTips API.

func (*API) GetTransactionsToApprove Uses

func (api *API) GetTransactionsToApprove(depth, numWalks int64, reference Trytes) (*GetTransactionsToApproveResponse, error)

GetTransactionsToApprove calls GetTransactionsToApprove API.

func (*API) GetTrytes Uses

func (api *API) GetTrytes(hashes []Trytes) (*GetTrytesResponse, error)

GetTrytes calls GetTrytes API.

func (*API) InterruptAttachingToTangle Uses

func (api *API) InterruptAttachingToTangle() error

InterruptAttachingToTangle calls InterruptAttachingToTangle API.

func (*API) RemoveNeighbors Uses

func (api *API) RemoveNeighbors(uris []string) (*RemoveNeighborsResponse, error)

RemoveNeighbors calls RemoveNeighbors API.

func (*API) StoreTransactions Uses

func (api *API) StoreTransactions(trytes []Transaction) error

StoreTransactions calls StoreTransactions API.

type AddNeighborsRequest Uses

type AddNeighborsRequest struct {
    Command string `json:"command"`

    // URIS is an array of strings in the form of "udp://identifier:port"
    // where identifier can be either an IP address or a domain name.
    URIS []string `json:"uris"`

AddNeighborsRequest is for AddNeighbors API request.

type AddNeighborsResponse Uses

type AddNeighborsResponse struct {
    Duration       int64 `json:"duration"`
    AddedNeighbors int64 `json:"addedNeighbors"`

AddNeighborsResponse is for AddNeighbors API response.

type Address Uses

type Address Trytes

Address represents address without a checksum for iota. Don't type cast, use ToAddress instead to check validity.

func GetUsedAddress Uses

func GetUsedAddress(api *API, seed Trytes, security int) (Address, []Address, error)

GetUsedAddress generates a new address which is not found in the tangle and returns its new address and used addresses.

func NewAddress Uses

func NewAddress(seed Trytes, index, security int) (Address, error)

NewAddress generates a new address from seed without checksum

func NewAddresses Uses

func NewAddresses(seed Trytes, start, count, security int) ([]Address, error)

NewAddresses generates new count addresses from seed without a checksum

func ToAddress Uses

func ToAddress(t string) (Address, error)

ToAddress converts string to address, and checks the validity

func (Address) Checksum Uses

func (a Address) Checksum() Trytes

Checksum returns checksum trytes. This panics if len(address)<81 TODO: does this really need to panic? can it just return an error?

func (Address) Hash Uses

func (a Address) Hash() Trytes

Hash hashes the address and returns trytes

func (Address) IsValid Uses

func (a Address) IsValid() error

IsValid return nil if address is valid.

func (Address) WithChecksum Uses

func (a Address) WithChecksum() Trytes

WithChecksum returns Address+checksum. This panics if len(address)<81 TODO: does this really need to panic?

type AddressInfo Uses

type AddressInfo struct {
    Seed     Trytes
    Index    int
    Security int

AddressInfo includes an address and its infomation for signing.

func (*AddressInfo) Address Uses

func (a *AddressInfo) Address() (Address, error)

Address makes an Address from an AddressInfo

func (*AddressInfo) Key Uses

func (a *AddressInfo) Key() (Trytes, error)

Key makes a Key from an AddressInfo

type AttachToTangleRequest Uses

type AttachToTangleRequest struct {
    Command            string        `json:"command"`
    TrunkTransaction   Trytes        `json:"trunkTransaction"`
    BranchTransaction  Trytes        `json:"branchTransaction"`
    MinWeightMagnitude int64         `json:"minWeightMagnitude"`
    Trytes             []Transaction `json:"trytes"`

AttachToTangleRequest is for AttachToTangle API request.

type AttachToTangleResponse Uses

type AttachToTangleResponse struct {
    Duration int64         `json:"duration"`
    Trytes   []Transaction `json:"trytes"`

AttachToTangleResponse is for AttachToTangle API response.

type Balance Uses

type Balance struct {
    Address Address
    Value   int64
    Index   int

Balance is the total balance of an Address.

type Balances Uses

type Balances []Balance

Balances is a slice of Balance.

func GetInputs Uses

func GetInputs(api *API, seed Trytes, start, end int, threshold int64, security int) (Balances, error)

GetInputs gets all possible inputs of a seed and returns them with the total balance. end must be under start+500.

func (Balances) Total Uses

func (bs Balances) Total() int64

Total returns the total balance.

type BroadcastTransactionsRequest Uses

type BroadcastTransactionsRequest struct {
    Command string        `json:"command"`
    Trytes  []Transaction `json:"trytes"`

BroadcastTransactionsRequest is for BroadcastTransactions API request.

type Bundle Uses

type Bundle []Transaction

Bundle is transactions that are bundled (grouped) together when creating a transfer.

func PrepareTransfers Uses

func PrepareTransfers(api *API, seed Trytes, trs []Transfer, inputs []AddressInfo, remainder Address, security int) (Bundle, error)

PrepareTransfers gets an array of transfer objects as input, and then prepares the transfer by generating the correct bundle as well as choosing and signing the inputs if necessary (if it's a value transfer).

func Send Uses

func Send(api *API, seed Trytes, security int, trs []Transfer, mwm int64, pow PowFunc) (Bundle, error)

Send sends tokens. If you need to do pow locally, you must specifiy pow func, otherwise this calls the AttachToTangle API

func (*Bundle) Add Uses

func (bs *Bundle) Add(num int, address Address, value int64, timestamp time.Time, tag Trytes)

Add adds a bundle to bundle slice. Elements which are not specified are filled with zeroed trits.

func (Bundle) Categorize Uses

func (bs Bundle) Categorize(adr Address) (send Bundle, received Bundle)

Categorize categorizes a list of transfers into sent and received. It is important to note that zero value transfers (which for example, are being used for storing addresses in the Tangle), are seen as received in this function.

func (Bundle) Finalize Uses

func (bs Bundle) Finalize(sig []Trytes)

Finalize filled sigs, bundlehash, and indices elements in bundle.

func (Bundle) Hash Uses

func (bs Bundle) Hash() Trytes

Hash calculates hash of Bundle.

func (Bundle) IsValid Uses

func (bs Bundle) IsValid() error

IsValid checks the validity of Bundle. It checks that total balance==0 and that its has a valid signature. The caller must call Finalize() beforehand. nolint: gocyclo

type CheckConsistencyResponse Uses

type CheckConsistencyResponse struct {
    Duration int64  `json:"duration"`
    State    bool   `json:"state"`
    Info     string `json:"info"`

CheckConsistencyResponse is for CheckConsistency API response.

type Curl Uses

type Curl struct {
    // contains filtered or unexported fields

Curl is a sponge function with an internal state of size StateSize. b = r + c, b = StateSize, r = HashSize, c = StateSize - HashSize

func NewCurl Uses

func NewCurl() *Curl

NewCurl initializes a new instance with an empty state.

func (*Curl) Absorb Uses

func (c *Curl) Absorb(inn Trytes)

Absorb fills the internal state of the sponge with the given trits.

func (*Curl) Reset Uses

func (c *Curl) Reset()

Reset the internal state of the Curl sponge by filling it with all 0's.

func (*Curl) Squeeze Uses

func (c *Curl) Squeeze() Trytes

Squeeze do Squeeze in sponge func.

func (*Curl) Transform Uses

func (c *Curl) Transform()

Transform does Transform in sponge func.

type ErrorResponse Uses

type ErrorResponse struct {
    Error     string `json:"error"`
    Exception string `json:"exception"`

ErrorResponse is for an exception occurring while calling API.

type FindTransactionsRequest Uses

type FindTransactionsRequest struct {
    Command   string    `json:"command"`
    Bundles   []Trytes  `json:"bundles,omitempty"`
    Addresses []Address `json:"addresses,omitempty"`
    Tags      []Trytes  `json:"tags,omitempty"`
    Approvees []Trytes  `json:"approvees,omitempty"`

FindTransactionsRequest is for FindTransactions API request.

type FindTransactionsResponse Uses

type FindTransactionsResponse struct {
    Duration int64    `json:"duration"`
    Hashes   []Trytes `json:"hashes"`

FindTransactionsResponse is for FindTransaction API response.

type GetBalancesRequest Uses

type GetBalancesRequest struct {
    Command   string    `json:"command"`
    Addresses []Address `json:"addresses"`
    Threshold int64     `json:"threshold"`

GetBalancesRequest is for GetBalances API request.

type GetBalancesResponse Uses

type GetBalancesResponse struct {
    Duration       int64   `json:"duration"`
    Balances       []int64 `json:"balances"`
    Milestone      Trytes  `json:"milestone"`
    MilestoneIndex int64   `json:"milestoneIndex"`

GetBalancesResponse is for GetBalances API response.

type GetInclusionStatesRequest Uses

type GetInclusionStatesRequest struct {
    Command      string   `json:"command"`
    Transactions []Trytes `json:"transactions"`
    Tips         []Trytes `json:"tips"`

GetInclusionStatesRequest is for GetInclusionStates API request.

type GetInclusionStatesResponse Uses

type GetInclusionStatesResponse struct {
    Duration int64  `json:"duration"`
    States   []bool `json:"states"`

GetInclusionStatesResponse is for GetInclusionStates API response.

type GetNeighborsRequest Uses

type GetNeighborsRequest struct {
    Command string `json:"command"`

GetNeighborsRequest is for GetNeighbors API request.

type GetNeighborsResponse Uses

type GetNeighborsResponse struct {
    Duration  int64
    Neighbors []Neighbor

GetNeighborsResponse is for GetNeighbors API response.

type GetNodeInfoRequest Uses

type GetNodeInfoRequest struct {
    Command string `json:"command"`

GetNodeInfoRequest is for GetNodeInfo API request.

type GetNodeInfoResponse Uses

type GetNodeInfoResponse struct {
    AppName                            string `json:"appName"`
    AppVersion                         string `json:"appVersion"`
    Duration                           int64  `json:"duration"`
    JREVersion                         string `json:"jreVersion"`
    JREAvailableProcessors             int64  `json:"jreAvailableProcessors"`
    JREFreeMemory                      int64  `json:"jreFreeMemory"`
    JREMaxMemory                       int64  `json:"jreMaxMemory"`
    JRETotalMemory                     int64  `json:"jreTotalMemory"`
    LatestMilestone                    Trytes `json:"latestMilestone"`
    LatestMilestoneIndex               int64  `json:"latestMilestoneIndex"`
    LatestSolidSubtangleMilestone      Trytes `json:"latestSolidSubtangleMilestone"`
    LatestSolidSubtangleMilestoneIndex int64  `json:"latestSolidSubtangleMilestoneIndex"`
    Neighbors                          int64  `json:"neighbors"`
    PacketQueueSize                    int64  `json:"packetQueueSize"`
    Time                               int64  `json:"time"`
    Tips                               int64  `json:"tips"`
    TransactionsToRequest              int64  `json:"transactionsToRequest"`

GetNodeInfoResponse is for GetNode API response.

type GetTipsRequest Uses

type GetTipsRequest struct {
    Command string `json:"command"`

GetTipsRequest is for GetTipsRequest API request.

type GetTipsResponse Uses

type GetTipsResponse struct {
    Duration int64    `json:"duration"`
    Hashes   []Trytes `json:"hashes"`

GetTipsResponse is for GetTips API response.

type GetTransactionsToApproveRequest Uses

type GetTransactionsToApproveRequest struct {
    Command string `json:"command"`
    Depth   int64  `json:"depth"`

GetTransactionsToApproveRequest is for GetTransactionsToApprove API request.

type GetTransactionsToApproveResponse Uses

type GetTransactionsToApproveResponse struct {
    Duration          int64  `json:"duration"`
    TrunkTransaction  Trytes `json:"trunkTransaction"`
    BranchTransaction Trytes `json:"branchTransaction"`

GetTransactionsToApproveResponse is for GetTransactionsToApprove API response.

type GetTrytesRequest Uses

type GetTrytesRequest struct {
    Command string   `json:"command"`
    Hashes  []Trytes `json:"hashes"`

GetTrytesRequest is for GetTrytes API request.

type GetTrytesResponse Uses

type GetTrytesResponse struct {
    Duration int64         `json:"duration"`
    Trytes   []Transaction `json:"trytes"`

GetTrytesResponse is for GetTrytes API response.

type InterruptAttachingToTangleRequest Uses

type InterruptAttachingToTangleRequest struct {
    Command string `json:"command"`

InterruptAttachingToTangleRequest is for InterruptAttachingToTangle API request.

type Kerl Uses

type Kerl struct {
    // contains filtered or unexported fields

Kerl ... TODO: find out the difference between this anc Curl and document

func NewKerl Uses

func NewKerl() *Kerl

NewKerl returns a new Kerl

func (*Kerl) Absorb Uses

func (k *Kerl) Absorb(in Trits) error

Absorb fills the internal state of the sponge with the given trits. This is only defined for Trit slices that are a multiple of TritHashLength long.

func (*Kerl) Reset Uses

func (k *Kerl) Reset()

Reset the internal state of the Kerl sponge.

func (*Kerl) Squeeze Uses

func (k *Kerl) Squeeze(length int) (Trits, error)

Squeeze out `length` trits. Length has to be a multiple of TritHashLength.

type Neighbor Uses

type Neighbor struct {
    Address                           Address `json:"address"`
    ConnectionType                    string  `json:"connectionType"`
    NumberOfAllTransactions           int64   `json:"numberOfAllTransactions"`
    NumberOfInvalidTransactions       int64   `json:"numberOfInvalidTransactions"`
    NumberOfNewTransactions           int64   `json:"numberOfNewTransactions"`
    NumberOfRandomTransactionRequests int64   `json:"numberOfRandomTransactionRequests"`
    NumberOfSentTransactions          int64   `json:"numberOfSentTransactions"`

Neighbor is a part of response of GetNeighbors API.

type PowFunc Uses

type PowFunc func(Trytes, int) (Trytes, error)

PowFunc is the func type for PoW

type RemoveNeighborsRequest Uses

type RemoveNeighborsRequest struct {
    Command string `json:"command"`

    // URIS is an array of strings in the form of "udp://identifier:port"
    // where identifier can be either an IP address or a domain name.
    URIS []string `json:"uris"`

RemoveNeighborsRequest is for RemoveNeighbors API request.

type RemoveNeighborsResponse Uses

type RemoveNeighborsResponse struct {
    Duration         int64 `json:"duration"`
    RemovedNeighbors int64 `json:"removedNeighbors"`

RemoveNeighborsResponse is for RemoveNeighbors API response.

type StoreTransactionsRequest Uses

type StoreTransactionsRequest struct {
    Command string        `json:"command"`
    Trytes  []Transaction `json:"trytes"`

StoreTransactionsRequest is for StoreTransactions API request.

type Transaction Uses

type Transaction struct {
    SignatureMessageFragment      Trytes
    Address                       Address
    Value                         int64 `json:",string"`
    ObsoleteTag                   Trytes
    Timestamp                     time.Time `json:",string"`
    CurrentIndex                  int64     `json:",string"`
    LastIndex                     int64     `json:",string"`
    Bundle                        Trytes
    TrunkTransaction              Trytes
    BranchTransaction             Trytes
    Tag                           Trytes
    AttachmentTimestamp           Trytes
    AttachmentTimestampLowerBound Trytes
    AttachmentTimestampUpperBound Trytes
    Nonce                         Trytes

Transaction contains all info needed for an iota transaction

func NewTransaction Uses

func NewTransaction(trytes Trytes) (*Transaction, error)

NewTransaction makes tx from trits.

func (*Transaction) HasValidNonce Uses

func (t *Transaction) HasValidNonce(mwm int64) bool

HasValidNonce checks if the transaction has the valid MinWeightMagnitude. In order to check the MWM we count trailing 0's of the curlp hash of a transaction.

func (*Transaction) Hash Uses

func (t *Transaction) Hash() Trytes

Hash returns the hash of the transaction.

func (*Transaction) MarshalJSON Uses

func (t *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON makes trytes ([]byte) from a transaction.

func (*Transaction) Trytes Uses

func (t *Transaction) Trytes() Trytes

Trytes converts the transaction to Trytes.

func (*Transaction) UnmarshalJSON Uses

func (t *Transaction) UnmarshalJSON(b []byte) error

UnmarshalJSON makes transaction struct from json.

type Transfer Uses

type Transfer struct {
    Address Address
    Value   int64
    Message Trytes
    Tag     Trytes

Transfer is the data to be transfered by bundles.

type Trits Uses

type Trits []int8

Trits is a slice of int8. You should not use cast, use ToTrits instead to ensure the validity.

func BytesToTrits Uses

func BytesToTrits(b []byte) (Trits, error)

BytesToTrits converts binary to ternay

func Digests Uses

func Digests(key Trits) (Trits, error)

Digests calculates hash x 26 for each segment in keyTrits

func Int2Trits Uses

func Int2Trits(v int64, size int) Trits

Int2Trits converts int64 to trits.

func ToTrits Uses

func ToTrits(t []int8) (Trits, error)

ToTrits casts Trits and checks its validity.

func (Trits) Bytes Uses

func (t Trits) Bytes() ([]byte, error)

Bytes is only defined for hashes, i.e. slices of trits of length 243. It returns 48 bytes. nolint: gocyclo, gas

func (Trits) CanTrytes Uses

func (t Trits) CanTrytes() bool

CanTrytes returns true if t can be converted to trytes.

func (Trits) Equal Uses

func (t Trits) Equal(b Trits) bool

Equal returns true if t and b are equal Trits

func (Trits) Int Uses

func (t Trits) Int() int64

Int converts a slice of trits into an integer and assumes little-endian notation.

func (Trits) IsValid Uses

func (t Trits) IsValid() error

IsValid returns true if t is valid trits.

func (Trits) IsValidLength Uses

func (t Trits) IsValidLength() bool

IsValidLength returns the validity of the trit length

func (Trits) TrailingZeros Uses

func (t Trits) TrailingZeros() int64

TrailingZeros returns the number of trailing zeros of the given trits.

func (Trits) Trytes Uses

func (t Trits) Trytes() Trytes

Trytes converts a slice of trits into trytes. panics if len(t)%3!=0

type Trytes Uses

type Trytes string

Trytes is a string of trytes. You should not typecast, use ToTrytes instead to be safe

func NewKey Uses

func NewKey(seed Trytes, index, securityLevel int) (Trytes, error)

NewKey takes a seed encoded as Trytes, an index and a security level to derive a private key returned as Trytes

func NewSeed Uses

func NewSeed() Trytes

NewSeed generate a random Trytes

func PowC Uses

func PowC(trytes Trytes, mwm int) (Trytes, error)

PowC is proof of work of iota using pure C.

func PowGo Uses

func PowGo(trytes Trytes, mwm int) (Trytes, error)

PowGo is proof of work for iota in pure Go

func PowSSE Uses

func PowSSE(trytes Trytes, mwm int) (Trytes, error)

PowSSE is proof of work for iota for amd64 using SSE2(or AMD64).

func Sign Uses

func Sign(normalizedBundleFragment []int8, keyFragment Trytes) Trytes

Sign calculates signature from bundle hash and key by hashing x 13-normalizedBundleFragment[i] for each segments in keyTrits.

func ToTrytes Uses

func ToTrytes(t string) (Trytes, error)

ToTrytes casts to Trytes and checks its validity.

func (Trytes) Hash Uses

func (t Trytes) Hash() Trytes

Hash returns hash of t.

func (Trytes) IsValid Uses

func (t Trytes) IsValid() error

IsValid returns true if t is made of valid trytes.

func (Trytes) Normalize Uses

func (t Trytes) Normalize() []int8

Normalize normalized bits into trits so that the sum of trits TODO: (and?) bits is zero. nolint: gocyclo

func (Trytes) ToAddress Uses

func (t Trytes) ToAddress() (Address, error)

ToAddress convert trytes(with and without checksum) to address and checks the validity

func (Trytes) Trits Uses

func (t Trytes) Trits() Trits

Trits converts a slice of trytes into trits,


clPackage cl provides a binding to the OpenCL api.

Package giota imports 18 packages (graph). Updated 2018-03-01. Refresh now. Tools for package owners.