cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Attack.DatumHijacking

Description

This module provides an automated attack to try and redirect outputs to a certain target with a similar datum type.

Synopsis

Documentation

redirectOutputTweakAll :: (MonadTweak m, IsTxSkelOutAllowedOwner owner) => (TxSkelOut -> Maybe owner) -> (Integer -> Bool) -> m ([TxSkelOut], [TxSkelOut]) Source #

Redirects, in the same transaction, all the outputs targetted by an output and an index predicates. See DatumHijackingParams for more information on those predicates. Returns a pair of the old outputs before they were redirected, and the new updated list of outputs.

data DatumHijackingParams where Source #

Parameters of the datum hijacking attacks. They state precisely which outputs should have their owner changed, wich owner should be assigned, to each of these outputs, and whether several modified outputs should be combined in a single transaction, or instead spread out multiple branches.

Constructors

DatumHijackingParams 

Fields

  • :: IsTxSkelOutAllowedOwner owner
     
  • => { dhpOutputPred :: TxSkelOut -> Maybe owner

    Return Just the new owner, or Nothing if you want to leave this output unchanged.

  •    , dhpIndexPred :: Integer -> Bool

    The redirection described by the previous argument might apply to more than one of the outputs of the transaction. Use this predicate to select which of the redirectable outputs to actually redirect. We count the redirectable outputs from the left to the right, starting with zero.

  •    , dhpAllOutputs :: Bool

    Whether all the outputs targetted by the predicates should be redirected in the same transaction, or one at a time, each in a distinct transaction.

  •    } -> DatumHijackingParams
     

redirectOutputTweakAny :: (MonadTweak m, IsTxSkelOutAllowedOwner owner) => (TxSkelOut -> Maybe owner) -> (Integer -> Bool) -> m ([TxSkelOut], [TxSkelOut]) Source #

Redirects, each in their own transaction, all the outputs targetted by an output and an index predicates. See DatumHijackingParams for more information on those predicates.

datumHijackingAttack :: MonadTweak m => DatumHijackingParams -> m [TxSkelOut] Source #

A datum hijacking attack, simplified: This attack tries to substitute a different recipient on certain outputs based on a DatumHijackingParams.

A DatumHijackingLabel is added to the labels of the TxSkel using addLabelTweak. It contains the outputs that have been redirected, which also corresponds to the returned value of this tweak. The tweak fails if no such outputs have been redirected.

ownedByDatumHijackingParams :: forall (oldOwner :: Type) owner. (IsTxSkelOutAllowedOwner owner, Typeable oldOwner) => owner -> DatumHijackingParams Source #

Datum hijacking parameters targetting all the outputs owned by a certain type of owner, and redirecting each of them in a separate transaction.

scriptsDatumHijackingParams :: IsTxSkelOutAllowedOwner owner => owner -> DatumHijackingParams Source #

Datum hijacking parameters targetting all the outputs owned by a script, and redirecting each of them in a separate transaction.

defaultDatumHijackingParams :: (IsTxSkelOutAllowedOwner owner, Is k An_AffineFold) => Optic' k is TxSkelOut x -> owner -> DatumHijackingParams Source #

Targets all the outputs for which the focus of a given optic exists, and redirects each of them in a separate transaction.

datumOfDatumHijackingParams :: forall dat owner. (IsTxSkelOutAllowedOwner owner, DatumConstrs dat) => owner -> DatumHijackingParams Source #

Datum hijacking parameters targetting all the outputs with a certain type of datum, and redirecting each of them in a separate transaction.

txSkelOutPredDatumHijackingParams :: IsTxSkelOutAllowedOwner owner => (TxSkelOut -> Bool) -> owner -> DatumHijackingParams Source #

Targets all the outputs satisfying a given predicate, and redirects each of them in a separate transaction.