Library SetcodeConcrete.nativeoutputs

Bounds for every native precompile in the SETCODE revision

The actual MODEXP parser retains its 1024-byte cap. The other precompile bounds are shared with QEDK, including the approved BLS cofactor premises. This discharges the native-output obligation of the recursive VM proof.
From Stdlib Require Import ZArith Lia.
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import QedkConcrete.dispatchoutputs QedkConcrete.modexpoutputs
  QedkConcrete.precompileoutputs QedkConcrete.blsmapbounds QedkConcrete.assemblychecked
  QedkConcrete.hashwords QedkConcrete.hostchecked QedkConcrete.vmsupplywords
  QedkConcrete.vmcallchecked QedkConcrete.recursiveassembly
  SetcodeConcrete.executionsupply.
Set Default Goal Selector "!".
#[local] Hint Extern 100 (Basics.Unreachable _) ⇒
  (apply Opaque.legacy_witness; Opaque.opaque_inhabit 64%nat) : typeclass_instances.

Lemma setcode_modexp_parameter_bound {MF : MX.FArgs} prices :
  MF.(MX.Revision).(Precompiles.Modexp.Make_Revision_signature.revision) =
    Support.Variants.Revision.Setcode prices →
  nativeEnsures (fun n ⇒ (n ≤ 1024)%N) (@MX.parameter_length MF).
Proof.
  intro Hrevision. unfold MX.parameter_length. rewrite Hrevision.
  apply native_ensures_any; intro n.
  change (nativeEnsures (fun n ⇒ (n ≤ 1024)%N)
    (PC.op_letdollar (PC.when_ (N.ltb 1024 n) PC.precompile_failure)
      (fun _ ⇒ PC._return n))).
  destruct (N.ltb_spec 1024 n) as [Hlarge|Hsmall].
  - intros state. exact I.
  - apply native_ensures_any; intros []. apply native_ensures_return. lia.
Qed.

Theorem setcode_native_output_bounds {HF : Host.Instantiate.FArgs} prices :
  HF.(Host.Instantiate.ChainParams).(Chain.Monad.PARAMS.revision) =
    Support.Variants.Revision.Setcode prices →
  sha256OutputSize → blsG1CofactorOrder → blsG2CofactorOrder →
  @nativeOutputBounds HF.
Proof.
  intros Hrevision Hsha H1 H2. apply native_output_bounds_from_table.
  - intro vm. eapply setcode_reserve_precompile_table. exact Hrevision.
  - intros MF Hrev. eapply setcode_modexp_parameter_bound. rewrite Hrev. exact Hrevision.
  - exact Hsha.
  - apply bls_map_output_bounds_from_cofactor_orders; assumption.
Qed.
Print Assumptions setcode_native_output_bounds.

No recursive-call or precompile-output premise remains. The two hash contracts and BLS cofactor identities are the approved library premises.