Documentation ¶
Index ¶
- Constants
- type Client
- type ErrorServer
- type MockClient
- type Proof
- type ProofServerClient
- func (p *ProofServerClient) CalculateProof(ctx context.Context, zkInputs *common.ZKInputs) error
- func (p *ProofServerClient) Cancel(ctx context.Context) error
- func (p *ProofServerClient) GetProof(ctx context.Context) (*Proof, []*big.Int, error)
- func (p *ProofServerClient) WaitReady(ctx context.Context) error
- type PublicInputs
- type Status
- type StatusCode
Constants ¶
const ( // GET is an HTTP GET GET apiMethod = "GET" // POST is an HTTP POST with maybe JSON body POST apiMethod = "POST" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // Non-blocking CalculateProof(ctx context.Context, zkInputs *common.ZKInputs) error // Blocking. Returns the Proof and Public Data (public inputs) GetProof(ctx context.Context) (*Proof, []*big.Int, error) // Non-Blocking Cancel(ctx context.Context) error // Blocking WaitReady(ctx context.Context) error }
Client is the interface to a ServerProof that calculates zk proofs
type ErrorServer ¶
type ErrorServer struct { Status StatusCode `json:"status"` Message string `json:"msg"` }
ErrorServer is the return struct for an API error
type MockClient ¶
MockClient is a mock ServerProof to be used in tests. It doesn't calculate anything
func (*MockClient) CalculateProof ¶
CalculateProof sends the *common.ZKInputs to the ServerProof to compute the Proof
func (*MockClient) Cancel ¶
func (p *MockClient) Cancel(ctx context.Context) error
Cancel cancels any current proof computation
type Proof ¶
type Proof struct { PiA [3]*big.Int `json:"pi_a"` PiB [3][2]*big.Int `json:"pi_b"` PiC [3]*big.Int `json:"pi_c"` Protocol string `json:"protocol"` }
Proof TBD this type will be received from the proof server
func (*Proof) UnmarshalJSON ¶
UnmarshalJSON unmarshals the proof from a JSON encoded proof with the big ints as strings
type ProofServerClient ¶
type ProofServerClient struct { URL string // contains filtered or unexported fields }
ProofServerClient contains the data related to a ProofServerClient
func NewProofServerClient ¶
func NewProofServerClient(URL string, pollInterval time.Duration) *ProofServerClient
NewProofServerClient creates a new ServerProof
func (*ProofServerClient) CalculateProof ¶
CalculateProof sends the *common.ZKInputs to the ServerProof to compute the Proof
func (*ProofServerClient) Cancel ¶
func (p *ProofServerClient) Cancel(ctx context.Context) error
Cancel cancels any current proof computation
type PublicInputs ¶
PublicInputs are the public inputs of the proof
func (*PublicInputs) UnmarshalJSON ¶
func (p *PublicInputs) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON into the public inputs where the bigInts are in decimal as quoted strings
type Status ¶
type Status struct { Status StatusCode `json:"status"` Proof string `json:"proof"` PubData string `json:"pubData"` }
Status is the return struct for the status API endpoint
type StatusCode ¶
type StatusCode string
StatusCode is the status string of the ProofServer
const ( // StatusCodeAborted means prover is ready to take new proof. Previous // proof was aborted. StatusCodeAborted StatusCode = "aborted" // StatusCodeBusy means prover is busy computing proof. StatusCodeBusy StatusCode = "busy" // StatusCodeFailed means prover is ready to take new proof. Previous // proof failed StatusCodeFailed StatusCode = "failed" // StatusCodeSuccess means prover is ready to take new proof. Previous // proof succeeded StatusCodeSuccess StatusCode = "success" // StatusCodeUnverified means prover is ready to take new proof. // Previous proof was unverified StatusCodeUnverified StatusCode = "unverified" // StatusCodeUninitialized means prover is not initialized StatusCodeUninitialized StatusCode = "uninitialized" // StatusCodeUndefined means prover is in an undefined state. Most // likely is booting up. Keep trying StatusCodeUndefined StatusCode = "undefined" // StatusCodeInitializing means prover is initializing and not ready yet StatusCodeInitializing StatusCode = "initializing" // StatusCodeReady means prover initialized and ready to do first proof StatusCodeReady StatusCode = "ready" )
func (StatusCode) IsInitialized ¶
func (status StatusCode) IsInitialized() bool
IsInitialized returns true when the prover is initialized
func (StatusCode) IsReady ¶
func (status StatusCode) IsReady() bool
IsReady returns true when the prover is ready