From b272e7418c39cd42261f4da0ea6a6dd8c7688338 Mon Sep 17 00:00:00 2001 From: Wanwiset Peerapatanapokin Date: Sun, 11 Feb 2024 15:59:28 +0400 Subject: [PATCH] Fix curve (#429) * update secp256k1 library from go-eth code * cast deprecated functions to use new BitCurve type * add IsOnCurve checks and tests * add test outcome check * fix test --- core/vm/privacy/ringct_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/core/vm/privacy/ringct_test.go b/core/vm/privacy/ringct_test.go index 49dbc3a5ab..83075a64e1 100644 --- a/core/vm/privacy/ringct_test.go +++ b/core/vm/privacy/ringct_test.go @@ -231,7 +231,7 @@ func TestOnCurveDeserialize(t *testing.T) { } func TestCurveScalarMult(t *testing.T) { - curve := crypto.S256() + curve := crypto.S256().(*secp256k1.BitCurve) x, y := curve.ScalarBaseMult(curve.Params().N.Bytes()) if x == nil && y == nil { @@ -262,13 +262,7 @@ func TestNilPointerDereferencePanic(t *testing.T) { t.Error("Failed to Serialize input Ring signature") } - deserializedSig, err := Deserialize(sig) - if err != nil { - t.Error("Failed to Deserialize Ring signature") - } - - verified := Verify(deserializedSig, false) - if verified { - t.Error("Should failed to verify Ring signature as the signature is invalid") - } + _ , err = Deserialize(sig) + // Should failed to verify Ring signature as the signature is invalid + assert.EqualError(t, err, "failed to deserialize, invalid ring signature") }