common

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2016 License: MIT Imports: 26 Imported by: 21

Documentation

Index

Constants

View Source
const (

	//Entry Credit Blocks (For now, everyone gets the same cap)
	EC_CAP = 5      //Number of ECBlocks we start with.
	AB_CAP = EC_CAP //Administrative Block Cap for AB messages

	//Limits and Sizes
	MAX_ENTRY_SIZE    = uint16(10240) //Maximum size for Entry External IDs and the Data
	HASH_LENGTH       = int(32)       //Length of a Hash
	SIG_LENGTH        = int(64)       //Length of a signature
	MAX_ORPHAN_SIZE   = int(5000)     //Prphan mem pool size
	MAX_TX_POOL_SIZE  = int(50000)    //Transaction mem pool size
	MAX_BLK_POOL_SIZE = int(500000)   //Block mem bool size
	MAX_PLIST_SIZE    = int(150000)   //MY Process List size

	MAX_ENTRY_CREDITS = uint8(10) //Max number of entry credits per entry
	MAX_CHAIN_CREDITS = uint8(20) //Max number of entry credits per chain

	COMMIT_TIME_WINDOW = time.Duration(12) //Time windows for commit chain and commit entry +/- 12 hours

	// maxProtocolVersion is the max protocol version the peer supports.
	//Common constants
	VERSION_0       = byte(0)
	FACTOMD_VERSION = 3005               //fixed point. resolves to 0.<thousands place>.<rightmost digits>
	NETWORK_ID_DB   = uint32(4203931041) //0xFA92E5A1
	NETWORK_ID_EB   = uint32(4203931042) //0xFA92E5A2
	NETWORK_ID_CB   = uint32(4203931043) //0xFA92E5A3

	//For Factom TestNet
	NETWORK_ID_TEST = uint32(0) //0x0

	//Server running mode
	FULL_NODE   = "FULL"
	SERVER_NODE = "SERVER"
	LIGHT_NODE  = "LIGHT"

	//Server public key for milestone 1
	SERVER_PUB_KEY = "0426a802617848d4d16d87830fc521f4d136bb2d0c352850919c2679f189613a"
	//Genesis directory block timestamp in RFC3339 format
	GENESIS_BLK_TIMESTAMP = "2015-09-01T20:00:00+00:00"
	//Genesis directory block hash
	GENESIS_DIR_BLOCK_HASH = "cbd3d09db6defdc25dfc7d57f3479b339a077183cd67022e6d1ef6c041522b40"
)
View Source
const (
	TYPE_MINUTE_NUM uint8 = iota
	TYPE_DB_SIGNATURE
	TYPE_REVEAL_MATRYOSHKA
	TYPE_ADD_MATRYOSHKA
	TYPE_ADD_SERVER_COUNT
	TYPE_ADD_FED_SERVER
	TYPE_REMOVE_FED_SERVER
	TYPE_ADD_FED_SERVER_KEY
	TYPE_ADD_BTC_ANCHOR_KEY //8
)

--------------------------------------------------------------- Types of entries (transactions) for Admin Block https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#adminid-bytes ---------------------------------------------------------------

View Source
const (
	ECIDServerIndexNumber byte = iota
	ECIDMinuteNumber
	ECIDChainCommit
	ECIDEntryCommit
	ECIDBalanceIncrease
)
View Source
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
	ErrorVerifySignature       = 22
)
View Source
const (
	// CommitChainSize = 1+6+32+32+32+1+32+64
	CommitChainSize int = 200
)
View Source
const (
	// CommitEntrySize = 1 + 6 + 32 + 1 + 32 + 64
	CommitEntrySize int = 136
)
View Source
const DBlockVersion = 0
View Source
const (
	EBHeaderSize = 140 // 32+32+32+32+4+4+4
)
View Source
const (
	MinuteNumberSize = 1
)
View Source
const (
	ServerIndexNumberSize = 1
)

Variables

View Source
var ADMIN_CHAINID = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0a}

Directory Chain

View Source
var D_CHAINID = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0d}

Directory Chain

View Source
var EC_CHAINID = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0c}

Chain Values. Not exactly constants, but nice to have. Entry Credit Chain

View Source
var FACTOID_CHAINID = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0f}

Factoid chain

View Source
var FactoidState state.IFactoidState
View Source
var M = struct{ Main, Alt gocoding.Marshaller }{
	json.NewMarshaller(),
	json.NewMarshaller(),
}
View Source
var ZERO_HASH = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Functions

func AltBlockEncoder

func AltBlockEncoder(scratch [64]byte, r gocoding.Renderer, v reflect.Value)

func DecodeBinary

func DecodeBinary(bytes *string) ([]byte, error)

func DecodeJSON

func DecodeJSON(data []byte, v interface{}) error

func DecodeJSONString

func DecodeJSONString(data string, v interface{}) error

func DecodeVarInt

func DecodeVarInt(data []byte) (uint64, []byte)

Decode a varaible integer from the given data buffer. We use the algorithm used by Go, only BigEndian.

func DoubleSha

func DoubleSha(data []byte) []byte

shad Double Sha256 Hash; sha256(sha256(data))

func EncodeBinary

func EncodeBinary(bytes *[]byte) string

func EncodeJSON

func EncodeJSON(data interface{}) ([]byte, error)

func EncodeJSONString

func EncodeJSONString(data interface{}) (string, error)

func EncodeJSONToBuffer

func EncodeJSONToBuffer(data interface{}, b *bytes.Buffer) error

func EncodeVarInt

func EncodeVarInt(out *bytes.Buffer, v uint64) error

Encode an integer as a variable int into the given data buffer.

func NewDecoding

func NewDecoding(decoding gocoding.Decoding) gocoding.Decoding

func NewJSONUnmarshaller

func NewJSONUnmarshaller() gocoding.Unmarshaller

func NewUnmarshaller

func NewUnmarshaller(decoding gocoding.Decoding) gocoding.Unmarshaller

func Spew

func Spew(data interface{}) string

func StartDynamic

func StartDynamic(path string, readEH func(err error)) error

func StartStatic

func StartStatic(path string) (err error)

func UnmarshalJSON

func UnmarshalJSON(reader gocoding.SliceableRuneReader, obj interface{}) error

func VarIntLength

func VarIntLength(v uint64) uint64

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 VerifySlice

func VerifySlice(p []byte, message []byte, s []byte) bool

