DarkFi Testnet v0.2 alpha

DarkFi's proof-of-work alpha testnet

Today we are releasing DarkFi's proof-of-work (PoW) alpha testnet. This milestone leads us one major step toward the future we have envisioned. Anonymous, uncensored and sovereign: the future we were promised but don't yet have.

DarkFi has its own blockchain with fully-programmable smart contracts, its own P2P network, several apps and tooling.

The main changes over the previous testnet are:

  • Moving from a proof-of-stake (PoS) to a proof-of-work (PoW) consensus mechanism.
  • Improved native applications and some new applications.
  • Hardening and substantial improvements to the P2P network.

All areas have seen substantial work.

Move to proof-of-work

In 2023, we released the DarkFi PoS alpha testnet with a modified version of the Ouroboros Crypsinous anonymous PoS consensus algorithm.

We originally chose this direction since PoS has finality, which means once a block is confirmed, it cannot be reversed or changed. This is good because it is deterministic, and also reduces resource usage since state updates can never be reversed so less data is stored.

However, without a wide distribution of tokens, PoS systems can easily become oligarchic. In our implementation of Ouroboros Crypsinous, the probability of winning a block was quasi-linear with the amount staked. This meant that the initial balances of validators would determine the future power structure of the blockchain. Validators who start with large token balances would continue to gain rewards, compounding their stake and influence over time.

Further, PoS requires some token predistribution event to bootstrap the balances of validators, which is difficult to do without compromising user anonymity (an airdrop on a transparent blockchain or a public sale with KYC felt unacceptable to us due to the anonymity trade-offs).

These questions led us to switch to PoW consensus. The update took us over a year of work since it required a lot of deep wide-ranging changes to the codebase. But the end result enables a fully anonymous and peer-to-peer token distribution.

RandomX for decentralization

DarkFi uses RandomX, the same mining algorithm as Monero: RandomX

RandomX resists specialized ASIC miners— which contribute to centralization and are vulnerable to seizures— via a PoW algorithm based on randomized instruction execution and memory-hard computations.

These design choices make the CPU the best possible hardware for running RandomX. The algorithm matches CPU architecture so closely that building an ASIC for RandomX would mean building a CPU. Because CPUs are cheap and easy to get, RandomX prevents mining from being controlled by a select few. It's also highly censorship-resistant, since it runs on readily accessible consumer hardware.

In a future upgrade, DarkFi will introduce merge-mining with Monero, which gives us all the benefits of anonymous peer-to-peer mining without the security risk that comes with bootstrapping a brand new blockchain.

Anonymous smart contracts

DarkFi has full smart contract functionality, allowing any developer to create custom apps that are executed onchain.

DarkFi also comes with several native smart contracts, so that the following features are built-in with the blockchain:

  • Anonymous transfer of funds.
  • Onchain anonymous atomic swaps.
  • Arbitrary token issuance, which can also be made programmatic via an owner contract.
  • Fully anonymous onchain DAOs with token-weighted voting.

DarkFi provides a WASM engine with a secure protected environment. Contracts are able to inspect other contracts but not to modify them. The contracts have a process phase after which they produce an update that's applied atomically. Contracts are only allowed to read during the process phase, and all writes happen during update.

Contracts then export ZK data based off the contract call data. Because ZK proofs are computed in advance, the entire call trace of contract calls in DarkFi is public ahead of time. This is different to most other blockchains which compute the data dynamically. In DarkFi, data is checked rather than computed.

For composability, developers can specify contract function hooks. For example, when sending funds to a DAO, we use the spend hook of a token which specifies these funds can only be spent by the DAO::exec() function, which executes a proposal.

In the future, the DarkFi smart contract subsystem will be extended with more and better cryptography, as needs require.

Money Smart Contract

The core native contract is called Money. This contract allows anonymous payments and atomic swaps. Anybody can mint custom tokens and this can even be programmed by specifying an external contract function as the mint owner.

These functions are the backbone of a truly anonymous peer-to-peer payments system, following the defined specifications.

Anonymous DAO Smart Contract

We've created the world's first and only Anonymous DAO. This is a fully onchain anonymous DAO, with token-weighted voting, where all members, votes, and tokens are fully hidden and anonymous, as per its specifications. Using this you can raise an anonymous treasury onchain and manage it via onchain voting. The DAO is fully generalized, so it's not just managing a treasury, but can also call any other smart contract.

Anonymous DAOs are a major step forward for the agorist resistance. We can use them to fundraise for causes and direct resources with a single voice. This makes us a unified economic power.

