juno icon indicating copy to clipboard operation
juno copied to clipboard

`felt.SetHex` allows setting invalid hexadecimal strings

Open tshakalekholoane opened this issue 3 years ago • 0 comments

Describe the bug

The *felt.SetHex function will allow setting an invalid hexadecimal string for some inputs i.e. "0xabcdefg" (where g is an invalid character).

Expected behavior

This should panic or return nil.

Additional context

The current implementation does not validate the string so a better approach might be to parse the string into a *big.Int and use the *felt.Felt.ToBigInt method to set the number similar to how *felt.Felt.SetString does.

tshakalekholoane avatar Sep 19 '22 15:09 tshakalekholoane