Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit reveal #77 #184

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

LamsyA
Copy link
Contributor

@LamsyA LamsyA commented May 20, 2024

Issue(s): Close #77

Description

This is an implementation of the commitment scheme in cairo.

The contract uses a commitment scheme where bidders first commit to their bids and later reveal them. This ensures bid privacy until the reveal phase.

Interface: ICommitmentRevealTrait
The ICommitmentRevealTrait interface defines two essential methods:

commit(name: felt252, amount: felt252) -> felt252: Commits a bid with a name and amount, returning a hash.
reveal(name: felt252, amount: felt252) -> bool: Reveals a previously committed bid, returning true if the commitment is valid.

Checklist

  • CI Verifier: Run ./scripts/cairo_programs_verifier.sh successfully
  • Contract Tests: Added tests to cover the changes

Copy link
Contributor

@julio4 julio4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation does not fully conform to the commit-reveal scheme. The hash of the "secret", let's say x, should be computed off-chain, and the resulting hash should be used on-chain as an "attestation" that the user has committed to this value x, noted as commitment = hash(x). At the time of the commitment, the value x is kept secret while the commitment is made public.

Later, the user can reveal y, and the contract can verify that the revealed value y matches the committed value x by checking that hash(y) == commitment. This ensures that x == y.

A simple example could be the submission of a secret message, that can be optionally revealed at a later time with the guarantee that it was written at the time of commitment.

@LamsyA
Copy link
Contributor Author

LamsyA commented May 23, 2024

Okay, am on it.

@LamsyA LamsyA requested a review from julio4 May 29, 2024 07:05
@julio4
Copy link
Contributor

julio4 commented Jun 4, 2024

@LamsyA Hello, did you have the time to review and apply the changes in the last comments? Let me know if you need help.

@LamsyA
Copy link
Contributor Author

LamsyA commented Jun 5, 2024

@LamsyA Hello, did you have the time to review and apply the changes in the last comments? Let me know if you need help.

Yeah, I did

I will need your help to clarify something.

@julio4
Copy link
Contributor

julio4 commented Jun 8, 2024

@LamsyA Hello, did you have the time to review and apply the changes in the last comments? Let me know if you need help.

Yeah, I did

I will need your help to clarify something.

Yes, what points you would like me to clarify?

@LamsyA
Copy link
Contributor Author

LamsyA commented Jul 19, 2024

I have corrected the code;

  • Commitment Phase:

    • Off-chain: Compute the hash of the secret value.

    • On-chain: Store the hash (commitment).

  • Reveal Phase:

    • On-chain: Submit the original secret value.

    • On-chain: Verify that the hash of the submitted secret matches the stored commitment.

you can now review it.

@LamsyA
Copy link
Contributor Author

LamsyA commented Aug 12, 2024

Hi @julio4, kindly review this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Commit-Reveal scheme
2 participants