native: ensure proper endianness is used for CryptoLib's field element multiplier
Field element multiplier must be provided in the LE form, confirmed by cross-node invocation: https://github.com/nspcc-dev/neo-go/pull/3043#issuecomment-1733424840. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
8c46517522
commit
b7e019e7ef
1 changed files with 2 additions and 3 deletions
|
@ -230,9 +230,8 @@ func scalarFromBytes(bytes []byte, neg bool) (*fr.Element, error) {
|
||||||
return nil, fmt.Errorf("invalid multiplier: 32-bytes scalar is expected, got %d", len(bytes))
|
return nil, fmt.Errorf("invalid multiplier: 32-bytes scalar is expected, got %d", len(bytes))
|
||||||
}
|
}
|
||||||
// The input bytes are in the LE form, so we can't use fr.Element.SetBytesCanonical as far
|
// The input bytes are in the LE form, so we can't use fr.Element.SetBytesCanonical as far
|
||||||
// as it accepts BE.
|
// as it accepts BE. Confirmed by https://github.com/neo-project/neo/issues/2647#issuecomment-1129849870
|
||||||
// TODO: ensure that LE is really used in the C# node. More common way is to use BE form, and these
|
// and by https://github.com/nspcc-dev/neo-go/pull/3043#issuecomment-1733424840.
|
||||||
// lines of code are here only because that's the way how C# example works (https://github.com/neo-project/neo/issues/2647#issuecomment-1129849870).
|
|
||||||
v, err := fr.LittleEndian.Element((*[fr.Bytes]byte)(bytes))
|
v, err := fr.LittleEndian.Element((*[fr.Bytes]byte)(bytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid multiplier: failed to decode scalar: %w", err)
|
return nil, fmt.Errorf("invalid multiplier: failed to decode scalar: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue