Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: fix #1149 by removing unused code #1164

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading