Game Session and Session Creation
Every time a user wants to play a game, DRM authentication script challenges the device to prove that device is registered to able to run this game. This process is called session creation.
Authentication script collects device identifiers and calculates the hash of these identifiers. Then it fetches the current session ID of the device hash from the Mina blockchain.
If the session ID is not found or equal to zero, the script notices that the device is not registered and returns a GameNotBoughtOrNoConnection
status code. Please check the Status Codes section for more information about status codes.
If the session ID is found (greater than zero), the script picks a random new session ID between 1 and 2^64-1 and sends this new session ID to DRM Mina Local Prover with the device identifiers to create a session proof and sends to one one the available sequence of the DRM Mina.
Local prover takes the device identifiers and the new session ID creates a single use only proof with DeviceSessionProof zkProgram (opens in a new tab), it takes the device identifiers
as private inputs and takes session ID
and gameToken address
as public input then gives hash of the device identifiers
and other public inputs as public output.
Public Inputs | Private Inputs | Public Outputs |
---|---|---|
currentSessionKey | deviceIdentifiers | hash of device identifiers |
newSessionKey | currentSessionKey | |
gameTokenAddress | newSessionKey | |
gameTokenAddress |
After the proof is created, local prover sends the proof to the DRM Mina Sequencer. The sequencer verifies the proof and if the proof is valid, it append this proof to the bundle of the proofs of the same game token address. Then it sends this incoming proofs to the Mina blockchain regularly as bundles.
When the Mina blockchain generates a new block with the corresponding proofs, there is an event emitted by the DRM Contract. The authentication script listens to this event and if the event is emitted with the currentSessionKey
, newSessionKey
, gameTokenAddress
and hash of the device identifiers
, the script understands that the session proof is verified and devie's session is changed correctly. Then it returns a Success
status code and the game continues to run. If the event is not emitted within the determined time, the script returns a Timeout
status code and the game stops.