DRM Mina - Unity games

This topic is to discuss the proposal submitted by @kadirchan
Please see below for the details of the proposal and discussion.

27th August, 2024
The start date is updated to 1st September after discussing with proposer.

13th August, 2024
Current status: Funded
Funding Note: DRM is a great space to explore the application of zero-knowledge proofs and we look forward to the progress and support for this on mina. DRM mina has successfully delivered their project in cohort 3 of zkIgnite. The risk of funding this project is low. The budget is in line with the work proposed. Being one of the early applications of DRM in the space, we are assessing the impact to be medium-low in the short term. The project will help uncover design patterns and unique ways to approach this space.

31st July, 2024
Current status: Under Consideration.
Opened for community discussion on : 31st July.

1 Like

Navigators Season 2: DRM Mina Growth Grants Proposal

Project Background

DRM Mina is a game marketplace that connects game creators and players on Mina. It uses Mina’s zk-proofs as an alternative to today’s anti-piracy systems, preventing authorized or unauthorized use of 3rd party applications and users’ data, as well as removing the dependency of game ownership on game markets, preventing monopolies and high deductions from game developers.

  • Problems We Are Trying To Solve :
    1. Current game marketplace providers and third party companies collect user data with or without consent and use it for their own benefit, such as marketing.
    2. Marketplaces making cuts between 30% - 12% from each game sales. As these cuts are charged to the game producers, they find the solution in raising the price of the game. Rising game prices are also making it harder for gamers to access games and leading some gamers to pirate games.
    3. Game producers who want to provide piracy protection from a third party face high licensing fees, which are also reflected in the price of the game.
    4. When a game is purchased from one game provider, the licenses cannot be transferred to other game providers, forcing the player to use the same provider to play the purchased game. Each of these game providers also allows game files to be obtained only from their own servers, making them a monopoly in their own right.
  • Our Solutions:
    1. Thanks to Mina and its zk-proofs, users can prove whether or not they own the game without leaving their device. Only the unique hash of this information generated by the zk program is kept outside the device at on-chain.
    2. The system does not require high cost to maintain so the amount charged to the game producers and users will be much lower than competitors. Cheaper games are more accessible for more gamers.
    3. There is no monopoly here as players don’t have to use the platform to use the verification system.
    4. Once players have purchased the game and registered their device, they can download and play the game directly and do not need to use a separate client or app to do so. It doesn’t matter from which source they obtain the game files, this provides relief on storage and distribution fees and therefore on game prices.

DRM Mina started development in zkignite 3 and here is the version running on the Protokit appchain.

Github Repository

Proposal Overview

This project, which was planned and started within the scope of Zkignite, has turned out to have wider scope than expected as we realize its potential more and more every day. However, more time and resources are needed for the improvements and new features.

  • Problems:
    1. The current version works with Protokit, but due to the fact that the expected updates to Protokit are still not ready, the current version does not have L1 settlement and data storage. In addition, in order to be able to launch mainnet with Protokit, the framework must be completely finished and the necessary audits must be done. This is the biggest blocker of not being able to launch to mainnet.
    2. Since the current version is completely dependent on the Protokit appchain to work, the appchain needs to be stopped and restarted in case of errors on the appchain side (js heap full, wrong tx arriving, etc.). While this is a big problem for liveness, it also causes the information loss because the data is not stored permanently in current version.
    3. The inability to launch mainnet means that game developers are unable to sell their games for a real monetary value, which makes the games market less attractive, so currently there are only a few games that we have made with our own resources.
    4. Our modules and utilities are wirtten with o1js 0.13, so we cannot benefit from new upgrades and improvements in o1js.
  • Solution:
    1. In the current design, all operations are planned to be done with the Protokit and central sequencer, which send transactions to Mina L1. Instead, in the scope of this project, the main parts such as buying games, registering devices, etc. will work directly with L1 contracts using the new and updated OffchainState and Action & Reducer APIs.
    2. We plan to provide the state that will be changed with the deviceSession information generated during the game with a customized sequencer made for this purpose. This sequence will roll-up the proofs for the state change from the players and send them into the contract, so that the players are not asked to make a transaction for each game session.
    3. We will use this backend for data storage and data availability. Also we can add decentralized data availability and storage protocols to support these solutions in the future.
    4. After writing the contracts and utilities with the latest o1js with the planned additions and performing the necessary tests, the product will be firstly released to the testnet and then to the mainnet.
    5. Once the market is ready for shopping and attractive to users, we will negotiate with game producers and, if agreed, add their games to the market.
  • Impact:
    DRM Mina allows game developers to sell and authenticate games created using the Unity Game Engine (currently, we only support Unity) on the Mina Protocol. After registering their games to the system, game developers can import the DRM Mina Unity package into their existing games and use the system in their games as they wish. In this way, it will contribute to the growth of the game ecosystem within Mina by bringing the real power and application areas of zkproofs and Mina to the outside world.
  • Audience:
    DRM Mina targets the gamers and the game developers all around the world.