Verify returns true iff sig is a valid signature of message by publicKey.

Types

type ABEntry

type ABEntry interface {
	Printable
	BinaryMarshallable
	ShortInterpretable

	Type() byte
	Hash() *Hash
}

Generic admin block entry type

type ABlockHeader

type ABlockHeader struct {
	AdminChainID    *Hash
	PrevLedgerKeyMR *Hash
	DBHeight        uint32

	HeaderExpansionSize uint64
	HeaderExpansionArea []byte

	MessageCount uint32
	BodySize     uint32
}

Admin Block Header

func (*ABlockHeader) JSONBuffer

func (e *ABlockHeader) JSONBuffer(b *bytes.Buffer) error

func (*ABlockHeader) JSONByte

func (e *ABlockHeader) JSONByte() ([]byte, error)

func (*ABlockHeader) JSONString

func (e *ABlockHeader) JSONString() (string, error)

func (*ABlockHeader) MarshalBinary

func (b *ABlockHeader) MarshalBinary() (data []byte, err error)

Write out the ABlockHeader to binary.

func (*ABlockHeader) MarshalledSize

func (b *ABlockHeader) MarshalledSize() uint64

func (*ABlockHeader) Spew

func (e *ABlockHeader) Spew() string

func (*ABlockHeader) UnmarshalBinary

func (b *ABlockHeader) UnmarshalBinary(data []byte) (err error)

Read in the binary into the ABlockHeader.

func (*ABlockHeader) UnmarshalBinaryData

func (b *ABlockHeader) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type AdminBlock

type AdminBlock struct {
	//Marshalized
	Header    *ABlockHeader
	ABEntries []ABEntry //Interface
	// contains filtered or unexported fields
}

Administrative Block This is a special block which accompanies this Directory Block. It contains the signatures and organizational data needed to validate previous and future Directory Blocks. This block is included in the DB body. It appears there with a pair of the Admin AdminChainID:SHA256 of the block. For more details, please go to: https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#administrative-block

func CreateAdminBlock

func CreateAdminBlock(chain *AdminChain, prev *AdminBlock, cap uint) (b *AdminBlock, err error)

Create an empty Admin Block

func (*AdminBlock) AddABEntry

func (b *AdminBlock) AddABEntry(e ABEntry) (err error)

Add an Admin Block entry to the block

func (*AdminBlock) AddEndOfMinuteMarker

func (b *AdminBlock) AddEndOfMinuteMarker(eomType byte) (err error)

Add the end-of-minute marker into the admin block

func (*AdminBlock) GetDBSignature

func (b *AdminBlock) GetDBSignature() ABEntry

Read in the binary into the Admin block.

func (*AdminBlock) JSONBuffer

func (e *AdminBlock) JSONBuffer(b *bytes.Buffer) error

func (*AdminBlock) JSONByte

func (e *AdminBlock) JSONByte() ([]byte, error)

func (*AdminBlock) JSONString

func (e *AdminBlock) JSONString() (string, error)

func (*AdminBlock) LedgerKeyMR

func (ab *AdminBlock) LedgerKeyMR() (*Hash, error)

func (*AdminBlock) MarshalBinary

func (b *AdminBlock) MarshalBinary() (data []byte, err error)

Write out the AdminBlock to binary.

func (*AdminBlock) MarshalledSize

func (b *AdminBlock) MarshalledSize() uint64

Admin Block size

func (*AdminBlock) PartialHash

func (ab *AdminBlock) PartialHash() (*Hash, error)

func (*AdminBlock) Spew

func (e *AdminBlock) Spew() string

func (*AdminBlock) UnmarshalBinary

func (b *AdminBlock) UnmarshalBinary(data []byte) (err error)

Read in the binary into the Admin block.

func (*AdminBlock) UnmarshalBinaryData

func (b *AdminBlock) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type AdminChain

type AdminChain struct {
	ChainID *Hash
	Name    [][]byte

	NextBlock       *AdminBlock
	NextBlockHeight uint32
	BlockMutex      sync.Mutex
}

Administrative Chain

type BinaryMarshallable

type BinaryMarshallable interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	UnmarshalBinaryData([]byte) ([]byte, error)
	MarshalledSize() uint64
}

type ByteArray

type ByteArray []byte

func NewByteArray

func NewByteArray(newHash []byte) (*ByteArray, error)

func (ByteArray) Bytes

func (ba ByteArray) Bytes() []byte

func (ByteArray) MarshalBinary

func (ba ByteArray) MarshalBinary() ([]byte, error)

func (ByteArray) MarshalledSize

func (ba ByteArray) MarshalledSize() uint64

func (ByteArray) SetBytes

func (ba ByteArray) SetBytes(newArray []byte) error

func (ByteArray) UnmarshalBinary

func (ba ByteArray) UnmarshalBinary(data []byte) (err error)

func (ByteArray) UnmarshalBinaryData

func (ba ByteArray) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type CommitChain

type CommitChain struct {
	Version     uint8
	MilliTime   *[6]byte
	ChainIDHash *Hash
	Weld        *Hash
	EntryHash   *Hash
	Credits     uint8
	ECPubKey    *[32]byte
	Sig         *[64]byte
}

func NewCommitChain

func NewCommitChain() *CommitChain

func (*CommitChain) CommitMsg

func (c *CommitChain) CommitMsg() []byte

CommitMsg returns the binary marshaled message section of the CommitEntry that is covered by the CommitEntry.Sig.

func (*CommitChain) ECID

func (c *CommitChain) ECID() byte

func (*CommitChain) GetHash

func (c *CommitChain) GetHash() *Hash

func (*CommitChain) GetMilliTime

func (c *CommitChain) GetMilliTime() int64

Return the timestamp in milliseconds.

func (*CommitChain) GetSigHash

func (c *CommitChain) GetSigHash() *Hash

func (*CommitChain) Hash

func (e *CommitChain) Hash() *Hash

func (*CommitChain) InTime

func (c *CommitChain) InTime() bool

InTime checks the CommitEntry.MilliTime and returns true if the timestamp is whitin +/- 12 hours of the current time. TODO

func (*CommitChain) Interpret

func (b *CommitChain) Interpret() string

func (*CommitChain) IsInterpretable

func (b *CommitChain) IsInterpretable() bool

func (*CommitChain) IsValid

func (c *CommitChain) IsValid() bool

