From 46cbd65bc14bf4e9023e92ed5e2601b7dd8b3718 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewa Date: Thu, 12 Dec 2024 14:36:52 +0000 Subject: [PATCH] fix FillChallengeBytes --- arthur.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arthur.go b/arthur.go index 1a5632e..0bbbbc0 100644 --- a/arthur.go +++ b/arthur.go @@ -133,17 +133,20 @@ func (arthur *nativeArthur[H]) FillChallengeBytes(out []uints.U8) error { } lenGood := min(len(out), numBytes) tmp := make([]frontend.Variable, 1) - err = arthur.FillNextScalars(tmp) - if err != nil { - return err - } - bits := bits2.ToBinary(arthur.api, tmp[0]) - for i := 0; i < lenGood; i++ { - out[i] = uints.NewU8(0) - curMul := 1 - for j := range 8 { - out[i].Val = arthur.api.Add(arthur.api.Mul(curMul, bits[8*i+j]), out[i].Val) - curMul *= 2 + for i := range (len(out) + lenGood - 1) / lenGood { + err = arthur.FillNextScalars(tmp) + if err != nil { + return err + } + bits := bits2.ToBinary(arthur.api, tmp[0]) + for k := range lenGood { + o := i*lenGood + k + out[o] = uints.NewU8(0) + curMul := 1 + for j := range 8 { + out[o].Val = arthur.api.Add(arthur.api.Mul(curMul, bits[8*o+j]), out[o].Val) + curMul *= 2 + } } } return nil