ErgoScript Design patterns

proveDlog(h, a)

In ErgoScript (and ErgoTree), proveDlog(a) is defined for the default generator which is fixed in the protocol. If we want to use a different generator h, then we can emulate this using proveDHTuple as follows

proveDlog(h, a) = proveDHTuple(h, h, a, a)

An example of this is in the Stealth Address Contract


Discovered by @anon_real :
As is it possible to store box in a register (and context extension of an input), it is also possible to prove that spent box had some properties. For that, we need to issue certificate NFT during spending, to check then that corresponding box had some properties (while certificate box is not spent). Used in auctions contracts by @anon_real to get original author of NFT to pay royalty.


Another use-case: Some Details About Ergo Auction House - #36 by anon_real


Kind of meta-pattern: check in a contract if it interacts with other contracts (e.g. LP with order contract, hodl pool with proxy etc) only state (outputs) related to the contract and leave checking other outputs to counter-parties. So in case of LP contract interacting with an order contract, LP would check only correctness of LP output, leaving checking user’s output(s) to the order contract.

1 Like