Skip to content

noway/nzcb-circom

Repository files navigation

NZ COVID Badge - ZK-SNARK repo

Info & FAQ

Read the website for more info.

Technical info

Based on NZCP.circom

How it works

The circuit takes in the following private inputs:

The circuit outputs the following public inputs:

  • nullifierHashPart - the blinded sha512 hash of the credential subject of the NZ COVID Pass. That is your given name, family name and date of birth delimited by comma. The blinding is done by taking 256 bits of the 512 bit hash, therefore one blinded hash can represent 2256 identities.
  • toBeSignedSha256 - the SHA256 hash of the toBeSigned value.
  • exp - the expiry date of the NZ COVID Pass.
  • data - 20 bytes of pass-through data that is used for the receiving address (MEV protection)

NZ COVID Pass verification

The circuit does not verify the signature of the NZ COVID Pass. It merely proves that an identity is associated with the NZ COVID Pass, be it signed or unsigned. The user may not be in a possession of a valid signature for the ToBeSigned value that is provided.

The signature is verified in the solidity contract.

Limitations

For live passes:

  • The length of the ToBeSigned value is limited to 351 bytes.
  • The length of the credential subject string (defined as ${familyName},${givenName},${dob}) is limited to 64 bytes.

Tests

  • Create .env file in the root directory of the project
  • Populate it with at least 1 live pass URI.
    • Use .env.example as a reference.
  • Run make test

Plonk proving key generation

  • powersOfTau28_hez_final_21.ptau from https://github.com/iden3/snarkjs#7-prepare-phase-2 was used to generate the Plonk proving key. Blake2b hash is 9aef0573cef4ded9c4a75f148709056bf989f80dad96876aadeb6f1c6d062391f07a394a9e756d16f7eb233198d5b69407cca44594c763ab4a5b67ae73254678
  • nzcp_example_final.zkey b2sum is 0a1979ca92cc7bcd608b0a5eb7d5252959ab17ffa69758dab8f17a44a83e842d61aa5709bde426215beca4296d7f1ddb86aadd66708717f484ce7295c8f8250c
  • nzcp_live_final.zkey b2sum is edab1c7534d26b495ac0ac779b4fa9f2c75bc89fe9c38ed0a2767b0c390d7bd53594e27a3e106696c6186e82c27e6683f87fbe58d38f1190990971fea37d173f

The key was generated using the plonk_example and plonk_live tasks in Makefile.

Tech Spec

Related repos

License

MIT License