Architecture & Design

  • Detailed Design/Architecture:
    The DRM Mina architecture allows users to purchase their games and verify their purchases afterwards.

  • Current Architecture:
    Our current version working with Protokit consists of 3 main modules:
    Balances: control user balance (in Mina) to buy games.
    GameToken: allow creators to publish their games, customize them and controls the sales of games.
    DRM: keeps device information hash of users that have bought game, and their device’s last session informations.


    First, game producers register their games in the system using GameToken with a submission fee (currently 100 Mina fee in test appchain). In doing so, they set their own properties such as:

    gamePrice, discount, timeoutInterval, number_of_devices_allowed
    

    and only they can change them afterwards. In this way, users can purchase the game added to the system.

    Users purchase their games or can pay for their friends and gift to them on Mina by paying the sales amount gamePrice - discount set by the publisher with Mina. Users who have purchased the game are stored in a mapping as:

    [key: (gameId, UserPublicKey)] -> value: Bool
    

    After buying the game users can download games to their computers (we currently support Windows, MacOS and Linux). However, they will need to register their device in order to play. To submit their devices, they use zk-proofs with a built-in system to ensure privacy. This not only ensures privacy but also prevents them from spoofing information they don’t have.
    These are the unique identifiers that our system uses to distinguish devices from each other:

    cpuId
    systemSerial
    systemUUID
    baseboardSerial
    macAddress
    diskSerial (not active yet)
    

    After the device information is collected (without taking it out of the user’s computer), the hash is created with the zk-program to save in DRM module.

    This proof allows the device to be registered in any slot of the user’s choice from the number of slots specified by the game publisher. min: 1, max: 4 slots

    Session creation and playing

    DRM Mina uses its own DRM protection to solve ownership verification in the most player-friendly, flexible and secure way possible. The verification process consists of 3 main parts:

    App-chain
    Game and its verification scripts
    Local Nodejs host for generating zk-proofs and Mina txs 
    

    When the user first opens the game, the game verifier takes the device’s information in the background and runs some checks first, then it sends a query to the app-chain sequencer to get and check the current session information on the chain. If the game is enabled, it selects a random value that is different from the current one and sends the necessary information to the Nodejs host (which runs beside the game) and asks it to update the state and continuously checks the on-chain state for a certain period of time.

    Session Proof Generation and Submission

    As public input when generating session proof it takes:

    gameId
    currentSessionKey
    newSessionKey
    

    In addition to these, it also receives the information that we do not want to leave the user’s computer but at the same time we need to make sure that it is generated from the correct device as private input. After providing the necessary checks, it gives gameId, newSessionKey, hash as public output. In this way, both confidential information is prevented from leaving the computer and fraud attempts or double usage of proofs that can be made while updating the session state are prevented.

    The user’s wallet is not needed to send this transaction. The host can send the transaction to the sequencer from the random temporary wallet it created. The sent tx changes the state if it contains a valid proof. If the in-game validator validates it within the specified time, the player can play the game without generating a new session during the timeoutInterval but if not, the player is logged out from game.

  • New Architecture:
    With the new architecture, we plan to move game purchases, session creation and other contract interactions directly to L1 through OffchainState. In addition, we want to handle the process of sending the session proof that users need to generate to play their games to the network through a separate sequencer so that they do not sign and send tx on every game session.
    In addition to this, with the device data collected from volunteers so far, we will check the validity of the identifier information in the contract and in the game in general terms.

    The design of the purchasing system will be similar to the old one, but instead of doing it in the central sequencer, we will move it to L1. The sequencer will act as the data layer for offchain storage. Of course, the content and logics of the contract may need to change during this process.

    In the current version, users send their proofs to the appchain and let it handle the settlement, but there is no settlement part in the current version. In the new version, the local Nodejs prover that will run on the users’ local will send the proofs to our new sequencer customized for this instead of the appchain, the proofs collected in a recursive way with other users who send in that block will finally be settled to L1 by the sequencer.

    With all of this, we will release a more optimized and customizable version of the current DRM Mina Unity package in line with the revised contracts. We will also prepare the documentation of the system so that users who want to integrate the package into their own games can learn how to do it and find answers to their questions.

  • Vision:
    Our vision is to bring game developers and gamers together in a more fair gaming marketplace running on Mina. We want indie game developers can deliver their games securely to gamers without being crushed by massive cuts, and gamers can be confident that their data is safe while they enjoy the games they buy.

  • Existing Work : Github Repository

  • Production Timeline :
    The prototype of the product is ready, but the infrastructure needs to be overhauled and tested. It would also be good to extend the Unity package and improve its UX. For this reason, the product is planned to launch Mainnet in October or November.

