Skip to content

Commit

Permalink
random notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsaki committed Feb 10, 2023
1 parent 021dd2f commit ace9638
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 9 deletions.
78 changes: 69 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ZK gives similar vibes to Machine Learning. More and more people just mention ZK

Set of integers is denoted by Z. {...-4,-3,-2,-1,0,1,2,3,4..}

Set of Rational numbers denoted by Q. {..1, 3/2, 2, 22/7,...}
Set of Rational numbers denoted by Q. {..1, 3/2, 2, 22/7,...}

Set of Real Numbers denoted by R. {2, -4, 613, π, √2,..}

Expand Down Expand Up @@ -50,34 +50,94 @@ To be concidered a group the combination needs certain properties

**Closure:** For all a, b in set G, the result of operation a•b, is also in G

**Associativity:** for all a, b and c in set G, (a•b)•c
**Associativity:** for all a, b and c in set G, (a•b)•c

**Identity element:** there exists an element e in G such that every element a in G, the equation e•a = a•e=a holds.
**Identity element:** there exists an element e in G such that every element a in G, the equation e•a = a•e=a holds.

**Inverse element:** for each a in G, there exists an element b in G, denoted a<sup>-1</sup> (or -a if the operation is "+"), such that a•b = b•a = e, where e is the identity element

### Sub Groups

if a subset of the elements in a group also satisfies the group properties, then that is a subgroup of the original group


### Cyclic groups and generators

A finite group can be cyclic. That means it has a generator element. If you start at any point and apply a group operation with the generator as argument a certain number of times, you can go around the whole group and end in the same place.

### Finding and inverse
### Finding an inverse

fermat's little theorem

a<sup>-1</sup> ≡ a <sup>p-2</sup> (modp)

Let p = 7 and a = 2
Let p = 7 and a = 2. We can compute the inverse of a as:

a<sup>p-2</sup> = 2<sup>5</sup> = 32 ≡ 4 mod 7

Verify: 2 x 4 ≡ 1 mod 7

### Equivalence classes

- Homework 1
since

## Lesson 2: ZKP Theory / Zokrates
6 mod 7 = 6

- Homework 2
13 mod 7 = 6

20 mod 7 = 6

6, 13, 20 form equivalence classes

more formally

i + kN | k EZ for some i between 0 and N - 1.

Thus if we are trying to solve the equation

x mod 7 = 6

x could be 6, 13, 20 ....

This gives us the basis for a one way function

### Fields

A field is a set of say integers together with two operations called addition and multiplication.

One example of a field is the Real Numbers under addition and multiplication, another is a ser of integers mod a prime number with addition and multiplication.

The field operations are required to satisfy the following field axioms. In these axioms, a, b and c are arbitrary element s of the field F.

1. Associativity of addition and multiplication: a+(b+c) = (a+b)+c and a•(b•c)=(a•b)•c

2. Commutativity of addition and multiplication: a+b=b+a and a•b=b•a

3. Additive and multiplicative identity. Additve = 0, a + 0 = a, multiplicative = 1, a • 1 = a

4. Additive inverse: For every a in F, there exists an element in F, denoted -a, called the additive invers of a, such that a + (-a) = 0

5. Multicative inverse: For every a ≠ 0 in F, the exists an element in F, denoted by a<sup>-1</sup>, called the multiplicative inverse of a, such that a•a<sup>-1</sup>=1

6. Distributivity of multiplication over addition: a•(b+c) = (a•b)+(a•c)

### Finite fields and generators

### Proving systems

- Instance variables --> which are public
- Witness variables ---> which are private


- Interactive proofs --> Multiple rounds
- Non-interactive proofs ---> no repeated communications between the prover and the verifier
- Succint --->
- Non Succint --->
- Proof
- Proof of Knowledge --->
- Argument

- [Homework 1](./homework/homework1.py)

## Lesson 2: ZKP Theory / Zokrates

- Homework 2
48 changes: 48 additions & 0 deletions lesson2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Lesson 2

This stuff is hard. Don't feel bad if you don't get it.

- Fully Homomorphic encryption

Plonomials in ZKPs

If a prover claims to know some polynomial (no matter how large its degree is) that the verifier also knows, they can follow a simple protocol to verify the statement:

- verifier chooses a random value for x and evaluates his polynomial locally
- Verifier gives x to the prover and asks to evaluate the polynimial in question
- prover evaluates her polynomial at x and the result to the verifier
- Verifier checks if the local result is equal to the prover's result, and if so then the statement is proven with a high confidence

Why is degree important

in general, there is a rule that if a polynomial is zeor accross some set

S = x1, x2 ... sn then it can be expressed as

P(x) = Z(x) * H(s), where Z(x) = (x-x1) • (x-x2) •...•(x-xn) and H(x) is also a polynomial.

In other words, any polynomial that equals zero accross set is a (polynomial) mulitiple of the (lowest-degree) polynomial that equals zero across that same set.

## Homomorphic Hiding

Taken from Zcash explanation

if E(x) is a function with the following properties.

- Given E(x) it is hard to find x
- Different inputs lead to different outputs so if x≠yE(x) ≠ E(y)
- We can compute E(x+y) given E(x) and E(y)

The group Z<sub>p</sub> with operations addition and multiplication allows this.

Here's a toy example of why Homomorphic Hiding is useful for Zero-Knowledge proofs.

Suppoese Alice wants to prove to bob she knows numbers x,y such taht x+y = 7

1. Alice sends E(x) and E(y) to Bob.
2. Bob computes E(x+y) from these values (which he is to do since E is an HH).
3. Bob also computes E(7), and now checks whether E(x+y) = E(7). He accepts Alice's proof pnly if equality holds.

As different inputs are mapped by E to different hidings. Bob indedd accepts the proof oonly if Alice sent hidings of x,y such that x + y = 7. On the other hand, Bob does not learn x and y he just has acess to their hidings.

## ZoKrates - xkSNARKs on Ethereum

0 comments on commit ace9638

Please sign in to comment.