0

I read this paper: https://eprint.iacr.org/2013/784.pdf

that introduces the idea of Bitcoin-based time commitment scheme. In which if the commiter does not open his commitment before a specific time t, the other party can fine him some bitcoins so the committer is enforced to open the commitment before time t. Is that kind of time commitment is available using etherum smart contacts?

This article speaks about commit and reveal on etherum https://medium.com/gitcoin/commit-reveal-scheme-on-ethereum-25d1d1a25428

  • Sure, this seems easy and not very different from my answer to your recent question about zero knowledge contingent payments: ethereum.stackexchange.com/questions/65884/…. Just have the party with the secret escrow the ether instead. – smarx Jan 22 at 5:43
  • I think your answer on previous question can not work. If you see Fig.1 in academic paper which I have attached. A bitcoin time based bitcoin works as follows, the commiter and the receiver jointly send the transaction( Tx commit) to the bitcoin. Then there is 2 options . First if the commiter open his commitment in time by sending the open transaction, he will get the bitcoin he has posted back. Otherwise, the receiver can fine him by sending the fine transaction if he commiter do not open his commitment before a certain time – Mohamed Jan 22 at 6:02
  • That's pretty much exactly the code from the other question. I'll make an answer here with the change. – smarx Jan 22 at 6:02
2

This code is nearly identical to my answer here: Zero knowledge contingent payment on etherum?. The changes mostly involved renaming variables, but the core concept is the same:

  • ether is escrowed
  • if the preimage is revealed before the deadline, the funds go to one account
  • if the preimage is not revealed before the deadline, the funds go to a different account
pragma solidity 0.5.2;

contract TimedCommitment {
    address payable revealer;
    address payable fineRecipient;
    bytes32 public hash;
    uint256 public deadline;

    constructor(address payable _fineRecipient, bytes32 _hash, uint256 timeout) public payable {
        revealer = msg.sender;
        fineRecipient = _fineRecipient;

        hash = _hash;
        deadline = now + timeout;
    }

    // If this is called with the correct preimage, the revealer gets their funds back.
    function providePreimage(bytes calldata preimage) external {
        require(keccak256(preimage) == hash);
        revealer.transfer(address(this).balance);
    }

    // Pay the fine to the fineRecipient if the timeout has expired.
    function refund() external {
        require(msg.sender == fineRecipient);
        require(now >= deadline);

        msg.sender.transfer(address(this).balance);
    }
}
  • Thanks for your answer, I think that is different than the way it was implemented on the paper which is based on bitcoin scripts. Is it works on the same way – Mohamed Jan 22 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.