DarkFi loosely follows the standardized Unix directory structure.
bin/ subdirectory.contrib/.doc/.example/.script/.
See also the large script/research/ subdir.src/.
See Architecture Overview for a detailed
description.
src/sdk/ crate is used by WASM contracts and core code.
It contains essential primitives and code shared between them.src/serial/ is a crate containing the binary serialization code.src/contract/ contains our native bundled contracts. It's worth
looking at these to familiarize yourself with what contracts on
DarkFi are like.Refer to the main README file for instructions on how to install Rust and necessary dependencies.
Then proceed to the Running a Node guide.
Our core community organizes through DarkIRC, our peer-to-peer chat daemon. DarkIRC supports multiple transports, including Tor and I2P. Public channels remain public, and the privacy properties depend on the configured transport and message-encryption settings.
Every Monday at 14:00 UTC (DST) or 15:00 UTC (ST) in #dev we have our main project meeting.
See the guide on darkirc for instructions on joining the chat.
Check out the contributor's guide for where to find tasks and submitting patches to the project.
If you're not a dev but wish to learn then take a look at the agorism hackers study guide.
Lastly familiarize yourself with the project architecture. The book also contains a cryptography section with a helpful ZK explainer.
DarkFi also has a project spec and a DEP (DarkFi Enhancement Proposals) system.
Source code is under src/ subdirectory. Main interesting modules are:
net/ is our own p2p network. There are sessions such as incoming or
outgoing that have channels (connections). Protocols are attached to
channels depending on the session. The p2p network is also
multi-transport with support for TCP (+TLS), Tor and I2P. An anonymity
transport can hide a node's clearnet address from application peers, subject
to that transport's threat model.event_graph/ which is a DAG sync protocol used for ensuring
eventual consistency of data, such as with chat systems (you don't
drop any messages).runtime/ is the WASM smart contract engine. We separate computation
into several stages which is checks-effects-interactions paradigm in
solidity but enforced in the smart contract explicitly. For example
in the exec() phase, you can only read, whereas writes must occur
in the apply(update) phase.blockchain/ and validator/ is the blockchain and consensus algos.zk/ is the ZK VM, which simply loads bytecode which is used to
build the circuits. It's a very simple model rather than the TinyRAM
computation models. We opted for this because we prefer simplicity in
systems design.sdk/ contains a crypto SDK usable in smart contracts and
applications. There are also Python bindings here, useful for making
utilities or small apps.serial/ contains our own serialization because we don't trust Rust
serialization libs like serde. We also have async serialization and
deserialization which is good for network code.tx/ is the tx we use. Note signatures are not in the calldata as
having this outside it allows more efficient verification (since you
can do it in parallel and so on).
contract/ contains our native smart contracts. Namely:
money, which is multi-asset anonymous transfers, anonymous
swaps and token issuance. The token issuance is programmatic.
When creating a token, it commits to a smart contract which
specifies how the token is allowed to be issued.deploy for deploying smart contracts.dao, which is a fully anonymous DAO. All the DAOs on chain are
anonymous, including the amounts and activity of the treasury.
All participants are anonymous, proposals are anonymous and votes
are anonymous including the token weighted vote amount, and user
identity. You cannot see who is in the DAO.Note: We try to minimize external dependencies in our code as much as possible. We even try to limit dependencies within submodules.
Inside bin/ contains utilities and applications:
darkfid/ is the main daemon and drk/ is the wallet.dnet/ is a viewer to see the p2p traffic of nodes, and deg/ is a
viewer for the event graph data. We use these as debugging and
monitoring tools.dhtd/ is a distributed hash table, like IPFS, for transferring
static data and large files around. Currently just a prototype but
we'll use this later for images in the chat or other static content
like seller pages on the marketplace.tau/ is an anon p2p task manager which we use. We don't use Github
issues, and seek to minimize our dependence on centralized services.
Eventually we want to be fully p2p and attack resistant.darkirc/ is our main community chat. It uses event_graph to synchronize
hourly message DAGs and exposes a local IRC interface. Optional
RLN rate limiting exists but is disabled by default; the
current implementation uses compiled pregenerated identities rather than a
public staking/free-tier workflow.zkas/ is our ZK compiler.zkrunner/ contains our ZK debugger (run zkrunner with --trace),
and zkrender which renders a graphic of the circuit layout.lilith/ is a universal seed node. Eventually we will add swarming
support to our p2p network which is an easy addon.Lastly worth taking a look is script/research/ and
script/research/zk/ which contains impls of most major ZK algos.
bench/ contains benchmarks. script/escrow.sage is a utility for
doing escrow. We'll integrate it in the wallet later.
Our design philosophy and simplicity oriented approach to systemd dev:
Recent crypto code audit: ZK Security DarkFi Code Audit
Useful link on our ZK toolchain
For proof files, see proof/ and src/contract/*/proof/ subdirs.