func (*CommitChain) JSONBuffer

func (e *CommitChain) JSONBuffer(b *bytes.Buffer) error

func (*CommitChain) JSONByte

func (e *CommitChain) JSONByte() ([]byte, error)

func (*CommitChain) JSONString

func (e *CommitChain) JSONString() (string, error)

func (*CommitChain) MarshalBinary

func (c *CommitChain) MarshalBinary() ([]byte, error)

func (*CommitChain) MarshalledSize

func (c *CommitChain) MarshalledSize() uint64

func (*CommitChain) Spew

func (e *CommitChain) Spew() string

func (*CommitChain) UnmarshalBinary

func (c *CommitChain) UnmarshalBinary(data []byte) (err error)

func (*CommitChain) UnmarshalBinaryData

func (c *CommitChain) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type CommitEntry

type CommitEntry struct {
	Version   uint8
	MilliTime *[6]byte
	EntryHash *Hash
	Credits   uint8
	ECPubKey  *[32]byte
	Sig       *[64]byte
}

func NewCommitEntry

func NewCommitEntry() *CommitEntry

func (*CommitEntry) CommitMsg

func (c *CommitEntry) CommitMsg() []byte

CommitMsg returns the binary marshaled message section of the CommitEntry that is covered by the CommitEntry.Sig.

func (*CommitEntry) ECID

func (c *CommitEntry) ECID() byte

func (*CommitEntry) GetHash

func (c *CommitEntry) GetHash() *Hash

func (*CommitEntry) GetMilliTime

func (c *CommitEntry) GetMilliTime() int64

Return the timestamp in milliseconds.

func (*CommitEntry) GetSigHash

func (c *CommitEntry) GetSigHash() *Hash

func (*CommitEntry) Hash

func (e *CommitEntry) Hash() *Hash

func (*CommitEntry) InTime

func (c *CommitEntry) InTime() bool

InTime checks the CommitEntry.MilliTime and returns true if the timestamp is whitin +/- 12 hours of the current time.

func (*CommitEntry) Interpret

func (b *CommitEntry) Interpret() string

func (*CommitEntry) IsInterpretable

func (b *CommitEntry) IsInterpretable() bool

func (*CommitEntry) IsValid

func (c *CommitEntry) IsValid() bool

func (*CommitEntry) JSONBuffer

func (e *CommitEntry) JSONBuffer(b *bytes.Buffer) error

func (*CommitEntry) JSONByte

func (e *CommitEntry) JSONByte() ([]byte, error)

func (*CommitEntry) JSONString

func (e *CommitEntry) JSONString() (string, error)

func (*CommitEntry) MarshalBinary

func (c *CommitEntry) MarshalBinary() ([]byte, error)

func (*CommitEntry) MarshalledSize

func (c *CommitEntry) MarshalledSize() uint64

func (*CommitEntry) Spew

func (e *CommitEntry) Spew() string

func (*CommitEntry) UnmarshalBinary

func (c *CommitEntry) UnmarshalBinary(data []byte) (err error)

func (*CommitEntry) UnmarshalBinaryData

func (c *CommitEntry) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type DBEntry

type DBEntry struct {
	ChainID *Hash
	KeyMR   *Hash // Different MR in EBlockHeader
}

func NewDBEntry

func NewDBEntry(eb *EBlock) (*DBEntry, error)

func NewDBEntryFromABlock

func NewDBEntryFromABlock(b *AdminBlock) *DBEntry

func NewDBEntryFromECBlock

func NewDBEntryFromECBlock(cb *ECBlock) (*DBEntry, error)

func (*DBEntry) JSONBuffer

func (e *DBEntry) JSONBuffer(b *bytes.Buffer) error

func (*DBEntry) JSONByte

func (e *DBEntry) JSONByte() ([]byte, error)

func (*DBEntry) JSONString

func (e *DBEntry) JSONString() (string, error)

func (*DBEntry) MarshalBinary

func (e *DBEntry) MarshalBinary() (data []byte, err error)

func (*DBEntry) MarshalledSize

func (c *DBEntry) MarshalledSize() uint64

func (*DBEntry) ShaHash

func (e *DBEntry) ShaHash() *Hash

func (*DBEntry) Spew

func (e *DBEntry) Spew() string

func (*DBEntry) UnmarshalBinary

func (e *DBEntry) UnmarshalBinary(data []byte) (err error)

func (*DBEntry) UnmarshalBinaryData

func (e *DBEntry) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type DBSignatureEntry

type DBSignatureEntry struct {
	IdentityAdminChainID *Hash
	PubKey               PublicKey
	PrevDBSig            *Sig
	// contains filtered or unexported fields
}

DB Signature Entry -------------------------

func NewDBSignatureEntry

func NewDBSignatureEntry(identityAdminChainID *Hash, sig Signature) (e *DBSignatureEntry)

Create a new DB Signature Entry

func (*DBSignatureEntry) Hash

func (e *DBSignatureEntry) Hash() *Hash

func (*DBSignatureEntry) Interpret

func (e *DBSignatureEntry) Interpret() string

func (*DBSignatureEntry) IsInterpretable

func (e *DBSignatureEntry) IsInterpretable() bool

func (*DBSignatureEntry) JSONBuffer

func (e *DBSignatureEntry) JSONBuffer(b *bytes.Buffer) error

func (*DBSignatureEntry) JSONByte

func (e *DBSignatureEntry) JSONByte() ([]byte, error)

func (*DBSignatureEntry) JSONString

func (e *DBSignatureEntry) JSONString() (string, error)

func (*DBSignatureEntry) MarshalBinary

func (e *DBSignatureEntry) MarshalBinary() (data []byte, err error)

func (*DBSignatureEntry) MarshalledSize

func (e *DBSignatureEntry) MarshalledSize() uint64

func (*DBSignatureEntry) Spew

func (e *DBSignatureEntry) Spew() string

func (*DBSignatureEntry) Type

func (e *DBSignatureEntry) Type() byte

func (*DBSignatureEntry) UnmarshalBinary

func (e *DBSignatureEntry) UnmarshalBinary(data []byte) (err error)

func (*DBSignatureEntry) UnmarshalBinaryData

func (e *DBSignatureEntry) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type DBlockHeader

