github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/crypto/ed25519/ecmath/point_test.go (about) 1 package ecmath 2 3 import "testing" 4 5 // base is the ed25519 base point 6 var base Point 7 8 func init() { 9 base.ScMulBase(&One) 10 } 11 12 func TestBasePointArith(t *testing.T) { 13 var base1 Point 14 base1.ScMul(&base, &One) 15 if !base.ConstTimeEqual(&base1) { 16 ebase := base.Encode() 17 ebase1 := base1.Encode() 18 t.Errorf("base [%x] != 1*base [%x]", ebase[:], ebase1[:]) 19 } 20 21 Two := One 22 Two.Add(&Two, &One) 23 24 base2a := base 25 base2a.Add(&base2a, &base) 26 27 base2b := base 28 base2b.ScMul(&base2b, &Two) 29 30 if !base2a.ConstTimeEqual(&base2b) { 31 ebase2a := base2a.Encode() 32 ebase2b := base2b.Encode() 33 t.Errorf("base+base [%x] != 2*base [%x] (1)", ebase2a[:], ebase2b[:]) 34 } 35 36 var base2c Point 37 base2c.ScMulBase(&Two) 38 39 if !base2a.ConstTimeEqual(&base2c) { 40 ebase2a := base2a.Encode() 41 ebase2c := base2c.Encode() 42 t.Errorf("base+base [%x] != 2*base [%x] (2)", ebase2a[:], ebase2c[:]) 43 } 44 }