Skip to content

Commit

Permalink
Formatting updates and sidebar inclusion
Browse files Browse the repository at this point in the history
Formatting updates per Gene and Lori's recommendations.
Note - I have left the H2 headings in caps to align with other docs.

Sidebar inclusion - updating sidebar.js to include this tutorial.
  • Loading branch information
BrandtH22 committed Oct 10, 2023
1 parent 2c48027 commit 0225968
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
74 changes: 37 additions & 37 deletions docs/guides/tutorials/prefarm-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ slug: /guides/prefarm-audit-tutorial
title: Prefarm Audit Tutorial
---

Chia Network Inc's prefarm is being secured by a complex set of custodial rules. This document will describe how to use the custody tool to audit the prefarm configuration. A moderate level of technical proficiency is probably needed to understand the details. For a high-level overview of the prefarm custody wallets, see our [blog post](https://www.chia.net/2022/10/29/a-new-home-for-the-prefarm/).
Chia Network Inc's prefarm is secured by a complex set of custodial rules. This document describes how to use the custody tool to audit the prefarm configuration. A moderate level of technical proficiency is probably needed to understand the details. For a high-level overview of the prefarm custody wallets, see our [blog post](https://www.chia.net/2022/10/29/a-new-home-for-the-prefarm/).

Other relevant documents:

- [Flow chart](/img/chia-custody-tool.png) to visualize how the custody tool works
- [User guide](/guides/custody-tool-user-guide) to help you get up and running
- [CLI reference](/custody-tool) for all custody commands used in this tutorial
- [Prefarm Alert Tool](https://github.com/Chia-Network/prefarm-alert) for accessing the public prefarm config files
- [Prefarm Alert Tool](https://github.com/Chia-Network/prefarm-alert) to access the public prefarm config files

## Prefarm Audit with the Internal Custody Tool
The following steps assume that you have installed and setup the custody tool following the [User guide](/guides/custody-tool-user-guide).
The [chia-dev-tools](https://github.com/Chia-Network/chia-dev-tools#install) are also needed for this audit, examples shown have chia dev tools installed in a separate venv as the custody tool.

1. Download the prefarm configuration files from the [Prefarm Alert Tool](https://github.com/Chia-Network/prefarm-alert/tree/main/singleton-metadata).
2. Run the custody tool command `cic sync -c <config-file-path>.txt -db <unique_db_path>.sqlite`
Expand All @@ -24,7 +23,7 @@ The [chia-dev-tools](https://github.com/Chia-Network/chia-dev-tools#install) are

:::info

NOTE - this command will have no result if completed successfully but you will see the corresponding sqlite file created.
NOTE: This command has no result if completed successfully, but, you will see the corresponding sqlite file created.

:::

Expand Down Expand Up @@ -56,7 +55,7 @@ Config:

:::info

This command will show the singleton launcher ID and the parameters associated with this specific prefarm wallet configuration (withdrawal, clawback, and cancellation periods).
This command shows the singleton launcher ID and the parameters associated with this specific prefarm wallet configuration (withdrawal, clawback, and cancellation periods).

:::

Expand All @@ -72,44 +71,45 @@ xch1jj0gm4ahhlu3ke0r0fx955v8axr6za7rzz6hc0y26lewa7zw6fws5nwvv6

:::info

NOTE - a high level of technical proficiency is needed to understand the details of this manual process for what the cic tool does above.
This process is a high level guide and does not display expected results for each step.
NOTE: A high level of technical proficiency is needed to understand the details of this manual process for what the cic tool does above.
This process is a high-level guide and does not display expected results for each step.
The [chia-dev-tools](https://github.com/Chia-Network/chia-dev-tools#install) are needed for this audit.

:::

1. Use the internal custody tool to reveal the current root and other curried parameters (steps 1-4 above)
2. Curry the necessary parameters into the prefarm_inner.clsp:
`(THIS_MOD_HASH, ROOT, STATE)`
1. `THIS_MOD_HASH` = this code's sha256 tree hash without its curried arguments
2. `ROOT` = the current root provided by the internal custody tool
3. `STATE` = a tree with the following elements in order
`((REKEY_MOD_HASH . ACH_MOD_HASH) . (ACH_TIMELOCK . (BASE_REKEY_TIMELOCK . SLOW_REKEY_PENALTY)))`
1. `REKEY_MOD_HASH` = rekey puzzle sha256 tree hash without its curried arguments
2. `ACH_MOD_HASH` = ach puzzle sha256 tree hash without its curried arguments
3. `ACH_TIMELOCK` = integer of the ach timelock also referred to as the Withdrawal Timelock
4. `BASE_REKEY_TIMELOCK` = integer of the rekey timelock
5. `SLOW_REKEY_PENALTY` = integer of the slow rekey penalty
3. Curry the necessary parameters into singleton_top_layer_v1_1.clsp:
`(SINGLETON_STRUCT INNER_PUZZLE)`
1. `SINGLETON_STRUCT` = a tree with the following elements in order
`(MOD_HASH . (LAUNCHER_ID . LAUNCHER_PUZZLE_HASH))`
1. `MOD_HASH` = singleton_top_layer puzzle sha256 tree hash without its curried arguments
2. `LAUNCHER_ID` = the ID of the singleton we are committed to paying
3. `LAUNCHER_PUZZLE_HASH` = the puzzle hash of the launcher
1. Use the internal custody tool to reveal the current root and other curried parameters (steps 1-4 above).
2. Curry the necessary parameters into the prefarm_inner.clsp `(THIS_MOD_HASH, ROOT, STATE)`:
1. `THIS_MOD_HASH` = this code's sha256 tree hash without its curried arguments.
2. `ROOT` = the current root provided by the internal custody tool.
3. `STATE` = a tree with the following elements in order `((REKEY_MOD_HASH . ACH_MOD_HASH) . (ACH_TIMELOCK . (BASE_REKEY_TIMELOCK . SLOW_REKEY_PENALTY)))`:
1. `REKEY_MOD_HASH` = rekey puzzle sha256 tree hash without its curried arguments.
2. `ACH_MOD_HASH` = ach puzzle sha256 tree hash without its curried arguments.
3. `ACH_TIMELOCK` = integer of the ach timelock also referred to as the Withdrawal Timelock.
4. `BASE_REKEY_TIMELOCK` = integer of the rekey timelock.
5. `SLOW_REKEY_PENALTY` = integer of the slow rekey penalty.
3. Curry the necessary parameters into singleton_top_layer_v1_1.clsp `(SINGLETON_STRUCT INNER_PUZZLE)`:
1. `SINGLETON_STRUCT` = a tree with the following elements in order `(MOD_HASH . (LAUNCHER_ID . LAUNCHER_PUZZLE_HASH))`:
1. `MOD_HASH` = singleton_top_layer puzzle sha256 tree hash without its curried arguments.
2. `LAUNCHER_ID` = the ID of the singleton we are committed to paying.
3. `LAUNCHER_PUZZLE_HASH` = the puzzle hash of the launcher.
2. `INNER_PUZZLE` = the compiled form of the inner puzzle (result of the previous curry).
4. Derive the puzzle hash from the compiled form of the singleton
`opc -H <compiled_puzzle>`
5. Convert the puzzle hash into the singleton p2 puzzle by currying the necessary parameters
`(SINGLETON_MOD_HASH, LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)`
1. `SINGLETON_MOD_HASH` - singleton_top_layer puzzle sha256 tree hash without its curried arguments
2. `LAUNCHER_ID` - the ID of the singleton we are committed to paying
3. `LAUNCHER_PUZZLE_HASH` - the puzzle hash of the launcher
6. Encode the singleton p2 puzzle to reveal the p2 address
`cdv encode -p xch <singleton_p2_puzzle>`
4. Derive the puzzle hash from the compiled form of the singleton.
```bash
opc -H <compiled_puzzle>
```
5. Convert the puzzle hash into the singleton p2 puzzle by currying the necessary parameters `(SINGLETON_MOD_HASH, LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)`:
1. `SINGLETON_MOD_HASH` - singleton_top_layer puzzle sha256 tree hash without its curried arguments .
2. `LAUNCHER_ID` - the ID of the singleton we are committed to paying.
3. `LAUNCHER_PUZZLE_HASH` - the puzzle hash of the launcher.
6. Encode the singleton p2 puzzle to reveal the p2 address.
```bash
cdv encode -p xch <singleton_p2_puzzle>
```


:::info

NOTE - This is the address used when sending funds to the vault.
NOTE: This is the address used when sending funds to the vault.

:::

Expand All @@ -118,4 +118,4 @@ NOTE - This is the address used when sending funds to the vault.
## Further reading

- [A New Home for the Prefarm blog](https://www.chia.net/2022/10/29/a-new-home-for-the-prefarm/)
- [Cypherpunks in Sportcoats](https://www.chia.net/2023/01/17/cypherpunks-in-sportcoats-chias-custody-is-a-killer-app/)
- [Cypherpunks in Sportcoats: Blockchain in the Real World](https://www.chia.net/2023/01/17/cypherpunks-in-sportcoats-chias-custody-is-a-killer-app/)
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ module.exports = {
'guides/tutorials/custom-puzzle-lock',
'guides/tutorials/coin-spend-rpc',
'guides/tutorials/application-structure',
'guides/prefarm-audit-tutorial',
],
},
],
Expand Down

0 comments on commit 0225968

Please sign in to comment.