-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use hash placeholder for IFC predicate
- Loading branch information
1 parent
5c1838e
commit 1440119
Showing
2 changed files
with
20 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Anoma.Resource.Index; | ||
|
||
import Anoma.Resource.Types open using {Resource} public; | ||
import Anoma.Resource.Logic open using {Instance; Witness} public; | ||
import Anoma.Resource.Logic open using {Tag; Instance; Witness} public; | ||
import Anoma.Resource.Computable.Commitment open using {Commitment; commitment} public; | ||
import Anoma.Resource.Computable.Nullifier open using {Nullifier; NullifierKey; nullifier} public; | ||
import Anoma.Resource.Computable.Delta open using {delta} public; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
module Anoma.Transaction.InformationFlow; | ||
|
||
import Stdlib.Prelude open using {Bool; List; true; false; all; any}; | ||
import Stdlib.Prelude open using {Bool; List; true; false; all; any; not}; | ||
import Data.Set as Set open using {Set; toList; member?}; | ||
|
||
import Anoma.Identity open; | ||
import Anoma.Transaction.Types as Transaction open; | ||
import Anoma.Identity open using {ExternalIdentity}; | ||
import Anoma.Transaction.Types as Transaction open using {Transaction}; | ||
|
||
--- The information flow predicate function type definition. | ||
InformationFlowControlPredicate : Type := (tx : Transaction) -> (id : ExternalIdentity) -> Bool; | ||
|
||
--- A fixed-size data type encoding a hash. | ||
--- TODO: Is this type definition needed? Should this be Anoma.Resource.Logic.Tag? | ||
axiom Hash : Type; | ||
--- A placeholder for an unspecified hash type. | ||
--- NOTE: this will be concretized in an upcoming RM specs version. | ||
axiom HashPlaceholder : Type; | ||
|
||
--- TODO This type is here to prevent the Juvix compiler from getting stuck in a loop in the type definition below. | ||
BaseDataSet : Type := Set BaseData; | ||
--- A placeholder for a function checking if a ;Transaction; does not include ;HashPlaceholder; ;Set;. | ||
--- NOTE: this will be concretized in an upcoming RM specs version. | ||
axiom requireShieldedCheckPlaceholder : (tx : Transaction) | ||
-> (hashes : Set HashPlaceholder) | ||
-> Bool; | ||
|
||
--- The input data of the basePredicate function. | ||
type BaseData := | ||
| AllowAny | ||
| AllowOnly (Set ExternalIdentity) | ||
| RequireShielded (Set Hash) | ||
-- TODO Use ;Set; instead of ;List; | ||
| And (BaseDataSet) | ||
| Or (BaseDataSet); | ||
|
||
| RequireShielded (Set HashPlaceholder) | ||
-- TODO Use ;Set; instead of ;List; once https://github.com/anoma/juvix/issues/3048 is resolved. | ||
| And (List BaseData) | ||
| Or (List BaseData); | ||
|
||
--- Returns the ;InformationFlowControlPredicate; depending on the provided ;BaseData;. | ||
terminating | ||
basePredicate (baseData : BaseData) : InformationFlowControlPredicate := | ||
case baseData of | ||
| None := \ {_ _ := true} | ||
| AllowAny := \ {_ _ := true} | ||
| AllowOnly identites := \ {_ self := member? self identites} | ||
-- TODO How to handle the hashes? | ||
-- | RequireShielded hashes := \ {tx _ := not (any (h in hashes) member? h ??)} | ||
| RequireShielded hashes := \ {_ _ := false} | ||
| And predicates := \ {tx id := all (p in Set.toList predicates) basePredicate p tx id} | ||
| Or predicates := \ {tx id := any (p in Set.toList predicates) basePredicate p tx id}; | ||
| RequireShielded hashes := \ {tx _ := requireShieldedCheckPlaceholder tx hashes} | ||
| And predicates := \ {tx id := all (p in predicates) basePredicate p tx id} | ||
| Or predicates := \ {tx id := any (p in predicates) basePredicate p tx id}; |