From 6bf3dbaeb1af9a5e83792faa04db30878e27523c Mon Sep 17 00:00:00 2001 From: Guido Iribarren Date: Mon, 16 Feb 2026 07:48:28 -0300 Subject: [PATCH 1/2] fix(tree_big): don't hash single bigints --- tree_big.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tree_big.go b/tree_big.go index b27c3de..f099bdb 100644 --- a/tree_big.go +++ b/tree_big.go @@ -181,13 +181,21 @@ func (t *Tree) leafToBigInts(bkey, value, serializedBigInts []byte) ( // reverse the process of bigints encoding bigints = deserializeBigInts(serializedBigInts) // reencode the leaf value of the tree to check if it matches the value - bigintsHash, err := HashBigInts(t.HashFunction(), bigints...) - if err != nil { - return nil, nil, err + var expectedLeafValue []byte + if len(bigints) == 1 { + expectedLeafValue = t.HashFunction().SafeBigInt(bigints[0]) + if expectedLeafValue == nil { + return nil, nil, fmt.Errorf("value cannot be nil") + } + } else { + expectedLeafValue, err = HashBigInts(t.HashFunction(), bigints...) + if err != nil { + return nil, nil, err + } } // check if the value of the leaf node matches the value used to build the // tree - if !bytes.Equal(bigintsHash, value) { + if !bytes.Equal(expectedLeafValue, value) { return nil, nil, fmt.Errorf("LeafToBigInt: bigintsHash != value") } // convert the bytes of the key to a big.Int @@ -258,9 +266,16 @@ func bigIntsToLeaf(hFn HashFunction, keyLen int, key *big.Int, bigints []*big.In return nil, nil, nil, err } // calculate the value used to build the tree - bValue, err = HashBigInts(hFn, bigints...) - if err != nil { - return nil, nil, nil, err + if len(bigints) == 1 { + bValue = hFn.SafeBigInt(bigints[0]) + if bValue == nil { + return nil, nil, nil, fmt.Errorf("value cannot be nil") + } + } else { + bValue, err = HashBigInts(hFn, bigints...) + if err != nil { + return nil, nil, nil, err + } } return bKey, bValue, serializedBigInts, nil } From 69196e0fd7b0fba7a842b0e61490e31d95ce178b Mon Sep 17 00:00:00 2001 From: Guido Iribarren Date: Fri, 20 Feb 2026 11:22:22 -0300 Subject: [PATCH 2/2] ci(github): update lint.yml actions --- .github/workflows/lint.yml | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7e3ef0d..4fc4f74 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,24 +2,13 @@ name: Lint on: [ push, pull_request ] jobs: lint: - strategy: - matrix: - go-version: [1.23.x] - platform: [ubuntu-latest] - runs-on: ${{ matrix.platform }} + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - uses: actions/setup-go@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: - go-version: ${{ matrix.go-version }} - cache: true + go-version-file: go.mod - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v8 with: - version: latest - skip-cache: false - skip-pkg-cache: false - skip-build-cache: false - only-new-issues: true + version: v2.5