native: allow to use EQUAL opcode for BLS12-381 points comparison
That's the way how C# node handles equality checks for stackitem.Interop types for these points. Ref. https://github.com/nspcc-dev/neo-go/issues/3002#issuecomment-1591220501. Along the way, add GT case for CryptoLib's bls12381Equal method. It should be there since #2940. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
a2daad6ba6
commit
71bcb8bade
5 changed files with 275 additions and 109 deletions
|
@ -60,6 +60,13 @@ type Convertible interface {
|
|||
FromStackItem(Item) error
|
||||
}
|
||||
|
||||
// Equatable describes a special value of Interop that can be compared with
|
||||
// value of some other Interop that implements Equatable.
|
||||
type Equatable interface {
|
||||
// Equals checks if two objects are equal.
|
||||
Equals(other Equatable) bool
|
||||
}
|
||||
|
||||
var (
|
||||
// ErrInvalidConversion is returned upon an attempt to make an incorrect
|
||||
// conversion between item types.
|
||||
|
@ -994,7 +1001,12 @@ func (i *Interop) Equals(s Item) bool {
|
|||
return false
|
||||
}
|
||||
val, ok := s.(*Interop)
|
||||
return ok && i.value == val.value
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
a, okA := i.value.(Equatable)
|
||||
b, okB := val.value.(Equatable)
|
||||
return (okA && okB && a.Equals(b)) || (!okA && !okB && i.value == val.value)
|
||||
}
|
||||
|
||||
// Type implements the Item interface.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue