paint-brush

This story draft by @escholar has not been reviewed by an editor, YET.

Zero-Knowledge Proofs for Questionnaire Result Verification in Smart Contracts: Design

EScholar: Electronic Academic Papers for Scholars HackerNoon profile picture

This paper is available on arxiv under CC BY-NC-SA 4.0 DEED license.

Authors:

(1) Carlos Efrain Quintero-Narvaez, School of Science and Engineering Tecnologico de Monterrey;

(2) Raul Monroy-Borja, School of Science and Engineering Tecnologico de Monterrey.

TABLE OF LINKS

Abstract and Introduction

Background

Design

Discussion

Conclusions and References

III. DESIGN

Our implementation makes heavy usage of Circom 2 and its features for generating Solidity code for ZK proof verifiers. This code is then integrated into an ERC-721 Smart Contract that allows the user to mint an NFT when a result of the questionnaire with the corresponding proof is provided. A basic implementation was made for a new Web3 platform called P3rsonalities, intended to have a personality test with results validated with a ZK proof and attested through a generated ERC-721 NFT. The deployed contract code with the Circom 2 generated Solidity verifier can be found at the P3rsonalities GitHub Repository.


We designed the Circom 2 code in such a way that it receives a two bit masks and one integer as inputs, one bit mask representing the user’s answers for each question, the other representing the answer key, and the integer representing the result of the test, having a total of 10 questions. The questions are divided into two groups so that each one represents an attribute of the final result, i.e. the final result will be a two bits integer, each bit representing an attribute. After compiling, Circom 2 generates two files we use, one WebAssembly script for the generation of the ZK witness and another Solidity script for verification of said witness on a Smart Contract executed on an EVM Blockchain. It is important to note that the generated Solidity code makes heavy use of the assembly functionalities available on the EVM, as to ensure that gas costs for executing the verification are as low as possible.


The witness generator along with the questionnaire evaluator are deployed to a centralized server, in this case an AWS Lambda function, for easy deployment and access from a REST API endpoint. The user then makes a request to this API, sending its answers to the questionnaire. The API then executes the witness generator code and returns the result of the test together with the ZK witness.


The user then makes a call, with the generated witness as an input, to the deployed ERC-721 Smart Contract for minting the NFT, attesting the result returned by the API. This Smart Contract is modified so that the Solidity verifier script generated by Circom 2 is used as a required check before minting the NFT to the user’s address.


At the end of the procedure, the user obtains a Soulbound NFT (an NFT that cannot be transferred) representing the result of their answers to the questionnaire. As this NFT can only be generated when the user possesses a valid witness for that result, it holds a special value as evidence for anyone interested in verifying the results of such a test.



Fig. 2. Architecture diagram of the complete Web3 platform for questionnaire verification generation.