type DBlockHeader struct {
	Version   byte
	NetworkID uint32

	BodyMR          *Hash
	PrevKeyMR       *Hash
	PrevLedgerKeyMR *Hash

	Timestamp  uint32
	DBHeight   uint32
	BlockCount uint32
}

func NewDBlockHeader

func NewDBlockHeader() *DBlockHeader

func (*DBlockHeader) EncodableFields

func (b *DBlockHeader) EncodableFields() map[string]reflect.Value

func (*DBlockHeader) JSONBuffer

func (e *DBlockHeader) JSONBuffer(b *bytes.Buffer) error

func (*DBlockHeader) JSONByte

func (e *DBlockHeader) JSONByte() ([]byte, error)

func (*DBlockHeader) JSONString

func (e *DBlockHeader) JSONString() (string, error)

func (*DBlockHeader) MarshalBinary

func (b *DBlockHeader) MarshalBinary() (data []byte, err error)

func (*DBlockHeader) MarshalledSize

func (b *DBlockHeader) MarshalledSize() uint64

func (*DBlockHeader) Spew

func (e *DBlockHeader) Spew() string

func (*DBlockHeader) UnmarshalBinary

func (b *DBlockHeader) UnmarshalBinary(data []byte) (err error)

func (*DBlockHeader) UnmarshalBinaryData

func (b *DBlockHeader) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type DChain

type DChain struct {
	ChainID      *Hash
	Blocks       []*DirectoryBlock
	BlockMutex   sync.Mutex
	NextBlock    *DirectoryBlock
	NextDBHeight uint32
	IsValidated  bool
}

func NewDChain

func NewDChain() *DChain

func (*DChain) AddABlockToDBEntry

func (c *DChain) AddABlockToDBEntry(b *AdminBlock) (err error)

Add DBEntry from an Admin Block

func (*DChain) AddDBEntry

func (c *DChain) AddDBEntry(dbEntry *DBEntry) (err error)

Add DBEntry

func (*DChain) AddDBlockToDChain

func (c *DChain) AddDBlockToDChain(b *DirectoryBlock) (err error)

// Add DBEntry from a Factoid Block func (c *DChain) AddFBlockMRToDBEntry(dbEntry *DBEntry) (err error) {

	fmt.Println("AddFDBlock >>>>>")

	if len(c.NextBlock.DBEntries) < 3 {
		panic("4 DBEntries not initialized properly for block: " + string(c.NextDBHeight))
	}
	c.BlockMutex.Lock()
	// Factoid entry is alwasy at the same position
	// First three entries are ABlock, CBlock, FBlock
	//c.NextBlock.DBEntries[2] = dbEntry
	c.BlockMutex.Unlock()

	return nil
}

Add DBlock to the chain in memory

func (*DChain) AddEBlockToDBEntry

func (c *DChain) AddEBlockToDBEntry(eb *EBlock) (err error)

Add DBEntry from an Entry Block

func (*DChain) AddECBlockToDBEntry

func (c *DChain) AddECBlockToDBEntry(ecb *ECBlock) (err error)

Add DBEntry from an Entry Credit Block

func (*DChain) AddFBlockToDBEntry

func (c *DChain) AddFBlockToDBEntry(b block.IFBlock) (err error)

Add DBEntry from an SC Block

func (*DChain) IsBlockExisting

func (c *DChain) IsBlockExisting(height uint32) bool

Check if the block with the input block height is existing in chain

type DetachedPublicKey

type DetachedPublicKey [ed25519.PublicKeySize]byte

type DetachedSignature

type DetachedSignature [ed25519.SignatureSize]byte

func (*DetachedSignature) String

func (ds *DetachedSignature) String() string

type DirBlockInfo

type DirBlockInfo struct {
	// Serial hash for the directory block
	DBHash *Hash

	DBHeight uint32 //directory block height

	Timestamp int64 // time of this dir block info being created

	// BTCTxHash is the Tx hash returned from rpcclient.SendRawTransaction
	BTCTxHash *Hash // use string or *btcwire.ShaHash ???

	// BTCTxOffset is the index of the TX in this BTC block
	BTCTxOffset int32

	// BTCBlockHeight is the height of the block where this TX is stored in BTC
	BTCBlockHeight int32

	//BTCBlockHash is the hash of the block where this TX is stored in BTC
	BTCBlockHash *Hash // use string or *btcwire.ShaHash ???

	// DBMerkleRoot is the merkle root of the Directory Block
	// and is written into BTC as OP_RETURN data
	DBMerkleRoot *Hash

	// A flag to to show BTC anchor confirmation
	BTCConfirmed bool
}

func NewDirBlockInfoFromDBlock

func NewDirBlockInfoFromDBlock(b *DirectoryBlock) *DirBlockInfo

func (*DirBlockInfo) JSONBuffer

func (e *DirBlockInfo) JSONBuffer(b *bytes.Buffer) error

func (*DirBlockInfo) JSONByte

func (e *DirBlockInfo) JSONByte() ([]byte, error)

func (*DirBlockInfo) JSONString

func (e *DirBlockInfo) JSONString() (string, error)

func (*DirBlockInfo) MarshalBinary

func (b *DirBlockInfo) MarshalBinary() (data []byte, err error)

func (*DirBlockInfo) Spew

func (e *DirBlockInfo) Spew() string

func (*DirBlockInfo) UnmarshalBinary

func (b *DirBlockInfo) UnmarshalBinary(data []byte) (err error)

func (*DirBlockInfo) UnmarshalBinaryData

func (b *DirBlockInfo) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type DirectoryBlock

type DirectoryBlock struct {
	//Marshalized
	Header    *DBlockHeader
	DBEntries []*DBEntry

	//Not Marshalized
	Chain       *DChain
	IsSealed    bool
	DBHash      *Hash
	KeyMR       *Hash
	IsSavedInDB bool
	IsValidated bool
}

func CreateDBlock

func CreateDBlock(chain *DChain, prev *DirectoryBlock, cap uint) (b *DirectoryBlock, err error)

func NewDBlock

func NewDBlock() *DirectoryBlock

func NewDirectoryBlock

func NewDirectoryBlock() *DirectoryBlock

func (*DirectoryBlock) BuildBodyMR

func (b *DirectoryBlock) BuildBodyMR() (mr *Hash, err error)

func (*DirectoryBlock) BuildKeyMerkleRoot

func (b *DirectoryBlock) BuildKeyMerkleRoot() (err error)

func (*DirectoryBlock) EncodableFields

