microsoft / Spartan

Spartan: High-speed zkSNARKs without trusted setup
MIT License
672 stars 112 forks source link

How to determine num_non_zero_entries #64

Open mottla opened 11 months ago

mottla commented 11 months ago

I do not understand num_non_zero_entries. For a R1CS instance defined via matrices A,B,C, num_non_zero_entries refers to which matrix? It appears to be essential for the runtime of SNARK proof.

Thanks for this great project! Cheers

Xor0v0 commented 2 months ago

R1CS instance is a 7-tuple: $(\mathbb{F}, A, B, C, \bf{io}, m, n)$, where $A, B, C$ are $m\times m$ matrices. num_non_zero_entries is actually the n in the R1CS instance, which dipct the sparsity and density of polynomials encoded by these matrices. When you get $A, B, C$ matrices, you can count the non-zero entries of the three matrices and define num_non_zero_entries with the max.