Skip to content

Commit

Permalink
fix: spell checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsaki committed Feb 21, 2023
1 parent 7726392 commit 8f81b3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions examples/snark_powered_rng/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ If this is your first time using zokrates make sure you have followed instructio
Alice and bob want to be on the results of a series of coin tosses. To do so, they need to generate a series of random bits. They proceed as follows:

1. Each of them commits a 512 bit value aka a **preimage**. They publish the hash of the preimage.
2. Each time they need a new random value, they reveal on bit from their preimage, and agree that the new random value is the result of XORing these two bits, so that neither of them can contral the output.
2. Each time they need a new random value, they reveal on bit from their preimage, and agree that the new random value is the result of XORing these two bits, so that neither of them can control the output.

Note that we are making the following assumptions:

1. They make sure they do no tuse all 512 bits of their preimage, as the more they reveal, the easier it gets for the other to brute-force their preimage.
2. They need a way to be convinved that the bit the other revealed is indeed part of their preimage.
1. They make sure they do not use all 512 bits of their preimage, as the more they reveal, the easier it gets for the other to brute-force their preimage.
2. They need a way to be convinced that the bit the other revealed is indeed part of their preimage.

In this tutorial you learn how to use ZoKrates and zero knowledge proofs to reveal a single bit from the preimage of a hash value.

