Skip to content

Commit

Permalink
feat: update compress version; failing test (resolved) (#979)
Browse files Browse the repository at this point in the history
* test: highlight failing test -> resolved

* build: update compress version

* build: update to compress v0.2.0

* build upgrade compress dependency

* fix compression mode at byte 2

---------

Co-authored-by: Arya Tabaie <[email protected]>
  • Loading branch information
gbotrel and Tabaie authored Jan 8, 2024
1 parent f9c3514 commit 256e069
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/bits-and-blooms/bitset v1.8.0
github.com/blang/semver/v4 v4.0.0
github.com/consensys/bavard v0.1.13
github.com/consensys/compress v0.1.0
github.com/consensys/compress v0.2.1-0.20240103160955-e4fcce3dc96a
github.com/consensys/gnark-crypto v0.12.2-0.20231221171913-5d5eded6bb15
github.com/fxamacker/cbor/v2 v2.5.0
github.com/google/go-cmp v0.5.9
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/compress v0.1.0 h1:fczDaganmx2198GudPo4+5VX3eBvKy/bEJfmNotbr70=
github.com/consensys/compress v0.1.0/go.mod h1:Ne8+cGKjqgjF1dlHapZx38pHzWpaBYhsKxQa+JPl0zM=
github.com/consensys/compress v0.2.0 h1:aBg3YJe8ZFUxm/RF+ppx/URFsZq3aJ6o8isLDQysYDA=
github.com/consensys/compress v0.2.0/go.mod h1:Ne8+cGKjqgjF1dlHapZx38pHzWpaBYhsKxQa+JPl0zM=
github.com/consensys/compress v0.2.1-0.20240103160955-e4fcce3dc96a h1:0Y7y1JXtP8O/nL7LHpBt62pGZ87so63uWrYqUoq920s=
github.com/consensys/compress v0.2.1-0.20240103160955-e4fcce3dc96a/go.mod h1:Ne8+cGKjqgjF1dlHapZx38pHzWpaBYhsKxQa+JPl0zM=
github.com/consensys/gnark-crypto v0.12.2-0.20231221171913-5d5eded6bb15 h1:mcxhrDtXKIepsKXofxSuXRst+41yzAcoNWKIotsjMTQ=
github.com/consensys/gnark-crypto v0.12.2-0.20231221171913-5d5eded6bb15/go.mod h1:wKqwsieaKPThcFkHe0d0zMsbHEUWFmZcG7KBCse210o=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
Expand Down
10 changes: 6 additions & 4 deletions std/compress/lzss/snark.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ func Decompress(api frontend.API, c []frontend.Variable, cLength frontend.Variab
dictBrNbWords := int(dictBackRefType.NbBitsBackRef) / wordNbBits
byteNbWords := 8 / wordNbBits

api.AssertIsEqual(compress.ReadNum(api, c, byteNbWords, wordNbBits), 0) // compressor version TODO @tabaie @gbotrel Handle this outside the circuit instead?
fileCompressionMode := compress.ReadNum(api, c[byteNbWords:], byteNbWords, wordNbBits)
const sizeHeader = 3 // TODO @tabaie @gbotrel Handle this outside the circuit instead

api.AssertIsEqual(compress.ReadNum(api, c, (sizeHeader-1)*byteNbWords, wordNbBits), 0) // compressor version TODO @tabaie @gbotrel Handle this outside the circuit instead?
fileCompressionMode := compress.ReadNum(api, c[(sizeHeader-1)*byteNbWords:], byteNbWords, wordNbBits)
api.AssertIsEqual(api.Mul(fileCompressionMode, fileCompressionMode), api.Mul(fileCompressionMode, wordNbBits)) // if fcm!=0, then fcm=wordNbBits
decompressionNotBypassed := api.Sub(1, api.IsZero(fileCompressionMode))

c = c[2*byteNbWords:]
cLength = api.Sub(cLength, 2*byteNbWords)
c = c[sizeHeader*byteNbWords:]
cLength = api.Sub(cLength, sizeHeader*byteNbWords)

outTable := logderivlookup.New(api)
for i := range dict {
Expand Down
5 changes: 3 additions & 2 deletions std/compress/lzss/snark_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package lzss

import (
"os"
"testing"

goCompress "github.com/consensys/compress"
"github.com/consensys/compress/lzss"
"github.com/consensys/gnark-crypto/ecc"
Expand All @@ -10,8 +13,6 @@ import (
"github.com/consensys/gnark/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"testing"
)

func Test1ZeroSnark(t *testing.T) {
Expand Down

0 comments on commit 256e069

Please sign in to comment.