ZK Tooling Enhancements

zkas, as a language, supports specifying ZK circuits with witness definitions. Tools like zkrunner enable debugging and visualization of circuit execution. Circuit simulations provide insights into ZKVM behavior during proof generation.

Security

DarkFi's code is simple and direct. Wherever possible, complexity is kept out. We've also had audits of our ZKVM by cryptographer Ying Tong, and our ZK contracts were audited by ZKSecurity. For this audit, we also produced a spec of our ZK contracts.

"Darkfi's codebase was found to be well-organized, with clarity provided by a large number of inline code comments. The protocol is elegantly designed, powered by a lightweight, unopinionated contract VM, on top of which most of the core protocol is implemented as userland contracts. Great care is taken to preserve user privacy and ownership at all levels of the software stack."

— ZKSecurity

Native applications

The better the foundation of the tech, the higher quality products you can deliver to users. DarkFi tech is fully programmable and generalized, but also opinionated and oriented towards specific uses.

darkfid

The main daemon participating in the Darkfi network. It's responsible with connecting to rest network nodes, syncing the blockchain and perform consensus. Keeps the current state of the Darkfi network, which can be accessed from other tools via its exposed JSON-RPC methods.

minerd

The daemon responsible for mining Darkfi native blocks. It receives requests from darkfid and mines the block using RandomX algorithm.

drk

The command line client for darkfid has been upgraded to support all the Darkfi blockchain network upgrades. Users can now perform anonymous transactions, DAO operations, tokens issuance and more.

explorer

A daemon providing a visual interface to explore blockchains on DarkFi networks. It can be self-hosted, for users that want to only keep track of their node(s).

Vanity Adddresses

Users can use vanityaddr tool to generate custom DarkFi keypairs, contract IDs and token IDs.

P2P Network Upgrades

Our P2P network is based on the implementation of the Bitcoin P2P network by evoskuil but implemented in Rust and with extended features. It manages sessions for seeding, inbound/outbound connections, and manual connection management.

The network is transport agnostic, and can use transports like TCP, Tor, and I2P. Transparently it is also possible to additionally encapsulate and encrypt the protocols with TLS, which for example we do by default when using TCP.

DoS Protections

The P2P module now natively supports protections against denial-of-service attacks, by enabling app developers to set messages limits, like its max size. The P2P module meters each connection individually and decides whether to throttle it, or ban it, if it exceeds configured limits.

DoS Analysis Multitool

A suite of tools was developed to simulate flooding attacks on a P2P network, to verify and fine tune protection mechanisms against them.

Hostlist filtering

DarkFi now supports hostlist filtering like the Monero P2P network. Nodes can maintain a hostlist consisting of known peers, categorized into gold (peers we have connected to previously), white (peers that are online), grey (peers we're not sure about), and black (peers we will never connect to).

This reduces the reliance on seed nodes and results in faster and more stable connections.

Auto-Host Support

P2P can now auto-set its advertisable IPv6 address, making configuring a public node having less friction, enabling community members to support the network with publically accesible nodes.

dnet

The python based tui has been massively improved, enabling users to explore Darkfi P2P network topology, supporting multiple applications.

Enter the Dark Forest

Start using the testnet now!

Explore the current testnet via our deployed blockchain explorer. Updates and upgrades on DarkFi PoW alpha testnet will be published on DarkFi insights and on our social channels. Future upgrades will include merge-mining with Monero, custom smart contract deployment, and many more apps and use cases.

DarkFi is providing the tools for the sci-fi future we were promised — without compromise. We build privacy-preserving tools using the tools that protect our rights and the freedoms of every user of DarkFi.

DarkFi is built by anonymous developers using P2P anonymous software.

Want to contribute? Join us.

About the release: This is the testnet code of the DarkFi network. It is being provided _as is_. We encourage everyone to try out the testnet and find bugs. Please send us feedback on IRC or via Codeberg. To be clear: no guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the testnet code. No assurances are given the testnet will work as intended and users may experience delays, failures, errors, omissions, financial loss or loss of transmitted information. By electing to use the testnet you are doing so at your own risk. Neither the authors and contributors to the testnet code nor any member of the DarkFi community shall be held responsible or liable in any manner. You hereby release them from all liability or responsibility for any loss of whatsoever due to the foregoing factors. We do not condone illegal or unethical behaviour. Nothing in this post should be construed as investment advice or legal advice. All testnet code is licensed under AGPL3.
Back to top
Back to dark.fi