Tezos_sapling.Rustzcashinclude Rustzcash_sig.Tval compare_diversifier_index : diversifier_index -> diversifier_index -> inttype zip32_expanded_spending_key = {depth : Stdlib.Bytes.t;parent_fvk_tag : Stdlib.Bytes.t;child_index : Stdlib.Bytes.t;chain_code : Stdlib.Bytes.t;expsk : expanded_spending_key;dk : Stdlib.Bytes.t;}type zip32_full_viewing_key = {depth : Stdlib.Bytes.t;parent_fvk_tag : Stdlib.Bytes.t;child_index : Stdlib.Bytes.t;chain_code : Stdlib.Bytes.t;fvk : full_viewing_key;dk : Stdlib.Bytes.t;}val to_nk : Stdlib.Bytes.t -> nkval to_ak : Stdlib.Bytes.t -> akval to_ask : Stdlib.Bytes.t -> askval to_nsk : Stdlib.Bytes.t -> nskval to_pkd : Stdlib.Bytes.t -> pkdval to_ovk : Stdlib.Bytes.t -> ovkval to_nullifier : Stdlib.Bytes.t -> nullifierval to_commitment : Stdlib.Bytes.t -> commitmentval to_symkey : Stdlib.Bytes.t -> symkeyval to_epk : Stdlib.Bytes.t -> epkval to_spend_sig : Stdlib.Bytes.t -> spend_sigval to_hash : Stdlib.Bytes.t -> hashval to_cv : Stdlib.Bytes.t -> cvval to_rk : Stdlib.Bytes.t -> rkval to_spend_proof : Stdlib.Bytes.t -> spend_proofval to_output_proof : Stdlib.Bytes.t -> output_proofval to_sighash : Stdlib.Bytes.t -> sighashval to_binding_sig : Stdlib.Bytes.t -> binding_sigval to_diversifier : Stdlib.Bytes.t -> diversifier optionval to_diversifier_index : Stdlib.Bytes.t -> diversifier_indexval to_ar : Stdlib.Bytes.t -> arval to_rcm : Stdlib.Bytes.t -> rcmval to_esk : Stdlib.Bytes.t -> eskval to_ivk : Stdlib.Bytes.t -> ivkval to_expanded_spending_key : Stdlib.Bytes.t -> expanded_spending_keyval to_zip32_expanded_spending_key :
Stdlib.Bytes.t ->
zip32_expanded_spending_keyval to_full_viewing_key : Stdlib.Bytes.t -> full_viewing_keyval to_zip32_full_viewing_key : Stdlib.Bytes.t -> zip32_full_viewing_keyval of_nk : nk -> Stdlib.Bytes.tval of_ak : ak -> Stdlib.Bytes.tval of_ask : ask -> Stdlib.Bytes.tval of_nsk : nsk -> Stdlib.Bytes.tval of_pkd : pkd -> Stdlib.Bytes.tval of_ovk : ovk -> Stdlib.Bytes.tval of_nullifier : nullifier -> Stdlib.Bytes.tval of_commitment : commitment -> Stdlib.Bytes.tval of_symkey : symkey -> Stdlib.Bytes.tval of_epk : epk -> Stdlib.Bytes.tval of_spend_sig : spend_sig -> Stdlib.Bytes.tval of_hash : hash -> Stdlib.Bytes.tval of_cv : cv -> Stdlib.Bytes.tval of_rk : rk -> Stdlib.Bytes.tval of_spend_proof : spend_proof -> Stdlib.Bytes.tval of_output_proof : output_proof -> Stdlib.Bytes.tval of_sighash : sighash -> Stdlib.Bytes.tval of_binding_sig : binding_sig -> Stdlib.Bytes.tval of_diversifier : diversifier -> Stdlib.Bytes.tval of_diversifier_index : diversifier_index -> Stdlib.Bytes.tval of_ar : ar -> Stdlib.Bytes.tval of_rcm : rcm -> Stdlib.Bytes.tval of_esk : esk -> Stdlib.Bytes.tval of_ivk : ivk -> Stdlib.Bytes.tval of_expanded_spending_key : expanded_spending_key -> Stdlib.Bytes.tval of_zip32_expanded_spending_key :
zip32_expanded_spending_key ->
Stdlib.Bytes.tval of_full_viewing_key : full_viewing_key -> Stdlib.Bytes.tval of_zip32_full_viewing_key : zip32_full_viewing_key -> Stdlib.Bytes.tval hash_of_commitment : commitment -> hashval commitment_of_hash : hash -> commitmentIn 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_filesFind 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.
Derives the spending/signing pk corresponding to a secret spending/signing sk
val check_diversifier : diversifier -> boolChecks that a potential diversifier respects the needed properties
val ivk_to_pkd : ivk -> diversifier -> pkdComputes a diversified pk that the payee gives to the payer offline.
val compute_nf :
diversifier ->
pkd ->
amount:int64 ->
rcm ->
ak ->
nk ->
position:int64 ->
nullifierComputes 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.
val compute_cm : diversifier -> pkd -> amount:int64 -> rcm -> commitmentComputes 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.
val ka_derivepublic : diversifier -> esk -> epkComputes 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
val proving_ctx_init : unit -> proving_ctxCreates 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
val proving_ctx_free : proving_ctx -> unitval with_proving_ctx : (proving_ctx -> 'a) -> 'aEvaluates 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.
val make_binding_sig : proving_ctx -> balance:int64 -> sighash -> binding_sigCreates 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_proofCreates proof and sig for an output
val spend_proof :
proving_ctx ->
ak ->
nsk ->
diversifier ->
rcm ->
ar ->
amount:int64 ->
root:hash ->
witness:Stdlib.Bytes.t ->
cv * rk * spend_proofCreates 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).
val verification_ctx_init : unit -> verification_ctxCreates 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
val verification_ctx_free : verification_ctx -> unitval with_verification_ctx : (verification_ctx -> 'a) -> 'aEvaluates 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_output :
verification_ctx ->
cv ->
commitment ->
epk ->
output_proof ->
boolval check_spend :
verification_ctx ->
cv ->
hash ->
nullifier ->
rk ->
spend_proof ->
spend_sig ->
sighash ->
boolval tree_uncommitted : hashval final_check : verification_ctx -> int64 -> binding_sig -> sighash -> boolval zip32_xsk_master : Stdlib.Bytes.t -> zip32_expanded_spending_keyval zip32_xfvk_address :
zip32_full_viewing_key ->
diversifier_index ->
(diversifier_index * diversifier * pkd) optionval zip32_xsk_derive :
zip32_expanded_spending_key ->
Stdlib.Int32.t ->
zip32_expanded_spending_keyval zip32_xfvk_derive :
zip32_full_viewing_key ->
Stdlib.Int32.t ->
zip32_full_viewing_key