Private Key encryption in Solidity

Viewed 235

I need a way to decrypt a string in a smart contract with a private key.

The scenario is:

I am building a lotto-like smart contract. Users will buy random tokens which are mapped to an encrypted string so users can not track whether the more valuable tokens are already purchased. At the end of the campaign, I will publish the private key in the smart contract so the tokenURI function can return the decrypted URI for the token.

mapping(uint256 => string) private _tokenURIs;
string defaultUri;
string privateKey;

function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
    if (privateKey == "") {
        return defaultUri
    }
    return decrype(_tokenURIs[tokenId], privateKey);
}
0 Answers
Related