Documentation ¶
Overview ¶
Client package is responsible for connecting to a server, and if wanted checking proofs of both the chain commitment and the inclusion of our logs in the commitment
Index ¶
- type AppendLogParameters
- type AppendLogReply
- type Client
- func (c *Client) AddForeignLog(statement *wire.ForeignStatement) error
- func (c *Client) AppendLog(idx uint64, logId [32]byte, statement []byte) error
- func (c *Client) AppendLogText(idx uint64, logId [32]byte, statement string) error
- func (c *Client) ClearCommitments() error
- func (c *Client) ExportLog(logId [32]byte) (*wire.ForeignStatement, error)
- func (c *Client) GetAllLogIDs() ([][32]byte, error)
- func (c *Client) GetBlockHeaderByHash(hash *chainhash.Hash) (*btcwire.BlockHeader, error)
- func (c *Client) GetCommitmentDetails(commitment [32]byte) (*wire.Commitment, error)
- func (c *Client) GetCommitmentHistory(sinceCommitment [32]byte) ([]*wire.Commitment, error)
- func (c *Client) GetForeignLogIDAndHash(statement *wire.ForeignStatement) ([32]byte, [32]byte, error)
- func (c *Client) GetLastCommittedLog(logId [32]byte) (int64, [32]byte, error)
- func (c *Client) GetLastHash(logId [32]byte) (int64, [32]byte, error)
- func (c *Client) GetLogCommitment(logId [32]byte, idx uint64) ([32]byte, error)
- func (c *Client) GetLogPreimage(logId [32]byte, idx uint64) (string, error)
- func (c *Client) GetProofForCommitment(commitment [32]byte, logIds [][]byte) (*mpt.PartialMPT, error)
- func (c *Client) IsCommitted(logId [32]byte, idx uint64) bool
- func (c *Client) IsForeignLog(logId [32]byte) bool
- func (c *Client) LogHasCommitment(logId [32]byte) bool
- func (c *Client) ReceiveLoop()
- func (c *Client) Reconnect()
- func (c *Client) RequestProof(logIds [][32]byte) (*mpt.PartialMPT, error)
- func (c *Client) Run(resync bool) error
- func (c *Client) SPVAskHeaders() error
- func (c *Client) SPVHeight() int32
- func (c *Client) SPVSynced() bool
- func (c *Client) SignedAppendLog(idx uint64, logId [32]byte, statement []byte) (*wire.SignedLogStatement, error)
- func (c *Client) StartLog(initialStatement []byte) ([32]byte, error)
- func (c *Client) StartLogText(initialStatement string) ([32]byte, error)
- func (c *Client) StartSPV() error
- func (c *Client) SubscribeProofUpdates() error
- func (c *Client) UnsubscribeProofUpdates() error
- func (c *Client) UsesKey(key []byte) bool
- type ErrorResponse
- type JsonCommitment
- type LogInfo
- type RpcServer
- func (s *RpcServer) AddForeignLog(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) AppendLog(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) Commitments(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) Export(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) Logs(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) Start() error
- func (s *RpcServer) StartLog(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) Status(w http.ResponseWriter, r *http.Request)
- func (s *RpcServer) VerifyOnce(w http.ResponseWriter, r *http.Request)
- type StartLogParameters
- type StartLogReply
- type StatusReply
- type VerificationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendLogParameters ¶
type AppendLogReply ¶
type AppendLogReply struct {
Success bool
}
type Client ¶
type Client struct { // You can set these function pointers to receive events // from the client (errors and proof updates) OnError func(error, *Client) OnProofUpdate func([]byte, *Client) // FastMode means you can log more than once every commitment. This is achieved // by forming a hash-chain of statements. The proof size will however grow linearly // with the amount of statements between the commitments, you will need to include // the hashes of all statements up until the next commitment FastMode bool // Ready indicates the client is ready to serve commands (only relevant for FullClient) Ready bool // When connecting using NewClient() the address is kept. When there's a failure // the server will disconnect us for, it will automatically reconnect. ReconnectOnFailure bool // Don't create actual signatures, just dummy ones - used for initialization during // benchmarks DummySignatures bool AckTimeout time.Duration ProofTimeout time.Duration // contains filtered or unexported fields }
func NewClient ¶
NewClient will create a new Client that connects to the server and port specified in addr
func NewClientWithConnection ¶
NewClientWithConnection creates a new b_verify client using the provided private key bytes and net.Conn
func (*Client) AddForeignLog ¶
func (c *Client) AddForeignLog(statement *wire.ForeignStatement) error
AddForeignLog will keep updating the logID's proofs for the given statement
func (*Client) AppendLogText ¶
AppendLogText is a convenience function called by the RPC server to append a particular piece of information to the log. This function will take care of hashing it before passing it to AppendLog. It will also keep the clear text (preimage) in our database for future verification purposes.
func (*Client) ClearCommitments ¶
ClearCommitments delets the client-side cache of the server commitments. This will trigger a resynchronization of the commitments and proofs.
func (*Client) ExportLog ¶
func (c *Client) ExportLog(logId [32]byte) (*wire.ForeignStatement, error)
ExportLog will create a ForeignStatement out of the last committed statement in the given log
func (*Client) GetAllLogIDs ¶
func (*Client) GetBlockHeaderByHash ¶
GetBlockHeaderByHash will return a single block header from the SPV data based on the blockhash
func (*Client) GetCommitmentDetails ¶
func (c *Client) GetCommitmentDetails(commitment [32]byte) (*wire.Commitment, error)
GetCommitmentDetails will request the server to send over commitment details for a single commitment. If commitment is an empty byte array, the details of the last commitment will be returned.
func (*Client) GetCommitmentHistory ¶
func (c *Client) GetCommitmentHistory(sinceCommitment [32]byte) ([]*wire.Commitment, error)
GetCommitmentHistory will request the server to send over commitment details for every commitment since sinceCommitment. If sinceCommitment is an empty byte array, all commitments will be returned.
func (*Client) GetForeignLogIDAndHash ¶
func (*Client) GetLastCommittedLog ¶
GetLastCommittedHash returns the last committed hash for the given log
func (*Client) GetLastHash ¶
GetLastHash returns the last known hash for the given log
func (*Client) GetLogCommitment ¶
func (*Client) GetLogPreimage ¶
func (*Client) GetProofForCommitment ¶
func (*Client) IsForeignLog ¶
IsFollowingLog returns true when the passed LogID is merely being followed by this client, and not being actively written to.
func (*Client) LogHasCommitment ¶
func (*Client) ReceiveLoop ¶
func (c *Client) ReceiveLoop()
ReceiveLoop will fetch new messages as they come in on the wire (from the server) and try to process them accordingly.
func (*Client) RequestProof ¶
func (c *Client) RequestProof(logIds [][32]byte) (*mpt.PartialMPT, error)
RequestProof asks the server for a full proof of the passed in LogIDs. These are the LogIDs returned from CreateLog() or CreateLogText(). The return value is a partial MPT that only contains the paths from these logs to the root.
func (*Client) Run ¶
Run will kick off the full client functionality, that also stores its key in a keyfile in the user's home directory, keep track of log statements and their proofs, as well as commitments and their merkle proof to the blockchain block headers. This is the "complete" functionality for b_verify.
func (*Client) SPVAskHeaders ¶
SPVAskHeaders will (re)initiate the header synchronization if we have the idea that we might have stale data, we can call this to talk to our known peers and fetch new headers.
func (*Client) SPVSynced ¶
SPVSynced returns true if there's no more headers to fetch for us (and we can assume we've synced up all the headers from the blockchain)
func (*Client) SignedAppendLog ¶
func (c *Client) SignedAppendLog(idx uint64, logId [32]byte, statement []byte) (*wire.SignedLogStatement, error)
SignedAppendLog is a convenience function to generate a SignedLogStatement message using the key in this client
func (*Client) StartLog ¶
StartLog will start a new log on the server. It will locally calculate the LogID, since that's deterministic. It will sign the CreateLog instruction with the client's key and then send it to the server. It will wait for the server to have acknowledged the log.
func (*Client) StartLogText ¶
StartLogText is a convenience function called by the RPC server to start a new log with a particular piece of information. This function will take care of hashing it before passing it to StartLog. It will also keep the clear text (preimage) in our database for future verification purposes.
func (*Client) StartSPV ¶
StartSPV will initiate the process of downloading headers from the blockchain to allow us to check SPV proofs for the commitment transactions
func (*Client) SubscribeProofUpdates ¶
SubscribeProofUpdates will tell the server that we want to receive delta proofs as soon as the server commits a new value to the chain. The server will then send us a ProofUpdate message automatically, which the client can read out by setting a function pointer to OnProofUpdate
func (*Client) UnsubscribeProofUpdates ¶
UnsubscribeProofUpdates will tell the server to stop sending us automatic proof updates. In that case, the proofs will have to be requested manually
type ErrorResponse ¶
type JsonCommitment ¶
type RpcServer ¶
type RpcServer struct {
// contains filtered or unexported fields
}
RpcServer runs a simple JSON based API for clients to start and maintain logs using the client
func (*RpcServer) AddForeignLog ¶
func (s *RpcServer) AddForeignLog(w http.ResponseWriter, r *http.Request)
AddForeignLog is an RPC method to instruct this client to keep updated proofs for the given log statement
func (*RpcServer) AppendLog ¶
func (s *RpcServer) AppendLog(w http.ResponseWriter, r *http.Request)
AppendLog is an RPC method to append to an existing log
func (*RpcServer) Commitments ¶
func (s *RpcServer) Commitments(w http.ResponseWriter, r *http.Request)
Commitments will return a list of server commitments
func (*RpcServer) Export ¶
func (s *RpcServer) Export(w http.ResponseWriter, r *http.Request)
Logs will return a list of known logs and their last statements and proofs
func (*RpcServer) Logs ¶
func (s *RpcServer) Logs(w http.ResponseWriter, r *http.Request)
Logs will return a list of known logs and their last statements and proofs
func (*RpcServer) StartLog ¶
func (s *RpcServer) StartLog(w http.ResponseWriter, r *http.Request)
StartLog is an RPC method to start a new log
func (*RpcServer) Status ¶
func (s *RpcServer) Status(w http.ResponseWriter, r *http.Request)
Status is an RPC method to fetch the status of the server
func (*RpcServer) VerifyOnce ¶
func (s *RpcServer) VerifyOnce(w http.ResponseWriter, r *http.Request)
type StartLogParameters ¶
type StartLogParameters struct {
InitialStatement string // The statement (in clear text) you wish to start the log with
}
type StartLogReply ¶
type StartLogReply struct {
LogID string // The Log ID (hex encoded bytes)
}