Documentation
¶
Index ¶
- Constants
- func Decode(encodedData []byte, sliceSize int) (data [][]byte)
- func Encode(data [][]byte, sliceSize int) []byte
- func RandomBytes() []byte
- func RandomBytesWithLength(length int) []byte
- func SerializeHashContent(data interface{}) (hash [32]byte)
- func SerializeHashContentIoT(data [32]byte) (hash [32]byte)
- type AccTx
- type Account
- type AggTx
- type Block
- func (block *Block) Decode(encoded []byte) (b *Block)
- func (block *Block) Encode() []byte
- func (block *Block) EncodeHeader() []byte
- func (block *Block) GetBloomFilterSize() uint64
- func (block *Block) GetBodySize() uint64
- func (block *Block) GetHeaderSize() uint64
- func (block *Block) GetSize() uint64
- func (block *Block) GetTxDataSize() uint64
- func (block *Block) HashBlock() [32]byte
- func (block *Block) HashBlockWithoutMerkleRoot() [32]byte
- func (block *Block) InitBloomFilter(txPubKeys [][32]byte)
- func (block Block) String() string
- type ByteArray
- type Change
- type ConfigTx
- func (*ConfigTx) Decode(encodedTx []byte) (tx *ConfigTx)
- func (tx *ConfigTx) Encode() (encodedTx []byte)
- func (tx *ConfigTx) Hash() (hash [32]byte)
- func (tx *ConfigTx) Receiver() [32]byte
- func (tx *ConfigTx) Sender() [32]byte
- func (tx *ConfigTx) Size() uint64
- func (tx ConfigTx) String() string
- func (tx *ConfigTx) TxFee() uint64
- type Context
- func (c *Context) GetAddress() [32]byte
- func (c *Context) GetAmount() uint64
- func (c *Context) GetBalance() uint64
- func (c *Context) GetContract() []byte
- func (c *Context) GetContractVariable(index int) ([]byte, error)
- func (c *Context) GetFee() uint64
- func (c *Context) GetIssuer() [32]byte
- func (c *Context) GetSender() [32]byte
- func (c *Context) GetSig() [64]byte
- func (c *Context) GetTransactionData() []byte
- func (c *Context) PersistChanges()
- func (c *Context) SetContractVariable(index int, value []byte) error
- type FundsTx
- func (*FundsTx) Decode(encodedTx []byte) *FundsTx
- func (tx *FundsTx) Encode() (encodedTx []byte)
- func (tx *FundsTx) Hash() (hash [32]byte)
- func (tx *FundsTx) Receiver() [32]byte
- func (tx *FundsTx) Sender() [32]byte
- func (tx *FundsTx) Size() uint64
- func (tx FundsTx) String() string
- func (tx *FundsTx) TxFee() uint64
- type Iot
- type IotTx
- type MerkleTree
- type Node
- type StakeTx
- func (*StakeTx) Decode(encodedTx []byte) (tx *StakeTx)
- func (tx *StakeTx) Encode() (encodedTx []byte)
- func (tx *StakeTx) Hash() (hash [32]byte)
- func (tx *StakeTx) Receiver() [32]byte
- func (tx *StakeTx) Sender() [32]byte
- func (tx *StakeTx) Size() uint64
- func (tx StakeTx) String() string
- func (tx *StakeTx) TxFee() uint64
- type Transaction
Constants ¶
const ( HASH_LEN = 32 HEIGHT_LEN = 4 //All fixed sizes form the Block struct are 254 MIN_BLOCKSIZE = 254 + crypto.COMM_PROOF_LENGTH + 1 MIN_BLOCKHEADER_SIZE = 104 BLOOM_FILTER_ERROR_RATE = 0.1 )
const ( CONFIGTX_SIZE = 83 BLOCK_SIZE_ID = 1 DIFF_INTERVAL_ID = 2 FEE_MINIMUM_ID = 3 BLOCK_INTERVAL_ID = 4 BLOCK_REWARD_ID = 5 STAKING_MINIMUM_ID = 6 WAITING_MINIMUM_ID = 7 ACCEPTANCE_TIME_DIFF_ID = 8 SLASHING_WINDOW_SIZE_ID = 9 SLASHING_REWARD_ID = 10 MIN_BLOCK_SIZE = 1000 //1KB MAX_BLOCK_SIZE = 100000000 //100MB MIN_DIFF_INTERVAL = 3 //amount in seconds MAX_DIFF_INTERVAL = 9223372036854775807 MIN_FEE_MINIMUM = 0 MAX_FEE_MINIMUM = 9223372036854775807 MIN_BLOCK_INTERVAL = 3 //30 seconds MAX_BLOCK_INTERVAL = 86400 //24 hours MIN_BLOCK_REWARD = 0 MAX_BLOCK_REWARD = 1152921504606846976 //2^60 MIN_STAKING_MINIMUM = 5 //minimum number of coins for staking MAX_STAKING_MINIMUM = 9223372036854775807 //2^60 MIN_WAITING_TIME = 0 //number of blocks that must a new validator must wait before it can start validating MAX_WAITING_TIME = 100000 MIN_ACCEPTANCE_TIME_DIFF = 0 //semi-synchronous time difference between local clock of validators MAX_ACCEPTANCE_TIME_DIFF = 60 //1min MIN_SLASHING_WINDOW_SIZE = 0 //window size where a node has to commit itself to a competing branch in case of a fork MAX_SLASHING_WINDOW_SIZE = 10000 //1000 Blocks (totally random) MIN_SLASHING_REWARD = 0 // reward for providing a valid slashing proof MAX_SLASHING_REWARD = 1152921504606846976 //2^60 )
const (
ACCTX_SIZE = 169
)
const (
AGGTX_SIZE = 53 //Only constant Values --> Without To & AggregatedTxSlice
)
const (
FUNDSTX_SIZE = 213
)
const (
STAKETX_SIZE = 106 + crypto.COMM_KEY_LENGTH
)
Variables ¶
This section is empty.
Functions ¶
func RandomBytes ¶
func RandomBytes() []byte
func RandomBytesWithLength ¶
func SerializeHashContent ¶
func SerializeHashContent(data interface{}) (hash [32]byte)
Serializes the input and returns the sha3 hash function applied on ths input
func SerializeHashContentIoT ¶
Types ¶
type AccTx ¶
type AccTx struct {
Header byte
Issuer [32]byte
Fee uint64
PubKey [32]byte
Sig [64]byte
Contract []byte
ContractVariables []ByteArray
}
func ConstrAccTx ¶
type Account ¶
type Account struct {
Address [32]byte // 64 Byte
Issuer [32]byte // 32 Byte
Balance uint64 // 8 Byte
TxCnt uint32 // 4 Byte
IsStaking bool // 1 Byte
CommitmentKey [crypto.COMM_KEY_LENGTH]byte // represents the modulus N of the RSA public key
StakingBlockHeight uint32 // 4 Byte
Contract []byte // Arbitrary length
ContractVariables []ByteArray // Arbitrary length
}
func NewAccount ¶
type AggTx ¶
type AggTx struct {
Amount uint64
Fee uint64
From [][32]byte
To [][32]byte
AggregatedTxSlice [][32]byte
}
func ConstrAggTx ¶
type Block ¶
type Block struct {
//Header
Header byte
Hash [32]byte
PrevHash [32]byte
HashWithoutTx [32]byte //valid hash once all tx are aggregated
PrevHashWithoutTx [32]byte //valid hash of ancestor once all tx are aggregated
NrConfigTx uint8
NrElementsBF uint16
BloomFilter *bloom.BloomFilter
Height uint32
Beneficiary [32]byte
Aggregated bool //Indicates if All transactions are aggregated with a boolean.
//Body
Nonce [8]byte
Timestamp int64
MerkleRoot [32]byte
NrAccTx uint16
NrFundsTx uint16
NrStakeTx uint16
NrAggTx uint16
NrIoTTx uint16
SlashedAddress [32]byte
CommitmentProof [crypto.COMM_PROOF_LENGTH]byte
ConflictingBlockHash1 [32]byte
ConflictingBlockHash2 [32]byte
ConflictingBlockHashWithoutTx1 [32]byte
ConflictingBlockHashWithoutTx2 [32]byte
StateCopy map[[32]byte]*Account //won't be serialized, just keeping track of local state changes
AccTxData [][32]byte
FundsTxData [][32]byte
ConfigTxData [][32]byte
StakeTxData [][32]byte
AggTxData [][32]byte
IoTTxData [][32]byte
SizeIoTData uint64
}
func (*Block) EncodeHeader ¶
func (*Block) GetBloomFilterSize ¶
func (*Block) GetBodySize ¶
func (*Block) GetHeaderSize ¶
func (*Block) GetTxDataSize ¶
func (*Block) HashBlockWithoutMerkleRoot ¶
func (*Block) InitBloomFilter ¶
type ConfigTx ¶
func ConstrConfigTx ¶
type Context ¶
func NewContext ¶
func (*Context) GetAddress ¶
func (*Context) GetBalance ¶
func (*Context) GetContract ¶
func (*Context) GetContractVariable ¶
func (*Context) GetTransactionData ¶
func (*Context) PersistChanges ¶
func (c *Context) PersistChanges()
type FundsTx ¶
type FundsTx struct {
Header byte
Amount uint64
Fee uint64
TxCnt uint32
From [32]byte
To [32]byte
Sig [64]byte
Aggregated bool
Data []byte
}
func ConstrFundsTx ¶
type IotTx ¶
type IotTx struct {
Header byte
TxCnt uint32
From [32]byte
To [32]byte
Sig [64]byte
Data []byte
Fee uint64
}
func ConstrIotTx ¶
type MerkleTree ¶
MerkleTree is the container for the tree. It holds a pointer to the root of the tree, a list of pointers to the leaf nodes, and the merkle root.
func BuildMerkleTree ¶
func BuildMerkleTree(b *Block) *MerkleTree
func (*MerkleTree) MerkleRoot ¶
func (m *MerkleTree) MerkleRoot() [32]byte
MerkleRoot returns the unverified Merkle Root (hash of the root node) of the tree.
func (*MerkleTree) String ¶
func (m *MerkleTree) String() string
String returns a string representation of the tree. Only leaf nodes are included in the output.
func (*MerkleTree) VerifyTree ¶
func (m *MerkleTree) VerifyTree() bool
VerifyTree verify tree validates the hashes at each level of the tree and returns true if the resulting hash at the root of the tree matches the resulting root hash; returns false otherwise.
type Node ¶
type Node struct {
Parent *Node
Left *Node
Right *Node
Hash [32]byte
// contains filtered or unexported fields
}
Node represents a node, root, or leaf in the tree. It stores pointers to its immediate relationships, a hash, the content stored if it is a leaf, and other metadata.
func GetIntermediate ¶
VerifyContent indicates whether a given content is in the tree and the hashes are valid for that content. Returns true if the expected Merkle Root is equivalent to the Merkle root calculated on the critical path for a given content. Returns true if valid and false otherwise.
func GetLeaf ¶
func GetLeaf(merkleTree *MerkleTree, leafHash [32]byte) *Node
type StakeTx ¶
type StakeTx struct {
Header byte // 1 Byte
Fee uint64 // 8 Byte
IsStaking bool // 1 Byte
Account [32]byte // 32 Byte
Sig [64]byte // 64 Byte
CommitmentKey [crypto.COMM_KEY_LENGTH]byte // the modulus N of the RSA public key
}