Documentation ¶
Index ¶
- Constants
- Variables
- func BasicDataSize(data interface{}) int
- func Bytes2Hex(d []byte) string
- func Bytes2Uint(src []byte) (uint64, error)
- func CopyBytes(b []byte) (copiedBytes []byte)
- func DecodeSliceSize(elementSize int, data []byte) (int, error)
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func HexEncode(b []byte) string
- func LeftPadBytes(slice []byte, l int) []byte
- func LenTo2Byte(datalen int, data []byte)
- func RightPadBytes(slice []byte, l int) []byte
- func TagTo2Byte(tag Tlvtag, data []byte)
- func TlvDecodeFromMap(data []byte, smap map[Tlvtag]Serializable) error
- func TlvDecodeFromSlice(data []byte, sSlice []Serializable, elementSize int) error
- func TlvEncodeFromMap(data []byte, smap map[Tlvtag]Serializable) (int, error)
- func TlvEncodeFromSlice(data []byte, sSlice []Serializable, elementSize int) (int, error)
- func ToHex(b []byte) stringdeprecated
- type AccountAddress
- type AccountKey
- type BasiceSerializer
- type BlobData
- type Block
- type BlockCompleteEntry
- type BlockHeader
- type BlockOutputIndices
- type BoroSig
- type Bulletproof
- type CryptoNoteBlock
- type CryptonoteTransaction
- type Ctkey
- type CtkeyM
- type CtkeyV
- type EcPoint
- type EcScalar
- type EcdhTuple
- type FieldSerializable
- type Hash
- type Hash8
- type Key
- type Key64
- type KeyDerivation
- type KeyImage
- type KeyM
- type KeyV
- type Lk_amount
- type MgSig
- type MultisigKLRki
- type MultisigOut
- type ParsedBlock
- type PublicKey
- type RangeProofType
- type RangeSig
- type RctConfig
- type RctSig
- type RctSigBase
- type RctSigPrunable
- type SecretKey
- type SecretKeyV
- type Serializable
- type Signature
- type SliceSerializer
- type TlvMapSerializer
- type Tlvtag
- type Transaction
- type TransactionPrefix
- type TxCacheData
- type TxExtraField
- type TxOut
- type TxOutputIndices
- type TxinGen
- type TxinToKey
- type TxinToScript
- type TxinToScripthash
- type TxinV
- type TxoutTargetV
- type TxoutToKey
- type TxoutToScript
- type TxoutToScripthash
Constants ¶
const ( COMMONLEN = 32 KEY64 = 64 )
const ( HASH_SIZE = 32 HASH_DATA_AREA = 136 HashLength = HASH_SIZE )
Variables ¶
var ( TAGSIZE = 2 LENSIZE = 2 TAGOFFSET = 0 LENOFFSET = TAGSIZE HEADSIZE = TAGSIZE + LENSIZE VOFFSET = HEADSIZE IvalidCodeERR = errors.New("invalid code") EncodeSpaceERR = errors.New("unexpected encode space") NilEncoderERR = errors.New("encoder is nil") EncodeTypeERR = errors.New("unexpected encode type") DecodeSpaceERR = errors.New("unexpected decode space") NotSerializableTypeERR = errors.New("just support Serializable type") )
* TLV serialization protocal 1)tlv normal format:
tlv_format=tag + datalen + rawdata|tlv_format
|--2bytes--|--2bytes--|----datalen bytes--------| | tag | datalen | rawdata/tlv_format |
- array/slice format tlv_format = [tlv_format,tlv_format,.......]
special:
array/slice with const size element: tlv_format whitout tag field and without datalen field array/slice with uncertain size element: tag fied is unused
3)rawdata use bigEndian for basic type
datalen max value is (1<<16)-1, so just only support 65535 bytes rawdata.
var (
ErrParamInvalid = errors.New("param invalid")
)
var NullHash = Hash{}
Functions ¶
func BasicDataSize ¶
func BasicDataSize(data interface{}) int
func Bytes2Uint ¶
Bytes2Uint returns the uint64 by the hexadecimal src.
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func LenTo2Byte ¶
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func TagTo2Byte ¶
func TlvDecodeFromMap ¶
func TlvDecodeFromMap(data []byte, smap map[Tlvtag]Serializable) error
func TlvDecodeFromSlice ¶
func TlvDecodeFromSlice(data []byte, sSlice []Serializable, elementSize int) error
func TlvEncodeFromMap ¶
func TlvEncodeFromMap(data []byte, smap map[Tlvtag]Serializable) (int, error)
func TlvEncodeFromSlice ¶
func TlvEncodeFromSlice(data []byte, sSlice []Serializable, elementSize int) (int, error)
*
elementSize=0, elementSize > 0,Each element has same length with elementSize,tag and len is unnecessary
Types ¶
type AccountAddress ¶
AccountAddress represents the address with a view-public-key and a spend-public-ley
func (*AccountAddress) DecodeMap ¶
func (k *AccountAddress) DecodeMap() map[Tlvtag]Serializable
func (*AccountAddress) EncodeMap ¶
func (k *AccountAddress) EncodeMap() map[Tlvtag]Serializable
AccountAddress
func (*AccountAddress) TlvDecode ¶
func (k *AccountAddress) TlvDecode(data []byte) error
func (*AccountAddress) TlvSize ¶
func (k *AccountAddress) TlvSize() int
type AccountKey ¶
type AccountKey struct { Addr AccountAddress SpendSKey SecretKey ViewSKey SecretKey Address string SubIdx uint64 }
AccountKey represents a utxo account
func (*AccountKey) DecodeMap ¶
func (k *AccountKey) DecodeMap() map[Tlvtag]Serializable
func (*AccountKey) String ¶
func (a *AccountKey) String() string
func (*AccountKey) TlvDecode ¶
func (k *AccountKey) TlvDecode(data []byte) error
func (*AccountKey) TlvSize ¶
func (k *AccountKey) TlvSize() int
type BasiceSerializer ¶
type BasiceSerializer struct {
// contains filtered or unexported fields
}
func NewBasiceSerializer ¶
func NewBasiceSerializer(target interface{}) *BasiceSerializer
func (*BasiceSerializer) TlvDecode ¶
func (e *BasiceSerializer) TlvDecode(data []byte) error
func (*BasiceSerializer) TlvSize ¶
func (e *BasiceSerializer) TlvSize() int
type Block ¶
type Block struct { BlockHeader MinerTx Transaction `json:"miner_tx"` TxHashes []string `json:"tx_hashes"` // hash cash Hash string `json:"block"` // contains filtered or unexported fields }
func (*Block) InvalidateHashes ¶
func (b *Block) InvalidateHashes()
func (*Block) IsHashValid ¶
func (*Block) SetHashValid ¶
type BlockCompleteEntry ¶
type BlockHeader ¶
type BlockOutputIndices ¶
type BlockOutputIndices struct {
Indices []TxOutputIndices
}
type BoroSig ¶
func (*BoroSig) DecodeMap ¶
func (k *BoroSig) DecodeMap() map[Tlvtag]Serializable
func (*BoroSig) EncodeMap ¶
func (k *BoroSig) EncodeMap() map[Tlvtag]Serializable
BoroSig : tlv interface implements
type Bulletproof ¶
type Bulletproof struct { V KeyV `json:"-" rlp:"-"` A, S, T1, T2 Key Taux, Mu Key L, R KeyV Aa, B, T Key // Aa --> a }
func (*Bulletproof) DecodeMap ¶
func (k *Bulletproof) DecodeMap() map[Tlvtag]Serializable
func (*Bulletproof) EncodeMap ¶
func (k *Bulletproof) EncodeMap() map[Tlvtag]Serializable
Bulletproof : tlv interface implements
func (*Bulletproof) TlvDecode ¶
func (k *Bulletproof) TlvDecode(data []byte) error
func (*Bulletproof) TlvSize ¶
func (k *Bulletproof) TlvSize() int
type CryptonoteTransaction ¶
type CryptonoteTransaction struct { }
type Ctkey ¶
func (*Ctkey) DecodeMap ¶
func (k *Ctkey) DecodeMap() map[Tlvtag]Serializable
func (*Ctkey) EncodeMap ¶
func (k *Ctkey) EncodeMap() map[Tlvtag]Serializable
type EcdhTuple ¶
func (*EcdhTuple) DecodeMap ¶
func (k *EcdhTuple) DecodeMap() map[Tlvtag]Serializable
func (*EcdhTuple) EncodeMap ¶
func (k *EcdhTuple) EncodeMap() map[Tlvtag]Serializable
EcdhTuple : tlv interface implements
type FieldSerializable ¶
type Hash ¶
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
type Hash8 ¶
type Hash8 [8]byte
func BytesToHash8 ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash8 ¶
=========================== HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
type Key ¶
func BytesToKey ¶ added in v0.1.1
BytesToKey returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func HexToKey ¶ added in v0.1.1
HexToKey returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
type KeyDerivation ¶
type KeyDerivation EcPoint
func (KeyDerivation) Big ¶
func (h KeyDerivation) Big() *big.Int
Big converts a hash to a big integer.
func (KeyDerivation) String ¶
func (h KeyDerivation) String() string
String implements the stringer interface and is used also by the logger when doing full logging into a file.
type MgSig ¶
func (*MgSig) DecodeMap ¶
func (k *MgSig) DecodeMap() map[Tlvtag]Serializable
func (*MgSig) EncodeMap ¶
func (k *MgSig) EncodeMap() map[Tlvtag]Serializable
MgSig : tlv interface implements
type MultisigKLRki ¶
func (*MultisigKLRki) DecodeMap ¶
func (k *MultisigKLRki) DecodeMap() map[Tlvtag]Serializable
func (*MultisigKLRki) EncodeMap ¶
func (k *MultisigKLRki) EncodeMap() map[Tlvtag]Serializable
MultisigKLRki : tlv interface implements
func (*MultisigKLRki) TlvDecode ¶
func (k *MultisigKLRki) TlvDecode(data []byte) error
func (*MultisigKLRki) TlvSize ¶
func (k *MultisigKLRki) TlvSize() int
type MultisigOut ¶
type MultisigOut struct {
C KeyV
}
func (*MultisigOut) DecodeMap ¶
func (k *MultisigOut) DecodeMap() map[Tlvtag]Serializable
func (*MultisigOut) EncodeMap ¶
func (k *MultisigOut) EncodeMap() map[Tlvtag]Serializable
MultisigOut : tlv interface implements
func (*MultisigOut) TlvDecode ¶
func (k *MultisigOut) TlvDecode(data []byte) error
func (*MultisigOut) TlvSize ¶
func (k *MultisigOut) TlvSize() int
type ParsedBlock ¶
type ParsedBlock struct { Hash Hash Block Block Txes []Transaction OIndices BlockOutputIndices HasErr bool }
type PublicKey ¶
type PublicKey EcPoint
type RangeProofType ¶
type RangeProofType uint8
const ( RCTTypeNull RangeProofType = 0 RCTTypeFull RangeProofType = 1 RCTTypeSimple RangeProofType = 2 RCTTypeBulletproof RangeProofType = 3 RCTTypeBulletproof2 RangeProofType = 4 )
func (*RangeProofType) TlvDecode ¶
func (k *RangeProofType) TlvDecode(data []byte) error
func (*RangeProofType) TlvSize ¶
func (k *RangeProofType) TlvSize() int
RangeProofType : tlv interface implements
type RangeSig ¶
func (*RangeSig) DecodeMap ¶
func (k *RangeSig) DecodeMap() map[Tlvtag]Serializable
func (*RangeSig) EncodeMap ¶
func (k *RangeSig) EncodeMap() map[Tlvtag]Serializable
RangeSig : tlv interface implements
type RctConfig ¶
type RctConfig struct { RangeProofType RangeProofType BpVersion int32 }
func (*RctConfig) DecodeMap ¶
func (k *RctConfig) DecodeMap() map[Tlvtag]Serializable
func (*RctConfig) EncodeMap ¶
func (k *RctConfig) EncodeMap() map[Tlvtag]Serializable
RctConfig : tlv interface implements
type RctSig ¶
type RctSig struct { RctSigBase P RctSigPrunable }
func (*RctSig) DecodeMap ¶
func (k *RctSig) DecodeMap() map[Tlvtag]Serializable
func (*RctSig) EncodeMap ¶
func (k *RctSig) EncodeMap() map[Tlvtag]Serializable
RctSig : tlv interface implements
type RctSigBase ¶
type RctSigBase struct { Type uint8 Message Key `json:"-" rlp:"-"` MixRing CtkeyM `json:"-" rlp:"-"` PseudoOuts KeyV EcdhInfo []EcdhTuple OutPk CtkeyV TxnFee Lk_amount }
func (*RctSigBase) DecodeMap ¶
func (k *RctSigBase) DecodeMap() map[Tlvtag]Serializable
func (*RctSigBase) EncodeMap ¶
func (k *RctSigBase) EncodeMap() map[Tlvtag]Serializable
RctSigBase : tlv interface implements
func (*RctSigBase) TlvDecode ¶
func (k *RctSigBase) TlvDecode(data []byte) error
func (*RctSigBase) TlvSize ¶
func (k *RctSigBase) TlvSize() int
type RctSigPrunable ¶
type RctSigPrunable struct { RangeSigs []RangeSig Bulletproofs []Bulletproof MGs []MgSig PseudoOuts KeyV Ss []Signature }
func (*RctSigPrunable) DecodeMap ¶
func (k *RctSigPrunable) DecodeMap() map[Tlvtag]Serializable
func (*RctSigPrunable) EncodeMap ¶
func (k *RctSigPrunable) EncodeMap() map[Tlvtag]Serializable
RctSigPrunable : tlv interface implements
func (*RctSigPrunable) TlvDecode ¶
func (k *RctSigPrunable) TlvDecode(data []byte) error
func (*RctSigPrunable) TlvSize ¶
func (k *RctSigPrunable) TlvSize() int
type SecretKey ¶
type SecretKey EcScalar
type SecretKeyV ¶
type SecretKeyV []SecretKey
type Serializable ¶
type SliceSerializer ¶
type SliceSerializer struct {
// contains filtered or unexported fields
}
func NewSliceSerializer ¶
func NewSliceSerializer(elementSize int, target interface{}) *SliceSerializer
func (*SliceSerializer) TlvDecode ¶
func (e *SliceSerializer) TlvDecode(data []byte) error
func (*SliceSerializer) TlvSize ¶
func (e *SliceSerializer) TlvSize() int
type TlvMapSerializer ¶
type TlvMapSerializer struct {
// contains filtered or unexported fields
}
func NewTlvMapSerializer ¶
func NewTlvMapSerializer() *TlvMapSerializer
func NewTlvMapSerializerWith ¶
func NewTlvMapSerializerWith(serializer ...Serializable) *TlvMapSerializer
func (*TlvMapSerializer) SetTagAndSerializer ¶
func (tms *TlvMapSerializer) SetTagAndSerializer(tag Tlvtag, serializer Serializable)
func (*TlvMapSerializer) TlvDecode ¶
func (tms *TlvMapSerializer) TlvDecode(data []byte) error
func (*TlvMapSerializer) TlvEncode ¶
func (tms *TlvMapSerializer) TlvEncode(data []byte) (int, error)
func (*TlvMapSerializer) TlvSize ¶
func (tms *TlvMapSerializer) TlvSize() int
type Transaction ¶
type Transaction struct { TransactionPrefix Signatures [][]Signature //count signatures always the same as inputs count RctSignatures RctSig `json:"rct_signatures"` Hash Hash BlobSize int // contains filtered or unexported fields }
func (*Transaction) InvalidateHashes ¶
func (t *Transaction) InvalidateHashes()
func (*Transaction) IsHashValid ¶
func (t *Transaction) IsHashValid() bool
func (*Transaction) IstBlobSizeValid ¶
func (t *Transaction) IstBlobSizeValid() bool
func (*Transaction) SetBlobSizeValid ¶
func (t *Transaction) SetBlobSizeValid(v bool)
func (*Transaction) SetHashValid ¶
func (t *Transaction) SetHashValid(v bool)
type TransactionPrefix ¶
type TransactionPrefix struct { // tx information Version int `json:"version"` UnlockTime uint64 `json:"unlock_time"` //number of block (or time), used as a limitation like: spend this tx not early then block/time Vin []TxinV `json:"vin"` Vout []TxOut `json:"vout"` //extra Extra []uint8 `json:"extra"` }
type TxCacheData ¶
type TxCacheData struct {
TxExtraFields []TxExtraField
}
type TxExtraField ¶
type TxExtraField struct{}
func (*TxExtraField) Clear ¶
func (tef *TxExtraField) Clear()
type TxOut ¶
type TxOut struct { Amount *big.Int Target TxoutTargetV }
type TxOutputIndices ¶
type TxOutputIndices struct {
Indices []uint64
}
type TxinToScript ¶
type TxinToScripthash ¶
type TxinToScripthash struct { Prev Hash Prevout int Script TxoutToScript Sigset []uint8 }
type TxinV ¶
type TxinV interface{}
TxinV type is in(TxinGen TxinToScript TxinToScripthash TxinToKey)
type TxoutTargetV ¶
type TxoutTargetV struct{}
TxoutTargetV type is in(TxoutToScript TxoutToScripthash TxoutToKey)
type TxoutToKey ¶
type TxoutToKey struct {
Key PublicKey
}
type TxoutToScript ¶
type TxoutToScripthash ¶
type TxoutToScripthash struct {
Hash Hash
}