Consensys / gnark

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license
https://hackmd.io/@gnark
Apache License 2.0
1.41k stars 361 forks source link

byte operation problem #317

Closed SherLzp closed 1 year ago

SherLzp commented 2 years ago

Hi team, I have the problem for byte operations. For example: I have two byte array:

A []byte // size 20
B []byte // size 20

C := append(A, B) // size 40
CHash := mimc(C)

If I only put A,B into the circuit, how can I get the same result of CHash?

SherLzp commented 2 years ago

@gbotrel @ThomasPiellard

SherLzp commented 2 years ago

And another problem, if I have an array:

var A []Variable

Could I just use Select to decide to if I need to do an append operation.

My goal is to:

if flag{
    A = append(A, new value)
}