func (b *DirectoryBlock) EncodableFields() map[string]reflect.Value

func (*DirectoryBlock) JSONBuffer

func (e *DirectoryBlock) JSONBuffer(b *bytes.Buffer) error

func (*DirectoryBlock) JSONByte

func (e *DirectoryBlock) JSONByte() ([]byte, error)

func (*DirectoryBlock) JSONString

func (e *DirectoryBlock) JSONString() (string, error)

func (*DirectoryBlock) MarshalBinary

func (b *DirectoryBlock) MarshalBinary() (data []byte, err error)

func (*DirectoryBlock) MarshalledSize

func (c *DirectoryBlock) MarshalledSize() uint64

func (*DirectoryBlock) Spew

func (e *DirectoryBlock) Spew() string

func (*DirectoryBlock) UnmarshalBinary

func (b *DirectoryBlock) UnmarshalBinary(data []byte) (err error)

func (*DirectoryBlock) UnmarshalBinaryData

func (b *DirectoryBlock) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type EBlock

type EBlock struct {
	Header *EBlockHeader
	Body   *EBlockBody
}

EBlock is the Entry Block. It holds the hashes of the Entries and its Merkel Root is written into the Directory Blocks. Each Entry Block represents all of the entries for a paticular Chain during a 10 minute period.

func MakeEBlock

func MakeEBlock(echain *EChain, prev *EBlock) (*EBlock, error)

MakeEBlock creates a new Entry Block belonging to the provieded Entry Chain. Its PrevKeyMR and PrevLedgerKeyMR are populated by the provided previous Entry Block. If The previous Entry Block is nil (the new Entry Block is first in the Chain) the relevent Entry Block Header fields will contain zeroed Hashes.

func NewEBlock

func NewEBlock() *EBlock

NewEBlock returns a blank initialized Entry Block with all of its fields zeroed.

func (*EBlock) AddEBEntry

func (e *EBlock) AddEBEntry(entry *Entry) error

AddEBEntry creates a new Entry Block Entry from the provided Factom Entry and adds it to the Entry Block Body.

func (*EBlock) AddEndOfMinuteMarker

func (e *EBlock) AddEndOfMinuteMarker(m byte)

AddEndOfMinuteMarker adds the End of Minute to the Entry Block. The End of Minut byte becomes the last byte in a 32 byte slice that is added to the Entry Block Body as an Entry Block Entry.

func (*EBlock) BuildHeader

func (e *EBlock) BuildHeader() error

BuildHeader updates the Entry Block Header to include information about the Entry Block Body. BuildHeader should be run after the Entry Block Body has included all of its EntryEntries.

func (*EBlock) Hash

func (e *EBlock) Hash() (*Hash, error)

Hash returns the simple Sha256 hash of the serialized Entry Block. Hash is used to provide the PrevLedgerKeyMR to the next Entry Block in a Chain.

func (*EBlock) JSONBuffer

func (e *EBlock) JSONBuffer(b *bytes.Buffer) error

func (*EBlock) JSONByte

func (e *EBlock) JSONByte() ([]byte, error)

func (*EBlock) JSONString

func (e *EBlock) JSONString() (string, error)

func (*EBlock) KeyMR

func (e *EBlock) KeyMR() (*Hash, error)

KeyMR returns the hash of the hash of the Entry Block Header concatinated with the Merkle Root of the Entry Block Body. The Body Merkle Root is calculated by the func (e *EBlockBody) MR() which is called by the func (e *EBlock) BuildHeader().

func (*EBlock) MarshalBinary

func (e *EBlock) MarshalBinary() ([]byte, error)

MarshalBinary returns the serialized binary form of the Entry Block.

func (*EBlock) MarshalledSize

func (c *EBlock) MarshalledSize() uint64

func (*EBlock) Spew

func (e *EBlock) Spew() string

func (*EBlock) UnmarshalBinary

func (e *EBlock) UnmarshalBinary(data []byte) (err error)

func (*EBlock) UnmarshalBinaryData

func (e *EBlock) UnmarshalBinaryData(data []byte) (newData []byte, err error)

UnmarshalBinary populates the Entry Block object from the serialized binary data.

type EBlockBody

type EBlockBody struct {
	EBEntries []*Hash
}

EBlockBody is the series of Hashes that form the Entry Block Body.

func NewEBlockBody

func NewEBlockBody() *EBlockBody

NewEBlockBody initalizes an empty Entry Block Body.

func (*EBlockBody) JSONBuffer

func (e *EBlockBody) JSONBuffer(b *bytes.Buffer) error

func (*EBlockBody) JSONByte

func (e *EBlockBody) JSONByte() ([]byte, error)

func (*EBlockBody) JSONString

func (e *EBlockBody) JSONString() (string, error)

func (*EBlockBody) MR

func (e *EBlockBody) MR() *Hash

MR calculates the Merkle Root of the Entry Block Body. See func BuildMerkleTreeStore(hashes []*Hash) (merkles []*Hash) in common/merkle.go.

func (*EBlockBody) Spew

func (e *EBlockBody) Spew() string

type EBlockHeader

type EBlockHeader struct {
	ChainID         *Hash
	BodyMR          *Hash
	PrevKeyMR       *Hash
	PrevLedgerKeyMR *Hash
	EBSequence      uint32
	DBHeight        uint32
	EntryCount      uint32
}

EBlockHeader holds relevent metadata about the Entry Block and the data nessisary to verify the previous block in the Entry Block Chain.

func NewEBlockHeader

func NewEBlockHeader() *EBlockHeader

NewEBlockHeader initializes a new empty Entry Block Header.

func (*EBlockHeader) JSONBuffer

func (e *EBlockHeader) JSONBuffer(b *bytes.Buffer) error

func (*EBlockHeader) JSONByte

func (e *EBlockHeader) JSONByte() ([]byte, error)

func (*EBlockHeader) JSONString

func (e *EBlockHeader) JSONString() (string, error)

func (*EBlockHeader) Spew

func (e *EBlockHeader) Spew() string

type ECBlock

type ECBlock struct {
	Header *ECBlockHeader
	Body   *ECBlockBody
}

The Entry Credit Block consists of a header and a body. The body is composed of primarily Commits and Balance Increases with Minute Markers and Server Markers distributed throughout.

func NewECBlock

func NewECBlock() *ECBlock

func NextECBlock

