Git Product home page Git Product logo

farcaster-core's Introduction

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

farcaster-core's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar h4sh3d avatar kayabanerve avatar lederstrumpf avatar leonero avatar nickf12 avatar thecharlatan avatar zkao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

farcaster-core's Issues

SwapId missing traits

  • strict encoding
  • lightning encoding
  • bitcoin::hashes::hex::FromHex
  • bitcoin::bitcoin_hashes::Hash
  • serde::Serialize/Deserialize

Coin type serialization

Bip44 proposes the Registered coin types which are defined in slip44

Of interest:

index hexa symbol coin
128 0x80000080 XMR Monero
0 0x80000000 BTC Bitcoin
1 0x80000001   Testnet (all coins)

We should distinguish the testnets for the encoding

Proper return type to recover private key

On functions recover_accordant_assets the current returned type is the arb secret key type but should be the acc secret key type, the conversion between the two types should be handled internally and not externally.

SwapId info using swap-cli

swap0-cli info

returns

swaps:
  - "0xc706…17db"

To query info about a specific swap, swap-cli needs complete SwapId to make the call

Add blockchain features

We have Version in PublicOffer that may handle features at the 'node' level but we also need per blockchain features. Example is Bitcoin with its variation between ECDSA, Taproot, etc.

Add Funding Info struct

Add a {Bitcoin,Monero}FundingInfo struct that implements serde and consensus encode, with the following fields: amount, swap_id, address.

fix network conversions

e.g.

impl From<farcaster_core::blockchain::Network> for monero::Network {
    fn from(network: farcaster_core::blockchain::Network) -> Self {
        match network {
            blockchain::Network::Mainnet => monero::Network::Mainnet,
            blockchain::Network::Testnet => monero::Network::Stagenet,
            blockchain::Network::Local => monero::Network::Mainnet,
        }
    }
}

swap_id

core does not offer swap_id

Re-implement serde support

Remove the serde feature, require traits on associated types and implement for all struct serialization and deserialization.

Modify tx label display impl

Make TxLabel Display impl print:

Lock -> Arbitrating Lock
AccLock -> Accordant Lock

Usage: in node logs and to make sure which lock is about

Add max block validity in `Deal`

This should allow the same offer to have different ID each seconds, this is a temporary fix. The offer should evolve more later.

Adapted signature

An adapted adaptor signature is not obviously and adapted signature, as an adapted signature could also be an adaptor signature

That is a confusing notation

Replace Bitcoin Secret and Public key types

Replace key types with bitcoin::secp256k1 types instead of bitcoin wrapped version that contains network and compress attributes, those attributes are unnecessary and at the wrong place.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.