Expand All @@ -31,13 +31,13 @@ def main(u32[16] hashMe) -> u32[8] {
}
```

Compiler program to a form that is usable for zero knowledge proofs. This command writes the binary to `get_hash`. You can see a rext representation, at `get_hash.ztf` created by the inspect command.
Compiler program to a form that is usable for zero knowledge proofs. This command writes the binary to `get_hash`. You can see a text representation, at `get_hash.ztf` created by the inspect command.

```bash
zokrates compile -i get_hash.zok -o get_hash && zokrates inspect -i get_hash
```

The input to zokrates program is sixteen 32 bit values, each in decimal. Specifiy those values to get a hash. For example, to calculate the hash of `0x00000000000000010000000200000003000000040000000500000006...` use this command:
The input to zokrates program is sixteen 32 bit values, each in decimal. Specify those values to get a hash. For example, to calculate the hash of `0x00000000000000010000000200000003000000040000000500000006...` use this command:

```bash
zokrates compute-witness --verbose -i get_hash -a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Expand All @@ -64,7 +64,7 @@ Use this program, `reveal_bit.zok`:
import "hashes/sha256/512bit" as sha256;
import "utils/casts/u32_to_bits" as u32_to_bits;
def main(private u32[16] preimage, u32 bitnum) -> (u32[8], bool) {
def main(private u32[16] preimage, u32 bitNum) -> (u32[8], bool) {
// convert the preimage to bits
bool[512] mut preimageBits = [false; 512]
for u32 i in 0..16 {
Expand Down Expand Up @@ -105,7 +105,7 @@ The `reveal_bit.zok` program reveal a bit from the preimage, but who runs it?
1. If Alice runs the program, she can feed it her secret preimage and receive the correct result. However, when she send the output there is no reason for Bob to trust that she is proving the correct output.
2. If Bob runs the program, he does not have Alice's secret preimage. If Alice discloses he secret preimage, Bob can know the value of all the bits.

Therefore, we need to have Alice run the program and produce the output, bur produce it in such a way Bob will know it is the correct output. This is what zero knowledge proofs grive us.
Therefore, we need to have Alice run the program and produce the output, bur produce it in such a way Bob will know it is the correct output. This is what zero knowledge proofs give us.

Set up environment. Create two separate directories, `alice` and `bob`. You will perform the actions of Alice in the alice directory, and the actions of Bob in the `bob` directory.

Expand Down Expand Up @@ -195,4 +195,4 @@ Here are the instructions to use this program when using Truffle and Ganache. We

## Conclusion

At this point you should be able to create zero knowledge proofs and verify them from the commnand line. You should also be a ble to publish a veifier to a blockchain, generate proofs, and submit them using javascript.
At this point you should be able to create zero knowledge proofs and verify them from the command line. You should also be a ble to publish a verifier to a blockchain, generate proofs, and submit them using javascript.
4 changes: 2 additions & 2 deletions examples/square_root/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hello Zokrates

First create `hello_zokrates.zok` and impletment your program. In this example, we will prove knowledge of the square root a of a number b:
First create `hello_zokrates.zok` and implement your program. In this example, we will prove knowledge of the square root a of a number b:

```zokrates
def main(private field a, field b) {
Expand All @@ -10,7 +10,7 @@ def main(private field a, field b) {
```

- Keyword `field` is basic type, which is an element of a given prime field
- Keywork `private` siganls we do not want to reveal this input, but still prove that we know its value
- Keyword `private` signals we do not want to reveal this input, but still prove that we know its value

Install zokrates:

Expand Down
16 changes: 8 additions & 8 deletions examples/zk_hash_preImage/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example: Prooving knowledge of a hash preimage
# Example: Proving knowledge of a hash preimage

We'll implement an operations that's very common in blockchain usecases: proving knowledgeof a preimage for a given hash digest. In particular, we'll show how Zokrates and the Ethereum blockchain can be used to allow a prover, Peggy, to demonstrate beyond any doubt to a verifier, Victor, that she knows a hash preimage for a digest chosen by Victor, without revealing what that preimage is.
We'll implement an operations that's very common in blockchain use cases: proving knowledge of a preimage for a given hash digest. In particular, we'll show how Zokrates and the Ethereum blockchain can be used to allow a prover, Peggy, to demonstrate beyond any doubt to a verifier, Victor, that she knows a hash preimage for a digest chosen by Victor, without revealing what that preimage is.

## Prerequisites

Expand Down Expand Up @@ -54,7 +54,7 @@ We get the output:

For now, we have seen that we can compute a hash using ZoKrates.

Let's recall our goal: Peggy wants to prove that she know a preimage for a digest chosen by Victor, without revealing what the preimage is.Let's assum that Victor chooses the digest to be the one we found in our example above.
Let's recall our goal: Peggy wants to prove that she know a preimage for a digest chosen by Victor, without revealing what the preimage is. Let's assume that Victor chooses the digest to be the one we found in our example above.

To make this work, the two parties have to follow their roles in the protocol:

Expand All @@ -71,7 +71,7 @@ def main(private a, private field b, private field c, private field d) {
}
```

Note that we now compare the result fo `sha256packed` with hard-coded correct solution defined by Victor. These lines we added are assertions where the veifier will not accept a proof where these constraints were not satisfied. Clearly, this program only returns 1 if all of the computed bits are equal.
Note that we now compare the result fo `sha256packed` with hard-coded correct solution defined by Victor. These lines we added are assertions where the verifier will not accept a proof where these constraints were not satisfied. Clearly, this program only returns 1 if all of the computed bits are equal.

2. So, after writing the program. Victor is now ready to compile the code.

Expand All @@ -85,7 +85,7 @@ zokrates compile -i hashexample.zok
zokrates setup && zokrates export-verifier
```

4. The `setup` creates a `verifiaction.key` and a `proving.key` file.
4. The `setup` creates a `verification.key` and a `proving.key` file.
- Victor gives the proving key to Peggy. `mkdir peggy && cp victor/proving.key peggy`
- Victor deploys the `verifier.sol` contract created by `export-verifier`.

Expand All @@ -104,14 +104,14 @@ Zokrates creates a file for Peggy, `proof.json`, consisting of the three ellipti

In this example we're considering, all inputs are private and there is a single return value of 1, hence Peggy has to define her public input array as follows: `[1]`.

Peggy can then submit he prrof by calling `verifyTx`.
Peggy can then submit he proof by calling `verifyTx`.

Victor monitor the verification smart contract for the return value of Peggy's transaction. As soon as he observes a transaction from Peggy's public address with a `true` return value, he can be sure that she has a valid pre-image for the hash he set in the smart contract.

## Conlusion
## Conclusion

Remember that in this example only two parties were involved. This special case makes it easy to deal with the trust assumptions of zkSNARKs: only Victor was interested in verifying the claim by Peggy, hence he can trust his execution of the setup phase.

In general, multiple parties may be interested in verifying the correctness of Peggy's statement. For example, in the zero-knowledge based cryptocurrency Zcash, each node needs to be able to validate the correctness of transactions. In order to generalize the setup phase to these multi-party use-cases a tricky process, commonly referred to as "trusted setup" or "ceremony" needs to be conducted.
In general, multiple parties may be interested in verifying the correctness of Peggy's statement. For example, in the zero-knowledge based cryptocurrency ZCash, each node needs to be able to validate the correctness of transactions. In order to generalize the setup phase to these multi-party use-cases a tricky process, commonly referred to as "trusted setup" or "ceremony" needs to be conducted.

ZoKrates would welcome ideas to add support for such ceremonies!

0 comments on commit 8f81b3c

Please sign in to comment.