Library MonadVM.Ec.Secp256r1

File generated by rocq-of-ocaml
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import RocqOfOCaml.Settings.

Require Import MonadVM.Support.UintN.
Require MonadVM.Ec.Algebra.
Require MonadVM.Ec.Curve.
Require MonadVM.Numeric.
Require MonadVM.Option.
Require MonadVM.String.

Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
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.
Definition p_value : MonadVM.Support.UintN.t :=
  MonadVM.Support.UintN.of_string
    "0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff".

Definition q_value : MonadVM.Support.UintN.t :=
  MonadVM.Support.UintN.of_string
    "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551".

Definition curve_order : MonadVM.Support.UintN.t := q_value.

Definition F_p_fargs :=
  MonadVM.Ec.Algebra.Prime_field.Build_FArgs
    (let modulus := MonadVM.Support.UintN.as_signed p_value in
    ltac:(refine (_ :
      MonadVM.Ec.Algebra.Prime_field_Mod_signature); constructor; [refine (modulus)]; shelve)).

Definition F_p :
  MonadVM.Ec.Algebra.Prime_field.Prime_field_result (_fargs := F_p_fargs) :=
  (MonadVM.Ec.Algebra.Prime_field.functor (_fargs := (F_p_fargs ))).

Definition F_q_fargs :=
  MonadVM.Ec.Algebra.Prime_field.Build_FArgs
    (let modulus := MonadVM.Support.UintN.as_signed q_value in
    ltac:(refine (_ :
      MonadVM.Ec.Algebra.Prime_field_Mod_signature); constructor; [refine (modulus)]; shelve)).

Definition F_q :
  MonadVM.Ec.Algebra.Prime_field.Prime_field_result (_fargs := F_q_fargs) :=
  (MonadVM.Ec.Algebra.Prime_field.functor (_fargs := (F_q_fargs ))).

Definition C_1_fargs :=
  MonadVM.Ec.Curve.Make.Build_FArgs ltac:(refine (_ :
    MonadVM.Ec.Algebra.FIELD
      (t := F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.t))); constructor; [refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_eq)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_ltgt)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.zero)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.one)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_tildedollar)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_tildeat)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_plus)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_minus)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_star)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_div)) | refine (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.inv))]; shelve)
    (let a_value :=
      F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_tildeat)
        "0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc" in
    let b_value :=
      F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_tildeat)
        "0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b" in
    ltac:(refine (_ :
      MonadVM.Ec.Curve.Make_P_signature); constructor; [refine (a_value) | refine (b_value)]; shelve)).

Definition C_1 : MonadVM.Ec.Curve.Make.Make_result (_fargs := C_1_fargs) :=
  (MonadVM.Ec.Curve.Make.functor (_fargs := (C_1_fargs ))).

Section G_1_application.
#[local] Existing Instance C_1_fargs.

Definition G_1_fargs
  {_rocq_module_assumption_0 :
    ltac:(let typ := constr:(ltac:(first [unshelve refine ((C_1.(MonadVM.Ec.Curve.Make.Make_result.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)}
  :=
  ltac:(first [unshelve refine ((MonadVM.Ec.Curve.Make.Subgroup.Build_FArgs
    (_fargs := C_1_fargs))
    (let order := curve_order in
    let generator :=
      (MonadVM.Option.get
        (ltac:(first [exact _rocq_module_assumption_0 | eassumption])))
        (C_1.(MonadVM.Ec.Curve.Make.Make_result.of_coords)
          (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_tildeat)
            "0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296")
          (F_p.(MonadVM.Ec.Algebra.Prime_field.Prime_field_result.op_tildeat)
            "0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"))
      in
    ltac:(refine (_ :
      MonadVM.Ec.Curve.Make.Subgroup_O_signature); constructor; [refine (order) | refine (generator)]; shelve))
  )]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | exact
  _rocq_module_assumption_0 | eassumption | typeclasses eauto]).

Definition G_1
  {_rocq_module_assumption_0 :
    ltac:(let typ := constr:(ltac:(first [unshelve refine ((C_1.(MonadVM.Ec.Curve.Make.Make_result.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)}
  :
  MonadVM.Ec.Curve.Make.Subgroup.Subgroup_result
    (_fargs :=
      (G_1_fargs (_rocq_module_assumption_0 := _rocq_module_assumption_0))) :=
  ltac:(first [unshelve refine ((MonadVM.Ec.Curve.Make.Subgroup.functor
  (_fargs := (G_1_fargs (_rocq_module_assumption_0 := _rocq_module_assumption_0))))
  )]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | exact
  _rocq_module_assumption_0 | eassumption | typeclasses eauto]).
End G_1_application.