Documentation ¶
Index ¶
- Constants
- Variables
- func AddCommas(v int64) (ret string)
- func AreBinaryMarshallablesEqual(b1, b2 interfaces.BinaryMarshallable) (bool, error)
- func AreBytesEqual(b1, b2 []byte) bool
- func BuildMerkleTreeStore(hashes []interfaces.IHash) (merkles []interfaces.IHash)
- func CalculateCoinbasePayout(efficiency uint16) uint64
- func ComputeMerkleRoot(hashes []interfaces.IHash) interfaces.IHash
- func ConvertAddressToUser(prefix []byte, addr interfaces.IAddress) []byte
- func ConvertDecimalToFloat(v uint64) float64
- func ConvertDecimalToPaddedString(v uint64) string
- func ConvertDecimalToString(v uint64) string
- func ConvertECAddressToUserStr(addr interfaces.IAddress) string
- func ConvertECPrivateToUserStr(addr interfaces.IAddress) string
- func ConvertFctAddressToUserStr(addr interfaces.IAddress) string
- func ConvertFctPrivateToUserStr(addr interfaces.IAddress) string
- func ConvertFixedPoint(amt string) (string, error)
- func ConvertUserStrToAddress(userFAddr string) []byte
- func CreateHash(entities ...interfaces.BinaryMarshallable) (h interfaces.IHash, err error)
- func DecodeBinary(bytes string) ([]byte, error)
- func DecodeJSON(data []byte, v interface{}) error
- func DecodeJSONString(data string, v interface{}) error
- func DecodeVarInt(data []byte) (uint64, []byte)
- func DecodeVarIntGo(data []byte) (uint64, []byte)
- func DoubleSha(data []byte) []byte
- func EfficiencyToString(eff uint16) string
- func EncodeBinary(bytes []byte) string
- func EncodeJSON(data interface{}) ([]byte, error)
- func EncodeJSONString(data interface{}) (string, error)
- func EncodeJSONToBuffer(data interface{}, b *bytes.Buffer) error
- func EncodeVarInt(out *Buffer, v uint64) error
- func EncodeVarIntGo(out *Buffer, v uint64) error
- func GenerateKeyFromPrivateKey(privateKey []byte) (public []byte, private []byte, err error)
- func GetTime() uint64
- func GetTimeMilli() uint64
- func HashMerkleBranches(left interfaces.IHash, right interfaces.IHash) interfaces.IHash
- func HexToHash(hexStr string) (h interfaces.IHash, err error)
- func HumanReadableECPrivateKeyToPrivateKey(human string) ([]byte, error)
- func HumanReadableECPrivateKeyToPrivateKeyString(human string) (string, error)
- func HumanReadableFactoidPrivateKeyToPrivateKey(human string) ([]byte, error)
- func HumanReadableFactoidPrivateKeyToPrivateKeyString(human string) (string, error)
- func Log(format string, args ...interface{})
- func LogJSONs(format string, args ...interface{})
- func LogNilHashBug(msg string)
- func Loghash(h interfaces.IHash)
- func Loghashfixed(h [32]byte)
- func MnemonicStringToPrivateKey(mnemonic string) ([]byte, error)
- func MnemonicStringToPrivateKeyString(mnemonic string) (string, error)
- func NewHash(b []byte) interfaces.IHash
- func NewShaHashFromStruct(DataStruct interface{}) (interfaces.IHash, error)
- func NewZeroHash() interfaces.IHash
- func NextPowerOfTwo(n int) int
- func PrivateKeyStringToHumanReadableECPrivateKey(priv string) (string, error)
- func PrivateKeyStringToHumanReadableFactoidPrivateKey(priv string) (string, error)
- func PrivateKeyStringToHumanReadablePrivateKey(priv string, b1, b2 byte) (string, error)
- func PrivateKeyStringToPublicKey(private string) ([]byte, error)
- func PrivateKeyStringToPublicKeyString(private string) (string, error)
- func PrivateKeyToPublicKey(private []byte) ([]byte, error)
- func RandomHash() interfaces.IHash
- func RandomSignatureSet() ([]byte, interfaces.Signer, interfaces.IFullSignature)
- func RandomVarInt() uint64
- func Sha(p []byte) interfaces.IHash
- func Shad(data []byte) interfaces.IHash
- func Sign(priv, data []byte) []byte
- func SignSignable(priv []byte, data interfaces.ISignable) ([]byte, error)
- func UnmarshalBinaryDataOfLength(dest []byte, source []byte, length int) (newData []byte, err error)
- func ValidateECPrivateUserStr(userFAddr string) bool
- func ValidateECUserStr(userFAddr string) bool
- func ValidateFPrivateUserStr(userFAddr string) bool
- func ValidateFUserStr(userFAddr string) bool
- func VarIntLength(v uint64) uint64
- func Verify(publicKey *[ed25519.PublicKeySize]byte, message []byte, ...) bool
- func VerifySignature(data, publicKey, signature []byte) error
- func VerifySlice(p []byte, message []byte, s []byte) bool
- func WriteNumber16(out *Buffer, num uint16)
- func WriteNumber32(out *Buffer, num uint32)
- func WriteNumber64(out *Buffer, num uint64)
- func WriteNumber8(out *Buffer, num uint8)
- type Buffer
- func (b *Buffer) DeepCopyBytes() []byte
- func (b *Buffer) PeekByte() (byte, error)
- func (b *Buffer) Pop(h []byte) error
- func (b *Buffer) PopBinaryMarshallable(dst interfaces.BinaryMarshallable) error
- func (b *Buffer) PopBinaryMarshallableMsgArray() ([]interfaces.IMsg, error)
- func (b *Buffer) PopBool() (bool, error)
- func (b *Buffer) PopByte() (byte, error)
- func (b *Buffer) PopBytes() ([]byte, error)
- func (b *Buffer) PopIHash() (interfaces.IHash, error)
- func (b *Buffer) PopInt() (int, error)
- func (b *Buffer) PopInt64() (int64, error)
- func (b *Buffer) PopLen(l int) ([]byte, error)
- func (b *Buffer) PopMsg() (msg interfaces.IMsg, err error)
- func (b *Buffer) PopString() (string, error)
- func (b *Buffer) PopTimestamp() (interfaces.Timestamp, error)
- func (b *Buffer) PopUInt16() (uint16, error)
- func (b *Buffer) PopUInt32() (uint32, error)
- func (b *Buffer) PopUInt64() (uint64, error)
- func (b *Buffer) PopUInt8() (uint8, error)
- func (b *Buffer) PopVarInt() (uint64, error)
- func (b *Buffer) Push(h []byte) error
- func (b *Buffer) PushBinaryMarshallable(bm interfaces.BinaryMarshallable) error
- func (b *Buffer) PushBinaryMarshallableMsgArray(bm []interfaces.IMsg) error
- func (b *Buffer) PushBool(boo bool) error
- func (b *Buffer) PushByte(h byte) error
- func (b *Buffer) PushBytes(h []byte) error
- func (b *Buffer) PushIHash(h interfaces.IHash) error
- func (b *Buffer) PushInt(i int) error
- func (b *Buffer) PushInt64(i int64) error
- func (b *Buffer) PushMsg(msg interfaces.IMsg) error
- func (b *Buffer) PushString(s string) error
- func (b *Buffer) PushTimestamp(ts interfaces.Timestamp) error
- func (b *Buffer) PushUInt16(i uint16) error
- func (b *Buffer) PushUInt32(i uint32) error
- func (b *Buffer) PushUInt64(i uint64) error
- func (b *Buffer) PushUInt8(h uint8) error
- func (b *Buffer) PushVarInt(vi uint64) error
- type ByteSlice
- func (bs *ByteSlice) IsSameAs(b *ByteSlice) bool
- func (bs *ByteSlice) JSONByte() ([]byte, error)
- func (bs *ByteSlice) JSONString() (string, error)
- func (bs *ByteSlice) MarshalBinary() (rval []byte, err error)
- func (bs *ByteSlice) MarshalText() (rval []byte, err error)
- func (bs *ByteSlice) New() interfaces.BinaryMarshallableAndCopyable
- func (bs *ByteSlice) String() string
- func (bs *ByteSlice) UnmarshalBinary(data []byte) (err error)
- func (bs *ByteSlice) UnmarshalBinaryData(data []byte) (newData []byte, err error)
- type ByteSlice20
- func (bs *ByteSlice20) GetFixed() ([20]byte, error)
- func (bs *ByteSlice20) IsSameAs(b *ByteSlice20) bool
- func (bs *ByteSlice20) JSONByte() ([]byte, error)
- func (bs *ByteSlice20) JSONString() (string, error)
- func (bs *ByteSlice20) MarshalBinary() (rval []byte, err error)
- func (bs *ByteSlice20) MarshalText() (rval []byte, err error)
- func (bs *ByteSlice20) String() string
- func (bs *ByteSlice20) UnmarshalBinary(data []byte) (err error)
- func (bs *ByteSlice20) UnmarshalBinaryData(data []byte) (newData []byte, err error)
- type ByteSlice32
- func (bs *ByteSlice32) Fixed() [32]byte
- func (bs *ByteSlice32) IsSameAs(b *ByteSlice32) bool
- func (bs *ByteSlice32) JSONByte() ([]byte, error)
- func (bs *ByteSlice32) JSONString() (string, error)
- func (bs *ByteSlice32) MarshalBinary() (rval []byte, err error)
- func (bs *ByteSlice32) MarshalText() (rval []byte, err error)
- func (bs *ByteSlice32) String() string
- func (bs *ByteSlice32) UnmarshalBinary(data []byte) (err error)
- func (bs *ByteSlice32) UnmarshalBinaryData(data []byte) (newData []byte, err error)
- type ByteSlice6
- func (bs *ByteSlice6) IsSameAs(b *ByteSlice6) bool
- func (bs *ByteSlice6) JSONByte() ([]byte, error)
- func (bs *ByteSlice6) JSONString() (string, error)
- func (bs *ByteSlice6) MarshalBinary() (rval []byte, err error)
- func (bs *ByteSlice6) MarshalText() (rval []byte, err error)
- func (bs *ByteSlice6) String() string
- func (bs *ByteSlice6) UnmarshalBinary(data []byte) (err error)
- func (bs *ByteSlice6) UnmarshalBinaryData(data []byte) (newData []byte, err error)
- type ByteSlice64
- func (bs *ByteSlice64) IsSameAs(b *ByteSlice64) bool
- func (bs *ByteSlice64) JSONByte() ([]byte, error)
- func (bs *ByteSlice64) JSONString() (string, error)
- func (bs *ByteSlice64) MarshalBinary() (rval []byte, err error)
- func (bs *ByteSlice64) MarshalText() (rval []byte, err error)
- func (bs *ByteSlice64) String() string
- func (bs *ByteSlice64) UnmarshalBinary(data []byte) (err error)
- func (bs *ByteSlice64) UnmarshalBinaryData(data []byte) (newData []byte, err error)
- type ByteSliceSig
- func (bs *ByteSliceSig) GetFixed() ([ed25519.SignatureSize]byte, error)
- func (bs *ByteSliceSig) IsSameAs(b *ByteSliceSig) bool
- func (bs *ByteSliceSig) JSONByte() ([]byte, error)
- func (bs *ByteSliceSig) JSONString() (string, error)
- func (bs *ByteSliceSig) MarshalBinary() (rval []byte, err error)
- func (bs *ByteSliceSig) MarshalText() (rval []byte, err error)
- func (bs *ByteSliceSig) String() string
- func (bs *ByteSliceSig) UnmarshalBinary(data []byte) (err error)
- func (bs *ByteSliceSig) UnmarshalBinaryData(data []byte) (newData []byte, err error)
- func (bs *ByteSliceSig) UnmarshalText(text []byte) error
- type Error
- type Hash
- func (h *Hash) ByteString() string
- func (h *Hash) Bytes() (rval []byte)
- func (h *Hash) Copy() (rval interfaces.IHash)
- func (h *Hash) Fixed() [constants.HASH_LENGTH]byte
- func (h *Hash) GetBytes() []byte
- func (Hash) GetHash() interfaces.IHash
- func (h *Hash) IsHashNil() bool
- func (h *Hash) IsMinuteMarker() bool
- func (a *Hash) IsSameAs(b interfaces.IHash) bool
- func (h *Hash) IsZero() bool
- func (h *Hash) JSONByte() ([]byte, error)
- func (h *Hash) JSONString() (string, error)
- func (h *Hash) MarshalBinary() (rval []byte, err error)
- func (h *Hash) MarshalText() (rval []byte, err error)
- func (h *Hash) New() interfaces.BinaryMarshallableAndCopyable
- func (h *Hash) PFixed() *[constants.HASH_LENGTH]byte
- func (h *Hash) SetBytes(newHash []byte) error
- func (h *Hash) String() string
- func (h *Hash) ToMinute() byte
- func (h *Hash) UnmarshalBinary(p []byte) (err error)
- func (h *Hash) UnmarshalBinaryData(p []byte) (newData []byte, err error)
- func (h *Hash) UnmarshalText(b []byte) error
- type JSON2Request
- type JSON2Response
- type JSONError
- type MerkleNode
- type PrivateKey
- func (pk *PrivateKey) CustomMarshalText2(string) ([]byte, error)
- func (pk *PrivateKey) GenerateKey() error
- func (pk *PrivateKey) Init()
- func (pk *PrivateKey) MarshalSign(msg interfaces.BinaryMarshallable) (sig interfaces.IFullSignature)
- func (pk *PrivateKey) PrivateKeyString() string
- func (pk *PrivateKey) Public() []byte
- func (pk *PrivateKey) PublicKeyString() string
- func (pk *PrivateKey) Sign(msg []byte) (sig interfaces.IFullSignature)
- type PublicKey
- func (k *PublicKey) Copy() (*PublicKey, error)
- func (k PublicKey) Fixed() [ed25519.PublicKeySize]byte
- func (k *PublicKey) IsSameAs(b *PublicKey) bool
- func (k *PublicKey) MarshalBinary() (rval []byte, err error)
- func (k *PublicKey) MarshalText() (rval []byte, err error)
- func (k *PublicKey) String() string
- func (k *PublicKey) UnmarshalBinary(p []byte) (err error)
- func (k *PublicKey) UnmarshalBinaryData(p []byte) ([]byte, error)
- func (k *PublicKey) UnmarshalText(b []byte) error
- func (k *PublicKey) Verify(msg []byte, sig *[ed25519.SignatureSize]byte) bool
- type Signature
- func (sig *Signature) Bytes() []byte
- func (sig *Signature) CustomMarshalText() ([]byte, error)
- func (sig *Signature) GetKey() []byte
- func (sig *Signature) GetPubBytes() []byte
- func (sig *Signature) GetSigBytes() []byte
- func (sig *Signature) GetSignature() *[ed25519.SignatureSize]byte
- func (e *Signature) Init()
- func (a *Signature) IsSameAs(b interfaces.IFullSignature) bool
- func (s *Signature) MarshalBinary() (rval []byte, err error)
- func (sig *Signature) SetPub(publicKey []byte)
- func (sig *Signature) SetSignature(signature []byte) error
- func (s *Signature) UnmarshalBinary(data []byte) error
- func (sig *Signature) UnmarshalBinaryData(data []byte) ([]byte, error)
- func (sig *Signature) Verify(msg []byte) bool
- type Timestamp
- func (t Timestamp) Clone() interfaces.Timestamp
- func (t *Timestamp) GetTime() time.Time
- func (t *Timestamp) GetTimeMilli() int64
- func (t *Timestamp) GetTimeMilliUInt64() uint64
- func (t *Timestamp) GetTimeMinutesUInt32() uint32
- func (t *Timestamp) GetTimeSeconds() int64
- func (t *Timestamp) GetTimeSecondsUInt32() uint32
- func (a *Timestamp) IsSameAs(b interfaces.Timestamp) bool
- func (t *Timestamp) MarshalBinary() (rval []byte, err error)
- func (t *Timestamp) SetTime(miliseconds uint64)
- func (t *Timestamp) SetTimeMilli(miliseconds int64)
- func (t *Timestamp) SetTimeNow()
- func (t *Timestamp) SetTimeSeconds(seconds int64)
- func (t *Timestamp) SetTimestamp(b interfaces.Timestamp)
- func (t *Timestamp) String() string
- func (t *Timestamp) UTCString() string
- func (t *Timestamp) UnmarshalBinary(data []byte) error
- func (t *Timestamp) UnmarshalBinaryData(data []byte) (newData []byte, err error)
Constants ¶
const ( ErrorBadMethod = 0 ErrorNotAcceptable = 1 ErrorMissingVersionSpec = 2 ErrorMalformedVersionSpec = 3 ErrorBadVersionSpec = 4 ErrorEmptyRequest = 5 ErrorBadElementSpec = 6 ErrorBadIdentifier = 7 ErrorBlockNotFound = 8 ErrorEntryNotFound = 9 ErrorInternal = 10 ErrorJSONMarshal = 11 ErrorXMLMarshal = 12 ErrorUnsupportedMarshal = 13 ErrorJSONUnmarshal = 14 ErrorXMLUnmarshal = 15 ErrorUnsupportedUnmarshal = 16 ErrorBadPOSTData = 17 ErrorTemplateError = 18 ErrorHTTPNewRequestFailure = 19 ErrorHTTPDoRequestFailure = 20 ErrorHTMLMarshal = 21 )
Variables ¶
var EntryCreditPrefix = []byte{0x59, 0x2a}
var EntryCreditPrivatePrefix = []byte{0x5d, 0xb6}
var FactoidPrefix = []byte{0x5f, 0xb1}
var FactoidPrivatePrefix = []byte{0x64, 0x78}
var General interfaces.IGeneralMsg
var ZeroHash interfaces.IHash = NewHash(constants.ZERO_HASH)
ZeroHash is a zero hash
Functions ¶
func AreBinaryMarshallablesEqual ¶
func AreBinaryMarshallablesEqual(b1, b2 interfaces.BinaryMarshallable) (bool, error)
AreBinaryMarshallablesEqual returns true if the input interfaces are both nil, or both exist and can be marshalled into byte identical arrays
func AreBytesEqual ¶
AreBytesEqual returns true iff the lengths and byte values of the input []byte arrays are equal
func BuildMerkleTreeStore ¶
func BuildMerkleTreeStore(hashes []interfaces.IHash) (merkles []interfaces.IHash)
The root of the Merkle Tree is returned in merkles[len(merkles)-1]
func CalculateCoinbasePayout ¶
func ComputeMerkleRoot ¶
func ComputeMerkleRoot(hashes []interfaces.IHash) interfaces.IHash
Give a list of hashes, return the root of the Merkle Tree
func ConvertAddressToUser ¶
func ConvertAddressToUser(prefix []byte, addr interfaces.IAddress) []byte
Convert Factoid and Entry Credit addresses to their more user friendly and human readable formats.
Creates the binary form. Just needs the conversion to base58 for display.
func ConvertDecimalToFloat ¶
Converts factoshis to floating point factoids
func ConvertDecimalToPaddedString ¶
Take fixed point data and produce a nice decimal point sort of output that users can handle.
func ConvertDecimalToString ¶
Converts factoshis to floating point string
func ConvertECAddressToUserStr ¶
func ConvertECAddressToUserStr(addr interfaces.IAddress) string
Convert Entry Credits
func ConvertECPrivateToUserStr ¶
func ConvertECPrivateToUserStr(addr interfaces.IAddress) string
Convert Entry Credit Private key
func ConvertFctAddressToUserStr ¶
func ConvertFctAddressToUserStr(addr interfaces.IAddress) string
Convert Factoid Addresses
func ConvertFctPrivateToUserStr ¶
func ConvertFctPrivateToUserStr(addr interfaces.IAddress) string
Convert Factoid Private Key
func ConvertFixedPoint ¶
Convert Decimal point input to FixedPoint (no decimal point) output suitable for Factom to chew on.
func ConvertUserStrToAddress ¶
Convert a User facing Factoid or Entry Credit address or their Private Key representations to the regular form. Note validation must be done separately!
func CreateHash ¶
func CreateHash(entities ...interfaces.BinaryMarshallable) (h interfaces.IHash, err error)
CreateHash returns a hash created from all input entities
func DecodeBinary ¶
DecodeBinary returns a byte array of the decoded input hexadecimal (0-F) string
func DecodeJSON ¶
DecodeJSON unmarshals input []byte into input interface
func DecodeJSONString ¶
DecodeJSONString unmarshals input string into input interface
func DecodeVarInt ¶
DecodeVarInt decodes a variable integer from the given data buffer. We use the algorithm used by Go, only BigEndian.
func DecodeVarIntGo ¶
DecodeVarIntGo decodes a variable integer from the given data buffer. We use the algorithm used by Go, only BigEndian.
func DoubleSha ¶
DoubleSha returns a new hash created by double hashing the input: shad Double Sha256 Hash; sha256(sha256(data))
func EfficiencyToString ¶
func EncodeBinary ¶
EncodeBinary returns the hexadecimal (0-F) encoding of input byte array
func EncodeJSON ¶
EncodeJSON marshals data into Json format
func EncodeJSONString ¶
EncodeJSONString marshals data into Json format
func EncodeJSONToBuffer ¶
EncodeJSONToBuffer marshals input data into Json format and writes it to the input buffer
func EncodeVarInt ¶
EncodeVarInt encodes an integer as a variable int into the given data buffer.
func EncodeVarIntGo ¶
EncodeVarIntGo encodes an integer as a variable int into the given data buffer.
func GetTimeMilli ¶
func GetTimeMilli() uint64
func HashMerkleBranches ¶
func HashMerkleBranches(left interfaces.IHash, right interfaces.IHash) interfaces.IHash
HashMerkleBranches takes two hashes, treated as the left and right tree nodes, and returns the hash of their concatenation. This is a helper function used to aid in the generation of a merkle tree.
func HexToHash ¶
func HexToHash(hexStr string) (h interfaces.IHash, err error)
HexToHash converts the input hexidecimal (0-F) string into the internal []byte array
func Log ¶
func Log(format string, args ...interface{})
Log prints the formated string with args (using fmt.Printf) with a prepended file and line number of the calling function: "<file>:<linenumber> - <fmt.Printf_output>\n"
func LogJSONs ¶
func LogJSONs(format string, args ...interface{})
LogJSONs converts input args to Json format and then prints the formated string with new Json args (using fmt.Printf) with a prepended file and line number of the calling function: "<file>:<linenumber> - <fmt.Printf_output>\n"
func LogNilHashBug ¶
func LogNilHashBug(msg string)
func Loghashfixed ¶
func Loghashfixed(h [32]byte)
Loghashfixed logs the input hash ***************************************************************
DEBUG logging to keep full hash. Turned on from command line ***************************************************************
func NewHash ¶
func NewHash(b []byte) interfaces.IHash
NewHash creates a new object for the input hash
func NewShaHashFromStruct ¶
func NewShaHashFromStruct(DataStruct interface{}) (interfaces.IHash, error)
NewShaHashFromStruct marshals the input struct into a json byte array, then double hashes the json array
func NextPowerOfTwo ¶
NextPowerOfTwo returns the next highest power of two from a given number if it is not already a power of two. This is a helper function used during the calculation of a merkle tree.
func PrivateKeyToPublicKey ¶
func RandomSignatureSet ¶
func RandomSignatureSet() ([]byte, interfaces.Signer, interfaces.IFullSignature)
func Shad ¶
func Shad(data []byte) interfaces.IHash
Shad returns a new hash created by double hashing the input: Double Sha256 Hash; sha256(sha256(data))
func SignSignable ¶
func SignSignable(priv []byte, data interfaces.ISignable) ([]byte, error)
func UnmarshalBinaryDataOfLength ¶
func UnmarshalBinaryDataOfLength(dest []byte, source []byte, length int) (newData []byte, err error)
UnmarshalBinaryDataOfLength unmarshals an arbitrary input []byte array up to specified length, returning residual
func ValidateECPrivateUserStr ¶
Validate Entry Credit Private Key
func ValidateFPrivateUserStr ¶
Validate Factoid Private Key
func VarIntLength ¶
VarIntLength returns the length of the variable integer when encoded as a var int
func Verify ¶
func Verify(publicKey *[ed25519.PublicKeySize]byte, message []byte, sig *[ed25519.SignatureSize]byte) bool
Verify returns true iff sig is a valid signature of message by publicKey.
func VerifySignature ¶
func VerifySlice ¶
VerifySlice returns true iff sig is a valid signature of message by publicKey.
func WriteNumber16 ¶
func WriteNumber32 ¶
func WriteNumber64 ¶
func WriteNumber8 ¶
Types ¶
type Buffer ¶
Buffer contains a bytes.Buffer
func NewBuffer ¶
NewBuffer copies the input []byte array int a new Buffer object and returns the Buffer
func (*Buffer) DeepCopyBytes ¶
DeepCopyBytes returns the remainder of the unread buffer. Despite its name, it DOES NOT COPY!
func (*Buffer) PeekByte ¶
PeekByte returns the next unread byte in the buffer without advancing the read state
func (*Buffer) PopBinaryMarshallable ¶
func (b *Buffer) PopBinaryMarshallable(dst interfaces.BinaryMarshallable) error
PopBinaryMarshallable reads a binary marshallable interface object from the Buffer
func (*Buffer) PopBinaryMarshallableMsgArray ¶
func (b *Buffer) PopBinaryMarshallableMsgArray() ([]interfaces.IMsg, error)
PopBinaryMarshallableMsgArray reads a message array from the Buffer
func (*Buffer) PopIHash ¶
func (b *Buffer) PopIHash() (interfaces.IHash, error)
PopIHash reads an hash from the Buffer
func (*Buffer) PopMsg ¶
func (b *Buffer) PopMsg() (msg interfaces.IMsg, err error)
PopMsg reads a message from the Buffer
func (*Buffer) PopTimestamp ¶
func (b *Buffer) PopTimestamp() (interfaces.Timestamp, error)
PopTimestamp reads a time stamp from the Buffer
func (*Buffer) Push ¶
Push appends the input []byte array to the Buffer. Return error will always be nil, because Write gaurantees a nil error return.
func (*Buffer) PushBinaryMarshallable ¶
func (b *Buffer) PushBinaryMarshallable(bm interfaces.BinaryMarshallable) error
PushBinaryMarshallable marshals the input and writes it to the Buffer
func (*Buffer) PushBinaryMarshallableMsgArray ¶
func (b *Buffer) PushBinaryMarshallableMsgArray(bm []interfaces.IMsg) error
PushBinaryMarshallableMsgArray marshals the input message array and writes it into the Buffer
func (*Buffer) PushByte ¶
PushByte writes the input byte to the Buffer. Returned error is always nil.
func (*Buffer) PushIHash ¶
func (b *Buffer) PushIHash(h interfaces.IHash) error
PushIHash marshals and writes the input hash to the Buffer
func (*Buffer) PushMsg ¶
func (b *Buffer) PushMsg(msg interfaces.IMsg) error
PushMsg marshals and writes the input message to the Buffer
func (*Buffer) PushString ¶
PushString marshals and writes the string to the Buffer
func (*Buffer) PushTimestamp ¶
func (b *Buffer) PushTimestamp(ts interfaces.Timestamp) error
PushTimestamp writes a timestamp into the Buffer
func (*Buffer) PushUInt16 ¶
PushUInt16 writes the input uint16 to the Buffer
func (*Buffer) PushUInt32 ¶
PushUInt32 writes the input uint32 to the Buffer
func (*Buffer) PushUInt64 ¶
PushUInt64 writes the input uint64 to the Buffer
func (*Buffer) PushVarInt ¶
PushVarInt writes the smallest possible data to the Buffer to represent the input integer
type ByteSlice ¶
type ByteSlice struct {
Bytes []byte
}
ByteSlice contains a []byte
func RandomByteSlice ¶
func RandomByteSlice() *ByteSlice
RandomByteSlice returns a random non empty ByteSlice of length 1 <= len <= 63
func StringToByteSlice ¶
StringToByteSlice converts the input string to a ByteSlice
func (*ByteSlice) IsSameAs ¶
IsSameAs returns true iff the input ByteSlice is binary identical to this ByteSlice
func (*ByteSlice) JSONString ¶
JSONString marshals the ByteSlice into json format byte string
func (*ByteSlice) MarshalBinary ¶
MarshalBinary returns the byte array of the ByteSlice
func (*ByteSlice) MarshalText ¶
MarshalText marshals the receiver into text
func (*ByteSlice) New ¶
func (bs *ByteSlice) New() interfaces.BinaryMarshallableAndCopyable
New returns a new ByteSlice
func (*ByteSlice) UnmarshalBinary ¶
UnmarshalBinary unmarshals the input byte array into the ByteSlice
type ByteSlice20 ¶
type ByteSlice20 [20]byte
ByteSlice20 is a fixed [20]byte
func (*ByteSlice20) GetFixed ¶
func (bs *ByteSlice20) GetFixed() ([20]byte, error)
GetFixed returns a new copy of the internal byte array
func (*ByteSlice20) IsSameAs ¶
func (bs *ByteSlice20) IsSameAs(b *ByteSlice20) bool
IsSameAs returns true iff input ByteSlice20 is binary identical to this ByteSlice20
func (*ByteSlice20) JSONByte ¶
func (bs *ByteSlice20) JSONByte() ([]byte, error)
JSONByte returns the encoded JSON format data
func (*ByteSlice20) JSONString ¶
func (bs *ByteSlice20) JSONString() (string, error)
JSONString returns the encoded JSON format byte string
func (*ByteSlice20) MarshalBinary ¶
func (bs *ByteSlice20) MarshalBinary() (rval []byte, err error)
MarshalBinary returns the byte array of the ByteSlice20
func (*ByteSlice20) MarshalText ¶
func (bs *ByteSlice20) MarshalText() (rval []byte, err error)
MarshalText marshals the internal ByteSlice20
func (*ByteSlice20) String ¶
func (bs *ByteSlice20) String() string
String returns a hexidecimal (0-F) string of the internal data
func (*ByteSlice20) UnmarshalBinary ¶
func (bs *ByteSlice20) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals the input data into the ByteSlice20
func (*ByteSlice20) UnmarshalBinaryData ¶
func (bs *ByteSlice20) UnmarshalBinaryData(data []byte) (newData []byte, err error)
UnmarshalBinaryData unmarshals the input data into the ByteSlice20
type ByteSlice32 ¶
type ByteSlice32 [32]byte
ByteSlice32 is a fixed [32]byte array
func Byte32ToByteSlice32 ¶
func Byte32ToByteSlice32(b [32]byte) *ByteSlice32
Byte32ToByteSlice32 returns a new ByteSlice32 containing the input data
func StringToByteSlice32 ¶
func StringToByteSlice32(s string) *ByteSlice32
StringToByteSlice32 converts the input hexidecimal string (0-F) to a new ByteSlice32
func (*ByteSlice32) Fixed ¶
func (bs *ByteSlice32) Fixed() [32]byte
Fixed returns the internal fixed byte array data
func (*ByteSlice32) IsSameAs ¶
func (bs *ByteSlice32) IsSameAs(b *ByteSlice32) bool
IsSameAs returns true iff input ByteSlice32 is binary identical to this ByteSlice
func (*ByteSlice32) JSONByte ¶
func (bs *ByteSlice32) JSONByte() ([]byte, error)
JSONByte returns the encoded json data of this ByteSlice32
func (*ByteSlice32) JSONString ¶
func (bs *ByteSlice32) JSONString() (string, error)
JSONString returns the encoded json byte string of this ByteSlice32
func (*ByteSlice32) MarshalBinary ¶
func (bs *ByteSlice32) MarshalBinary() (rval []byte, err error)
MarshalBinary marshals this ByteSlice32 into []byte array
func (*ByteSlice32) MarshalText ¶
func (bs *ByteSlice32) MarshalText() (rval []byte, err error)
MarshalText marshals this ByteSlice32 into the returned array
func (*ByteSlice32) String ¶
func (bs *ByteSlice32) String() string
String returns the hexidecimal string (0-F) of this ByteSlice32
func (*ByteSlice32) UnmarshalBinary ¶
func (bs *ByteSlice32) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals the input data into this ByteSlice32
func (*ByteSlice32) UnmarshalBinaryData ¶
func (bs *ByteSlice32) UnmarshalBinaryData(data []byte) (newData []byte, err error)
UnmarshalBinaryData unmarshals the input data into this ByteSlice32
type ByteSlice6 ¶
type ByteSlice6 [6]byte
ByteSlice6 is a fixed [6]byte array
func (*ByteSlice6) IsSameAs ¶
func (bs *ByteSlice6) IsSameAs(b *ByteSlice6) bool
IsSameAs returns true iff the input ByteSlice6 is binary identical to this ByteSlice6
func (*ByteSlice6) JSONByte ¶
func (bs *ByteSlice6) JSONByte() ([]byte, error)
JSONByte returns the json encoded data of the ByteSlice6
func (*ByteSlice6) JSONString ¶
func (bs *ByteSlice6) JSONString() (string, error)
JSONString returns the json encoded byte string of the ByteSlice6
func (*ByteSlice6) MarshalBinary ¶
func (bs *ByteSlice6) MarshalBinary() (rval []byte, err error)
MarshalBinary marshals this ByteSlice6 into a []byte array
func (*ByteSlice6) MarshalText ¶
func (bs *ByteSlice6) MarshalText() (rval []byte, err error)
MarshalText marshals the ByteSlice6 into text
func (*ByteSlice6) String ¶
func (bs *ByteSlice6) String() string
String returns the hexidecimal (0-F) string of the ByteSlice6S
func (*ByteSlice6) UnmarshalBinary ¶
func (bs *ByteSlice6) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals the input data into the ByteSlice6
func (*ByteSlice6) UnmarshalBinaryData ¶
func (bs *ByteSlice6) UnmarshalBinaryData(data []byte) (newData []byte, err error)
UnmarshalBinaryData unmarshals the input data into the ByteSlice6
type ByteSlice64 ¶
type ByteSlice64 [64]byte
ByteSlice64 is a fixed [64]byte array
func (*ByteSlice64) IsSameAs ¶
func (bs *ByteSlice64) IsSameAs(b *ByteSlice64) bool
IsSameAs returns true iff the input ByteSlice64 is binary identical to this ByteSlice64
func (*ByteSlice64) JSONByte ¶
func (bs *ByteSlice64) JSONByte() ([]byte, error)
JSONByte returns the json encoded data
func (*ByteSlice64) JSONString ¶
func (bs *ByteSlice64) JSONString() (string, error)
JSONString returns the json encoded byte string
func (*ByteSlice64) MarshalBinary ¶
func (bs *ByteSlice64) MarshalBinary() (rval []byte, err error)
MarshalBinary marshals this ByteSlice64
func (*ByteSlice64) MarshalText ¶
func (bs *ByteSlice64) MarshalText() (rval []byte, err error)
MarshalText marshals this ByteSlice64 into text
func (*ByteSlice64) String ¶
func (bs *ByteSlice64) String() string
String returns the json encoded hexidecimal (0-F) string
func (*ByteSlice64) UnmarshalBinary ¶
func (bs *ByteSlice64) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals the input data into this ByteSlice64
func (*ByteSlice64) UnmarshalBinaryData ¶
func (bs *ByteSlice64) UnmarshalBinaryData(data []byte) (newData []byte, err error)
UnmarshalBinaryData unmarshals the input data into this ByteSlice64
type ByteSliceSig ¶
type ByteSliceSig [ed25519.SignatureSize]byte
ByteSliceSig is a fixed byte array of the ed25519 signature length
func (*ByteSliceSig) GetFixed ¶
func (bs *ByteSliceSig) GetFixed() ([ed25519.SignatureSize]byte, error)
GetFixed returns a new copy of the internal byte array
func (*ByteSliceSig) IsSameAs ¶
func (bs *ByteSliceSig) IsSameAs(b *ByteSliceSig) bool
IsSameAs returns true iff the input ByteSliceSig is binary identical to this ByteSliceSig
func (*ByteSliceSig) JSONByte ¶
func (bs *ByteSliceSig) JSONByte() ([]byte, error)
JSONByte returns the json encoded data of the ByteSliceSig
func (*ByteSliceSig) JSONString ¶
func (bs *ByteSliceSig) JSONString() (string, error)
JSONString returns the json encoded byte string of the ByteSliceSig
func (*ByteSliceSig) MarshalBinary ¶
func (bs *ByteSliceSig) MarshalBinary() (rval []byte, err error)
MarshalBinary marshals this ByteSliceSig into []byte array
func (*ByteSliceSig) MarshalText ¶
func (bs *ByteSliceSig) MarshalText() (rval []byte, err error)
MarshalText marshals the ByteSliceSig into text
func (*ByteSliceSig) String ¶
func (bs *ByteSliceSig) String() string
String returns a hexidecimal (0-F) string of the ByteSliceSig
func (*ByteSliceSig) UnmarshalBinary ¶
func (bs *ByteSliceSig) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary unmarshals the input data into the ByteSliceSig
func (*ByteSliceSig) UnmarshalBinaryData ¶
func (bs *ByteSliceSig) UnmarshalBinaryData(data []byte) (newData []byte, err error)
UnmarshalBinaryData unmarshals the input data into the ByteSliceSig
func (*ByteSliceSig) UnmarshalText ¶
func (bs *ByteSliceSig) UnmarshalText(text []byte) error
UnmarshalText unmarshals the input text to the ByteSliceSig
type Error ¶
type Error struct { APICode uint HTTPCode int Name string Description string SupportURL string Message string }
func CreateError ¶
type Hash ¶
type Hash [constants.HASH_LENGTH]byte
Hash is a convenient fixed []byte type created at the hash length
func NewShaHash ¶
NewShaHash returns a new ShaHash from a byte slice. An error is returned if the number of bytes passed in is not constants.HASH_LENGTH.
func NewShaHashFromStr ¶
NewShaHashFromStr creates a ShaHash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the ShaHash.
func Sha512Half ¶
Sha512Half creates a Sha512[:256] Hash from a byte array
func (*Hash) ByteString ¶
ByteString returns the hash as a byte string
func (*Hash) Fixed ¶
func (h *Hash) Fixed() [constants.HASH_LENGTH]byte
Fixed returns the fixed []byte array
func (*Hash) GetBytes ¶
GetBytes makes a copy of the hash in this hash. Changes to the return value WILL NOT be reflected in the source hash. You have to do a SetBytes to change the source value.
func (Hash) GetHash ¶
func (Hash) GetHash() interfaces.IHash
GetHash is unused, merely here to implement the IHash interface
func (*Hash) IsMinuteMarker ¶
IsMinuteMarker checks if the Hash is the hash of a minute marker (the last byte indicates the minute number) A minute marker is determined by having all but the last value as zero
func (*Hash) IsSameAs ¶
func (a *Hash) IsSameAs(b interfaces.IHash) bool
IsSameAs compares two Hashes and returns true iff they hashs are binary identical
func (*Hash) JSONString ¶
JSONString returns the json encoded byte string of the Hash
func (*Hash) MarshalBinary ¶
MarshalBinary returns a copy of the []byte array
func (*Hash) MarshalText ¶
MarshalText marshals the Hash as text
func (*Hash) New ¶
func (h *Hash) New() interfaces.BinaryMarshallableAndCopyable
New creates a new Hash (required for BinarymarshallableAndCopyable interface)
func (*Hash) PFixed ¶
func (h *Hash) PFixed() *[constants.HASH_LENGTH]byte
PFixed returns a pointer to the fixed []byte array
func (*Hash) SetBytes ¶
SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not constants.HASH_LENGTH.
func (*Hash) UnmarshalBinary ¶
UnmarshalBinary unmarshals the input array into the Hash
func (*Hash) UnmarshalBinaryData ¶
UnmarshalBinaryData unmarshals the input array into the Hash
func (*Hash) UnmarshalText ¶
UnmarshalText unmarshals the input array
type JSON2Request ¶
type JSON2Request struct { JSONRPC string `json:"jsonrpc"` // version string which MUST be "2.0" (version 1.0 didn't have this field) ID interface{} `json:"id"` // Unique client defined ID associated with this request. It may be a number, // string, or nil. It is used by the remote to formulate a response object // containing the same ID back to the client. If nil, remote treats request object // as a notification, and that the client does not expect a response object back Params interface{} `json:"params,omitempty"` // input parameters for the subroutine called on the remote - may be omitted Method string `json:"method,omitempty"` // name of the subroutine to be called on the remote }
JSON2Request is an JSON RPC request object used in factomd according to the specification for JSON RPC 2.0 See specification: https://www.jsonrpc.org/specification Remote Proceedure Call (RPC) is a protocol for executing subroutines on a remote
func NewJSON2Request ¶
func NewJSON2Request(method string, id, params interface{}) *JSON2Request
NewJSON2Request creates a new JSON2Request with the input parameters
func NewJSON2RequestBlank ¶
func NewJSON2RequestBlank() *JSON2Request
NewJSON2RequestBlank creates a new blank JSON2Request object with only the JSONRPC field filled (because it has 1 acceptable value)
func ParseJSON2Request ¶
func ParseJSON2Request(request string) (*JSON2Request, error)
ParseJSON2Request unmarshals a string into a JSON2Request object
func (*JSON2Request) JSONByte ¶
func (j *JSON2Request) JSONByte() ([]byte, error)
JSONByte encodes object to a json []byte
func (*JSON2Request) JSONString ¶
func (j *JSON2Request) JSONString() (string, error)
JSONString encodes object to a json string with error return
func (*JSON2Request) String ¶
func (j *JSON2Request) String() string
String encodes object to a json string with no error return
type JSON2Response ¶
type JSON2Response struct { JSONRPC string `json:"jsonrpc"` // version string which MUST be "2.0" (version 1.0 didn't have this field) ID interface{} `json:"id"` // Unique client defined ID associated with incoming request. It may be a number, // string, or nil. It is used by the remote to formulate a this response object // containing the same ID back to the client. If nil, remote treats request object // as a notification, and that the client does not expect a response object back Error *JSONError `json:"error,omitempty"` // Must be present if called subroutine had an error (mutually exclusive with Result) Result interface{} `json:"result,omitempty"` // Must be present if called subroutine succeeded (mutually exclusive with Error) }
JSON2Response is an JSON RPC response object used in factomd according to the specification for JSON RPC 2.0 See specification: https://www.jsonrpc.org/specification Remote Proceedure Call (RPC) is a protocol for executing subroutines on a remote
func NewJSON2Response ¶
func NewJSON2Response() *JSON2Response
NewJSON2Response returns a new JSON2Response initialized with defaults
func (*JSON2Response) AddError ¶
func (j *JSON2Response) AddError(code int, message string, data interface{})
AddError sets the member Error with a new JSONError formed from the inputs
func (*JSON2Response) JSONByte ¶
func (j *JSON2Response) JSONByte() ([]byte, error)
JSONByte encodes object to a json []byte
func (*JSON2Response) JSONString ¶
func (j *JSON2Response) JSONString() (string, error)
JSONString encodes object to a json string
func (*JSON2Response) String ¶
func (j *JSON2Response) String() string
String encodes object to a json string
type JSONError ¶
type JSONError struct { Code int `json:"code"` // The error code associated with the error type Message string `json:"message"` // The error message as a concise single sentence Data interface{} `json:"data,omitempty"` // Optional data object containing additional information about the error }
JSONError is an JSON RPC error object used in factomd according to the specification for JSON RPC 2.0 See specification: https://www.jsonrpc.org/specification Remote Proceedure Call (RPC) is a protocol for executing subroutines on a remote
func NewJSONError ¶
NewJSONError returns a new JSONError struct filled with the inputs
type MerkleNode ¶
type MerkleNode struct { Left *Hash `json:"left,omitempty"` Right *Hash `json:"right,omitempty"` Top *Hash `json:"top,omitempty"` }
func BuildMerkleBranch ¶
func BuildMerkleBranch(hashes []interfaces.IHash, entryIndex int, fullDetail bool) []*MerkleNode
func BuildMerkleBranchForHash ¶
func BuildMerkleBranchForHash(hashes []interfaces.IHash, target interfaces.IHash, fullDetail bool) []*MerkleNode
type PrivateKey ¶
type PrivateKey struct { Key *[ed25519.PrivateKeySize]byte Pub *PublicKey }
PrivateKey contains Public/Private key pair
func NewPrivateKeyFromHex ¶
func NewPrivateKeyFromHex(s string) (*PrivateKey, error)
NewPrivateKeyFromHex creates a new private key from a hex string
func NewPrivateKeyFromHexBytes ¶
func NewPrivateKeyFromHexBytes(privKeybytes []byte) *PrivateKey
NewPrivateKeyFromHexBytes creates a new private key from hex []byte
func RandomPrivateKey ¶
func RandomPrivateKey() *PrivateKey
RandomPrivateKey returns a new random private key
func (*PrivateKey) CustomMarshalText2 ¶
func (pk *PrivateKey) CustomMarshalText2(string) ([]byte, error)
CustomMarshalText2 is a badly named function which encodes the private key to a string and concatenates with the public key to return single string with both private and public keys - suggest renaming: MarshalPrivateAndPublicKeys
func (*PrivateKey) GenerateKey ¶
func (pk *PrivateKey) GenerateKey() error
GenerateKey creates new PrivateKey / PublicKey pair or returns error
func (*PrivateKey) Init ¶
func (pk *PrivateKey) Init()
Init initializes the internal Key/Pub pair to new []byte if previously nil
func (*PrivateKey) MarshalSign ¶
func (pk *PrivateKey) MarshalSign(msg interfaces.BinaryMarshallable) (sig interfaces.IFullSignature)
MarshalSign marshals and signs msg with PrivateKey and return Signature
func (*PrivateKey) PrivateKeyString ¶
func (pk *PrivateKey) PrivateKeyString() string
PrivateKeyString returns hex-encoded string of first 32 bytes of key (private key portion)
func (*PrivateKey) Public ¶
func (pk *PrivateKey) Public() []byte
Public returns the public key of PrivateKey struct
func (*PrivateKey) PublicKeyString ¶
func (pk *PrivateKey) PublicKeyString() string
PublicKeyString returns string of the public key
func (*PrivateKey) Sign ¶
func (pk *PrivateKey) Sign(msg []byte) (sig interfaces.IFullSignature)
Sign signs msg with PrivateKey and return Signature
type PublicKey ¶
type PublicKey [ed25519.PublicKeySize]byte
PublicKey contains only Public part of Public/Private key pair
func PubKeyFromString ¶
PubKeyFromString decodes an input string into a public key
func (PublicKey) Fixed ¶
func (k PublicKey) Fixed() [ed25519.PublicKeySize]byte
Fixed returns itself
func (*PublicKey) MarshalBinary ¶
MarshalBinary marshals and returns a new []byte containing the PublicKey k
func (*PublicKey) MarshalText ¶
MarshalText marshals the public key into a []byte
func (*PublicKey) UnmarshalBinary ¶
UnmarshalBinary unmarshals the input p into the public key k
func (*PublicKey) UnmarshalBinaryData ¶
UnmarshalBinaryData unmarshals the first section of input p of the size of a public key, and returns the residual data p
func (*PublicKey) UnmarshalText ¶
UnmarshalText decodes the input []byte public key into 'k'
type Signature ¶
type Signature struct { Pub *PublicKey `json:"pub"` Sig *ByteSliceSig `json:"sig"` }
type DetachedSignature [ed25519.SignatureSize]byte type DetachedPublicKey [ed25519.PublicKeySize]byte
Signature has signed data and its corresponding PublicKey
func (*Signature) CustomMarshalText ¶
func (*Signature) GetPubBytes ¶
func (*Signature) GetSigBytes ¶
func (*Signature) GetSignature ¶
func (sig *Signature) GetSignature() *[ed25519.SignatureSize]byte
func (*Signature) IsSameAs ¶
func (a *Signature) IsSameAs(b interfaces.IFullSignature) bool
func (*Signature) MarshalBinary ¶
func (*Signature) SetSignature ¶
func (*Signature) UnmarshalBinary ¶
func (*Signature) UnmarshalBinaryData ¶
type Timestamp ¶
type Timestamp uint64 //in miliseconds
A structure for handling timestamps for messages
func NewTimestampFromMinutes ¶
func NewTimestampFromSeconds ¶
func NewTimestampNow ¶
func NewTimestampNow() *Timestamp
func (Timestamp) Clone ¶
func (t Timestamp) Clone() interfaces.Timestamp
Clone() Functions that return timestamps in structures should clone said timestamps so users don't change the timestamp in the structures.
func (*Timestamp) GetTimeMilli ¶
func (*Timestamp) GetTimeMilliUInt64 ¶
func (*Timestamp) GetTimeMinutesUInt32 ¶
func (*Timestamp) GetTimeSeconds ¶
func (*Timestamp) GetTimeSecondsUInt32 ¶
func (*Timestamp) MarshalBinary ¶
func (*Timestamp) SetTimeMilli ¶
func (*Timestamp) SetTimeNow ¶
func (t *Timestamp) SetTimeNow()
func (*Timestamp) SetTimeSeconds ¶
func (*Timestamp) SetTimestamp ¶
func (t *Timestamp) SetTimestamp(b interfaces.Timestamp)