Budget & milestones

  • Deliverables:
    • o1js Contracts
      • GameMarket and DRM contracts in pure o1js
      • OffchainState mechanisims
      • At least 90% test coverage
    • Customized Sequencer and Improved Backend
      • Proof aggregation and settlement
      • Merkle tree storage and its CRUD operations
    • Improved Unity Package
      • Code refactoring and optimizations based on improved contracts
      • Improving the developer experience
    • Improvements on website
      • Increasing user interactions such as comments and reviews
    • Improved and Renewed Game Addition Portal
    • DRM Mina Documentation
    • (Optional) New Games on Marketplace
  • Mid-Point milestones:
    • Partially completed and tested o1js smart contracts
    • Sequencer and proof aggregation prototype
    • Refactored DRM Mina Unity Package
    • Website improvements and additional user interactions, comments and ratings
  • Project Timeline : 3M
  • Budget Requested : 30,000 MINA
  • Budget Breakdown:
    • New sequencer and backend implementations (13500 Mina)
    • Smart contract implementation & integrations (6500 Mina)
    • Frontend improvements & implementations (5000 Mina)
    • Unity package and integration costs (3000 Mina)
    • Budget of oursourcing for designs, incentives and server costs (2000 Mina)
  • Wallet Address:
    B62qonjCTTzww6w7Msquv5sH5Ti5A2XNPfzjBPzN6zFHkX8LyzKuS4C

Team Info

Risks & Mitigations

  • What risks or dependencies do you foresee with building this project ?
    • Since a lot of the execution and proof generation will be on the user’s computer, it may be slow for some.
    • It may be difficult for a while to get small-medium game studios to integrate their games and add them to the market, so in the early stages there may be small scale games in the market.
    • Since it will take advantage of experimental o1js features, unexpected bugs may be encountered, but this will be fixed with future updates.
    • The use of a central server as a data layer and users sending some proofs with a sequencer can prevent the system from being full live.
  • What are your mitigations if any?
    • We will migrate the whole system from Protokit app-chain to o1js L1 and customized sequencer.

Thank you for the proposal! I noticed that you mentioned liveness as one of the problems that you are trying to solve. However, your implementation of a sequencer might also face similar challenges, such as a single point of failure and censorship. Could you please elaborate on your plans to mitigate these risks?

2 Likes

Hi :slight_smile: , thanks for the feedback. In this architecture sequencer will work as a transaction aggregaotr to prevent users from paying transaction fees for each game session, because they need to proof they can change corresponding state to auth. Of course, if the sequencer gets congested or crashes, they can send the transaction directly from their computer if they wish but this time they need an Mina account on their local prover. Actually, the problem we will face is similar to the one we would have if we were using the protokit appchain in its current form, which can also crash and stop. Since Sequencer will only be used as a transaction aggregator, it cannot be said that the system stops completely if it crashes. However, since we are using a centralized system as a data availability layer for now, temporary blockages may occur in some cases. We will try to solve these as well.

