-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "update validation" to the Symbolic Ledger library
- Loading branch information
Showing
5 changed files
with
34 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module ZkFold.Symbolic.Ledger.Validation.Common where | ||
|
||
import Prelude hiding (Bool, Eq (..), all, length, splitAt, zip, (&&), | ||
(*), (+), (==)) | ||
|
||
import ZkFold.Symbolic.Ledger.Types | ||
|
||
-- | References in the chain of updates are consistent. | ||
updateChainIsValid :: | ||
UpdateChain context | ||
-> Bool context | ||
updateChainIsValid _ = undefined |
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
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
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,12 +1,25 @@ | ||
module ZkFold.Symbolic.Ledger.Validation.Update where | ||
|
||
import Prelude hiding (Bool, Eq (..), all, length, splitAt, zip, (&&), | ||
(*), (+), (==)) | ||
import Prelude hiding (Bool, Eq (..), all, length, splitAt, zip, (&&), | ||
(*), (+), (==)) | ||
|
||
import ZkFold.Symbolic.Data.Bool (BoolType(..)) | ||
import ZkFold.Symbolic.Data.Eq (Eq(..)) | ||
import ZkFold.Symbolic.Ledger.Types | ||
import ZkFold.Symbolic.Ledger.Validation.Block (BlockWitness, newBlockIsValid) | ||
|
||
-- | References in the chain of updates are consistent. | ||
updateChainIsValid :: | ||
UpdateChain context | ||
type UpdateWitness context = (Block context, BlockWitness context) | ||
|
||
-- | Check if a new update is valid given the latest valid update. | ||
newUpdateIsValid :: | ||
Signature context | ||
=> UpdateId context | ||
-- ^ The id of the latest valid update. | ||
-> Update context | ||
-- ^ The new update to check. | ||
-> UpdateWitness context | ||
-- ^ The witness data for the new update. | ||
-> Bool context | ||
updateChainIsValid _ = undefined | ||
newUpdateIsValid lastUpdateId Update {..} (wBlock, wBlockWitness) = | ||
lastUpdateId == updateReference | ||
&& newBlockIsValid lastUpdateId wBlock wBlockWitness |
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