package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-libs.tezos-sapling/Tezos_sapling/Rustzcash/index.html
Module Tezos_sapling.Rustzcash
Source
In principle the definition of a valid position depends on the data structure that holds it, so it should be defined in storage.ml. However librustzcash imposes a particular tree structure of depth 32, so we hardcode it here.
Raised by init_params
if it failed to find parameters.
The string list is the list of locations where they were looked up.
Location of parameter files for our instance of Groth16.
We are only using and loading sapling parameters.
val find_params :
?getenv_opt:(string -> string option) ->
?getcwd:(unit -> string) ->
?file_exists:(string -> bool) ->
unit ->
parameter_files
Find parameter files.
The parameters are searched in:
$XDG_DATA_HOME/.local/share/zcash-params
;$XDG_DATA_DIRS/zcash-params
(splitting on the:
character);$OPAM_SWITCH_PREFIX/share/zcash-params
;_opam/share/zcash-params
;$HOME/.zcash-params
;$HOME/.local/share/zcash-params
;/usr/local/share/zcash-params
;/usr/share/zcash-params
; in this order.
This function uses getenv_opt
, getcwd
and file_exists
from the Sys
module. You can use the corresponding optional arguments to override their behavior, for instance with a mock for testing purposes.
Load parameter files.
Derives the spending/signing pk corresponding to a secret spending/signing sk
Checks that a potential diversifier respects the needed properties
Computes a diversified pk that the payee gives to the payer offline.
val compute_nf :
diversifier ->
pkd ->
amount:int64 ->
rcm ->
ak ->
nk ->
position:int64 ->
nullifier
Computes a nullifier. The first int64 is the amount of the note, the second is the position you want it inserted in. The rcm should be the same as the one to compute cm and the spend or output proof, and should be generated using generate_r.
Computes a commitment. The int64 is the amount, and the rcm is the same than for the nullifier and output or spend proof. It should be generated at random using generate_r.
Computes the shared secret of a Diffie Hellman key exchange (on the JubJub curve) with base depending on the diversifier. For the sender the epk is the pkd of the receiver, the esk was generated by him using generate_r. For the receiver the epk is the one published by the sender, and the secret is his ivk.
Computes the ephemeral pk from the ephemeral sk for a Diffie Hellman key exchange. This is used by the sender. The esk should be generated using generate_r
Creates the spend sig for an input. The sighash argument is the hash of the input ie. cv,cm,... This has to be generated using generate_r
Creates and frees a proving context. The proving context has to be created before creating proofs for inputs and outputs. It is then used to create the binding sig, and freed. It is a rust pointer to a scalar and an elliptic curve point
Evaluates a function that needs a proving context. This function takes care of allocating and freeing it. The context should not escape the scope of the given function and should not be freed during its execution.
Creates the binding signature for a transaction. It is effectively a zk proof that the sum of the amounts of a list of inputs and outputs is the same as the given balance. The necessary information is stored in the proving context when creating the proofs for inputs and outputs. The proving context has to be freed after calling this function.
val output_proof :
proving_ctx ->
esk ->
diversifier ->
pkd ->
rcm ->
amount:int64 ->
cv * output_proof
Creates proof and sig for an output
val spend_proof :
proving_ctx ->
ak ->
nsk ->
diversifier ->
rcm ->
ar ->
amount:int64 ->
root:hash ->
witness:Bytes.t ->
cv * rk * spend_proof
Creates the zk proof and sig for an input. The first is the same as the one for the commitment and nullifier. The second one is the same as for the binding sig. This function can panic (e.g. if the arguments are not coherent).
Creates and frees a verifying context. The proving context has to be created before verifying proofs the inputs and outputs. It is then used to verify the binding sig, and freed. It is a rust pointer to an elliptic curve point
Evaluates a function that needs a verification context. This function takes care of allocating and freeing it. The context should not escape the scope of the given function and should not be freed during its execution.
val check_spend :
verification_ctx ->
cv ->
hash ->
nullifier ->
rk ->
spend_proof ->
spend_sig ->
sighash ->
bool
val zip32_xfvk_address :
zip32_full_viewing_key ->
diversifier_index ->
(diversifier_index * diversifier * pkd) option