cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Attack.TokenDuplication

Description

This module provides an automated attack to add minted tokens in a TxSkel. In principle, a token duplication attack consist in minting a higher amount of tokens already minted in the transaction, but we generalise it to also add arbitrary tokens if needed.

Synopsis

Token duplication params

data TokenDuplicationParams owner effs Source #

Parameters of the token duplication attack

Constructors

TokenDuplicationParams 

Fields

  • tdpNewMints :: Sem effs [Mint]

    The new mints to add in the transaction. These are effectful because they can depend on the existing mints.

  • tdpThief :: owner

    The target of the added tokens.

anyMintTokenDuplicationParams Source #

Arguments

:: [Mint]

The Mints to add.

-> owner

The attacker, who receives the extra tokens.

-> TokenDuplicationParams owner effs 

Token duplications based on a list of Mint.

existingCurrencyTokenDuplicationParams Source #

Arguments

:: Member Tweak effs 
=> (VScript -> [(TokenName, Integer)])

For each policy that occurs in some Mint constraint, return a list of token names together with how many tokens with that name should be minted, in addition to the existing tokens.

-> owner

The attacker, who receives the extra tokens.

-> TokenDuplicationParams owner effs 

Token duplications based on a function applied to existing currencies (cannot add new currencies, but can add new types of tokens).

existingAssetClassTokenDuplicationParams Source #

Arguments

:: Member Tweak effs 
=> (VScript -> TokenName -> Integer -> Integer)

A function returning the new amount of tokens to mint given a specific currency, token name and amount. This new amount replaces the old one.

-> owner

The attacker, who receives the extra tokens.

-> TokenDuplicationParams owner effs 

Token duplications based on a function applied to both existing currencies and token (cannot add new currencies nor new types of tokens).

Token duplication label

newtype TokenDuplicationLabel Source #

A label added to a TxSkel on which a tweak duplicating tokens has been applied. The label contains the value that was added to the transaction.

Token duplication attack

tokenDuplicationAttack Source #

Arguments

:: (Members '[Tweak, NonDet] effs, IsTxSkelOutAllowedOwner owner) 
=> TokenDuplicationParams owner effs

The parameters of the attack

-> Sem effs Value 

This attack adds extra tokens of any kind in the minted value. The additional minted value is redirected to the attacker.