Modules

categorical-crypto

  • Prelude

CategoricalCrypto

  • CategoricalCrypto
  • Abstract
  • Abstract2
  • Abstract2.Equivalence
  • Abstract2.Morphism
  • Abstract2.OAPEmulation
  • Abstract2.WideSubcategory
  • Channel.Category
  • Channel.Core
  • Channel.Selection
  • Examples.Basic
  • Examples.Commitment
  • Examples.RelSetup
  • Examples.Signatures
  • FamilyCategory
  • Machine.Constraints
  • Machine.Core
  • MachineAxioms
  • RandomOracle
  • RandomOracle2
  • SFunM
  • Standard
  • Standard2
  • Standard2.Morphism
  • StandardTV
  • UCSetup
  • UCSetup.Morphism
  • VanishingTV

Categories

  • Actegory
  • Actegory.Underlying
  • Category.EquivClosureHelper
  • Coherence.Monoidal
  • Coherence.Monoidal.Compare
  • Coherence.Monoidal.Diagram
  • Coherence.Monoidal.Frontend
  • Coherence.Monoidal.Frontend.Core
  • Coherence.Monoidal.Frontend.Sigma
  • Coherence.Monoidal.MacLane
  • Coherence.Monoidal.Normalize
  • Coherence.Monoidal.Reflect
  • Coherence.Monoidal.Sigma
  • Coherence.Monoidal.Test.Frontend
  • Coherence.Monoidal.Test.InterchangeStress
  • Coherence.Monoidal.Test.Limitations
  • Coherence.Monoidal.Test.SigmaFrontend
  • Coherence.Monoidal.WireCoherence
  • CoherenceIsos
  • Diagram.Coend.Ext.Setoids
  • Discrete
  • FreeMonoidal
  • FreeStrictMonoidal
  • Functor.Monoidal.CurriedTensor
  • Functor.Monoidal.CurriedTensor.Properties
  • Functor.Monoidal.Properties.Ext
  • Functor.Presheaf.Morphism
  • GradedKleisli
  • GradedKleisli.Functorial
  • GradedKleisli.Functorial.Category
  • GradedKleisli.Regrade
  • KernelCongruence
  • KernelCongruence.Reindex
  • LocallyGraded
  • LocallyGraded.FreeActegory
  • LocallyGraded.FreeActegory.Kleisli
  • LocallyGraded.Kleisli
  • Monad.Graded.Ext
  • Monad.Graded.Morphism
  • Monad.Graded.Pullback
  • Monad.Graded.Uncurried
  • Morphism.Reasoning.Ext
  • NaturalTransformationHelper
  • Properties

Class

  • Monad.Ext

Data

  • List.Properties.Ext
  • Maybe.Ext
  • Nat.Poly

LibExt

  • LibExt
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
{-# OPTIONS --safe #-}
 
module CategoricalCrypto.Machine.Constraints where
 
open import CategoricalCrypto.Channel.Core
open import CategoricalCrypto.Channel.Selection
open import CategoricalCrypto.Machine.Core
open import Tactic.Defaults
 
open import categorical-crypto.Prelude
 
record IsConstrained
{A B : Channel}
-- The machine that needs to be constrained
(m : Machine A B)
-- The type of possible queries
{Query : Type}
-- The return type from a given query
(QueryReturnType : Query → Type) : Type₁ where
 
open Channel
open Machine m renaming (stepRel to _-⟦_/_⟧ᵐ⇀_)
 
field
-- We can create an input message from a query
queryI : Query → machine-channel .inType
 
-- We can create an output message for all the possible types of the queries
-- responses
queryO : ∀ {query} → QueryReturnType query → machine-channel .outType
 
-- Correctness: For every received query of a given shape and wiring which
-- gets a response, the response is also properly shaped and wired.
correctness : ∀ {query s response' s'}
→ s -⟦ queryI query / response' ⟧ᵐ⇀ s'
→ ∃ λ response → response' ≡ just (queryO {query} response)
 
-- Completeness: queries of the right shape and wiring always get a response
completeness : ∀ {query s}
→ ∃ λ response'
→ ∃ λ s'
→ s -⟦ queryI query / just response' ⟧ᵐ⇀ s'
 
-- Retrieves the response to a given query
queryCompute : ∀ query (s : State) → (QueryReturnType query × State)
queryCompute query s with completeness {query} {s}
... | response' , s' , p with correctness p
... | response , _ = response , s'
 
-- Ensures that a certain constrained machine does not change it inner state
-- when receiving a specific constrained query
IsPureOn :
{A B : Channel}
{m : Machine A B}
{Query : Type}
{QueryReturnType : Query → Type}
(isConstrained : IsConstrained m QueryReturnType)
(query : Query)
→ Type
IsPureOn {m = m} isConstrained query =
let open IsConstrained isConstrained
open Machine m renaming (stepRel to _-⟦_/_⟧ᵐ⇀_)
in ∀ {s s' response'}
→ s -⟦ queryI query / response' ⟧ᵐ⇀ s'
→ s ≡ s'
 
-- Ensures that a certain constrained machine does not change its inner state
-- when receiving any constrained query
IsPure :
{A B : Channel}
{m : Machine A B}
{Query : Type}
{QueryReturnType : Query → Type}
(isConstrained : IsConstrained m QueryReturnType)
→ Type
IsPure isConstrained = ∀ query → IsPureOn isConstrained query