This application is approved for Funding.

DRM is a great space to explore the application of zero-knowledge proofs and we look forward to the progress and support for this on mina. DRM mina has successfully delivered their project in cohort 3 of zkIgnite. The risk of funding this project is low. The budget is in line with the work proposed. Being one of the early applications of DRM in the space, we are assessing the impact to be medium-low in the short term. The project will help uncover design patterns and unique ways to approach this space.

2 Likes

We have updated the start date to 1st September after discussing with proposer.

Greetings from DRM Mina updates:

  • The skeleton of the website has been rebuilt, places that may be incompatible with the new version have been changed/removed.
  • Backend was renewed and incompatible parts were replaced.
  • Contract helper structs and functions written.
  • We are currently working on a customized token contract, we are trying to write the token contract in accordance with the new standard as much as possible.
  • New games will start to be onboarded once the contract and the overall system is complete.

DRM Mina second update:

  • Contracts and tests almost finished, also deployed to devnet and make onchain tests.
  • Web worker and their contract interactions partially completed. I’m trying to run offChainState program in web workers but currently it seems inefficient.
  • Improvements on server.
2 Likes

Third Update:

  • Waiting offchainstate refactor pr for finalize contracts.
  • Implemented event listening on unity game.
    Unfortunately blocked by current offchainState API but refactor pr going to release soon.
1 Like

It will be an interesting project, and I’m eagerly looking forward to the developments

1 Like

Current status of DRM Mina:

  • New o1js version for offchainState api released on oct 15, upgraded contracts to new version and deployed to devnet.
  • Re-organized backend as 3 main container:
  1. API Server for off-chain components.
  2. Sequencer for bundling and creating session txs for gamers.
  3. Settlement for listening and creating settlement proofs regularly for offchainState Actions.
  • Created bundled session proofs to reduce sequencer maintenance costs.
  • Implemented action & event listener for Unity Package.
  • Integrated buy game & register device to front-end and other on-chain listeners to provide real time data on UI.
  • Comment Section added in game pages, every user can create comment and rate games!
1 Like

Updating current status of DRM Mina:

  • New version of website is live! ( Downloadable contents are not updated yet make sure you cloned apps from DRM-Mina github )
  • Sequencer and Settlement services are finally running on Devnet. Players can submit their sessions without giving tx fee through Sequencer and Settlement service makes sure all valid actions are reduced and everything is up to date :star_struck:.
  • DRM Unity package is updated (not released yet). Now it sends proofs to sequencer with using local nodejs prover and directly listens emitted events through Mina Archive nodes.
  • Many not directly mentioned infra and uptime improvements in backend services.
  • More improvements on website responsiveness and speed.

Known Issues

  • OffchainState API seems to fragile and gives error when right after reducing actions, and sometime docker instance need to restarted.
2 Likes

Last update before delivery of DRM Mina

  • More UI/UX improvements in website, downloadables are now available for MacOS (Windows and Linux coming by the end of this week)
  • Added DRM Mina fee to (currently 5% from each sale) GameToken Contract, and some improvements on contracts.
  • Sequencer and Settlement services tested on Devnet. They are available for 3 games of DRM Mina.
  • DRM Mina Unity package released also waiting to be added to the Unity Asset Store.
  • Integrated DRM package into 3 games (It was easier than I thought) there have also been improvements for game time and gameplay to the games.
  • Added game deployment and publisher dashboard to the website.
  • Updated desktop client and released.
  • More improvements in Docs and more in the way.

Release soon!

The website looks nice. Apart from the games, do you plan on selling in-game items, boosts, etc.? These can be purchased as NFT.

1 Like

Thanks İzzet, I’m so glad you like that. Yes, it is possible to integrate these ways of monetization in the future, we can add DLCs to the list. But we need to consider if this approach would cause discomfort to the players. Because main goal of this project is provide a comfortable environment that game developers and gamers especially in indie games where they can feel this marketplace belong to them

1 Like