Documentation ¶
Overview ¶
Package factom provides data types corresponding to some of the Factom blockchain's data structures, as well as methods on those types for querying the data from factomd and factom-walletd's APIs.
All of the Factom data structure types in this package have the Get and IsPopulated methods.
Methods that accept a *Client, like those that start with Get, may make calls to the factomd or factom-walletd API queries to populate the data in the variable on which it is called. The returned error can be checked to see if it is a jsonrpc2.Error type, indicating that the networking calls were successful, but that there is some error returned by the RPC method.
IsPopulated methods return whether the data in the variable has been populated by a successful call to Get.
The DBlock, EBlock and Entry types allow for exploring the Factom blockchain.
The Bytes and Bytes32 types are used by other types when JSON marshaling and unmarshaling to and from hex encoded data is required. Bytes32 is used for Chain IDs and KeyMRs.
The Address interfaces and types allow for working with the four Factom address types.
The IDKey interfaces and types allow for working with the id/sk key pairs for server identities.
Currently this package supports creating new chains and entries using both the factom-walletd "compose" methods, and by locally generating the commit and reveal data, if the private entry credit key is available locally. See Entry.Create and Entry.ComposeCreate.
This package does not yet support Factoid transactions, nor does it support the binary data structures for DBlocks or EBlocks. Additionally, working with Identity Chains is not yet supported beyond querying the ID1Key.
Index ¶
- Constants
- func EntryCost(size int) (int8, error)
- func ValidIdentityChainID(chainID Bytes) bool
- func ValidIdentityNameIDs(nameIDs []Bytes) bool
- type Address
- type Bytes
- type Bytes32
- type Client
- func (c *Client) Commit(commit []byte) error
- func (c *Client) FactomdRequest(method string, params, result interface{}) error
- func (c *Client) GetAddress(pubAdr Address, privAdr PrivateAddress) error
- func (c *Client) GetAddresses() ([]Address, error)
- func (c *Client) GetECAddresses() ([]ECAddress, error)
- func (c *Client) GetEsAddresses() ([]EsAddress, error)
- func (c *Client) GetFAAddresses() ([]FAAddress, error)
- func (c *Client) GetFsAddresses() ([]FsAddress, error)
- func (c *Client) GetPrivateAddresses() ([]PrivateAddress, error)
- func (c *Client) RemoveAddress(adr Address) error
- func (c *Client) Reveal(reveal []byte) error
- func (c *Client) SavePrivateAddresses(adrs ...PrivateAddress) error
- func (c *Client) WalletdRequest(method string, params, result interface{}) error
- type DBlock
- func (db DBlock) ComputeBodyMR() (Bytes32, error)
- func (db DBlock) ComputeFullHash() (Bytes32, error)
- func (db DBlock) ComputeHeaderHash() (Bytes32, error)
- func (db DBlock) ComputeKeyMR() (Bytes32, error)
- func (db DBlock) EBlock(chainID Bytes32) *EBlock
- func (db *DBlock) Get(c *Client) (err error)
- func (db DBlock) IsPopulated() bool
- func (db *DBlock) MarshalBinary() ([]byte, error)
- func (db *DBlock) MarshalBinaryHeader() ([]byte, error)
- func (db *DBlock) MarshalBinaryLen() int
- func (db *DBlock) UnmarshalBinary(data []byte) error
- type DBlockHeader
- type EBlock
- func (eb EBlock) ComputeBodyMR() (Bytes32, error)
- func (eb EBlock) ComputeFullHash() (Bytes32, error)
- func (eb EBlock) ComputeHeaderHash() (Bytes32, error)
- func (eb EBlock) ComputeKeyMR() (Bytes32, error)
- func (eb *EBlock) CountObjects() uint32
- func (eb *EBlock) Get(c *Client) error
- func (eb EBlock) GetAllPrev(c *Client) ([]EBlock, error)
- func (eb *EBlock) GetChainHead(c *Client) error
- func (eb *EBlock) GetFirst(c *Client) error
- func (eb EBlock) IsFirst() bool
- func (eb EBlock) IsPopulated() bool
- func (eb *EBlock) MarshalBinary() ([]byte, error)
- func (eb *EBlock) MarshalBinaryHeader() ([]byte, error)
- func (eb *EBlock) MarshalBinaryLen() int
- func (eb *EBlock) Objects() ([]Bytes32, error)
- func (eb EBlock) Prev() EBlock
- func (eb *EBlock) UnmarshalBinary(data []byte) error
- type ECAddress
- func (adr ECAddress) GetBalance(c *Client) (uint64, error)
- func (adr ECAddress) GetEsAddress(c *Client) (EsAddress, error)
- func (adr ECAddress) GetPrivateAddress(c *Client) (PrivateAddress, error)
- func (adr ECAddress) MarshalJSON() ([]byte, error)
- func (adr ECAddress) Payload() [sha256.Size]byte
- func (ECAddress) PrefixBytes() []byte
- func (ECAddress) PrefixString() string
- func (adr ECAddress) PublicAddress() Address
- func (adr ECAddress) PublicKey() ed25519.PublicKey
- func (adr ECAddress) Remove(c *Client) error
- func (adr *ECAddress) Set(adrStr string) error
- func (adr ECAddress) String() string
- func (adr *ECAddress) UnmarshalJSON(data []byte) error
- type Entry
- func (e *Entry) Compose(es EsAddress) (commit []byte, reveal []byte, txID *Bytes32, err error)
- func (e *Entry) ComposeCreate(c *Client, es EsAddress) (*Bytes32, error)
- func (e Entry) ComputeHash() (Bytes32, error)
- func (e Entry) Cost() (int8, error)
- func (e *Entry) Create(c *Client, ec ECAddress) (*Bytes32, error)
- func (e *Entry) Get(c *Client) error
- func (e Entry) IsPopulated() bool
- func (e *Entry) MarshalBinary() ([]byte, error)
- func (e Entry) MarshalBinaryLen() int
- func (e *Entry) UnmarshalBinary(data []byte) error
- type EsAddress
- func (adr EsAddress) ECAddress() (ec ECAddress)
- func (adr EsAddress) GetBalance(c *Client) (uint64, error)
- func (adr EsAddress) GetPrivateAddress(_ *Client) (PrivateAddress, error)
- func (adr EsAddress) MarshalJSON() ([]byte, error)
- func (adr EsAddress) Payload() [sha256.Size]byte
- func (EsAddress) PrefixBytes() []byte
- func (EsAddress) PrefixString() string
- func (adr EsAddress) PrivateKey() ed25519.PrivateKey
- func (adr EsAddress) PublicAddress() Address
- func (adr EsAddress) PublicKey() ed25519.PublicKey
- func (adr EsAddress) Remove(c *Client) error
- func (adr EsAddress) Save(c *Client) error
- func (adr *EsAddress) Set(adrStr string) error
- func (adr EsAddress) String() string
- func (adr *EsAddress) UnmarshalJSON(data []byte) error
- type FAAddress
- func (adr FAAddress) GetBalance(c *Client) (uint64, error)
- func (adr FAAddress) GetFsAddress(c *Client) (FsAddress, error)
- func (adr FAAddress) GetPrivateAddress(c *Client) (PrivateAddress, error)
- func (adr FAAddress) MarshalJSON() ([]byte, error)
- func (adr FAAddress) Payload() [sha256.Size]byte
- func (FAAddress) PrefixBytes() []byte
- func (FAAddress) PrefixString() string
- func (adr FAAddress) PublicAddress() Address
- func (adr FAAddress) RCDHash() [sha256.Size]byte
- func (adr FAAddress) Remove(c *Client) error
- func (adr *FAAddress) Scan(v interface{}) error
- func (adr *FAAddress) Set(adrStr string) error
- func (adr FAAddress) String() string
- func (adr *FAAddress) UnmarshalJSON(data []byte) error
- func (adr FAAddress) Value() (driver.Value, error)
- type FsAddress
- func (adr FsAddress) FAAddress() FAAddress
- func (adr FsAddress) GetBalance(c *Client) (uint64, error)
- func (adr FsAddress) GetPrivateAddress(_ *Client) (PrivateAddress, error)
- func (adr FsAddress) MarshalJSON() ([]byte, error)
- func (adr FsAddress) Payload() [sha256.Size]byte
- func (FsAddress) PrefixBytes() []byte
- func (FsAddress) PrefixString() string
- func (adr FsAddress) PrivateKey() ed25519.PrivateKey
- func (adr FsAddress) PublicAddress() Address
- func (adr FsAddress) PublicKey() ed25519.PublicKey
- func (adr FsAddress) RCD() []byte
- func (adr FsAddress) RCDHash() [sha256.Size]byte
- func (adr FsAddress) Remove(c *Client) error
- func (adr FsAddress) Save(c *Client) error
- func (adr *FsAddress) Set(adrStr string) error
- func (adr FsAddress) String() string
- func (adr *FsAddress) UnmarshalJSON(data []byte) error
- type Heights
- type ID1Key
- func (key ID1Key) IDKey() IDKey
- func (key ID1Key) MarshalJSON() ([]byte, error)
- func (key ID1Key) Payload() [sha256.Size]byte
- func (ID1Key) PrefixBytes() []byte
- func (ID1Key) PrefixString() string
- func (key ID1Key) RCDHash() [sha256.Size]byte
- func (key *ID1Key) Scan(v interface{}) error
- func (key *ID1Key) Set(keyStr string) error
- func (key ID1Key) String() string
- func (ID1Key) Type() string
- func (key *ID1Key) UnmarshalJSON(data []byte) error
- func (key ID1Key) Value() (driver.Value, error)
- type ID2Key
- func (key ID2Key) IDKey() IDKey
- func (key ID2Key) MarshalJSON() ([]byte, error)
- func (key ID2Key) Payload() [sha256.Size]byte
- func (ID2Key) PrefixBytes() []byte
- func (ID2Key) PrefixString() string
- func (key ID2Key) RCDHash() [sha256.Size]byte
- func (key *ID2Key) Scan(v interface{}) error
- func (key *ID2Key) Set(keyStr string) error
- func (key ID2Key) String() string
- func (ID2Key) Type() string
- func (key *ID2Key) UnmarshalJSON(data []byte) error
- func (key ID2Key) Value() (driver.Value, error)
- type ID3Key
- func (key ID3Key) IDKey() IDKey
- func (key ID3Key) MarshalJSON() ([]byte, error)
- func (key ID3Key) Payload() [sha256.Size]byte
- func (ID3Key) PrefixBytes() []byte
- func (ID3Key) PrefixString() string
- func (key ID3Key) RCDHash() [sha256.Size]byte
- func (key *ID3Key) Scan(v interface{}) error
- func (key *ID3Key) Set(keyStr string) error
- func (key ID3Key) String() string
- func (ID3Key) Type() string
- func (key *ID3Key) UnmarshalJSON(data []byte) error
- func (key ID3Key) Value() (driver.Value, error)
- type ID4Key
- func (key ID4Key) IDKey() IDKey
- func (key ID4Key) MarshalJSON() ([]byte, error)
- func (key ID4Key) Payload() [sha256.Size]byte
- func (ID4Key) PrefixBytes() []byte
- func (ID4Key) PrefixString() string
- func (key ID4Key) RCDHash() [sha256.Size]byte
- func (key *ID4Key) Scan(v interface{}) error
- func (key *ID4Key) Set(keyStr string) error
- func (key ID4Key) String() string
- func (ID4Key) Type() string
- func (key *ID4Key) UnmarshalJSON(data []byte) error
- func (key ID4Key) Value() (driver.Value, error)
- type IDKey
- type Identity
- type PendingEntries
- type PrivateAddress
- type RCDPrivateKey
- type SK1Key
- func (key SK1Key) ID1Key() ID1Key
- func (key SK1Key) IDKey() IDKey
- func (key SK1Key) MarshalJSON() ([]byte, error)
- func (key SK1Key) Payload() [sha256.Size]byte
- func (SK1Key) PrefixBytes() []byte
- func (SK1Key) PrefixString() string
- func (key SK1Key) PrivateKey() ed25519.PrivateKey
- func (key SK1Key) PublicKey() ed25519.PublicKey
- func (key SK1Key) RCD() []byte
- func (key SK1Key) RCDHash() [sha256.Size]byte
- func (key SK1Key) SKKey() SKKey
- func (key *SK1Key) Set(keyStr string) error
- func (key SK1Key) String() string
- func (SK1Key) Type() string
- func (key *SK1Key) UnmarshalJSON(data []byte) error
- type SK2Key
- func (key SK2Key) ID2Key() ID2Key
- func (key SK2Key) IDKey() IDKey
- func (key SK2Key) MarshalJSON() ([]byte, error)
- func (key SK2Key) Payload() [sha256.Size]byte
- func (SK2Key) PrefixBytes() []byte
- func (SK2Key) PrefixString() string
- func (key SK2Key) PrivateKey() ed25519.PrivateKey
- func (key SK2Key) PublicKey() ed25519.PublicKey
- func (key SK2Key) RCD() []byte
- func (key SK2Key) RCDHash() [sha256.Size]byte
- func (key SK2Key) SKKey() SKKey
- func (key *SK2Key) Set(keyStr string) error
- func (key SK2Key) String() string
- func (SK2Key) Type() string
- func (key *SK2Key) UnmarshalJSON(data []byte) error
- type SK3Key
- func (key SK3Key) ID3Key() ID3Key
- func (key SK3Key) IDKey() IDKey
- func (key SK3Key) MarshalJSON() ([]byte, error)
- func (key SK3Key) Payload() [sha256.Size]byte
- func (SK3Key) PrefixBytes() []byte
- func (SK3Key) PrefixString() string
- func (key SK3Key) PrivateKey() ed25519.PrivateKey
- func (key SK3Key) PublicKey() ed25519.PublicKey
- func (key SK3Key) RCD() []byte
- func (key SK3Key) RCDHash() [sha256.Size]byte
- func (key SK3Key) SKKey() SKKey
- func (key *SK3Key) Set(keyStr string) error
- func (key SK3Key) String() string
- func (SK3Key) Type() string
- func (key *SK3Key) UnmarshalJSON(data []byte) error
- type SK4Key
- func (key SK4Key) ID4Key() ID4Key
- func (key SK4Key) IDKey() IDKey
- func (key SK4Key) MarshalJSON() ([]byte, error)
- func (key SK4Key) Payload() [sha256.Size]byte
- func (SK4Key) PrefixBytes() []byte
- func (SK4Key) PrefixString() string
- func (key SK4Key) PrivateKey() ed25519.PrivateKey
- func (key SK4Key) PublicKey() ed25519.PublicKey
- func (key SK4Key) RCD() []byte
- func (key SK4Key) RCDHash() [sha256.Size]byte
- func (key SK4Key) SKKey() SKKey
- func (key *SK4Key) Set(keyStr string) error
- func (key SK4Key) String() string
- func (SK4Key) Type() string
- func (key *SK4Key) UnmarshalJSON(data []byte) error
- type SKKey
Constants ¶
const ( // RCDType is the magic number identifying the currenctly accepted RCD. RCDType byte = 0x01 // RCDSize is the size of the RCD. RCDSize = ed25519.PublicKeySize + 1 // SignatureSize is the size of the ed25519 signatures. SignatureSize = ed25519.SignatureSize )
const ( FactomdDefault = "http://localhost:8088" WalletdDefault = "http://localhost:8089" )
Defaults for the factomd and factom-walletd endpoints.
const ( DBlockHeaderLen = 1 + 4 + 32 + 32 + 32 + 4 + 4 + 4 // EBlock Count DBlockEBlockLen = 32 + 32 // KeyMR DBlockMinBodyLen = DBlockEBlockLen + DBlockEBlockLen + DBlockEBlockLen // FCT Block DBlockMinTotalLen = DBlockHeaderLen + DBlockMinBodyLen DBlockMaxBodyLen = math.MaxUint32 * DBlockEBlockLen DBlockMaxTotalLen = DBlockHeaderLen + DBlockMaxBodyLen )
const ( EBlockHeaderLen = 32 + 32 + 32 + 32 + 4 + 4 + 4 // [Entry Count (uint32 BE)] EBlockObjectLen = 32 // Entry hash or minute marker EBlockMinBodyLen = EBlockObjectLen * 2 // one entry hash & one minute marker EBlockMinTotalLen = EBlockHeaderLen + EBlockMinBodyLen EBlockMaxBodyLen = math.MaxUint32 * EBlockObjectLen EBlockMaxTotalLen = EBlockHeaderLen + EBlockMaxBodyLen )
const ( EntryHeaderLen = 1 + 32 + 2 // total len EntryMaxDataLen = 10240 EntryMaxTotalLen = EntryMaxDataLen + EntryHeaderLen )
const NewChainCost = 10
NewChainCost is the fixed added cost of creating a new chain.
Variables ¶
This section is empty.
Functions ¶
func EntryCost ¶ added in v0.4.0
EntryCost returns the required Entry Credit cost for an entry with encoded length equal to size. An error is returned if size exceeds 10275.
func ValidIdentityChainID ¶ added in v0.4.0
ValidIdentityChainID returns true if the chainID matches the pattern for an Identity Chain ID.
The Identity Chain specification can be found here: https://github.com/FactomProject/FactomDocs/blob/master/Identity.md#factom-identity-chain-creation
func ValidIdentityNameIDs ¶ added in v0.4.0
ValidIdentityNameIDs returns true if the nameIDs match the pattern for a valid Identity Chain. The nameIDs for a chain are the ExtIDs of the first entry in the chain.
The Identity Chain specification can be found here: https://github.com/FactomProject/FactomDocs/blob/master/Identity.md#factom-identity-chain-creation
Types ¶
type Address ¶
type Address interface { // PrefixBytes returns the prefix bytes for the Address. PrefixBytes() []byte // PrefixString returns the encoded prefix string for the Address. PrefixString() string // String encodes the address to a base58check string with the // appropriate prefix. String() string // Payload returns the address as a byte array. Payload() [sha256.Size]byte // PublicAddress returns the corresponding public address in an Address // interface. Public addresses return themselves. Private addresses // compute the public address. PublicAddress() Address // GetPrivateAddress returns the corresponding private address in a // PrivateAddress interface. Public addresses query factom-walletd for // the private address. Private addresses return themselves. GetPrivateAddress(*Client) (PrivateAddress, error) // GetBalance returns the current balance for the address. GetBalance(*Client) (uint64, error) // Remove queries factom-walletd to remove the public and private // addresses from its database. // WARNING: DESTRUCTIVE ACTION! LOSS OF KEYS AND FUNDS MAY RESULT! Remove(*Client) error }
Address is the interface implemented by the four address types: FAAddress, FsAddress, ECAddress, and EsAddress.
func NewAddress ¶
NewAddress parses adrStr and returns the correct address type as an Address interface. This is useful when the address type isn't known prior to parsing adrStr. If the address type is known ahead of time, it is generally better to just use the appropriate concrete type.
func NewPublicAddress ¶ added in v0.4.0
NewPublicAddress parses adrStr and returns the correct address type as an Address interface. If adrStr is not a public address then an "invalid prefix" error is returned. This is useful when the address type isn't known prior to parsing adrStr, but must be a public address. If the address type is known ahead of time, it is generally better to just use the appropriate concrete type.
type Bytes ¶
type Bytes []byte
Bytes implements json.Marshaler and json.Unmarshaler to encode and decode strings with hex encoded data, such as an Entry's External IDs or content.
func (Bytes) MarshalJSON ¶
MarshalJSON encodes b as a hex JSON string.
func (*Bytes) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON string with hex encoded data.
type Bytes32 ¶
type Bytes32 [32]byte
Bytes32 implements json.Marshaler and json.Unmarshaler to encode and decode strings with exactly 32 bytes of hex encoded data, such as Chain IDs and KeyMRs.
func EntryHash ¶
EntryHash returns the Entry hash of data. Entry's are hashed via: sha256(sha512(data) + data).
func NewBytes32 ¶
NewBytes32 allocates a new Bytes32 object with the first 32 bytes of data contained in s32.
func NewBytes32FromString ¶ added in v0.6.0
NewBytes32FromString allocates a new Bytes32 object with the hex encoded string data contained in s32.
func (Bytes32) MarshalJSON ¶
MarshalJSON encodes b as a hex JSON string.
func (*Bytes32) Set ¶ added in v0.4.0
Set decodes a string with exactly 32 bytes of hex encoded data.
func (*Bytes32) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON string with exactly 32 bytes of hex encoded data.
type Client ¶ added in v0.4.0
type Client struct { Factomd jrpc.Client FactomdServer string Walletd jrpc.Client WalletdServer string }
Client makes RPC requests to factomd's and factom-walletd's APIs. Client embeds two jsonrpc2.Clients, and thus also two http.Client, one for requests to factomd and one for requests to factom-walletd. Use jsonrpc2.Client's BasicAuth settings to set up BasicAuth and http.Client's transport settings to configure TLS.
func NewClient ¶ added in v0.4.0
func NewClient() *Client
NewClient returns a pointer to a Client initialized with the default localhost endpoints for factomd and factom-walletd, and 15 second timeouts for each of the http.Clients.
func (*Client) FactomdRequest ¶ added in v0.4.0
FactomdRequest makes a request to factomd's v2 API.
func (*Client) GetAddress ¶ added in v0.4.0
func (c *Client) GetAddress(pubAdr Address, privAdr PrivateAddress) error
GetAddress queries factom-walletd for the privAdr corresponding to pubAdr. If the returned error is nil, then privAdr is now populated. Note that privAdr must be a pointer to a concrete type implementing PrivateAddress.
func (*Client) GetAddresses ¶ added in v0.4.0
GetAddresses queries factom-walletd for all public addresses.
func (*Client) GetECAddresses ¶ added in v0.4.0
GetECAddresses queries factom-walletd for all public Entry Credit addresses.
func (*Client) GetEsAddresses ¶ added in v0.4.0
GetEsAddresses queries factom-walletd for all secret Entry Credit addresses.
func (*Client) GetFAAddresses ¶ added in v0.4.0
GetFAAddresses queries factom-walletd for all public Factoid addresses.
func (*Client) GetFsAddresses ¶ added in v0.4.0
GetFsAddresses queries factom-walletd for all secret Factoid addresses.
func (*Client) GetPrivateAddresses ¶ added in v0.4.0
func (c *Client) GetPrivateAddresses() ([]PrivateAddress, error)
GetPrivateAddresses queries factom-walletd for all private addresses.
func (*Client) RemoveAddress ¶ added in v0.4.0
RemoveAddress removes adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.
func (*Client) SavePrivateAddresses ¶ added in v0.4.0
func (c *Client) SavePrivateAddresses(adrs ...PrivateAddress) error
SavePrivateAddresses saves many adrs with factom-walletd.
func (*Client) WalletdRequest ¶ added in v0.4.0
WalletdRequest makes a request to factom-walletd's v2 API.
type DBlock ¶
type DBlock struct { KeyMR *Bytes32 `json:"keymr"` FullHash *Bytes32 `json:"dbhash"` Header DBlockHeader `json:"header"` // DBlock.Get populates EBlocks with their ChainID and KeyMR. EBlocks []EBlock `json:"dbentries,omitempty"` }
DBlock represents a Factom Directory Block.
func (DBlock) ComputeBodyMR ¶ added in v0.6.0
func (DBlock) ComputeFullHash ¶ added in v0.6.0
func (DBlock) ComputeHeaderHash ¶ added in v0.6.0
func (DBlock) ComputeKeyMR ¶ added in v0.6.0
func (DBlock) EBlock ¶ added in v0.6.0
EBlock efficiently finds and returns the *EBlock in db.EBlocks for the given chainID, if it exists. Otherwise, EBlock returns nil.
func (*DBlock) Get ¶
Get queries factomd for the Directory Block at db.Header.Height. After a successful call, the EBlocks will all have their ChainID and KeyMR, but not their Entries. Call Get on the EBlocks individually to populate their Entries.
func (DBlock) IsPopulated ¶
IsPopulated returns true if db has already been successfully populated by a call to Get. IsPopulated returns false if db.EBlocks is nil.
func (*DBlock) MarshalBinary ¶ added in v0.6.0
func (*DBlock) MarshalBinaryHeader ¶ added in v0.6.0
func (*DBlock) MarshalBinaryLen ¶ added in v0.6.0
func (*DBlock) UnmarshalBinary ¶ added in v0.6.0
UnmarshalBinary unmarshals raw directory block data.
Header [Version byte (0x00)] + [NetworkID (4 bytes)] + [BodyMR (Bytes32)] + [PrevKeyMR (Bytes32)] + [PrevFullHash (Bytes32)] + [Timestamp (4 bytes)] + [DB Height (4 bytes)] + [EBlock Count (4 bytes)]
Body [Admin Block ChainID (Bytes32{31:0x0a})] + [Admin Block LookupHash (Bytes32)] + [EC Block ChainID (Bytes32{31:0x0c})] + [EC Block HeaderHash (Bytes32)] + [FCT Block ChainID (Bytes32{31:0x0f})] + [FCT Block KeyMR (Bytes32)] + [ChainID 0 (Bytes32)] + [KeyMR 0 (Bytes32)] + ... + [ChainID N (Bytes32)] + [KeyMR N (Bytes32)] +
type DBlockHeader ¶ added in v0.6.0
type DBlockHeader struct { NetworkID [4]byte `json:"networkid"` BodyMR *Bytes32 `json:"bodymr"` PrevKeyMR *Bytes32 `json:"prevkeymr"` PrevFullHash *Bytes32 `json:"prevfullhash"` Height uint32 `json:"dbheight"` Timestamp time.Time `json:"-"` }
func (*DBlockHeader) MarshalJSON ¶ added in v0.6.0
func (dbh *DBlockHeader) MarshalJSON() ([]byte, error)
func (*DBlockHeader) UnmarshalJSON ¶ added in v0.6.0
func (dbh *DBlockHeader) UnmarshalJSON(data []byte) error
type EBlock ¶
type EBlock struct { // DBlock.Get populates the ChainID, KeyMR, and Height. ChainID *Bytes32 `json:"chainid,omitempty"` KeyMR *Bytes32 `json:"keymr,omitempty"` PrevKeyMR *Bytes32 `json:"-"` PrevFullHash *Bytes32 `json:"-"` BodyMR *Bytes32 `json:"-"` Height uint32 `json:"-"` Sequence uint32 `json:"-"` ObjectCount uint32 `json:"-"` Timestamp time.Time `json:"-"` // EBlock.Get populates the EBlockHeader.PrevKeyMR and the Entries with // their Hash and Timestamp. Entries []Entry `json:"-"` }
EBlock represents a Factom Entry Block.
func (EBlock) ComputeBodyMR ¶ added in v0.6.0
func (EBlock) ComputeFullHash ¶ added in v0.6.0
func (EBlock) ComputeHeaderHash ¶ added in v0.6.0
func (EBlock) ComputeKeyMR ¶ added in v0.6.0
func (*EBlock) CountObjects ¶ added in v0.6.0
func (*EBlock) Get ¶
Get queries factomd for the Entry Block corresponding to eb.KeyMR, if not nil, and otherwise the Entry Block chain head for eb.ChainID. Either eb.KeyMR or eb.ChainID must be not nil or else Get will fail to populate the EBlock. After a successful call, EBlockHeader and Entries will be populated. Each Entry will be populated with its Hash, Timestamp, ChainID, and Height, but not its Content or ExtIDs. Call Get on the individual Entries to populate their Content and ExtIDs.
func (EBlock) GetAllPrev ¶
GetAllPrev returns a slice of all preceding EBlocks in eb's chain, in order from earliest to latest, up to and including eb. So the last element of the returned slice is always equal to eb. If eb is the first entry block in its chain, then it is the only element in the slice.
If you are only interested in obtaining the first entry block in eb's chain, and not all of the intermediary ones, then use GetFirst to reduce network calls and memory usage.
func (*EBlock) GetChainHead ¶
GetChainHead queries factomd for the latest eb.KeyMR for chain eb.ChainID.
func (*EBlock) GetFirst ¶
GetFirst finds the first Entry Block in eb's chain, and populates eb as such.
GetFirst differs from GetAllPrev in that it does not allocate any additional EBlocks. GetFirst avoids allocating any new EBlocks by reusing eb to traverse up to the first entry block.
func (EBlock) IsFirst ¶
IsFirst returns true if this is the first EBlock in its chain, indicated by the PrevKeyMR being all zeroes. IsFirst returns false if eb is not populated or if the PrevKeyMR is not all zeroes.
func (EBlock) IsPopulated ¶
func (*EBlock) MarshalBinary ¶ added in v0.6.0
func (*EBlock) MarshalBinaryHeader ¶ added in v0.6.0
func (*EBlock) MarshalBinaryLen ¶ added in v0.6.0
func (EBlock) Prev ¶
Prev returns the an EBlock with its KeyMR initialized to eb.PrevKeyMR and ChainID initialized to eb.ChainID. If eb is the first Entry Block in the chain, then eb is returned.
func (*EBlock) UnmarshalBinary ¶ added in v0.6.0
UnmarshalBinary unmarshals raw entry block data.
Header [ChainID (Bytes32)] + [BodyMR (Bytes32)] + [PrevKeyMR (Bytes32)] + [PrevFullHash (Bytes32)] + [EB Sequence (uint32 BE)] + [DB Height (uint32 BE)] + [Object Count (uint32 BE)]
Body [Object 0 (Bytes32)] + // entry hash or minute marker ... + [Object N (Bytes32)]
https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry-block
type ECAddress ¶ added in v0.4.0
ECAddress is a Public Entry Credit Address.
func NewECAddress ¶ added in v0.4.0
NewECAddress attempts to parse adrStr into a new ECAddress.
func (ECAddress) GetBalance ¶ added in v0.4.0
GetBalance queries factomd for the Entry Credit Balance for adr.
func (ECAddress) GetEsAddress ¶ added in v0.4.0
GetEsAddress queries factom-walletd for the EsAddress corresponding to adr.
func (ECAddress) GetPrivateAddress ¶ added in v0.4.0
func (adr ECAddress) GetPrivateAddress(c *Client) (PrivateAddress, error)
GetPrivateAddress queries factom-walletd for the secret address corresponding to adr and returns it as a PrivateAddress.
func (ECAddress) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes adr as a JSON string using adr.String().
func (ECAddress) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x59, 0x2a}.
func (ECAddress) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "EC".
func (ECAddress) PublicAddress ¶ added in v0.4.0
PublicAddress returns adr as an Address.
func (ECAddress) Remove ¶ added in v0.4.0
Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.
func (ECAddress) String ¶ added in v0.4.0
String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().
func (*ECAddress) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable public Entry Credit address into adr.
type Entry ¶
type Entry struct { // EBlock.Get populates the Hash, Timestamp, ChainID, and Height. Hash *Bytes32 `json:"entryhash,omitempty"` Timestamp time.Time `json:"-"` ChainID *Bytes32 `json:"chainid,omitempty"` Height uint32 // Entry.Get populates the Content and ExtIDs. ExtIDs []Bytes `json:"extids"` Content Bytes `json:"content"` }
Entry represents a Factom Entry with some additional useful fields. Both Timestamp and Height are not included in the entry binary structure or hash. These fields will only be populated if this Entry was initially part of a populated EBlock, and can be manipulated in this type without affecting the Entry Hash.
func (*Entry) Compose ¶ added in v0.4.0
Compose generates the commit and reveal data required to submit an entry to factomd. If e.ChainID is nil, then the ChainID is computed from the e.ExtIDs and a new chain commit is created.
func (*Entry) ComposeCreate ¶ added in v0.4.0
ComposeCreate Composes e locally and then Commit and Reveals it using factomd. This does not make any calls to factom-walletd. The Transaction ID is returned.
func (Entry) ComputeHash ¶
ComputeHash returns the Entry's hash as computed by hashing the binary representation of the Entry.
func (*Entry) Create ¶
Create queries factom-walletd to compose and factomd to commit and reveal a new Entry or new Chain, if e.ChainID is nil. ec must exist in factom-walletd's keystore.
func (*Entry) Get ¶
Get queries factomd for the entry corresponding to e.Hash, which must be not nil. After a successful call e.Content, e.ExtIDs, and e.Timestamp will be populated.
func (Entry) IsPopulated ¶
IsPopulated returns true if e has already been successfully populated by a call to Get. IsPopulated returns false if e.ExtIDs, e.Content, or e.Hash are nil, or if e.Timestamp is zero.
func (*Entry) MarshalBinary ¶
MarshalBinary marshals the entry to its binary representation. See UnmarshalBinary for encoding details. MarshalBinary populates e.ChainID if nil, and always overwrites e.Hash with the computed EntryHash. This is also the reveal data.
func (Entry) MarshalBinaryLen ¶ added in v0.4.0
func (*Entry) UnmarshalBinary ¶
UnmarshalBinary unmarshals raw entry data. It does not populate the Entry.Hash. Entries are encoded as follows:
[Version byte (0x00)] + [ChainID (Bytes32)] + [Total ExtID encoded length (uint16 BE)] + [ExtID 0 length (uint16)] + [ExtID 0 (Bytes)] + ... + [ExtID X length (uint16)] + [ExtID X (Bytes)] + [Content (Bytes)]
https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry
type EsAddress ¶ added in v0.4.0
EsAddress is the secret key to a ECAddress.
func GenerateEsAddress ¶ added in v0.4.0
GenerateEsAddress generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.
func NewEsAddress ¶ added in v0.4.0
NewEsAddress attempts to parse adrStr into a new EsAddress.
func (EsAddress) GetBalance ¶ added in v0.4.0
GetBalance queries factomd for the Entry Credit Balance for adr.
func (EsAddress) GetPrivateAddress ¶ added in v0.4.0
func (adr EsAddress) GetPrivateAddress(_ *Client) (PrivateAddress, error)
GetPrivateAddress returns adr as a PrivateAddress.
func (EsAddress) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes adr as a JSON string using adr.String().
func (EsAddress) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x5d, 0xb6}.
func (EsAddress) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "Es".
func (EsAddress) PrivateKey ¶ added in v0.4.0
func (adr EsAddress) PrivateKey() ed25519.PrivateKey
PrivateKey returns the ed25519.PrivateKey for adr.
func (EsAddress) PublicAddress ¶ added in v0.4.0
PublicAddress returns the ECAddress corresponding to adr as an Address.
func (EsAddress) Remove ¶ added in v0.4.0
Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.
func (EsAddress) String ¶ added in v0.4.0
String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().
func (*EsAddress) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable secret Entry Credit address into adr.
type FAAddress ¶ added in v0.4.0
FAAddress is a Public Factoid Address.
func NewFAAddress ¶ added in v0.4.0
NewFAAddress attempts to parse adrStr into a new FAAddress.
func (FAAddress) GetBalance ¶ added in v0.4.0
GetBalance queries factomd for the Factoid Balance for adr.
func (FAAddress) GetFsAddress ¶ added in v0.4.0
GetFsAddress queries factom-walletd for the FsAddress corresponding to adr.
func (FAAddress) GetPrivateAddress ¶ added in v0.4.0
func (adr FAAddress) GetPrivateAddress(c *Client) (PrivateAddress, error)
GetPrivateAddress queries factom-walletd for the secret address corresponding to adr and returns it as a PrivateAddress.
func (FAAddress) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes adr as a JSON string using adr.String().
func (FAAddress) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x5f, 0xb1}.
func (FAAddress) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "FA".
func (FAAddress) PublicAddress ¶ added in v0.4.0
PublicAddress returns adr as an Address.
func (FAAddress) Remove ¶ added in v0.4.0
Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.
func (*FAAddress) Scan ¶ added in v0.4.0
Scan implements sql.Scanner for adr using Bytes32.Scan. The FAAddress type is not encoded and is assumed.
func (FAAddress) String ¶ added in v0.4.0
String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().
func (*FAAddress) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable public Factoid address into adr.
type FsAddress ¶ added in v0.4.0
FsAddress is the secret key to a FAAddress.
func GenerateFsAddress ¶ added in v0.4.0
GenerateFsAddress generates a secure random private Factoid address using crypto/rand.Random as the source of randomness.
func NewFsAddress ¶ added in v0.4.0
NewFsAddress attempts to parse adrStr into a new FsAddress.
func (FsAddress) GetBalance ¶ added in v0.4.0
GetBalance queries factomd for the Factoid Balance for adr.
func (FsAddress) GetPrivateAddress ¶ added in v0.4.0
func (adr FsAddress) GetPrivateAddress(_ *Client) (PrivateAddress, error)
GetPrivateAddress returns adr as a PrivateAddress.
func (FsAddress) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes adr as a JSON string using adr.String().
func (FsAddress) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x64, 0x78}.
func (FsAddress) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "Fs".
func (FsAddress) PrivateKey ¶ added in v0.4.0
func (adr FsAddress) PrivateKey() ed25519.PrivateKey
PrivateKey returns the ed25519.PrivateKey for adr.
func (FsAddress) PublicAddress ¶ added in v0.4.0
PublicAddress returns the FAAddress corresponding to adr as an Address.
func (FsAddress) Remove ¶ added in v0.4.0
Remove adr from factom-walletd. WARNING: THIS IS DESTRUCTIVE.
func (FsAddress) String ¶ added in v0.4.0
String encodes adr into its human readable form: a base58check string with adr.PrefixBytes().
func (*FsAddress) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable secret Factoid address into adr.
type Heights ¶ added in v0.4.0
type Heights struct { // The current directory block height of the local factomd node. DirectoryBlock uint32 `json:"directoryblockheight"` // The current block being worked on by the leaders in the network. // This block is not yet complete, but all transactions submitted will // go into this block (depending on network conditions, the transaction // may be delayed into the next block) Leader uint32 `json:"leaderheight"` // The height at which the factomd node has all the entry blocks. // Directory blocks are obtained first, entry blocks could be lagging // behind the directory block when syncing. EntryBlock uint32 `json:"entryblockheight"` // The height at which the local factomd node has all the entries. If // you added entries at a block height above this, they will not be // able to be retrieved by the local factomd until it syncs further. Entry uint32 `json:"entryheight"` }
Heights contains all of the distinct heights for a factomd node and the Factom network.
type ID1Key ¶ added in v0.4.0
ID1Key is the id1 public key for an identity.
func (ID1Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (ID1Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbe, 0xba}.
func (ID1Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id1".
func (*ID1Key) Scan ¶ added in v0.4.0
Scan implements sql.Scanner for key using Bytes32.Scan. The ID1Key type is not encoded and is assumed.
func (ID1Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (ID1Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*ID1Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable id1 key into key.
type ID2Key ¶ added in v0.4.0
ID2Key is the id2 public key for an identity.
func (ID2Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (ID2Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbe, 0xd8}.
func (ID2Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id2".
func (*ID2Key) Scan ¶ added in v0.4.0
Scan implements sql.Scanner for key using Bytes32.Scan. The ID2Key type is not encoded and is assumed.
func (ID2Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (ID2Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*ID2Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable id2 key into key.
type ID3Key ¶ added in v0.4.0
ID3Key is the id3 public key for an identity.
func (ID3Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (ID3Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbe, 0xf6}.
func (ID3Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id3".
func (*ID3Key) Scan ¶ added in v0.4.0
Scan implements sql.Scanner for key using Bytes32.Scan. The ID3Key type is not encoded and is assumed.
func (ID3Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (ID3Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*ID3Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable id3 key into key.
type ID4Key ¶ added in v0.4.0
ID4Key is the id4 public key for an identity.
func (ID4Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (ID4Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x3f, 0xbf, 0x14}.
func (ID4Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "id4".
func (*ID4Key) Scan ¶ added in v0.4.0
Scan implements sql.Scanner for key using Bytes32.Scan. The ID4Key type is not encoded and is assumed.
func (ID4Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (ID4Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*ID4Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable id4 key into key.
type IDKey ¶ added in v0.4.0
type IDKey interface { // PrefixBytes returns the prefix bytes for the key. PrefixBytes() []byte // PrefixString returns the encoded prefix string for the key. PrefixString() string // String encodes the key to a base58check string with the appropriate // prefix. String() string // Payload returns the key as a byte array. Payload() [sha256.Size]byte // RCDHash returns the RCDHash as a byte array. For IDxKeys, this is // identical to Payload. For SKxKeys the RCDHash is computed. RCDHash() [sha256.Size]byte // IDKey returns the corresponding IDxKey in an IDKey interface. // IDxKeys return themselves. Private SKxKeys compute the // corresponding IDxKey. IDKey() IDKey }
IDKey is the interface implemented by the four ID and SK Key types.
type Identity ¶ added in v0.4.0
Identity represents the Token Issuer's Identity Chain and the public ID1Key.
func NewIdentity ¶ added in v0.4.0
NewIdentity initializes an Identity with the given chainID.
func (*Identity) Get ¶ added in v0.4.0
Get validates i.ChainID as an Identity Chain and parses out the ID1Key.
func (Identity) IsPopulated ¶ added in v0.4.0
IsPopulated returns true if the Identity has been populated with an ID1Key.
type PendingEntries ¶ added in v0.6.0
type PendingEntries []Entry
PendingEntries is a list of pending entries which may or may not be revealed. If the entry's ChainID is not nil, then its data has been revealed and can be queried from factomd.
func (PendingEntries) Entries ¶ added in v0.6.0
func (pe PendingEntries) Entries(chainID Bytes32) []Entry
Entries efficiently finds and returns all entries in pe for the given chainID, if any exist. Otherwise, Entries returns nil.
func (*PendingEntries) Get ¶ added in v0.6.0
func (pe *PendingEntries) Get(c *Client) error
Get returns all pending entries sorted by ChainID, and then order they were originally returned.
type PrivateAddress ¶ added in v0.4.0
type PrivateAddress interface { Address // PrivateKey returns the ed25519.PrivateKey which can be used for // signing data. PrivateKey() ed25519.PrivateKey // PublicKey returns the ed25519.PublicKey which can be used for // verifying signatures. PublicKey() ed25519.PublicKey }
PrivateAddress is the interface implemented by the two private address types: FsAddress, and EsAddress.
func NewPrivateAddress ¶ added in v0.4.0
func NewPrivateAddress(adrStr string) (PrivateAddress, error)
NewPrivateAddress parses adrStr and returns the correct address type as a PrivateAddress interface. If adrStr is not a private address then an "invalid prefix" error is returned. This is useful when the address type isn't known prior to parsing adrStr, but must be a private address. If the address type is known ahead of time, it is generally better to just use the appropriate concrete type.
type RCDPrivateKey ¶ added in v0.4.0
type RCDPrivateKey interface { // RCD returns the RCD corresponding to the private key. RCD() []byte // PrivateKey returns the ed25519.PrivateKey which can be used for // signing data. PrivateKey() ed25519.PrivateKey // PublicKey returns the ed25519.PublicKey which can be used for // verifying signatures. PublicKey() ed25519.PublicKey }
RCDPrivateKey is the interface implemented by the four SK Key types and the Fs Address type.
type SK1Key ¶ added in v0.4.0
SK1Key is the sk1 secret key for an identity.
func GenerateSK1Key ¶ added in v0.4.0
GenerateSK1Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.
func (SK1Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (SK1Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb6, 0xc9}.
func (SK1Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk1".
func (SK1Key) PrivateKey ¶ added in v0.4.0
func (key SK1Key) PrivateKey() ed25519.PrivateKey
PrivateKey returns the ed25519.PrivateKey for key.
func (SK1Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (SK1Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*SK1Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable sk1 key into key.
type SK2Key ¶ added in v0.4.0
SK2Key is the sk2 secret key for an identity.
func GenerateSK2Key ¶ added in v0.4.0
GenerateSK2Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.
func (SK2Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (SK2Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb6, 0xe7}.
func (SK2Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk2".
func (SK2Key) PrivateKey ¶ added in v0.4.0
func (key SK2Key) PrivateKey() ed25519.PrivateKey
PrivateKey returns the ed25519.PrivateKey for key.
func (SK2Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (SK2Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*SK2Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable sk2 key into key.
type SK3Key ¶ added in v0.4.0
SK3Key is the sk3 secret key for an identity.
func GenerateSK3Key ¶ added in v0.4.0
GenerateSK3Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.
func (SK3Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (SK3Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb7, 0x05}.
func (SK3Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk3".
func (SK3Key) PrivateKey ¶ added in v0.4.0
func (key SK3Key) PrivateKey() ed25519.PrivateKey
PrivateKey returns the ed25519.PrivateKey for key.
func (SK3Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (SK3Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*SK3Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable sk3 key into key.
type SK4Key ¶ added in v0.4.0
SK4Key is the sk4 secret key for an identity.
func GenerateSK4Key ¶ added in v0.4.0
GenerateSK4Key generates a secure random private Entry Credit address using crypto/rand.Random as the source of randomness.
func (SK4Key) MarshalJSON ¶ added in v0.4.0
MarshalJSON encodes key as a JSON string using key.String().
func (SK4Key) PrefixBytes ¶ added in v0.4.0
PrefixBytes returns the two byte prefix for the address type as a byte array. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns []byte{0x4d, 0xb7, 0x23}.
func (SK4Key) PrefixString ¶ added in v0.4.0
PrefixString returns the two prefix bytes for the address type as an encoded string. Note that the prefix for a given address type is always the same and does not depend on the address value. Returns "sk4".
func (SK4Key) PrivateKey ¶ added in v0.4.0
func (key SK4Key) PrivateKey() ed25519.PrivateKey
PrivateKey returns the ed25519.PrivateKey for key.
func (SK4Key) String ¶ added in v0.4.0
String encodes key into its human readable form: a base58check string with key.PrefixBytes().
func (SK4Key) Type ¶ added in v0.5.0
Type returns PrefixString() satisfies the pflag.Value interface.
func (*SK4Key) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON decodes a JSON string with a human readable sk4 key into key.
type SKKey ¶ added in v0.4.0
type SKKey interface { IDKey // SKKey returns the SKKey interface. IDxKeys return themselves. // Private SKxKeys compute the corresponding IDxKey. SKKey() SKKey // RCD returns the RCD corresponding to the private key. RCD() []byte // PrivateKey returns the ed25519.PrivateKey which can be used for // signing data. PrivateKey() ed25519.PrivateKey // PublicKey returns the ed25519.PublicKey which can be used for // verifying signatures. PublicKey() ed25519.PublicKey }
SKKey is the interface implemented by the four SK Key types.