func NextECBlock(prev *ECBlock) (*ECBlock, error)

func (*ECBlock) AddEntry

func (e *ECBlock) AddEntry(entries ...ECBlockEntry)

func (*ECBlock) BuildHeader

func (e *ECBlock) BuildHeader() error

func (*ECBlock) Hash

func (e *ECBlock) Hash() (*Hash, error)

func (*ECBlock) HeaderHash

func (e *ECBlock) HeaderHash() (*Hash, error)

func (*ECBlock) JSONBuffer

func (e *ECBlock) JSONBuffer(b *bytes.Buffer) error

func (*ECBlock) JSONByte

func (e *ECBlock) JSONByte() ([]byte, error)

func (*ECBlock) JSONString

func (e *ECBlock) JSONString() (string, error)

func (*ECBlock) MarshalBinary

func (e *ECBlock) MarshalBinary() ([]byte, error)

func (*ECBlock) MarshalledSize

func (c *ECBlock) MarshalledSize() uint64

func (*ECBlock) Spew

func (e *ECBlock) Spew() string

func (*ECBlock) UnmarshalBinary

func (e *ECBlock) UnmarshalBinary(data []byte) (err error)

func (*ECBlock) UnmarshalBinaryData

func (e *ECBlock) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type ECBlockBody

type ECBlockBody struct {
	Entries []ECBlockEntry
}

func NewECBlockBody

func NewECBlockBody() *ECBlockBody

func (*ECBlockBody) JSONBuffer

func (e *ECBlockBody) JSONBuffer(b *bytes.Buffer) error

func (*ECBlockBody) JSONByte

func (e *ECBlockBody) JSONByte() ([]byte, error)

func (*ECBlockBody) JSONString

func (e *ECBlockBody) JSONString() (string, error)

func (*ECBlockBody) Spew

func (e *ECBlockBody) Spew() string

type ECBlockEntry

type ECBlockEntry interface {
	Printable
	ShortInterpretable

	ECID() byte
	MarshalBinary() ([]byte, error)
	UnmarshalBinary(data []byte) error
	Hash() *Hash
}

type ECBlockHeader

type ECBlockHeader struct {
	ECChainID           *Hash
	BodyHash            *Hash
	PrevHeaderHash      *Hash
	PrevLedgerKeyMR     *Hash
	DBHeight            uint32
	HeaderExpansionArea []byte
	ObjectCount         uint64
	BodySize            uint64
}

func NewECBlockHeader

func NewECBlockHeader() *ECBlockHeader

func (*ECBlockHeader) JSONBuffer

func (e *ECBlockHeader) JSONBuffer(b *bytes.Buffer) error

func (*ECBlockHeader) JSONByte

func (e *ECBlockHeader) JSONByte() ([]byte, error)

func (*ECBlockHeader) JSONString

func (e *ECBlockHeader) JSONString() (string, error)

func (*ECBlockHeader) Spew

func (e *ECBlockHeader) Spew() string

type ECChain

type ECChain struct {
	ChainID         *Hash
	Name            [][]byte
	NextBlock       *ECBlock
	NextBlockHeight uint32
	BlockMutex      sync.Mutex
}

func NewECChain

func NewECChain() *ECChain

func (*ECChain) MarshalBinary

func (c *ECChain) MarshalBinary() ([]byte, error)

func (*ECChain) UnmarshalBinary

func (c *ECChain) UnmarshalBinary(data []byte) error

type EChain

type EChain struct {
	ChainID         *Hash
	FirstEntry      *Entry
	NextBlock       *EBlock
	NextBlockHeight uint32
	BlockMutex      sync.Mutex
}

func NewEChain

func NewEChain() *EChain

func (*EChain) MarshalBinary

func (e *EChain) MarshalBinary() ([]byte, error)

func (*EChain) MarshalledSize

func (c *EChain) MarshalledSize() uint64

func (*EChain) UnmarshalBinary

func (e *EChain) UnmarshalBinary(data []byte) (err error)

func (*EChain) UnmarshalBinaryData

func (e *EChain) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type EndOfMinuteEntry

type EndOfMinuteEntry struct {
	EOM_Type byte
	// contains filtered or unexported fields
}

func (*EndOfMinuteEntry) Hash

func (e *EndOfMinuteEntry) Hash() *Hash

func (*EndOfMinuteEntry) Interpret

func (e *EndOfMinuteEntry) Interpret() string

func (*EndOfMinuteEntry) IsInterpretable

func (e *EndOfMinuteEntry) IsInterpretable() bool

func (*EndOfMinuteEntry) JSONBuffer

func (e *EndOfMinuteEntry) JSONBuffer(b *bytes.Buffer) error

func (*EndOfMinuteEntry) JSONByte

func (e *EndOfMinuteEntry) JSONByte() ([]byte, error)

func (*EndOfMinuteEntry) JSONString

func (e *EndOfMinuteEntry) JSONString() (string, error)

func (*EndOfMinuteEntry) MarshalBinary

func (e *EndOfMinuteEntry) MarshalBinary() (data []byte, err error)

func (*EndOfMinuteEntry) MarshalledSize

func (e *EndOfMinuteEntry) MarshalledSize() uint64

func (*EndOfMinuteEntry) Spew

func (e *EndOfMinuteEntry) Spew() string

func (*EndOfMinuteEntry) Type

func (m *EndOfMinuteEntry) Type() byte

func (*EndOfMinuteEntry) UnmarshalBinary

func (e *EndOfMinuteEntry) UnmarshalBinary(data []byte) (err error)

func (*EndOfMinuteEntry) UnmarshalBinaryData

func (e *EndOfMinuteEntry) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type Entry

type Entry struct {
	Version uint8
	ChainID *Hash
	ExtIDs  [][]byte
	Content []byte
}

An Entry is the element which carries user data https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry

func NewEntry

func NewEntry() *Entry

func (*Entry) Hash

func (e *Entry) Hash() *Hash

func (*Entry) IsValid

func (e *Entry) IsValid() bool

func (*Entry) JSONBuffer

func (e *Entry) JSONBuffer(b *bytes.Buffer) error

func (*Entry) JSONByte

func (e *Entry) JSONByte() ([]byte, error)

func (*Entry) JSONString

func (e *Entry) JSONString() (string, error)

func (*Entry) MarshalBinary

func (e *Entry) MarshalBinary() ([]byte, error)

