Secure marketplace for selling digital assets without leaking them
Prize Pool
AssetGuild allows you to upload any content which can be viewed only by people who have bought it. The content or their IPFS hashes are stored on-chain in special ways which guarantee someone can access it only after paying. We store 2 versions of a content: the preview, and the original. While the preview is openly stored, the original one is stored using Fully Homomorphic Encryption, on 2 levels and an asymmetric key cryptography to ensure only the seller and buyer can see it, not even the contract executing it.
The project depends on Fully Homomorphic Encryption, which is a way to do computation on encrypted data. When the user uploads their content, the IPFS hash is what we want to protect, as you can access the content only with it, and without it you cannot.
When our contract gets the hash, it encrypts it using a symmetric key which the uploader gives. On-chain, it stores this encrypted hash openly, and the symmetric key securely (in a manner it cannot be read from the chain state, on a chain which supports such a form of storage). Since the chain we are using only supports such storage for integers, there's some back and forth conversion between string and int.
Before the user requests the original content, they generate an asymmetric key in their client, and they pass the public key in the function to get the original hash. Inside the smart contract, initially we verify (using internal structs/records) if the user (function caller) has paid for the content or not. If yes, we decrypt the encrypted hash using the privately stored symmetric key, and then we re-encrypt this hash using the public key of the function caller using FHE.
The function returns the version of the original content hash which is encrypted using the public key which they themselves provided. So, they can decrypt it on their end. We also add the public key to a nullifier set so the same key cannot be passed in twice to fetch the content.