Create the Commit // Reveal scheme design proposal document
alilloig opened this issue · 2 comments
alilloig commented
Issue To Be Solved
We need to create a generic solution that smoothly integrates into any (gaming) contract for any commit / reveal mechanic.
May be worth to take a look at pete's job with blind NFTs? https://github.com/psiemens/cadence-scratchpad/blob/main/BlindNFT.cdc
Suggest A Solution
TBD
Context
This needs to be done prior to the creation of the game contract proposal
satyamakgec commented
Suggested Solution -
/// Basic interface to fulfil the commit reveal technique
pub contract interface CommitReveal {
/// Public resource available to everyone to reveal the partial commitment
pub resource interface Reveal {
/// Optional reveal condition, It can be used when reveal is based on a certain on-chain event
/// ex - Only reveal after a certain block or once all participants are committed.
pub let revealCondition: AnyStruct?
/// Function used to reveal the partial secret commitment.
/// @param publicCommitment It is the partial data that get committed to the chain. Used to know
/// which commitment needs to get revealed to the public.
/// @param remainingPartialCommitment Remaining part of the commitment that was secret during the commitment phase.
/// @param salt Private key or any random string used to generate the `secretCommitment`.
pub fun reveal(publicCommitment: AnyStruct, remainingPartialCommitment: AnyStruct, salt: String) {
pre {
revealCondition == true, "Reveal phase is not kicked in yet."
}
}
}
/// Resource that will be owned by the user who calls the commit
pub resource interface Commit: Reveal {
/// Function used to commit anything on-chain.
/// @param publicCommitment It is the partial data that get committed to the chain.
/// @param secretCommitment It is the other partial data secretly committed to the chain.
pub fun commit(publicCommitment: AnyStruct, secretCommitment: String)
}
}
alilloig commented
Same than for the DynamicNFT design document issue, may I close this?