Library MonadVM.Rlp
File generated by rocq-of-ocaml
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import RocqOfOCaml.Settings.
From Stdlib Require Import Program.Wf.
Require MonadVM.Byte_string.
Require MonadVM.Result.
Require MonadVM.String.
Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
Require Import MonadExecutionSpecs.Termination.Rlp.
Require Import MonadVM.Support.ResultNotation.
Local Open Scope execution_result_scope.
Require Import RocqOfOCaml.Opaque.
Local Ltac _rocq_witness_type typ :=
let typ := eval hnf in typ in
lazymatch typ with
| list ?a ⇒ let a := _rocq_witness_type a in constr:(list a)
| option ?a ⇒ let a := _rocq_witness_type a in constr:(option a)
| prod ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(prod a b)
| sum ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(sum a b)
| ?a → ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(a → b)
| _ ⇒ typ
end.
Require Import RocqOfOCaml.Settings.
From Stdlib Require Import Program.Wf.
Require MonadVM.Byte_string.
Require MonadVM.Result.
Require MonadVM.String.
Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
Require Import MonadExecutionSpecs.Termination.Rlp.
Require Import MonadVM.Support.ResultNotation.
Local Open Scope execution_result_scope.
Require Import RocqOfOCaml.Opaque.
Local Ltac _rocq_witness_type typ :=
let typ := eval hnf in typ in
lazymatch typ with
| list ?a ⇒ let a := _rocq_witness_type a in constr:(list a)
| option ?a ⇒ let a := _rocq_witness_type a in constr:(option a)
| prod ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(prod a b)
| sum ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(sum a b)
| ?a → ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(a → b)
| _ ⇒ typ
end.
The type of RLP-encodable objects: either a byte string or a list of RLP-encodable objects. High-level types
define encoding and decoding functions into this type. YP (190), YP (191), YP (192)
The type of RLP-encodable objects: either a byte string or a list of RLP-encodable objects. High-level types
define encoding and decoding functions into this type. YP (190), YP (191), YP (192) The type of RLP-encodable objects: either a byte string or a list of RLP-encodable objects. High-level types
define encoding and decoding functions into this type. YP (190), YP (191), YP (192)
Recursive-length prefix encoding and decoding, as defined in YP Appendix B.
Fixpoint equal : t → t → Ppx_deriving_runtime.bool :=
let __1 : t → t → Ppx_deriving_runtime.bool :=
equal
in let __0
: MonadVM.Byte_string.Bytes.t → MonadVM.Byte_string.Bytes.t → bool :=
MonadVM.Byte_string.Bytes.equal in
fun (lhs : t) ⇒
fun (rhs : t) ⇒
match (lhs, rhs) with
| (MonadVM.Rlp.Bytes lhs0, MonadVM.Rlp.Bytes rhs0) ⇒ __0 lhs0 rhs0
| (MonadVM.Rlp.List lhs0, MonadVM.Rlp.List rhs0) ⇒
(let fix loop (x_value : list t) (y_value : list t) : bool :=
match (x_value, y_value) with
| ([], []) ⇒ true
| (Datatypes.cons a_value x_value, Datatypes.cons b_value y_value) ⇒
Ppx_deriving_runtime.op_andand (__1 a_value b_value)
(loop x_value y_value)
| _ ⇒ false
end in
fun (x_value : list t) ⇒ fun (y_value : list t) ⇒ loop x_value y_value)
lhs0 rhs0
| __ ⇒ false
end.
let __1 : t → t → Ppx_deriving_runtime.bool :=
equal
in let __0
: MonadVM.Byte_string.Bytes.t → MonadVM.Byte_string.Bytes.t → bool :=
MonadVM.Byte_string.Bytes.equal in
fun (lhs : t) ⇒
fun (rhs : t) ⇒
match (lhs, rhs) with
| (MonadVM.Rlp.Bytes lhs0, MonadVM.Rlp.Bytes rhs0) ⇒ __0 lhs0 rhs0
| (MonadVM.Rlp.List lhs0, MonadVM.Rlp.List rhs0) ⇒
(let fix loop (x_value : list t) (y_value : list t) : bool :=
match (x_value, y_value) with
| ([], []) ⇒ true
| (Datatypes.cons a_value x_value, Datatypes.cons b_value y_value) ⇒
Ppx_deriving_runtime.op_andand (__1 a_value b_value)
(loop x_value y_value)
| _ ⇒ false
end in
fun (x_value : list t) ⇒ fun (y_value : list t) ⇒ loop x_value y_value)
lhs0 rhs0
| __ ⇒ false
end.
Recursive-length prefix encoding and decoding, as defined in YP Appendix B.
Malformed encodings are ordinary errors, not runtime exceptions.
Inductive decode_error : Set :=
| Empty_input : decode_error
| Truncated_input : decode_error
| Non_canonical : decode_error
| Length_overflow : decode_error
| Trailing_bytes : decode_error.
Definition of_bytes (bs : MonadVM.Byte_string.Bytes.t) : t :=
MonadVM.Rlp.Bytes bs.
Definition of_bytes32 (bs : string) : t :=
MonadVM.Rlp.Bytes
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.to_bytes)
bs).
| Empty_input : decode_error
| Truncated_input : decode_error
| Non_canonical : decode_error
| Length_overflow : decode_error
| Trailing_bytes : decode_error.
Definition of_bytes (bs : MonadVM.Byte_string.Bytes.t) : t :=
MonadVM.Rlp.Bytes bs.
Definition of_bytes32 (bs : string) : t :=
MonadVM.Rlp.Bytes
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.to_bytes)
bs).
to_string t returns a human-readable representation of the given RLP structure t.
Fixpoint to_string (x_value : t) : string :=
match x_value with
| MonadVM.Rlp.Bytes bs ⇒
((RocqOfOCaml.OCamlFormat.sprintf
(CamlinternalFormatBasics.Format
(CamlinternalFormatBasics.String_literal "Bytes("""
(CamlinternalFormatBasics.String CamlinternalFormatBasics.No_padding
(CamlinternalFormatBasics.String_literal """)"
CamlinternalFormatBasics.End_of_format))) "Bytes(""%s"")")
(MonadVM.Byte_string.Bytes.to_hex_string bs)) : string)
| MonadVM.Rlp.List elts ⇒
((((RocqOfOCaml.OCamlFormat.sprintf
(CamlinternalFormatBasics.Format
(CamlinternalFormatBasics.String_literal "List("
(CamlinternalFormatBasics.String CamlinternalFormatBasics.No_padding
(CamlinternalFormatBasics.Char_literal ")" % char
CamlinternalFormatBasics.End_of_format))) "List(%s)")) :
string → string)
(MonadVM.String.concat ", " (RocqOfOCaml.OCamlList.map to_string elts))) :
string)
end.
match x_value with
| MonadVM.Rlp.Bytes bs ⇒
((RocqOfOCaml.OCamlFormat.sprintf
(CamlinternalFormatBasics.Format
(CamlinternalFormatBasics.String_literal "Bytes("""
(CamlinternalFormatBasics.String CamlinternalFormatBasics.No_padding
(CamlinternalFormatBasics.String_literal """)"
CamlinternalFormatBasics.End_of_format))) "Bytes(""%s"")")
(MonadVM.Byte_string.Bytes.to_hex_string bs)) : string)
| MonadVM.Rlp.List elts ⇒
((((RocqOfOCaml.OCamlFormat.sprintf
(CamlinternalFormatBasics.Format
(CamlinternalFormatBasics.String_literal "List("
(CamlinternalFormatBasics.String CamlinternalFormatBasics.No_padding
(CamlinternalFormatBasics.Char_literal ")" % char
CamlinternalFormatBasics.End_of_format))) "List(%s)")) :
string → string)
(MonadVM.String.concat ", " (RocqOfOCaml.OCamlList.map to_string elts))) :
string)
end.
be x encodes an integer as a big-endian byte array of minimal length. YP (195)
Definition _rocq_fallback_be_0 :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((string)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition _rocq_fallback_be_1 (x_value : int) :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((int)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | exact
_rocq_fallback_be_0 | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition _rocq_fallback_be_2 :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((ascii)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | exact
_rocq_fallback_be_0 | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition be (x_value : int) : string :=
let x_value := RocqOfOCaml.OCamlZ.of_int x_value in
let x_bytes :=
(RocqOfOCaml.OCamlInt.div
(H := RocqOfOCaml.Opaque.legacy_witness (_rocq_fallback_be_1 x_value)))
(RocqOfOCaml.OCamlInt.add (RocqOfOCaml.OCamlZ.numbits x_value) 7) 8 in
let x_le := RocqOfOCaml.OCamlZ.to_bits x_value in
let byte_i (i_value : int) : ascii :=
(MonadVM.String.get (_rocq_fallback_be_2)) x_le
(RocqOfOCaml.OCamlInt.sub (RocqOfOCaml.OCamlInt.sub x_bytes i_value) 1) in
(MonadVM.Byte_string.Bytes.init (_rocq_fallback_be_0)) x_bytes byte_i.
ltac:(let typ := constr:(ltac:(first [unshelve refine ((string)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition _rocq_fallback_be_1 (x_value : int) :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((int)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | exact
_rocq_fallback_be_0 | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition _rocq_fallback_be_2 :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((ascii)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | exact
_rocq_fallback_be_0 | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition be (x_value : int) : string :=
let x_value := RocqOfOCaml.OCamlZ.of_int x_value in
let x_bytes :=
(RocqOfOCaml.OCamlInt.div
(H := RocqOfOCaml.Opaque.legacy_witness (_rocq_fallback_be_1 x_value)))
(RocqOfOCaml.OCamlInt.add (RocqOfOCaml.OCamlZ.numbits x_value) 7) 8 in
let x_le := RocqOfOCaml.OCamlZ.to_bits x_value in
let byte_i (i_value : int) : ascii :=
(MonadVM.String.get (_rocq_fallback_be_2)) x_le
(RocqOfOCaml.OCamlInt.sub (RocqOfOCaml.OCamlInt.sub x_bytes i_value) 1) in
(MonadVM.Byte_string.Bytes.init (_rocq_fallback_be_0)) x_bytes byte_i.
decode_be bs decodes a big-endian byte array of minimal length as an integer. This is the inverse
of {!be}. If the input byte array is not of minimal length, Error Non_canonical is returned.
Definition _rocq_fallback_decode_be_0 :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((int)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition decode_be (bs : MonadVM.Byte_string.Bytes.t)
: sum Z.t decode_error :=
let bs_le := MonadVM.Byte_string.Bytes.reverse bs in
let num := RocqOfOCaml.OCamlZ.of_bits bs_le in
let significant_bytes :=
(RocqOfOCaml.OCamlInt.div
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_decode_be_0))
(RocqOfOCaml.OCamlInt.add (RocqOfOCaml.OCamlZ.numbits num) 7) 8 in
if Z.eqb significant_bytes (MonadVM.Byte_string.Bytes.length bs) then
((inl num) : sum Z.t decode_error)
else
((inr MonadVM.Rlp.Non_canonical) : sum Z.t decode_error).
Definition max_short_payload_len : int := 55.
Definition encode_payload
(payload : string) (long_payload_prefix : int) (short_payload_prefix : int)
: string :=
let len := MonadVM.Byte_string.Bytes.length payload in
let header :=
if Z.leb len max_short_payload_len then
MonadVM.Byte_string.Bytes.of_char
((RocqOfOCaml.OCamlChar.chr
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_be_2))
(RocqOfOCaml.OCamlInt.add short_payload_prefix len))
else
let len_bytes := be len in
let len_bytes_len := MonadVM.Byte_string.Bytes.length len_bytes in
String.append
(MonadVM.Byte_string.Bytes.of_char
((RocqOfOCaml.OCamlChar.chr
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_be_2))
(RocqOfOCaml.OCamlInt.add long_payload_prefix len_bytes_len)))
len_bytes in
String.append header payload.
Definition short_bytes_prefix : int := 128.
Definition long_bytes_prefix : int := 183.
Definition short_list_prefix : int := 192.
Definition long_list_prefix : int := 247.
ltac:(let typ := constr:(ltac:(first [unshelve refine ((int)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition decode_be (bs : MonadVM.Byte_string.Bytes.t)
: sum Z.t decode_error :=
let bs_le := MonadVM.Byte_string.Bytes.reverse bs in
let num := RocqOfOCaml.OCamlZ.of_bits bs_le in
let significant_bytes :=
(RocqOfOCaml.OCamlInt.div
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_decode_be_0))
(RocqOfOCaml.OCamlInt.add (RocqOfOCaml.OCamlZ.numbits num) 7) 8 in
if Z.eqb significant_bytes (MonadVM.Byte_string.Bytes.length bs) then
((inl num) : sum Z.t decode_error)
else
((inr MonadVM.Rlp.Non_canonical) : sum Z.t decode_error).
Definition max_short_payload_len : int := 55.
Definition encode_payload
(payload : string) (long_payload_prefix : int) (short_payload_prefix : int)
: string :=
let len := MonadVM.Byte_string.Bytes.length payload in
let header :=
if Z.leb len max_short_payload_len then
MonadVM.Byte_string.Bytes.of_char
((RocqOfOCaml.OCamlChar.chr
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_be_2))
(RocqOfOCaml.OCamlInt.add short_payload_prefix len))
else
let len_bytes := be len in
let len_bytes_len := MonadVM.Byte_string.Bytes.length len_bytes in
String.append
(MonadVM.Byte_string.Bytes.of_char
((RocqOfOCaml.OCamlChar.chr
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_be_2))
(RocqOfOCaml.OCamlInt.add long_payload_prefix len_bytes_len)))
len_bytes in
String.append header payload.
Definition short_bytes_prefix : int := 128.
Definition long_bytes_prefix : int := 183.
Definition short_list_prefix : int := 192.
Definition long_list_prefix : int := 247.
encode obj RLP-encodes the object obj into a byte array. YP (193)
Fixpoint encode (obj : t) : MonadVM.Byte_string.Bytes.t :=
match
(obj,
match obj with
| MonadVM.Rlp.Bytes bs ⇒
andb (Z.eqb (MonadVM.Byte_string.Bytes.length bs) 1)
(Z.ltb
(RocqOfOCaml.OCamlChar.code
((MonadVM.String.get (_rocq_fallback_be_2)) bs 0))
short_bytes_prefix)
| _ ⇒ false
end) with
| (MonadVM.Rlp.Bytes bs, true) ⇒ bs
| (MonadVM.Rlp.Bytes bs, _) ⇒
encode_payload bs long_bytes_prefix short_bytes_prefix
| (MonadVM.Rlp.List ls, _) ⇒
let bs :=
MonadVM.Byte_string.Bytes.concat MonadVM.Byte_string.Bytes.empty
(RocqOfOCaml.OCamlList.map encode ls) in
encode_payload bs long_list_prefix short_list_prefix
end.
match
(obj,
match obj with
| MonadVM.Rlp.Bytes bs ⇒
andb (Z.eqb (MonadVM.Byte_string.Bytes.length bs) 1)
(Z.ltb
(RocqOfOCaml.OCamlChar.code
((MonadVM.String.get (_rocq_fallback_be_2)) bs 0))
short_bytes_prefix)
| _ ⇒ false
end) with
| (MonadVM.Rlp.Bytes bs, true) ⇒ bs
| (MonadVM.Rlp.Bytes bs, _) ⇒
encode_payload bs long_bytes_prefix short_bytes_prefix
| (MonadVM.Rlp.List ls, _) ⇒
let bs :=
MonadVM.Byte_string.Bytes.concat MonadVM.Byte_string.Bytes.empty
(RocqOfOCaml.OCamlList.map encode ls) in
encode_payload bs long_list_prefix short_list_prefix
end.
decode_first bs decodes the first RLP-encoded object in the byte array bs and returns it and any
remaining bytes. Empty or malformed input returns Error.
Definition _rocq_fallback_decode_first_0 (bs : MonadVM.Byte_string.Bytes.t) :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((MonadVM.Byte_string.Bytes.t)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition _rocq_mutual_result_decode_first (_rocq_call :
sum MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) : Set :=
match _rocq_call with
| inl _ ⇒ sum (t × MonadVM.Byte_string.Bytes.t) decode_error
| inr (_) ⇒ sum (list t) decode_error
end.
Program Definition _rocq_mutual_dispatch_decode_first (_rocq_call :
sum MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) :
_rocq_mutual_result_decode_first _rocq_call :=
let _rocq_measure (_rocq_call : sum MonadVM.Byte_string.Bytes.t
MonadVM.Byte_string.Bytes.t) : nat := MonadExecutionSpecs.Termination.Rlp.decode_rank _rocq_call in
@Fix (sum MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) (ltof (sum
MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) _rocq_measure) (well_founded_ltof (sum
MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) _rocq_measure) (fun _rocq_call ⇒ _rocq_mutual_result_decode_first _rocq_call) (fun
_rocq_call _rocq_recurse ⇒
match _rocq_call as _rocq_call_view return (_rocq_call = _rocq_call_view → _rocq_mutual_result_decode_first _rocq_call_view) with
| inl _rocq_state ⇒ fun _rocq_call_eq ⇒
let bs := _rocq_state in
let len := MonadVM.Byte_string.Bytes.length bs in
let* function_parameter :=
MonadVM.Result.ensure (Z.gtb len 0) MonadVM.Rlp.Empty_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let tag :=
RocqOfOCaml.OCamlChar.code
((MonadVM.String.get (_rocq_fallback_be_2)) bs 0) in
let* function_parameter :=
let _rocq_match_scrutinee :=
(tag,
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
Z.ltb b_value short_bytes_prefix
end eq_refl),
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
andb (Z.geb b_value short_bytes_prefix)
(Z.leb b_value long_bytes_prefix)
end eq_refl),
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
andb (Z.gtb b_value long_bytes_prefix)
(Z.ltb b_value short_list_prefix)
end eq_refl),
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
andb (Z.geb b_value short_list_prefix)
(Z.leb b_value long_list_prefix)
end eq_refl)) in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| (b_value, true, _, _, _) ⇒ fun _rocq_match_eq ⇒
((inl (0, 1)) : sum (int × int) decode_error)
| (b_value, _, true, _, _) ⇒ fun _rocq_match_eq ⇒
let len := RocqOfOCaml.OCamlInt.sub b_value short_bytes_prefix in
let* function_parameter :=
MonadVM.Result.ensure
(orb (RocqOfOCaml.OCamlInt.not_equal len 1)
(Z.gtb (MonadVM.Byte_string.Bytes.length bs) 1))
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let* function_parameter :=
MonadVM.Result.ensure
(orb (RocqOfOCaml.OCamlInt.not_equal len 1)
(Z.geb
(RocqOfOCaml.OCamlChar.code
((MonadVM.String.get (_rocq_fallback_be_2)) bs 1))
short_bytes_prefix)) MonadVM.Rlp.Non_canonical in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
((inl (1, len)) : sum (int × int) decode_error)
end eq_refl
end eq_refl
| (b_value, _, _, true, _) ⇒ fun _rocq_match_eq ⇒
let payload_len_len :=
RocqOfOCaml.OCamlInt.sub b_value long_bytes_prefix in
let* function_parameter :=
MonadVM.Result.ensure (Z.ltb payload_len_len len)
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let* payload_len :=
decode_be
((MonadVM.Byte_string.Bytes.sub
((_rocq_fallback_decode_first_0 bs))) bs 1 payload_len_len)
in
let* function_parameter :=
MonadVM.Result.ensure (RocqOfOCaml.OCamlZ.fits_int payload_len)
MonadVM.Rlp.Length_overflow in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let payload_len :=
(RocqOfOCaml.OCamlZ.to_int
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_decode_be_0))
payload_len in
let* function_parameter :=
MonadVM.Result.ensure
(Z.gtb payload_len max_short_payload_len)
MonadVM.Rlp.Non_canonical in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
((inl
((RocqOfOCaml.OCamlInt.add 1 payload_len_len), payload_len))
: sum (int × int) decode_error)
end eq_refl
end eq_refl
end eq_refl
| (b_value, _, _, _, true) ⇒ fun _rocq_match_eq ⇒
((inl (1, (RocqOfOCaml.OCamlInt.sub b_value short_list_prefix))) :
sum (int × int) decode_error)
| (b_value, _, _, _, _) ⇒ fun _rocq_match_eq ⇒
let payload_len_len :=
RocqOfOCaml.OCamlInt.sub b_value long_list_prefix in
let* function_parameter :=
MonadVM.Result.ensure (Z.ltb payload_len_len len)
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let* payload_len :=
decode_be
((MonadVM.Byte_string.Bytes.sub
((_rocq_fallback_decode_first_0 bs))) bs 1 payload_len_len)
in
let* function_parameter :=
MonadVM.Result.ensure (RocqOfOCaml.OCamlZ.fits_int payload_len)
MonadVM.Rlp.Length_overflow in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let payload_len :=
(RocqOfOCaml.OCamlZ.to_int
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_decode_be_0))
payload_len in
let* function_parameter :=
MonadVM.Result.ensure
(Z.gtb payload_len max_short_payload_len)
MonadVM.Rlp.Non_canonical in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
((inl
((RocqOfOCaml.OCamlInt.add 1 payload_len_len), payload_len))
: sum (int × int) decode_error)
end eq_refl
end eq_refl
end eq_refl
end eq_refl in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| (payload_start, payload_len) ⇒ fun _rocq_match_eq ⇒
let* function_parameter :=
MonadVM.Result.ensure
(andb (Z.leb payload_start len)
(Z.leb payload_len (RocqOfOCaml.OCamlInt.sub len payload_start)))
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let payload :=
(MonadVM.Byte_string.Bytes.sub (_rocq_fallback_be_0)) bs
payload_start payload_len in
let rest :=
(MonadVM.Byte_string.Bytes.sub (_rocq_fallback_be_0)) bs
(RocqOfOCaml.OCamlInt.add payload_start payload_len)
(RocqOfOCaml.OCamlInt.sub
(RocqOfOCaml.OCamlInt.sub len payload_start) payload_len) in
match Z.ltb tag short_list_prefix as _rocq_guard return
(Z.ltb tag short_list_prefix = _rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒
((inl ((MonadVM.Rlp.Bytes payload), rest)) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
match Z.ltb (MonadVM.Byte_string.Bytes.length payload) len as
_rocq_guard return
(Z.ltb (MonadVM.Byte_string.Bytes.length payload) len =
_rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒
let* objects :=
_rocq_recurse (inr payload)
ltac:(MonadExecutionSpecs.Termination.Rlp.solve_decode_decrease)
in
((inl ((MonadVM.Rlp.List objects), rest)) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
((inr MonadVM.Rlp.Truncated_input) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error)
end eq_refl
end eq_refl
end eq_refl
end eq_refl
end eq_refl
| inr (_rocq_state) ⇒ fun _rocq_call_eq ⇒
let bs := _rocq_state in
match Z.eqb (MonadVM.Byte_string.Bytes.length bs) 0 as _rocq_guard return
(Z.eqb (MonadVM.Byte_string.Bytes.length bs) 0 = _rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒ ((inl nil) : sum (list t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
let* function_parameter :=
_rocq_recurse (inl bs)
ltac:(MonadExecutionSpecs.Termination.Rlp.solve_decode_decrease) in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| (fst, rest) ⇒ fun _rocq_match_eq ⇒
match
Z.ltb (MonadVM.Byte_string.Bytes.length rest)
(MonadVM.Byte_string.Bytes.length bs) as _rocq_guard return
(Z.ltb (MonadVM.Byte_string.Bytes.length rest)
(MonadVM.Byte_string.Bytes.length bs) = _rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒
let* objects :=
_rocq_recurse (inr rest)
ltac:(MonadExecutionSpecs.Termination.Rlp.solve_decode_decrease)
in
((inl (Datatypes.cons fst objects)) : sum (list t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
((inr MonadVM.Rlp.Truncated_input) : sum (list t) decode_error)
end eq_refl
end eq_refl
end eq_refl
end eq_refl) _rocq_call.
Definition decode_first (bs : MonadVM.Byte_string.Bytes.t) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error :=
_rocq_mutual_dispatch_decode_first (inl bs).
Definition decode_all (bs : MonadVM.Byte_string.Bytes.t) :
sum (list t) decode_error := _rocq_mutual_dispatch_decode_first (inr bs).
ltac:(let typ := constr:(ltac:(first [unshelve refine ((MonadVM.Byte_string.Bytes.t)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition _rocq_mutual_result_decode_first (_rocq_call :
sum MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) : Set :=
match _rocq_call with
| inl _ ⇒ sum (t × MonadVM.Byte_string.Bytes.t) decode_error
| inr (_) ⇒ sum (list t) decode_error
end.
Program Definition _rocq_mutual_dispatch_decode_first (_rocq_call :
sum MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) :
_rocq_mutual_result_decode_first _rocq_call :=
let _rocq_measure (_rocq_call : sum MonadVM.Byte_string.Bytes.t
MonadVM.Byte_string.Bytes.t) : nat := MonadExecutionSpecs.Termination.Rlp.decode_rank _rocq_call in
@Fix (sum MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) (ltof (sum
MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) _rocq_measure) (well_founded_ltof (sum
MonadVM.Byte_string.Bytes.t MonadVM.Byte_string.Bytes.t) _rocq_measure) (fun _rocq_call ⇒ _rocq_mutual_result_decode_first _rocq_call) (fun
_rocq_call _rocq_recurse ⇒
match _rocq_call as _rocq_call_view return (_rocq_call = _rocq_call_view → _rocq_mutual_result_decode_first _rocq_call_view) with
| inl _rocq_state ⇒ fun _rocq_call_eq ⇒
let bs := _rocq_state in
let len := MonadVM.Byte_string.Bytes.length bs in
let* function_parameter :=
MonadVM.Result.ensure (Z.gtb len 0) MonadVM.Rlp.Empty_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let tag :=
RocqOfOCaml.OCamlChar.code
((MonadVM.String.get (_rocq_fallback_be_2)) bs 0) in
let* function_parameter :=
let _rocq_match_scrutinee :=
(tag,
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
Z.ltb b_value short_bytes_prefix
end eq_refl),
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
andb (Z.geb b_value short_bytes_prefix)
(Z.leb b_value long_bytes_prefix)
end eq_refl),
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
andb (Z.gtb b_value long_bytes_prefix)
(Z.ltb b_value short_list_prefix)
end eq_refl),
(let _rocq_match_scrutinee := tag in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| b_value ⇒ fun _rocq_match_eq ⇒
andb (Z.geb b_value short_list_prefix)
(Z.leb b_value long_list_prefix)
end eq_refl)) in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| (b_value, true, _, _, _) ⇒ fun _rocq_match_eq ⇒
((inl (0, 1)) : sum (int × int) decode_error)
| (b_value, _, true, _, _) ⇒ fun _rocq_match_eq ⇒
let len := RocqOfOCaml.OCamlInt.sub b_value short_bytes_prefix in
let* function_parameter :=
MonadVM.Result.ensure
(orb (RocqOfOCaml.OCamlInt.not_equal len 1)
(Z.gtb (MonadVM.Byte_string.Bytes.length bs) 1))
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let* function_parameter :=
MonadVM.Result.ensure
(orb (RocqOfOCaml.OCamlInt.not_equal len 1)
(Z.geb
(RocqOfOCaml.OCamlChar.code
((MonadVM.String.get (_rocq_fallback_be_2)) bs 1))
short_bytes_prefix)) MonadVM.Rlp.Non_canonical in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
((inl (1, len)) : sum (int × int) decode_error)
end eq_refl
end eq_refl
| (b_value, _, _, true, _) ⇒ fun _rocq_match_eq ⇒
let payload_len_len :=
RocqOfOCaml.OCamlInt.sub b_value long_bytes_prefix in
let* function_parameter :=
MonadVM.Result.ensure (Z.ltb payload_len_len len)
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let* payload_len :=
decode_be
((MonadVM.Byte_string.Bytes.sub
((_rocq_fallback_decode_first_0 bs))) bs 1 payload_len_len)
in
let* function_parameter :=
MonadVM.Result.ensure (RocqOfOCaml.OCamlZ.fits_int payload_len)
MonadVM.Rlp.Length_overflow in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let payload_len :=
(RocqOfOCaml.OCamlZ.to_int
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_decode_be_0))
payload_len in
let* function_parameter :=
MonadVM.Result.ensure
(Z.gtb payload_len max_short_payload_len)
MonadVM.Rlp.Non_canonical in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
((inl
((RocqOfOCaml.OCamlInt.add 1 payload_len_len), payload_len))
: sum (int × int) decode_error)
end eq_refl
end eq_refl
end eq_refl
| (b_value, _, _, _, true) ⇒ fun _rocq_match_eq ⇒
((inl (1, (RocqOfOCaml.OCamlInt.sub b_value short_list_prefix))) :
sum (int × int) decode_error)
| (b_value, _, _, _, _) ⇒ fun _rocq_match_eq ⇒
let payload_len_len :=
RocqOfOCaml.OCamlInt.sub b_value long_list_prefix in
let* function_parameter :=
MonadVM.Result.ensure (Z.ltb payload_len_len len)
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let* payload_len :=
decode_be
((MonadVM.Byte_string.Bytes.sub
((_rocq_fallback_decode_first_0 bs))) bs 1 payload_len_len)
in
let* function_parameter :=
MonadVM.Result.ensure (RocqOfOCaml.OCamlZ.fits_int payload_len)
MonadVM.Rlp.Length_overflow in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let payload_len :=
(RocqOfOCaml.OCamlZ.to_int
(H := RocqOfOCaml.Opaque.legacy_witness _rocq_fallback_decode_be_0))
payload_len in
let* function_parameter :=
MonadVM.Result.ensure
(Z.gtb payload_len max_short_payload_len)
MonadVM.Rlp.Non_canonical in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
((inl
((RocqOfOCaml.OCamlInt.add 1 payload_len_len), payload_len))
: sum (int × int) decode_error)
end eq_refl
end eq_refl
end eq_refl
end eq_refl in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| (payload_start, payload_len) ⇒ fun _rocq_match_eq ⇒
let* function_parameter :=
MonadVM.Result.ensure
(andb (Z.leb payload_start len)
(Z.leb payload_len (RocqOfOCaml.OCamlInt.sub len payload_start)))
MonadVM.Rlp.Truncated_input in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| _ ⇒ fun _rocq_match_eq ⇒
let payload :=
(MonadVM.Byte_string.Bytes.sub (_rocq_fallback_be_0)) bs
payload_start payload_len in
let rest :=
(MonadVM.Byte_string.Bytes.sub (_rocq_fallback_be_0)) bs
(RocqOfOCaml.OCamlInt.add payload_start payload_len)
(RocqOfOCaml.OCamlInt.sub
(RocqOfOCaml.OCamlInt.sub len payload_start) payload_len) in
match Z.ltb tag short_list_prefix as _rocq_guard return
(Z.ltb tag short_list_prefix = _rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒
((inl ((MonadVM.Rlp.Bytes payload), rest)) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
match Z.ltb (MonadVM.Byte_string.Bytes.length payload) len as
_rocq_guard return
(Z.ltb (MonadVM.Byte_string.Bytes.length payload) len =
_rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒
let* objects :=
_rocq_recurse (inr payload)
ltac:(MonadExecutionSpecs.Termination.Rlp.solve_decode_decrease)
in
((inl ((MonadVM.Rlp.List objects), rest)) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
((inr MonadVM.Rlp.Truncated_input) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error)
end eq_refl
end eq_refl
end eq_refl
end eq_refl
end eq_refl
| inr (_rocq_state) ⇒ fun _rocq_call_eq ⇒
let bs := _rocq_state in
match Z.eqb (MonadVM.Byte_string.Bytes.length bs) 0 as _rocq_guard return
(Z.eqb (MonadVM.Byte_string.Bytes.length bs) 0 = _rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒ ((inl nil) : sum (list t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
let* function_parameter :=
_rocq_recurse (inl bs)
ltac:(MonadExecutionSpecs.Termination.Rlp.solve_decode_decrease) in
let _rocq_match_scrutinee := function_parameter in
match _rocq_match_scrutinee as _rocq_match_view return
(_rocq_match_scrutinee = _rocq_match_view → _) with
| (fst, rest) ⇒ fun _rocq_match_eq ⇒
match
Z.ltb (MonadVM.Byte_string.Bytes.length rest)
(MonadVM.Byte_string.Bytes.length bs) as _rocq_guard return
(Z.ltb (MonadVM.Byte_string.Bytes.length rest)
(MonadVM.Byte_string.Bytes.length bs) = _rocq_guard → _) with
| true ⇒ fun _rocq_guard_eq ⇒
let* objects :=
_rocq_recurse (inr rest)
ltac:(MonadExecutionSpecs.Termination.Rlp.solve_decode_decrease)
in
((inl (Datatypes.cons fst objects)) : sum (list t) decode_error)
| false ⇒ fun _rocq_guard_eq ⇒
((inr MonadVM.Rlp.Truncated_input) : sum (list t) decode_error)
end eq_refl
end eq_refl
end eq_refl
end eq_refl) _rocq_call.
Definition decode_first (bs : MonadVM.Byte_string.Bytes.t) :
sum (t × MonadVM.Byte_string.Bytes.t) decode_error :=
_rocq_mutual_dispatch_decode_first (inl bs).
Definition decode_all (bs : MonadVM.Byte_string.Bytes.t) :
sum (list t) decode_error := _rocq_mutual_dispatch_decode_first (inr bs).
decode bs behaves as decode_first bs except the input bs must contain exactly one RLP-encoded object,
otherwise Error Trailing_bytes is returned.
Definition decode (bytes_value : MonadVM.Byte_string.Bytes.t)
: sum t decode_error :=
let* '(obj, rest) := decode_first bytes_value in
if Z.eqb (MonadVM.Byte_string.Bytes.length rest) 0 then
((inl obj) : sum t decode_error)
else
((inr MonadVM.Rlp.Trailing_bytes) : sum t decode_error).
Definition op_eq : t → t → Ppx_deriving_runtime.bool := equal.
Definition op_ltgt (x_value : t) (y_value : t) : bool :=
negb (equal x_value y_value).
: sum t decode_error :=
let* '(obj, rest) := decode_first bytes_value in
if Z.eqb (MonadVM.Byte_string.Bytes.length rest) 0 then
((inl obj) : sum t decode_error)
else
((inr MonadVM.Rlp.Trailing_bytes) : sum t decode_error).
Definition op_eq : t → t → Ppx_deriving_runtime.bool := equal.
Definition op_ltgt (x_value : t) (y_value : t) : bool :=
negb (equal x_value y_value).