Module Snarky_backendless.Request

Custom requests.

These allow checked computations to use information that isn't passed as arguments -- and hence isn't compiled into the proof. These can be used to include 'secret' information in computations which should be hidden from verifiers.

To add a new kind of request, extend t:

type _ Request.t += Foo : request_type -> result_type Request.t

When a checked computation comp makes a request (Snark_intf.Basic.request) using the new Foo constructor, you can attach a handler to respond to it with Snark_intf.Basic.handle:

let handled_comp = handle comp (fun (With {request; respond}) ->
  match request with
  | Foo data ->
    let value = (* ... *) in
    respond (Provide value)
  | _ -> unhandled)
type _ t = ..

The type of all requests. This is an open type: you can extend it with your own requests as needed.

type t +=
| Fail : 'a t

The fail request

type 'a req = 'a t
type response

The type of responses. Use respond to create a response from a Response.t.

val unhandled : response

Indicates an unhandled response. Equivalent to calling respond on Response.Unhandled.

module Response : sig ... end
type request =
| With : {
request : 'a t;
respond : 'a Response.t -> response;
} -> request
module Handler : sig ... end

Internal, used by Snark0.