Skip to content

zkSNARK

Arthur Greef edited this page May 13, 2018 · 12 revisions

zkSNARK

  • We are using the libsnark library.
  • The mtxq balancing equation validation is the match transaction family is replaced with a zkSNARK protocol.

Representing balancing equation as R1CS problem

General form of the equations where i:initiating quantity, n: ratio numerator quantity, d:ratio denominator quantity, r: reciprocating quantity.

iq * nq / dq = rq for q in {quantity value, quantity unit, quantity resource}

Rewrite as algebraic circuit.

iq * nq - dq * rq = 0 for q in {0..2}

Rewrite as conjuction of three balancing equation using a slack variable.

iq * nq - dq * rq + 1 = sq for q in {0..2} product(sq) = 1 for q in {0..2}

Rewrite as statements of the form c = a * b

  1. in0 = i0 * n0

  2. dr0 = d0 * r0

  3. indr0 = in0 - dr0

  4. s0 = indr0 + 1

  5. in1 = i1 * n1

  6. dr1 = d1 * r1

  7. indr1 = in1 - dr1

  8. s1 = indr1 + 1

  9. in2 = i2 * n2

  10. dr2 = d2 * r2

  11. indr2 = in2 - dr2

  12. s2 = indr2 + 1

  13. ss = s0 * s1

  14. out = s2 * ss

Create R1CS as zkSNARK library relation.

Clone this wiki locally