func (*Entry) MarshalExtIDsBinary

func (e *Entry) MarshalExtIDsBinary() ([]byte, error)

MarshalExtIDsBinary marshals the ExtIDs into a []byte containing a series of 2 byte size of each ExtID followed by the ExtID.

func (*Entry) MarshalledSize

func (c *Entry) MarshalledSize() uint64

func (*Entry) Spew

func (e *Entry) Spew() string

func (*Entry) UnmarshalBinary

func (e *Entry) UnmarshalBinary(data []byte) (err error)

func (*Entry) UnmarshalBinaryData

func (e *Entry) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type Error

type Error struct {
	APICode     uint
	HTTPCode    int
	Name        string
	Description string
	SupportURL  string
	Message     string
}

func CreateError

func CreateError(code uint, message string) *Error

func Marshal

func Marshal(resource interface{}, accept string, writer io.Writer, alt bool) (r *Error)

func (*Error) Error

func (r *Error) Error() string

type FctChain

type FctChain struct {
	ChainID *Hash

	NextBlock       block.IFBlock
	NextBlockHeight uint32
	BlockMutex      sync.Mutex
}

factoid Chain

func (*FctChain) JSONBuffer

func (e *FctChain) JSONBuffer(b *bytes.Buffer) error

func (*FctChain) JSONByte

func (e *FctChain) JSONByte() ([]byte, error)

func (*FctChain) JSONString

func (e *FctChain) JSONString() (string, error)

func (*FctChain) Spew

func (e *FctChain) Spew() string

type Hash

type Hash struct {
	// contains filtered or unexported fields
}

func BuildMerkleTreeStore

func BuildMerkleTreeStore(hashes []*Hash) (merkles []*Hash)

func CreateHash

func CreateHash(entities ...BinaryMarshallable) (h *Hash, err error)

func HexToHash

func HexToHash(hexStr string) (h *Hash, err error)

func NewChainID

func NewChainID(e *Entry) *Hash

