GithubHelp home page GithubHelp logo

crossclaim / xclaim-sol Goto Github PK

View Code? Open in Web Editor NEW
24.0 5.0 8.0 1.24 MB

XCLAIM(BTC,ETH): Solidity implementation for Bitcoin backed tokens on Ethereum

Home Page: https://xclaim.io/

License: GNU General Public License v3.0

JavaScript 44.87% Shell 0.34% Solidity 54.80%
blockchain interoperability bitcoin ethereum solidity

xclaim-sol's Introduction

XCLAIM(BTC,ETH)

Gitter chat

Disclaimer: this project is still under development and not safe to use!

Overview

XCLAIM is a framework for achieving trustless and efficient cross-chain exchanges using cryptocurrency-backed assets (CbAs). XCLAIM allows to create assets which are 1:1 backed by existing cryptocurrencies, without requiring trust in a central operator. While this approach is applicable to a wide range of cryptocurrencies, we currently focus on implementing Bitcoin-backed tokens on Ethereum, i.e. XCLAIM(BTC,ETH).

XCLAIM introduces three main protocols to achieve decentralized, transparent, consistent, atomic, and censorship resistant blockchain interoperability for cryptocurrencies:

  • Issue: Create Bitcoin-backed tokens on Ethereum.
  • Swap: Swap Bitcoin-backed tokens on Ethereum with Ether.
  • Redeem: Burn Bitcoin-backed tokens on Ethereum and receive Bitcoins in return,

The current XCLAIM prototype is compliant with the ERC20 standard. An overview of the protocols is presented below:

overview of XCLAIM issue, swap and redeem protocols

XCLAIM guarantees that Bitcoin-backed tokens can be redeemed for the corresponding amount of Bitcoin, or the equivalent economic value in Ethereum. Thereby, XCLAIM overcomes the limitations of centralized approaches through three primary techniques:

  • Secure audit logs: Logs are constructed to record actions of all users both on Bitcoin and Ethereum.
  • Transaction inclusion proofs: Chain relays are used to prove correct behavior on Bitcoin to the smart contract on Ethereum.
  • Over-collateralization: Incentivize honest behavior following a proof-or-punishment approach. All involved parties must actively prove correct behaviour to the smart contract, e.g. by providing inclusion proofs for Bitcoin transactions.

Paper

Read more about XCLAIM in our paper (currently under submission).

Protocol Summary and Components

A concise overview is coming soon. For now, please refer to the paper.

API

Coming soon. For now, please refer to the paper.

Installation

Make sure ganache-cli and truffle are installed as global packages. Then, install the required packages with:

npm install

Testing

Start ganache:

ganache-cli

Migrate contracts:

truffle migrate

Run tests:

truffle test

This will also re-run migration scripts.

xclaim-sol's People

Contributors

alexeizamyatin avatar dependabot[bot] avatar nud3l avatar panispani 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

Watchers

 avatar  avatar  avatar  avatar  avatar

xclaim-sol's Issues

Heed Help: config for btc private network

Hi there!

I want to try to swap btc to eth on private network. In the repo I can not find where to set up and config btc private network. Can you kindly give me any clue?

Thanks!

redeem process - add replay protection

Add replay protection to redeem protocol, to prevent a vault from re-using the same Bitcoin transaction as proof for multiple redeemRequests.

Require the following digest is included in OP_RETURN of the redeem Bitcoin transaction:

  • redeemer Eth address
  • contract address
  • redeemRequestId

issueToken and registerCommit must only be called by same user account

Problem: if we do not check that the same user account is used to call issueToken, as registerCommit, the vault or a malicious user can call issueToken for arbitrary users with wrong data, causing it to failr (and collateral being slashed).

Solution: check that msg.sender is the same user that called registerCommit in issueToken

reimburseRedeem - implement reimbursement functionality

Required checks:

  • Redeem must be free! i.e., vault cannot charged a fee for this
  • User specifies bitcoin transaction fee? Challenge: if too low, tx never included. Who is to blame then? Problem!
  • We might need an oracle for current bitcoin transaction fees.

--> if BTC relay is used frequently, we can use verified TX as an estimate

Support for multiple issuers

We need to implement support for multiple issuers. Currently, it seems as if only a single issuer can register.

registerIssue: allow a user to issue multiple commitments simultaneously

Currently a user can only create a single issue commitment at a time.
Problem: mapping currently is msg.sender => CollateralCommit
Fix: increment a uint256 counter with each commitment and use the following mapping:
hash(msg.sender, counter) => CollateralCommit.

Challenge: user must track hash(msg.sender, counter)!
Fix: emit msg.sender and the counter non-digested

requestRedeem - specify vault and check if it has sufficient funds

Currently, no vault specified when making a redeem request.

Problem: vaults can prevent users from redeeming funds if they do not react -> however, we will not know who to punish.

Fix: add vault address as parameter.

Check required: does vault have sufficient funds?

requestRedeem - add "fill up" flag

Instead of users having to enter the precise amount of the vault's available BTC, when they want to redeem a large sum with multiple vaults, allow user to specify a "fill up" flag, which simply takes all of the vault's available funds.

Improvement: we avoid dust remaining in the vault's balance.

issueToken: implement replay protection for BTC lock transaction

Problem: transaction can be replayed by a user to trick contract into issuing multiple tokens, possible with different contracts

Fix:

  • Contract must check that contract address is in Bitcoin transaction -> prevent issuing on multiple issuing chains
  • Contract generates a nonce which must be included in the Bitcoin tx -> counter

As a result, the contract returns a digest of:

  • user eth address
  • contract address
  • counter

issueToken - where to send slashed collateral?

Currently, slashed collateral is paid to the vault, whose funds were locked.

Problem: may incentivize vault to try to force failures.

Alternative: burn? Keep in contract?

Other option: make vault reimbursement strictly smaller than the fee the vault would earn in case the issue would succeed

registerIssue: Update check for free vault collateral to consider expired commitments

The check for free vault collateral must also check for expired collateralized commitments.

Reason: otherwise, the vault would have to make a transaction to update the balances when a commitment expires (and user did not issue).

TODO:

  1. add additional method extracting correct amount of free vault collateral and marking it as free (stateful!)
  2. Getter method for free collateral must extract all expired commitments as well (stateless). Do the check/calculation in the frontend / offchain to save gas! (get all vaults and all existing commitments)

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.