Typ
should continue to exist on the OCaml side (same philosophy as the JS side)
let exists typ ~checked ~compute =
let cvars = match has_witness state with
true ->
(* we run our closure ourselves *)
let as_prover_backup = get_as_prover state in
set_as_prover state true;
let val = compute state in
set_as_prover state as_prover_backup;
let (fields, aux) = typ.value_to_fields val in
(* this will store the value in the witness + return the correct cvars *)
compute_ocaml_witness state fields
false ->
(* this will allocated cvars and return them *)
compute_ocaml state typ.size_in_field_elements
in
let aux = typ.constraint_system_auxiliary () in
let var = typ.var_of_fields (cvars, aux) in
if checked then typ.check state var;
var
where we exported some Rust functions in OCaml:
val has_witness : state -> bool
val get_as_prover : state -> bool
val set_as_prover : state -> bool -> unit
val compute_ocaml_witness : state -> field array -> cvar array
val compute_ocaml : state -> int -> cvar array
'cvar
type variable to typ
as_prover
stuff in OCaml as well (since it's not really useful in Rust)
type run_state = {
state: rust_state,
as_prover: bool,
}
'run_state
type variable to places that need it'cvar
type variable we just discussed, and the 'field
type variable that has always existedcvar.ml
, remove run_state
, pass both through backend, see what needs fixingor
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing