-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add zkp in neo #2647
Comments
Well, I will explain the Groth16 implementation of zk-snark |
Groth16Principle AnalysisGroth16 is one implementation of zk-snark, which is optimized mainly on the basis of PGRH13. It implements the process of proof and verification through 3 points (at least 2 points). Proof of CompletenessProof of Security
The PDF can be obtained here: References |
Later I will explain the trusted set-up scheme of Groth16. Related documents will be uploaded as soon as possible |
Really happy to see this direction on Neo @doubiliu! Could you clarify if this is a proposal to use Groth16 for SNARKs on Neo, or if Groth16 is only being used as an example to illustrate the concept? I ask because I believe it would be more practical to prioritize a universal SNARK proof system (like PLONK or Marlin). For the tradeoff of a somewhat larger proof size, it removes the need for a new trusted setup on every arbitrary circuit. Needing a new ceremony for every contract or update to a contract is very cumbersome and introduces more risks that toxic waste isn't properly dealt with. I think it would result in a much more developer-friendly solution for those who want to build their own applications using ZKP on Neo. |
We will first add some interoperability in neo-core to support the groth16 solution, because efficiency and some mature projects can learn from. |
We have prepared a demo. |
using System; namespace BLSVerifyDemoContract
} |
Use |
Port the neo-project/neo#2647 (comment). Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
@doubiliu, we've successfully adapted new Groth16-related interops and tried to build and run simple Groth16 verifier contract on NeoGo nodes (in the nspcc-dev/neo-go#3043), it works perfectly. My question is whether MPC ceremony will be organized by the core developers to generate the initial randomness after 3.6.0 release? Or maybe it's the duty of every dApp developer team to run the MPC ceremony for their own dApp? |
Is Neo going to offer an MPC setup solution? The way I see it, it should be both. Do an organized event for Powers of Tau to generate the universal* part. Then Neo provides tools for phase 2 setup so that dApp developers can take the responsibility of generating their own circuit-specific reference strings. * up to a constraint limit |
I'm not aware of it, that's why I'm interested in the way how it's planned to be held.
I absolutely agree, there should be two phases to match the standards, but I'm not sure whether some work is being made in this direction and what the real plans are. I'm wondering, who is responsible for the phase 1 organization and who are the participants of the upcoming MPC ceremony.
I saw the |
Let me explain that mpc has 2 parts, Phase 1 and Phase 2. In the library I provided to you, I have abstracted it into a very convenient interface, and I only used a compatible format for the relevant data format used in Phase 1, so you can directly use |
I have plans to prepare related documents. In fact, I originally planned to release it after the release of neo3.6, because it involves some changes to the compiler. In the library I provided to you, I have provided a minimal MPC process and comments (https://github.com/doubiliu/phase2/blob/dev/src/mpc/mod.rs) |
@doubiliu, thank you for the reply, I see that the library you've provided can be used by dApp developers to generate circuit-specific randomness. However, let's clarify the last thing:
Do you mean that Neo project is not going to organize its own Trusted Setup Ceremony (phase1, Powers of Tau)? Do you mean that as a base for Phase 2 we can use the result of Phase 1 got from Ethereum project? |
I mean compatible. The data generated in Phase 1 itself is common, and each project can use the same data generated in Phase 1. The only difference may be the size of the circuit to which the data fits. So this is a resource-intensive step, and a repetitive one. We can use already generated data such as zcash to use. Of course, if we don't trust them, we can be generated by neo, and the generated methods exist in the library. |
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Port the C# contract provided in the neo-project/neo#2647 (comment) and add an integration test for it. Part of the #3002. Signed-off-by: Anna Shaleva <[email protected]>
Summary or problem description
Zero-knowledge proof is currently one of the most popular technologies in blockchain technology. In this issue, I want to integrate this technology into neo, so that applications such as anonymous currency and 2-layer networks can be further developed.
There are multiple schemes for zero-knowledge proof, and there are multiple implementations for each scheme. The solution I explained is the PGRH13 implementation of zk-snark, and the groth16 implementation will be explained later.
Do you have any solution you want to propose?
Modification in neo:
Add new interoperability methods
zk protocol:
Suppose the prover needs to prove to the verifier that he knows some secret data
The above process may be too abstract, then I will make a detailed derivation.Welcome to discuss and point out the errors.
First, we limit the secret data to some special data, and then generalize it to the general form.
Then,suppose A claims to know a secret polynomial of degree d (B knows the secret polynomial, or only the calculation results of the polynomial at some particular points), how can verifier B verify that A knows the secret polynomial?
Proving protocol V1.0
Verification steps:
Some known issues:
......
Of course, if we understand the properties of some polynomials, the above verification protocol can also be written in another form.
Proving protocol V2.0
Verification steps:
Some known issues:
......
The major issue of above protocol is exposure of the random r and resulting value calculated with r.
Multiple issues can be addressed if there is a block box that could verify f(r)= t(r)⋅h(r) without revealing r and resulting values such as h(r),f(r).Fortunately, we can use the homomorphic properties of the encryption function to achieve.
Proving protocol V3.0
The biggest problem with the above verification protocol is that it cannot guarantee that the prover will construct the polynomial correctly according to the operation rules, so we need to introduce some additional security settings
Proving protocol V4.0 (Blind Evaluation of Polynomials)
Let us temporarily ignore some of the security issues that still exist in the verification protocol, and first extend it to the proof of general calculation problems.
Variables in general calculation problems always have some potential equation relations
Example: suppose A wants to prove to B that he knows c1,c2,c3, (c1⋅c2)⋅(c1+c3)=7, and he needs to keep c1,c2,c3 secret.
(c1⋅c2)⋅(c1+c3)=7 is the equation of c1,c2,c3.
We can use a special representation method R1CS to express these equation relations.
In addition, we found that these matrices are transformed by the Lagrangian interpolation theorem. This transformation is called the QAP quadratic arithmetic program.QAP is a program to transform vector verification into polynomial verification, the core of which is the Lagrange interpolation method.
Then we can get:
Universal proving protocol V1.0
At this point, we have been able to prove the general problem, but as mentioned before, the protocol still has some security issues. In order to solve these security issues, we need to introduce some additional settings, which we call the Pinocchio protocol
Universal proving protocol V2.0
The general protocol also has the problem of brute force cracking and the abuse of encryption certification, and random offset needs to be introduced.
Universal proving protocol (final version)
The PDF can be obtained here:
zksnarkissue(en).pdf
Commonly used R1CS circuits
Scope proof
To prove that the value of a private input w is between 0 and 15, construct a constraint as follows:
Purpose: Proof of amount
CRS public string in trusted initial process
All random values generated during the initialization process of the above protocols must be disclosed after being encrypted. The encrypted text is known as the CRS public string, while the original random values, called "toxic waste" must be destroyed as soon as the CRS is created, otherwise it can be used by adversaries to forge proofs.
To ensure that toxic waste is truly removed, multi-party computation (MPC) is required to ensure security.
References
Neo Version
Where in the software does this update applies to?
The text was updated successfully, but these errors were encountered: