Skip to content

Question about Hash #98

Answered by ThomasPiellard
kysee asked this question in Q&A
May 13, 2021 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @kysee , can you post the exact code which makes the test fail? I suspect that the error is linked to the fact that in a snark circuit, when you write hFunc.Hash(cs, cc.ByteSliceA, cc.ByteSliceB), cc.ByteSliceA and cc.ByteSliceA are interpreted as 254bits variables (in case of BN254), on the other hand when you write

hash.Write(byte_slice_A)
hash.Write(byte_slice_B)

then byte_slice_A and byte_slice_B are not interpreted as 254bits variables but as a raw byte slice. So it works when byte_slice_A and byte_slice_Bare of size 254bits, e.g. this works:

type MyCircuit struct {
	ByteSliceA frontend.Variable
	ByteSliceB frontend.Variable
	H1         frontend.Variable `gnark:",public"`
}

func…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kysee
Comment options

Answer selected by gbotrel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants