#bitcoin #farcaster #monero #atomic-swap

farcaster_core

Farcaster project core library, blockchain atomic swaps

15 unstable releases (5 breaking)

0.6.4 Jan 2, 2023
0.6.3 Dec 28, 2022
0.5.1 Aug 15, 2022
0.5.0 Jul 27, 2022
0.4.0 Nov 17, 2021

#1636 in Magic Beans


Used in farcaster_node

LGPL-3.0

405KB
7.5K SLoC

Build Status unsafe forbidden Crates.io Documentation License: LGPL v3 MSRV

Farcaster Core Library

The Farcaster atomic swaps project core library aim to implement in Rust the following functionalities needed to build a swap node:

  • Swap deals (contains all necessary information to start a swap)
  • Swap roles and trade roles (who does what during the swap)
  • Transaction templates implementing on-chain behaviours (arbitration engine, e.g. on Bitcoin blockchain)
  • Signature and cryptographic utilities
    • ECDSA adaptor signatures
    • Cross-group discrete logarithm proof system
    • Schnorr adaptor signature
  • Messages exchanged between farcaster nodes, i.e. the peer-to-peer messages also called protocol messages.

Documentation

Check out the documentation of this library on docs.rs/farcaster_core. All possible improvements, such as adding usage examples and expanding on existing docs would be extremely appreciated.

Core framework

This library's purpose is twofold: providing a flexible framework to add specific blockchain support and implementing these specific blockchains (currently bitcoin and monero). The framework is split in modules at the root of the crate:

  • blockchain: generic types and traits for declaring assets/chains and on-chain behavior.
  • consensus: encoding and decoding implementation for all types in the crate, used to serialize and deserialize messages exchanged.
  • crypto: traits and generic types to define cryptographic interactions (wallet capability, commit/reveal scheme, signature and key types, etc).
  • trade: generic types and utilities for handling the trade setup, e.g. creating a deal.
  • protocol: generic types related to the execution of the protocol and messages exchanged between peers.
  • role: role definitions (trade and swap) and trait for the generic framework.
  • script: generic types for transaction data management.
  • swap: swap related types and swap concrete instances (e.g. bitcoin-monero).
  • transaction: transaction traits for building and validating the arbitrating set of transactions, i.e. the on-chain engine that implements the protocol's game-theoretic mechanism.

The blockchain specific support is added under the the following modules:

  • bitcoin: support for Bitcoin, implementation of all required traits from the framework, e.g. the Arbitrating blockchain role.
  • monero: support for Monero, implementation of all required traits from the framework, e.g. the Accordant blockchain role.
  • swap/btcxmr: definition of a swap between bitcoin and monero modules with re-export of the majority of generic types with fixed types associated to bitcoin and monero.

Features

The experimental a,d taproot features are enabled by default.

  • experimental: enables experimental cryptography, i.e. not battle tested nor peer reviewed, use it at your own risks.
  • taproot: [work in progress] enables support for Bitcoin Taproot on-chain scripts as the arbitrating engine method.

Adding blockchain support

Check bitcoin, monero, and swap/btcxmr modules to see and example of swap pair. For more details on high level context see the RFCs.

Releases and Changelog

See CHANGELOG.md and RELEASING.md.

About

This work is part of the Farcaster cross-chain atomic swap project, see Farcaster Project.

Licensing

The code in this project is licensed under the LGPL-3.0 License

Dependencies

~19MB
~310K SLoC