Skip to content

Commit

Permalink
fix: fix #1149 by removing unused code (#1164)
Browse files Browse the repository at this point in the history
* fix: fix #1149 by removing unused code

* fix: update stats without toNAF
  • Loading branch information
gbotrel committed Jun 12, 2024
1 parent 6abed5a commit db299ce
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 141 deletions.
Binary file modified internal/stats/latest.stats
Binary file not shown.
6 changes: 0 additions & 6 deletions internal/stats/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ func initSnippets() {
registerSnippet("math/bits.ToTernary/unconstrained", func(api frontend.API, newVariable func() frontend.Variable) {
_ = bits.ToTernary(api, newVariable(), bits.WithUnconstrainedOutputs())
})
registerSnippet("math/bits.ToNAF", func(api frontend.API, newVariable func() frontend.Variable) {
_ = bits.ToNAF(api, newVariable())
})
registerSnippet("math/bits.ToNAF/unconstrained", func(api frontend.API, newVariable func() frontend.Variable) {
_ = bits.ToNAF(api, newVariable(), bits.WithUnconstrainedOutputs())
})

registerSnippet("hash/mimc", func(api frontend.API, newVariable func() frontend.Variable) {
mimc, _ := mimc.NewMiMC(api)
Expand Down
53 changes: 0 additions & 53 deletions std/math/bits/hints.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bits

import (
"errors"
"math/big"

"github.com/consensys/gnark/constraint/solver"
Expand All @@ -12,7 +11,6 @@ func GetHints() []solver.Hint {
ithBit,
nBits,
nTrits,
nNaf,
}
}

Expand Down Expand Up @@ -61,54 +59,3 @@ func nTrits(_ *big.Int, inputs []*big.Int, results []*big.Int) error {

return nil
}

// NNAF returns the NAF decomposition of the input. The number of digits is
// defined by the number of elements in the results slice.
func nNaf(_ *big.Int, inputs []*big.Int, results []*big.Int) error {
n := inputs[0]
return nafDecomposition(n, results)
}

// nafDecomposition gets the naf decomposition of a big number
func nafDecomposition(a *big.Int, results []*big.Int) error {
if a == nil || a.Sign() == -1 {
return errors.New("invalid input to naf decomposition; negative (or nil) big.Int not supported")
}

var zero, one, three big.Int

one.SetUint64(1)
three.SetUint64(3)

n := 0

// some buffers
var buf, aCopy big.Int
aCopy.Set(a)

for aCopy.Cmp(&zero) != 0 && n < len(results) {

// if aCopy % 2 == 0
buf.And(&aCopy, &one)

// aCopy even
if buf.Cmp(&zero) == 0 {
results[n].SetUint64(0)
} else { // aCopy odd
buf.And(&aCopy, &three)
if buf.IsUint64() && buf.Uint64() == 3 {
results[n].SetInt64(-1)
aCopy.Add(&aCopy, &one)
} else {
results[n].SetUint64(1)
}
}
aCopy.Rsh(&aCopy, 1)
n++
}
for ; n < len(results); n++ {
results[n].SetUint64(0)
}

return nil
}
50 changes: 0 additions & 50 deletions std/math/bits/naf.go

This file was deleted.

32 changes: 0 additions & 32 deletions std/math/bits/naf_test.go

This file was deleted.

0 comments on commit db299ce

Please sign in to comment.