| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Contract.Head
Synopsis
- type DatumType = State
- type RedeemerType = Input
- headValidator :: BuiltinByteString -> State -> Input -> ScriptContext -> Bool
- checkIncrement :: ScriptContext -> OpenDatum -> IncrementRedeemer -> Bool
- checkDecrement :: ScriptContext -> OpenDatum -> DecrementRedeemer -> Bool
- mustMatchAccumulatorCommitmentHash :: BuiltinBLS12_381_G1_Element -> Hash -> Bool
- checkClose :: ScriptContext -> OpenDatum -> CloseRedeemer -> Bool
- checkContest :: ScriptContext -> ClosedDatum -> ContestRedeemer -> Bool
- headIsFinalizedWith :: BuiltinByteString -> ScriptContext -> ClosedDatum -> Integer -> BuiltinBLS12_381_G1_Element -> TxOutRef -> Bool
- checkPartialFanout :: BuiltinByteString -> ScriptContext -> FanoutProgressDatum -> Integer -> TxOutRef -> Bool
- checkFinalPartialFanout :: BuiltinByteString -> ScriptContext -> FanoutProgressDatum -> Integer -> BuiltinBLS12_381_G1_Element -> TxOutRef -> Bool
- isG1Generator :: BuiltinBLS12_381_G1_Element -> Bool
- makeContestationDeadline :: ContestationPeriod -> ScriptContext -> POSIXTime
- getHeadInput :: ScriptContext -> TxInInfo
- getHeadAddress :: ScriptContext -> Address
- mustNotChangeParameters :: ([Party], [Party]) -> (ContestationPeriod, ContestationPeriod) -> (CurrencySymbol, CurrencySymbol) -> (DepositPeriod, DepositPeriod) -> Bool
- mustPreserveHeadAdaOverhead :: Integer -> Integer -> Bool
- mustBeSignedByParticipant :: ScriptContext -> CurrencySymbol -> Bool
- findParticipationTokens :: CurrencySymbol -> Value -> [TokenName]
- headOutputDatum :: ScriptContext -> Datum
- getTxOutDatum :: TxOut -> Datum
- verifySnapshotSignature :: [Party] -> (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Hash, Hash) -> [Signature] -> Bool
- verifyPartySignature :: (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Hash, Hash) -> Party -> Signature -> Bool
- unappliedValidator :: CompiledCode (BuiltinByteString -> ValidatorType)
- compiledValidator :: CompiledCode ValidatorType
- canonicalCRSDatumHash :: BuiltinByteString
- validatorScript :: PlutusScript
- decodeHeadOutputClosedDatum :: ScriptContext -> ClosedDatum
- decodeHeadOutputFanoutProgressDatum :: ScriptContext -> FanoutProgressDatum
- decodeHeadOutputOpenDatum :: ScriptContext -> OpenDatum
- afterContestationDeadline :: TxInfo -> POSIXTime -> Bool
- resolveCRS :: TxInfo -> TxOutRef -> CRSDatum
- hashCRSDatum :: CRSDatum -> BuiltinByteString
- withCRSLookup :: BuiltinByteString -> TxInfo -> TxOutRef -> (CRSDatum -> Bool) -> Bool
- txOutsToSubsetScalars :: [TxOut] -> [Integer]
Documentation
type RedeemerType = Input Source #
Arguments
| :: ScriptContext | |
| -> OpenDatum | Open state before the increment |
| -> IncrementRedeemer | |
| -> Bool |
Verify a increment transaction.
Arguments
| :: ScriptContext | |
| -> OpenDatum | Open state before the decrement |
| -> DecrementRedeemer | |
| -> Bool |
Verify a decrement transaction.
mustMatchAccumulatorCommitmentHash :: BuiltinBLS12_381_G1_Element -> Hash -> Bool Source #
Check that the G1 commitment stored in the output datum is consistent with the hash that parties signed. Prevents a malicious closer from storing a wrong commitment while providing a valid signature over a correct hash.
Arguments
| :: ScriptContext | |
| -> OpenDatum | Open state before the close |
| -> CloseRedeemer | Type of close transition. |
| -> Bool |
Verify a close transaction.
Arguments
| :: ScriptContext | |
| -> ClosedDatum | Closed state before the close |
| -> ContestRedeemer | Type of contest transition. |
| -> Bool |
Verify a contest transaction.
Arguments
| :: BuiltinByteString | |
| -> ScriptContext | |
| -> ClosedDatum | Closed state before the fanout |
| -> Integer | Number of distributed UTxO outputs (excludes change output) |
| -> BuiltinBLS12_381_G1_Element | Membership proof (quotient commitment G1 element) |
| -> TxOutRef | Reference input containing CRS |
| -> Bool |
Verify a fanout transaction using a KZG membership proof. All distributed outputs are verified as members of the accumulator in a single proof.
Arguments
| :: BuiltinByteString | |
| -> ScriptContext | |
| -> FanoutProgressDatum | Progress state (extracted from either Closed or FanoutProgress input) |
| -> Integer | Number of outputs to distribute in this partial fanout |
| -> TxOutRef | Reference input containing CRS |
| -> Bool |
Verify a partial fanout transaction. Transitions either Closed → FanoutProgress or FanoutProgress → FanoutProgress: distributes a subset of UTxOs and continues with a smaller FanoutProgressDatum.
The continuing head output must be the first transaction output. Distributed UTxOs follow at indices [1 .. numberOfPartialOutputs].
checkFinalPartialFanout Source #
Arguments
| :: BuiltinByteString | |
| -> ScriptContext | |
| -> FanoutProgressDatum | FanoutProgress state before the final fanout |
| -> Integer | Number of outputs to distribute |
| -> BuiltinBLS12_381_G1_Element | Membership proof (quotient commitment G1 element) |
| -> TxOutRef | Reference input containing CRS |
| -> Bool |
Verify the final partial fanout transaction. Transitions FanoutProgress → Final: distributes all remaining UTxOs and burns all head tokens.
Unlike intermediate steps, there is no continuing head output. All distributed UTxOs start at index 0. Tokens must be burned.
Note: headId, parties, and contestationDeadline are not re-verified explicitly. headId and parties are validated implicitly by mustBurnAllHeadTokens (wrong values would target the wrong token set). contestationDeadline was locked in by earlier checkPartialFanout steps and is trustworthy from the on-chain datum.
isG1Generator :: BuiltinBLS12_381_G1_Element -> Bool Source #
makeContestationDeadline :: ContestationPeriod -> ScriptContext -> POSIXTime Source #
getHeadInput :: ScriptContext -> TxInInfo Source #
This is safe only because usually Head transaction only consume one input.
getHeadAddress :: ScriptContext -> Address Source #
mustNotChangeParameters :: ([Party], [Party]) -> (ContestationPeriod, ContestationPeriod) -> (CurrencySymbol, CurrencySymbol) -> (DepositPeriod, DepositPeriod) -> Bool Source #
mustBeSignedByParticipant :: ScriptContext -> CurrencySymbol -> Bool Source #
findParticipationTokens :: CurrencySymbol -> Value -> [TokenName] Source #
headOutputDatum :: ScriptContext -> Datum Source #
getTxOutDatum :: TxOut -> Datum Source #
verifySnapshotSignature :: [Party] -> (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Hash, Hash) -> [Signature] -> Bool Source #
Verify the multi-signature of a snapshot using given constituents FanoutProgressDatum,
ClosedDatum, number, and ContestRedeemer. See 'SignableRepresentation Snapshot'
for more details.
verifyPartySignature :: (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Hash, Hash) -> Party -> Signature -> Bool Source #
Verify individual party signature of a snapshot. See 'SignableRepresentation Snapshot' for more details.
unappliedValidator :: CompiledCode (BuiltinByteString -> ValidatorType) Source #
compiledValidator :: CompiledCode ValidatorType Source #
canonicalCRSDatumHash :: BuiltinByteString Source #
BLAKE2b-256 of the canonical CRS datum: the published EIP-4844 trusted setup
(first defaultItems G2 points) hashed by hashCRSDatum. Baked into the
validator so every fanout rejects a reference input carrying any other
powers-of-tau setup. Computed directly from the embedded setup — no hardcoded value.
validatorScript :: PlutusScript Source #
decodeHeadOutputClosedDatum :: ScriptContext -> ClosedDatum Source #
decodeHeadOutputFanoutProgressDatum :: ScriptContext -> FanoutProgressDatum Source #
decodeHeadOutputOpenDatum :: ScriptContext -> OpenDatum Source #
afterContestationDeadline :: TxInfo -> POSIXTime -> Bool Source #
Check that the lower validity bound of the transaction is strictly after the contestation deadline. Used by all three fanout paths.
resolveCRS :: TxInfo -> TxOutRef -> CRSDatum Source #
Find a CRS reference input by TxOutRef and decode its non-empty datum.
Errors on missing input, undecoded datum, or empty CRS list.
hashCRSDatum :: CRSDatum -> BuiltinByteString Source #
Hash a CRS datum by its content: BLAKE2b-256 over the concatenation of the compressed G2 points. Binding the datum content is what keeps the membership proof sound — the trusted-setup τ is fixed and public, so any other setup would let a crafted fanout forge proofs.
withCRSLookup :: BuiltinByteString -> TxInfo -> TxOutRef -> (CRSDatum -> Bool) -> Bool Source #
Look up the CRS datum from a reference input and pass it to a continuation, rejecting any reference input whose datum is not the canonical trusted setup.
txOutsToSubsetScalars :: [TxOut] -> [Integer] Source #
Compute the accumulator scalar for each output in the list.
Used by all three fanout validators (headIsFinalizedWith, checkPartialFanout,
checkFinalPartialFanout) to produce subset scalars for checkMembershipPairing.
Each scalar is blake2b_224(hashTxOuts [txOut]), which equals
blake2b_224(sha2_256(serialised)) because hashTxOuts uses sha2_256 internally
(matching what addElement computes off-chain).