diff --git a/src/lib_crypto_dal/cryptobox.mli b/src/lib_crypto_dal/cryptobox.mli index 17f594747de4b8be7268090764f384b4220c63cc..34f1bb8e55279a66c8f554641f0d3fac0d710e7b 100644 --- a/src/lib_crypto_dal/cryptobox.mli +++ b/src/lib_crypto_dal/cryptobox.mli @@ -60,7 +60,7 @@ open Cryptobox_intf code: we've chosen and implemented a technique to produce the proofs in time [O(n log n)] (see {{: https://eprint.iacr.org/2023/033.pdf}Fast amortized KZG proofs}). - + More diverse details about the formalization are provided here : https://hackmd.io/36XUZUo7QqK5Ub6GvZmgOg *) @@ -114,35 +114,12 @@ type error += Failed_to_load_trusted_setup of string (** [Invalid_precomputation_hash], thrown by {!load_precompute_shards_proofs}. *) type error += Invalid_precomputation_hash of (string, string) error_container -module Verifier : - VERIFIER - with type t = t - and type commitment = commitment - and type commitment_proof = commitment_proof - and type page_proof = page_proof - and type ('a, 'b) error_container = ('a, 'b) error_container - -include - VERIFIER - with type t := t - and type parameters := Dal_config.parameters - and type commitment := commitment - and type commitment_proof := commitment_proof - and type page_proof := page_proof - and type ('a, 'b) error_container := ('a, 'b) error_container - (** The primitives exposed in this modules require some preprocessing. This preprocessing generates data from an unknown secret. For the security of those primitives, it is important that the secret is unknown. *) type initialisation_parameters -module Commitment : sig - include COMMITMENT with type t = commitment - - val rpc_arg : commitment Resto.Arg.t -end - (** A slot is a byte sequence corresponding to some data. *) type slot = bytes @@ -224,13 +201,45 @@ val string_of_commit_error : (** A portion of the data represented by a polynomial. *) type share -(** Encoding of a share. *) -val share_encoding : share Data_encoding.t - (** A shard is share with its index (see {!val:shards_from_polynomial}). *) type shard = {index : int; share : share} +(** A proof that a shard belongs to some commitment. *) +type shard_proof + +module Verifier : + VERIFIER + with type t = t + and type commitment = commitment + and type commitment_proof = commitment_proof + and type page_proof = page_proof + and type ('a, 'b) error_container = ('a, 'b) error_container + and type share = share + and type shard = shard + and type shard_proof = shard_proof + +include + VERIFIER + with type t := t + and type parameters := Dal_config.parameters + and type commitment := commitment + and type commitment_proof := commitment_proof + and type page_proof := page_proof + and type ('a, 'b) error_container := ('a, 'b) error_container + and type share := share + and type shard := shard + and type shard_proof := shard_proof + +module Commitment : sig + include COMMITMENT with type t = commitment + + val rpc_arg : commitment Resto.Arg.t +end + +(** Encoding of a share. *) +val share_encoding : share Data_encoding.t + (** An encoding of a share. *) val shard_encoding : shard Data_encoding.t @@ -278,9 +287,6 @@ val polynomial_from_shards : The shards in the returned sequence have increasing indexes. *) val shards_from_polynomial : t -> polynomial -> shard Seq.t -(** A proof that a shard belongs to some commitment. *) -type shard_proof - (** An encoding of a shard proof. *) val shard_proof_encoding : shard_proof Data_encoding.t diff --git a/src/lib_crypto_dal/cryptobox_intf.ml b/src/lib_crypto_dal/cryptobox_intf.ml index 46338cc16567583c1f6298688f9056ca3ade4239..2248a25e7053d14018f9cb7276bcc98171edcd23 100644 --- a/src/lib_crypto_dal/cryptobox_intf.ml +++ b/src/lib_crypto_dal/cryptobox_intf.ml @@ -147,4 +147,29 @@ module type VERIFIER = sig | `Page_length_mismatch | `Page_index_out_of_range ] ) Result.t + + type share + + val share_encoding : share Data_encoding.t + + type shard = {index : int; share : share} + + val shard_encoding : shard Data_encoding.t + + type shard_proof + + val shard_proof_encoding : shard_proof Data_encoding.t + + val verify_shard : + t -> + commitment -> + shard -> + shard_proof -> + ( unit, + [> `Invalid_degree_strictly_less_than_expected of + (int, int) error_container + | `Invalid_shard + | `Shard_length_mismatch + | `Shard_index_out_of_range of string ] ) + Result.t end diff --git a/src/lib_protocol_environment/environment_V14.ml b/src/lib_protocol_environment/environment_V14.ml index 39dc9de68f3b02d36f7706798e851f9fec701feb..a945f1245d12e3a47299fc24e10b72df8f14861f 100644 --- a/src/lib_protocol_environment/environment_V14.ml +++ b/src/lib_protocol_environment/environment_V14.ml @@ -114,6 +114,10 @@ module type T = sig and type Dal.commitment_proof = Tezos_crypto_dal.Cryptobox.Verifier.commitment_proof and type Dal.page_proof = Tezos_crypto_dal.Cryptobox.Verifier.page_proof + and type Dal.share = Tezos_crypto_dal.Cryptobox.Verifier.share + and type Dal.shard = Tezos_crypto_dal.Cryptobox.Verifier.shard + and type Dal.shard_proof = + Tezos_crypto_dal.Cryptobox.Verifier.shard_proof and type Bounded.Non_negative_int32.t = Tezos_base.Bounded.Non_negative_int32.t and type Wasm_2_0_0.version = Tezos_scoru_wasm.Wasm_pvm_state.version diff --git a/src/lib_protocol_environment/environment_V14.mli b/src/lib_protocol_environment/environment_V14.mli index 43977a828e53c891328607e8c35708ad613443db..ad0ca9325de3f019c6e9cbc29ac5e15fe69187e6 100644 --- a/src/lib_protocol_environment/environment_V14.mli +++ b/src/lib_protocol_environment/environment_V14.mli @@ -114,6 +114,10 @@ module type T = sig and type Dal.commitment_proof = Tezos_crypto_dal.Cryptobox.Verifier.commitment_proof and type Dal.page_proof = Tezos_crypto_dal.Cryptobox.Verifier.page_proof + and type Dal.share = Tezos_crypto_dal.Cryptobox.Verifier.share + and type Dal.shard = Tezos_crypto_dal.Cryptobox.Verifier.shard + and type Dal.shard_proof = + Tezos_crypto_dal.Cryptobox.Verifier.shard_proof and type Bounded.Non_negative_int32.t = Tezos_base.Bounded.Non_negative_int32.t and type Wasm_2_0_0.version = Tezos_scoru_wasm.Wasm_pvm_state.version diff --git a/src/lib_protocol_environment/sigs/v14.ml b/src/lib_protocol_environment/sigs/v14.ml index 02dc213a40f4e696ce9c5681f84fb40daba4c9f1..1a0c58043a1af21baf16c9fc65dd745664297b90 100644 --- a/src/lib_protocol_environment/sigs/v14.ml +++ b/src/lib_protocol_environment/sigs/v14.ml @@ -12360,6 +12360,32 @@ val verify_page : page -> page_proof -> (bool, [> `Segment_index_out_of_range | `Page_length_mismatch]) Result.t + +type share + +val share_encoding : share Data_encoding.t + +type shard = {index : int; share : share} + +val shard_encoding : shard Data_encoding.t + +type shard_proof + +val shard_proof_encoding : shard_proof Data_encoding.t + +type ('a, 'b) error_container + +val verify_shard : + t -> + commitment -> + shard -> + shard_proof -> + ( unit, + [> `Invalid_degree_strictly_less_than_expected of (int, int) error_container + | `Invalid_shard + | `Shard_length_mismatch + | `Shard_index_out_of_range of string ] ) + Result.t end # 138 "v14.in.ml" diff --git a/src/lib_protocol_environment/sigs/v14/dal.mli b/src/lib_protocol_environment/sigs/v14/dal.mli index 649ec4b84938df8fa148a3c2bf9793cfc1574c7a..77014baac50c4e5c39228d09ee5b4c2053f453a0 100644 --- a/src/lib_protocol_environment/sigs/v14/dal.mli +++ b/src/lib_protocol_environment/sigs/v14/dal.mli @@ -115,3 +115,29 @@ val verify_page : page -> page_proof -> (bool, [> `Segment_index_out_of_range | `Page_length_mismatch]) Result.t + +type share + +val share_encoding : share Data_encoding.t + +type shard = {index : int; share : share} + +val shard_encoding : shard Data_encoding.t + +type shard_proof + +val shard_proof_encoding : shard_proof Data_encoding.t + +type ('a, 'b) error_container + +val verify_shard : + t -> + commitment -> + shard -> + shard_proof -> + ( unit, + [> `Invalid_degree_strictly_less_than_expected of (int, int) error_container + | `Invalid_shard + | `Shard_length_mismatch + | `Shard_index_out_of_range of string ] ) + Result.t