NewChainID generates a ChainID from an entry. ChainID = Sha(Sha(ExtIDs[0]) + Sha(ExtIDs[1] + ... + Sha(ExtIDs[n]))

func NewHash

func NewHash() *Hash

func NewShaHash

func NewShaHash(newHash []byte) (*Hash, error)

NewShaHash returns a new ShaHash from a byte slice. An error is returned if the number of bytes passed in is not HASH_LENGTH.

func Sha

func Sha(p []byte) (h *Hash)

Create a Sha256 Hash from a byte array

func Sha512Half

func Sha512Half(p []byte) (h *Hash)

Create a Sha512[:256] Hash from a byte array

func (*Hash) BTCString

func (h *Hash) BTCString() string

String returns the ShaHash in the standard bitcoin big-endian form.

func (*Hash) ByteString

func (h *Hash) ByteString() string

func (*Hash) Bytes

func (h *Hash) Bytes() []byte

func (*Hash) GetBytes

func (h *Hash) GetBytes() []byte

func (*Hash) IsMinuteMarker

func (h *Hash) IsMinuteMarker() bool

Is the hash a minute marker (the last byte indicates the minute number)

func (*Hash) IsSameAs

func (a *Hash) IsSameAs(b *Hash) bool

Compare two Hashes

func (*Hash) JSONBuffer

func (e *Hash) JSONBuffer(b *bytes.Buffer) error

func (*Hash) JSONByte

func (e *Hash) JSONByte() ([]byte, error)

func (*Hash) JSONString

func (e *Hash) JSONString() (string, error)

func (*Hash) MarshalBinary

func (h *Hash) MarshalBinary() ([]byte, error)

func (*Hash) MarshalText

func (h *Hash) MarshalText() ([]byte, error)

func (*Hash) MarshalledSize

func (c *Hash) MarshalledSize() uint64

func (*Hash) SetBytes

func (hash *Hash) SetBytes(newHash []byte) error

SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not HASH_LENGTH.

func (*Hash) Spew

func (e *Hash) Spew() string

func (*Hash) String

func (h *Hash) String() string

Convert a hash into a string with hex encoding

func (*Hash) UnmarshalBinary

func (h *Hash) UnmarshalBinary(p []byte) (err error)

func (*Hash) UnmarshalBinaryData

func (h *Hash) UnmarshalBinaryData(p []byte) (newData []byte, err error)

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(b []byte) error

type IncreaseBalance

type IncreaseBalance struct {
	ECPubKey *[32]byte
	TXID     *Hash
	Index    uint64
	NumEC    uint64
}

func NewIncreaseBalance

func NewIncreaseBalance() *IncreaseBalance

func (*IncreaseBalance) ECID

func (b *IncreaseBalance) ECID() byte

func (*IncreaseBalance) Hash

func (e *IncreaseBalance) Hash() *Hash

func (*IncreaseBalance) Interpret

func (b *IncreaseBalance) Interpret() string

func (*IncreaseBalance) IsInterpretable

func (b *IncreaseBalance) IsInterpretable() bool

func (*IncreaseBalance) JSONBuffer

func (e *IncreaseBalance) JSONBuffer(b *bytes.Buffer) error

func (*IncreaseBalance) JSONByte

func (e *IncreaseBalance) JSONByte() ([]byte, error)

func (*IncreaseBalance) JSONString

func (e *IncreaseBalance) JSONString() (string, error)

func (*IncreaseBalance) MarshalBinary

func (b *IncreaseBalance) MarshalBinary() ([]byte, error)

func (*IncreaseBalance) Spew

func (e *IncreaseBalance) Spew() string

func (*IncreaseBalance) UnmarshalBinary

func (b *IncreaseBalance) UnmarshalBinary(data []byte) (err error)

func (*IncreaseBalance) UnmarshalBinaryData

func (b *IncreaseBalance) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type JSONable

type JSONable interface {
	JSONByte() ([]byte, error)
	JSONString() (string, error)
	JSONBuffer(b *bytes.Buffer) error
}

Interface for printing structures into JSON

type MinuteNumber

type MinuteNumber struct {
	Number uint8
}

func NewMinuteNumber

func NewMinuteNumber() *MinuteNumber

func (*MinuteNumber) ECID

func (m *MinuteNumber) ECID() byte

func (*MinuteNumber) Hash

func (e *MinuteNumber) Hash() *Hash

func (*MinuteNumber) Interpret

func (b *MinuteNumber) Interpret() string

func (*MinuteNumber) IsInterpretable

func (b *MinuteNumber) IsInterpretable() bool

func (*MinuteNumber) JSONBuffer

func (e *MinuteNumber) JSONBuffer(b *bytes.Buffer) error

func (*MinuteNumber) JSONByte

func (e *MinuteNumber) JSONByte() ([]byte, error)

func (*MinuteNumber) JSONString

func (e *MinuteNumber) JSONString() (string, error)

func (*MinuteNumber) MarshalBinary

func (m *MinuteNumber) MarshalBinary() ([]byte, error)

func (*MinuteNumber) MarshalledSize

func (c *MinuteNumber) MarshalledSize() uint64

func (*MinuteNumber) Spew

func (e *MinuteNumber) Spew() string

func (*MinuteNumber) UnmarshalBinary

func (m *MinuteNumber) UnmarshalBinary(data []byte) (err error)

func (*MinuteNumber) UnmarshalBinaryData

func (m *MinuteNumber) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type Printable

type Printable interface {
	JSONable
	Spewable
}

Interface for both JSON and Spew

type PrivateKey

type PrivateKey struct {
	Key *[ed25519.PrivateKeySize]byte
	Pub PublicKey
}

PrivateKey contains Public/Private key pair

func NewPrivateKeyFromHex

func NewPrivateKeyFromHex(s string) (pk PrivateKey, err error)

Create a new private key from a hex string

func (*PrivateKey) AllocateNew

func (pk *PrivateKey) AllocateNew()

func (*PrivateKey) GenerateKey

func (pk *PrivateKey) GenerateKey() (err error)

Generate creates new PrivateKey / PublciKey pair or returns error

func (PrivateKey) MarshalSign

func (pk PrivateKey) MarshalSign(msg BinaryMarshallable) (sig Signature)

Sign signs msg with PrivateKey and return Signature

func (PrivateKey) Public

func (pk PrivateKey) Public() []byte

func (PrivateKey) Sign

func (pk PrivateKey) Sign(msg []byte) (sig Signature)

Sign signs msg with PrivateKey and return Signature

type Properties

type Properties struct {
	Protocol_Version  int
	Factomd_Version   int
	Fctwallet_Version int
}

Structure for reporting properties (used by the web API

func (*Properties) MarshalJSON added in v0.3.5

func (p *Properties) MarshalJSON() ([]byte, error)

type PublicKey

type PublicKey struct {
	Key *[ed25519.PublicKeySize]byte
}

PublicKey contains only Public part of Public/Private key pair

func PubKeyFromString

func PubKeyFromString(instr string) (pk PublicKey)

func (*PublicKey) MarshalText

func (pk *PublicKey) MarshalText() ([]byte, error)

func (PublicKey) String

func (pk PublicKey) String() string

func (*PublicKey) UnmarshalText

func (pk *PublicKey) UnmarshalText(b []byte) error

func (PublicKey) Verify

func (k PublicKey) Verify(msg []byte, sig *[ed25519.SignatureSize]byte) bool

type ServerIndexNumber

type ServerIndexNumber struct {
	Number uint8
}

func NewServerIndexNumber

func NewServerIndexNumber() *ServerIndexNumber

func (*ServerIndexNumber) ECID

func (s *ServerIndexNumber) ECID() byte

func (*ServerIndexNumber) Hash

func (e *ServerIndexNumber) Hash() *Hash

func (*ServerIndexNumber) Interpret

func (b *ServerIndexNumber) Interpret() string

func (*ServerIndexNumber) IsInterpretable

func (b *ServerIndexNumber) IsInterpretable() bool

func (*ServerIndexNumber) JSONBuffer

func (e *ServerIndexNumber) JSONBuffer(b *bytes.Buffer) error

func (*ServerIndexNumber) JSONByte

func (e *ServerIndexNumber) JSONByte() ([]byte, error)

func (*ServerIndexNumber) JSONString

func (e *ServerIndexNumber) JSONString() (string, error)

func (*ServerIndexNumber) MarshalBinary

func (s *ServerIndexNumber) MarshalBinary() ([]byte, error)

func (*ServerIndexNumber) MarshalledSize

func (c *ServerIndexNumber) MarshalledSize() uint64

func (*ServerIndexNumber) Spew

func (e *ServerIndexNumber) Spew() string

func (*ServerIndexNumber) UnmarshalBinary

func (s *ServerIndexNumber) UnmarshalBinary(data []byte) (err error)

func (*ServerIndexNumber) UnmarshalBinaryData

func (s *ServerIndexNumber) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type ShortInterpretable

type ShortInterpretable interface {
	IsInterpretable() bool //Whether the structure can interpret itself
	Interpret() string     //Turns the data encoded int he structure into human-friendly string
}

Interface for short, reoccuring data structures to interpret themselves into human-friendly form

type Sig

type Sig [64]byte

func (*Sig) MarshalText

func (s *Sig) MarshalText() ([]byte, error)

func (*Sig) UnmarshalText

func (s *Sig) UnmarshalText(b []byte) error

type Signature

type Signature struct {
	Pub PublicKey
	Sig *[ed25519.SignatureSize]byte
}

Signature has signed data and its corresponsing PublicKey

func UnmarshalBinarySignature

func UnmarshalBinarySignature(data []byte) (sig Signature)

func (*Signature) DetachSig

func (sig *Signature) DetachSig() *DetachedSignature

func (Signature) Key

func (sig Signature) Key() []byte

func (Signature) Verify

func (sig Signature) Verify(msg []byte) bool

Verify returns true iff sig is a valid signature of msg by PublicKey.

type Signer

type Signer interface {
	Sign(msg []byte) Signature
}

Signer object can Sign msg

type SimpleData

type SimpleData struct {
	Data []byte
}

func (*SimpleData) MarshalBinary

func (d *SimpleData) MarshalBinary() ([]byte, error)

func (*SimpleData) MarshalledSize

func (d *SimpleData) MarshalledSize() uint64

func (*SimpleData) UnmarshalBinary

func (d *SimpleData) UnmarshalBinary([]byte) error

type Spewable

type Spewable interface {
	Spew() string
}

Interface for Spewing the structures for debugging

type Verifyer

type Verifyer interface {
	Verify(msg []byte) bool
}

Verifyer objects can Verify signed messages

Jump to

Keyboard shortcuts

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