Bug SetString for frElement
ThomasPiellard opened this issue · 2 comments
ThomasPiellard commented
SetString() doesn't erase the previous value of a frElement if a small number of bits is changed.
This example (r = BN254 scalar field) outputs the same result:
var y fr.Element
y.SetString("16406754891999554747479650379038048271643900448173543122927661446988296543616")
fmt.Println(y.String())
y.SetString("06406754891999554747479650379038048271643900448173543122927661446988296543616")
fmt.Println(y.String())
gbotrel commented
func TestString(t *testing.T) {
var y Element
y.SetString("16406754891999554747479650379038048271643900448173543122927661446988296543616")
fmt.Println(y.String())
if _, err := y.SetString("06406754891999554747479650379038048271643900448173543122927661446988296543616"); err != nil {
fmt.Println(err)
}
fmt.Println(y.String())
}
-->
Element.SetString failed -> can't parse number into a big.Int 06406754891999554747479650379038048271643900448173543122927661446988296543616
gbotrel commented
SetString
relies on big.Int
underneath, which errors with this input