package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65

doc/src/octez-libs.tezos-sapling/rustzcash_ctypes_bindings.ml.html

Source file rustzcash_ctypes_bindings.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
(*
  IMPORTANT:
  ocaml_bytes is translated into a C unsigned char* since ctypes 0.17.0
  https://github.com/ocamllabs/ocaml-ctypes/blob/0.17.0/CHANGES.md#ctypes-0170
  and commit: https://github.com/ocamllabs/ocaml-ctypes/commit/f13b5fc0736e226a134a880a366bd2c2f453d066

  char * and unsigned char * correspond to u8 in Rust, but c_uchar used in the
  binding is supposed to be an unsigned char in C.
*)
open Ctypes

module Bindings (F : Cstubs.FOREIGN) = struct
  open F

  let codeunit = uint8_t

  (* We don't load sprout's parameters.
     Parameters of type Rust `usize` are converted to OCaml `int` because they are only file paths.
     NULL is a void pointer.
     FIXME: ptr uchar is used for codeunit, which is uint8 on non WIN32
     machines. It is fine because unsigned char * is exactly uint8*. What about
     WIN32 machines?
     ptr uchar is used to give a NULL value using Ctypes.(from_voidp uchar null)
  *)
  let init_zksnark_params =
    foreign
      "librustzcash_init_zksnark_params"
      (ocaml_bytes @-> size_t @-> ocaml_bytes @-> size_t @-> ptr uchar
     @-> size_t @-> returning void)

  let nsk_to_nk =
    foreign
      "librustzcash_nsk_to_nk"
      (ocaml_bytes @-> ocaml_bytes @-> returning void)

  let ask_to_ak =
    foreign
      "librustzcash_ask_to_ak"
      (ocaml_bytes @-> ocaml_bytes @-> returning void)

  let crh_ivk =
    foreign
      "librustzcash_crh_ivk"
      (ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning void)

  let check_diversifier =
    foreign "librustzcash_check_diversifier" (ocaml_bytes @-> returning bool)

  let ivk_to_pkd =
    foreign
      "librustzcash_ivk_to_pkd"
      (ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  let sapling_generate_r =
    foreign "librustzcash_sapling_generate_r" (ocaml_bytes @-> returning void)

  let sapling_compute_nf =
    foreign
      "librustzcash_sapling_compute_nf"
      (ocaml_bytes @-> ocaml_bytes @-> uint64_t @-> ocaml_bytes @-> ocaml_bytes
     @-> ocaml_bytes @-> uint64_t @-> ocaml_bytes @-> returning bool)

  let sapling_compute_cm =
    foreign
      "librustzcash_sapling_compute_cmu"
      (bool @-> ocaml_bytes @-> ocaml_bytes @-> uint64_t @-> ocaml_bytes
     @-> ocaml_bytes @-> returning bool)

  let sapling_ka_agree =
    foreign
      "librustzcash_sapling_ka_agree"
      (bool @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  let sapling_ka_derivepublic =
    foreign
      "librustzcash_sapling_ka_derivepublic"
      (ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  let sapling_spend_sig =
    foreign
      "librustzcash_sapling_spend_sig"
      (ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes
     @-> returning bool)

  let merkle_hash =
    foreign
      "librustzcash_merkle_hash"
      (size_t @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning void)

  let to_scalar =
    foreign
      "librustzcash_to_scalar"
      (ocaml_bytes @-> ocaml_bytes @-> returning void)

  (* ZIP32 functions *)
  let zip32_xsk_master =
    foreign
      "librustzcash_zip32_sapling_xsk_master"
      (ocaml_bytes @-> size_t @-> ocaml_bytes @-> returning void)

  let zip32_xfvk_address =
    foreign
      "librustzcash_zip32_find_sapling_address"
      (ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes
     @-> ocaml_bytes @-> returning bool)

  let zip32_xsk_derive =
    foreign
      "librustzcash_zip32_sapling_xsk_derive"
      (ocaml_bytes @-> uint32_t @-> ocaml_bytes @-> returning void)

  let zip32_xfvk_derive =
    foreign
      "librustzcash_zip32_sapling_xfvk_derive"
      (ocaml_bytes @-> uint32_t @-> ocaml_bytes @-> returning bool)

  (* Prover *)
  let proving_ctx_init =
    foreign
      "librustzcash_sapling_proving_ctx_init"
      (void @-> returning (ptr void))

  let proving_ctx_free =
    foreign "librustzcash_sapling_proving_ctx_free" (ptr void @-> returning void)

  let sapling_spend_proof =
    foreign
      "librustzcash_sapling_spend_proof"
      (ptr void @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes
     @-> ocaml_bytes @-> uint64_t @-> ocaml_bytes @-> ocaml_bytes
     @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  let sapling_binding_sig =
    foreign
      "librustzcash_sapling_binding_sig"
      (ptr void @-> int64_t @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  let sapling_output_proof =
    foreign
      "librustzcash_sapling_output_proof"
      (ptr void @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> uint64_t
     @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  (* Verifier *)
  let verification_ctx_init =
    foreign
      "librustzcash_sapling_verification_ctx_init"
      (bool @-> returning (ptr void))

  let verification_ctx_free =
    foreign
      "librustzcash_sapling_verification_ctx_free"
      (ptr void @-> returning void)

  let sapling_check_spend =
    foreign
      "librustzcash_sapling_check_spend"
      (ptr void @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes
     @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)

  let sapling_check_output =
    foreign
      "librustzcash_sapling_check_output"
      (ptr void @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes @-> ocaml_bytes
     @-> returning bool)

  let sapling_final_check =
    foreign
      "librustzcash_sapling_final_check"
      (ptr void @-> int64_t @-> ocaml_bytes @-> ocaml_bytes @-> returning bool)
end
OCaml

Innovation. Community. Security.