1.0.1 • Published 1 year ago

zg_match3 v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Match 3 verifier demo

Purpose

  • Empower your match3 game with on-chain ZK-proofs

Installation

  • npx and a node package manager of choice yarn, pnpm, npm

Example

  • See test/src/index.ts
    • Try running cd test && pnpm verify

How it works

  • Essentially what we are trying to accomplish is verifying the game state after a player has made some moves. Once the verifying input is set, call the verify.verifyProof to have the ZK circuits verify the validity of the game.

Game state variables

These are the variables used to determine the state in the game.

  • scores
    • An array (the variety of items to be matched, currently of fixed length 5) of counts of pattern matched. Each count is mapped to the matching item with index as the array index.

Parameters

  • Inputs
    • fromSeed
      • An arbitrary bigint representing the inital state.
    • toSeed
      • A bigint representing the state after moves have been made.
    • fromBoardM
      • A two dimensional array (bigint) representing the state of the board. Note that the board is tilted 90 degrees counter-clockwise so adding new items can easily be done by appending to the end of the array
    • toBoardM
      • A two dimensional array (bigint) representing the state of the board after moves have been made.
    • step
      • The count of the moves that a player has made up to this point of the game.
    • stepAfter
      • The count of the moves that a player has made plus the amount of moves intended to make.
    • fromBoardPacked
      • The fromBoard two dimensional array packed into a single bigint. See packBoard in helpers.
    • toBoardPacked
      • The toBoard two dimensional array packed into a single bigint. See packBoard in helpers.
    • scorePacked
      • This is a big int representing the scores that a player has earned by creating matches. In the game, there should be a scores array that tracks the amount of pattern-matching a player has done, each time earning 1 point. And scorePacked is just a way to compress that down to a single bigint.
    • posPacked
      • All the positions on the board that a player have selected to play, compressed into a single bigint
    • itemPacked
      • All the actions that a player have played, compressed into a single bigint. Action value: 0 (no swap), 1 (horizontal swap), 2 (vertical swap)
    • moveN
    • argN
      • Currently unused. Can pass in 0n
1.0.1

1 year ago

1.0.0

1 year ago