Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file s.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openError_monad(** {2 Hash Types} *)(** The signature of an abstract hash type, as produced by functor
{!Make_Blake2B}. The {!t} type is abstracted for separating the
various kinds of hashes in the system at typing time. Each type is
equipped with functions to use it as is of as keys in the database
or in memory sets and maps. *)moduletypeMINIMAL_HASH=sigtypetvalname:stringvaltitle:stringvalpp:Format.formatter->t->unitvalpp_short:Format.formatter->t->unitincludeCompare.Swithtypet:=tvalhash_bytes:?key:Bytes.t->Bytes.tlist->t(** [hash_string ?key inputs] returns a hash.
Raises an [Assert_failure] if [String.length key > 64].
*)valhash_string:?key:string->stringlist->tvalzero:tendmoduletypeRAW_DATA=sigtypetvalsize:int(* in bytes *)valto_hex:t->Hex.tvalof_hex:Hex.t->ttzresultvalof_hex_opt:Hex.t->toptionvalof_hex_exn:Hex.t->tvalto_string:t->stringvalof_string:string->ttzresultvalof_string_opt:string->toptionvalof_string_exn:string->tvalto_bytes:t->Bytes.tvalof_bytes:Bytes.t->ttzresultvalof_bytes_opt:Bytes.t->toptionvalof_bytes_exn:Bytes.t->tendmoduletypeB58_DATA=sigtypetvalto_b58check:t->stringvalto_short_b58check:t->stringvalof_b58check:string->ttzresultvalof_b58check_exn:string->tvalof_b58check_opt:string->toptiontypeBase58.data+=Dataoftvalb58check_encoding:tBase58.encodingendmoduletypeENCODER=sigtypetvalencoding:tData_encoding.tvalrpc_arg:tTezos_rpc.Arg.tendmoduletypePVSS=sigtypeproofmoduleClear_share:sigtypetincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tendmoduleCommitment:sigtypetincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tendmoduleEncrypted_share:sigtypetincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tendmodulePublic_key:sigtypetvalpp:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tendmoduleSecret_key:sigtypetincludeENCODERwithtypet:=tvalto_public_key:t->Public_key.tendvalproof_encoding:proofData_encoding.tvaldealer_shares_and_proof:secret:Secret_key.t->threshold:int->public_keys:Public_key.tlist->Encrypted_share.tlist*Commitment.tlist*proofvalcheck_dealer_proof:Encrypted_share.tlist->Commitment.tlist->proof:proof->public_keys:Public_key.tlist->boolvalreveal_share:Encrypted_share.t->secret_key:Secret_key.t->public_key:Public_key.t->Clear_share.t*proofvalcheck_revealed_share:Encrypted_share.t->Clear_share.t->public_key:Public_key.t->proof->boolvalreconstruct:Clear_share.tlist->intlist->Public_key.tendmoduletypeINDEXES=sigtypetvalhash:t->intvalseeded_hash:int->t->intvalto_path:t->stringlist->stringlistvalof_path:stringlist->toptionvalof_path_exn:stringlist->tvalprefix_path:string->stringlistvalpath_length:intmoduleSet:sigincludeSet.Swithtypeelt=tvalrandom_elt:t->eltvalencoding:tData_encoding.tendmoduleMap:sigincludeMap.Swithtypekey=tvalencoding:'aData_encoding.t->'atData_encoding.tendmoduleTable:sigincludeHashtbl.SeededSwithtypekey=tvalencoding:'aData_encoding.t->'atData_encoding.tendmoduleError_table:sigincludeTezos_error_monad.TzLwtreslib.Hashtbl.S_ESwithtypekey=tendmoduleWeakRingTable:sigincludeAches.Vache.MAPwithtypekey=tvalencoding:'aData_encoding.t->'atData_encoding.tendendmoduletypeHASH=sigincludeMINIMAL_HASHincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tincludeINDEXESwithtypet:=tendmoduletypeMERKLE_TREE=sig(** The element type [elt] of the Merkle tree. *)typeelt(** [elt_bytes x] returns the byte sequence representation of the
element [x]. *)valelt_bytes:elt->Bytes.tincludeHASH(** [compute xs] computes a full binary tree from the list [xs].
In this tree the ith leaf (from left to right) is the ith element of the
list [xs]. If [xs] is the empty list, then the result is the empty tree. If the
length of [xs] is not a power of 2, then the tree is padded with leaves
containing the last element of [xs] such that a full tree is obtained.
Example: given the list [[1; 2; 3]], the tree
{v
/\
/ \
/\ /\
1 2 3 3
v}
is built.
*)valcompute:eltlist->t(** The [empty] Merkle tree. *)valempty:t(** A [path] to an element in a Merkle tree.
A [path] is either:
- [Left (p, r)], indicating that the element is in the left subtree,
from which the path [p] should be taken to find the element. [r] is
the left subtree where this branching decision is made.
- [Right (l, p)], indicating that the element is in the right subtree,
from which the path [p] should be taken to find the element. [l] is
the left subtree where this branching decision is made.
- [Op], indicating that the path traversal has reached the element.
Example:
{v
/\
/ \
/\ /\
4 5 6 7
v}
The path to the third leaf, containing [6] will be:
{v Right (node (leaf 4, leaf 5), Left (Op, leaf 7)) v}
Consequently, the path will contain all the information to reconstruct the
full tree, except the element to which the path lead.
*)typepath=Leftofpath*t|Rightoft*path|Op(** Encoding of a path. *)valpath_encoding:pathData_encoding.t(** Encoding of a path, with optional bound [max_length].
The encoding is bounded to [log2(max_length) * (size + 1) + 1] bytes. *)valbounded_path_encoding:?max_length:int->unit->pathData_encoding.t(** [compute_path xs i] computes the path to the [i]th leaf of the
Merkle tree computed from [xs], that will also contain the ith element
of [xs]. *)valcompute_path:eltlist->int->path(** [check_path p x] returns a pair [(t, i)] where [t] is the full
Merkle tree reconstructed from the path [t] with [x] at the last
position of the path, and [i] is the index of [x] in that tree.
*)valcheck_path:path->elt->t*intendmoduletypeCOMMON_SIGNATURE=sigmodulePublic_key_hash:sigtypetvalpp:Format.formatter->t->unitvalpp_short:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tincludeINDEXESwithtypet:=tvalzero:tmoduleLogging:sigvaltag:tTag.defendendmodulePublic_key:sigtypetvalpp:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tvalhash:t->Public_key_hash.tvalsize:t->int(* in bytes *)valof_bytes_without_validation:bytes->toptionendmoduleSecret_key:sigtypetvalpp:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tvalto_public_key:t->Public_key.tendtypetvalpp:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tendmoduletypeSIGNATURE=sigincludeCOMMON_SIGNATUREvalzero:ttypewatermark(** [sign ?watermark sk message] produce the signature of [message] (with
possibly [watermark]) using [sk].*)valsign:?watermark:watermark->Secret_key.t->Bytes.t->t(** [check pk ?watermark signature message] check that [signature] is the
signature produced by signing [message] (with possibly [watermark]) with
the secret key of [pk]. *)valcheck:?watermark:watermark->Public_key.t->t->Bytes.t->boolvalgenerate_key:?seed:Bytes.t->unit->Public_key_hash.t*Public_key.t*Secret_key.t(** [deterministic_nonce sk msg] returns a nonce that is determined
by [sk] and [msg] *)valdeterministic_nonce:Secret_key.t->Bytes.t->Bytes.t(** [deterministic_nonce_hash sk msg] returns the BLAKE2b hash of a nonce that
is determined by [sk] and [msg].
In other words, [Blake2b.digest (deterministic_nonce sk msg) =
deterministic_nonce_hash sk msg]
*)valdeterministic_nonce_hash:Secret_key.t->Bytes.t->Bytes.tendmoduletypeAGGREGATE_SIGNATURE=sigincludeSIGNATURE(** [agregate_check pk_msg_list signature] returns [true] if the [signature]
is a valid aggregate signature of the signatures produced by signing
message [msg] (with optional [watermark]) with the secret key of [pk] for
each element [(pk, watermark, msg)] of the list [pk_msg_list]. *)valaggregate_check:(Public_key.t*watermarkoption*bytes)list->t->bool(** [agregate_signature_opt sig_list] creates an aggregated signature using
the list of signatures [sig_list]. *)valaggregate_signature_opt:tlist->toptionendmoduletypeSPLIT_SIGNATURE=sigincludeSIGNATURE(** A signature prefix potentially carries data. *)typeprefix(** A splitted signature is a binary representation of a signature with a
fixed 64 bytes suffix and a possible prefix. *)typesplitted={prefix:prefixoption;suffix:Bytes.t}(** [split_signature s] splits the signature [s] into [{prefix; suffix}] where
suffix is the fixed 64 bytes suffix of [s] and prefix are the remaining
preceding bytes if any. *)valsplit_signature:t->splitted(** [of_splitted s] reconstructs a signature from a splitted one, if
possible. *)valof_splitted:splitted->toption(** Encoding for signature prefixes. *)valprefix_encoding:prefixData_encoding.tendmoduletypeFIELD=sigexceptionNot_in_fieldofBytes.ttypet(** The order of the finite field *)valorder:Z.t(** minimal number of bytes required to encode a value of the field. *)valsize_in_bytes:int(** [check_bytes bs] returns [true] if [bs] is a correct byte
representation of a field element *)valcheck_bytes:Bytes.t->bool(** The neutral element for the addition *)valzero:t(** The neutral element for the multiplication *)valone:t(** [add a b] returns [a + b mod order] *)valadd:t->t->t(** [mul a b] returns [a * b mod order] *)valmul:t->t->t(** [eq a b] returns [true] if [a = b mod order], else [false] *)valeq:t->t->bool(** [negate x] returns [-x mod order]. Equivalently, [negate x] returns the
unique [y] such that [x + y mod order = 0]
*)valnegate:t->t(** [inverse_exn x] returns [x^-1] if [x] is not [0], else raise
[Division_by_zero]
*)valinverse_exn:t->t(** [inverse_opt x] returns [x^-1] if [x] is not [0] as an option, else [None] *)valinverse_opt:t->toption(** [pow x n] returns [x^n] *)valpow:t->Z.t->t(** From a predefined bytes representation, construct a value t. It is not
required that to_bytes (of_bytes_exn t) = t.
Raise [Not_in_field] if the bytes do not represent an element in the field.
*)valof_bytes_exn:Bytes.t->t(** From a predefined bytes representation, construct a value t. It is not
required that to_bytes (Option.get (of_bytes_opt t)) = t. By default, little endian encoding
is used and the given element is modulo the prime order *)valof_bytes_opt:Bytes.t->toption(** Convert the value t to a bytes representation which can be used for
hashing for instance. It is not required that to_bytes (of_bytes_exn t) = t. By
default, little endian encoding is used, and length of the resulting bytes
may vary depending on the order.
*)valto_bytes:t->Bytes.tend(** Module type for the prime fields GF(p) *)moduletypePRIME_FIELD=sigincludeFIELD(** Actual number of bytes allocated for a value of type t *)valsize_in_memory:int(** [of_z x] builds an element t from the Zarith element [x]. [mod order] is
applied if [x >= order] or [x < 0]. *)valof_z:Z.t->t(** [to_z x] builds a Zarith element, using the decimal representation.
Arithmetic on the result can be done using the modular functions on
integers *)valto_z:t->Z.tendmoduletypeCURVE=sigexceptionNot_on_curveofBytes.t(** The type of the element in the elliptic curve *)typet(** Actual number of bytes allocated for a value of type t *)valsize_in_memory:int(** The size of a point representation, in bytes *)valsize_in_bytes:intmoduleScalar:FIELD(** Check if a point, represented as a byte array, is on the curve **)valcheck_bytes:Bytes.t->bool(** Attempt to construct a point from a byte array *)valof_bytes_opt:Bytes.t->toption(** Attempt to construct a point from a byte array.
Raise [Not_on_curve] if the point is not on the curve
*)valof_bytes_exn:Bytes.t->t(** Return a representation in bytes *)valto_bytes:t->Bytes.t(** Zero of the elliptic curve *)valzero:t(** A fixed generator of the elliptic curve *)valone:t(** Return the addition of two element *)valadd:t->t->t(** Double the element *)valdouble:t->t(** Return the opposite of the element *)valnegate:t->t(** Return [true] if the two elements are algebraically the same *)valeq:t->t->bool(** Multiply an element by a scalar *)valmul:t->Scalar.t->tend