github.com/cloudflare/circl@v1.5.0/ecc/goldilocks/isogeny_test.go (about) 1 package goldilocks 2 3 import ( 4 "crypto/rand" 5 "testing" 6 7 "github.com/cloudflare/circl/internal/test" 8 ) 9 10 func randomPoint() *Point { 11 var k Scalar 12 _, _ = rand.Read(k[:]) 13 return Curve{}.ScalarBaseMult(&k) 14 } 15 16 func TestIsogeny(t *testing.T) { 17 const testTimes = 1 << 10 18 var gold Curve 19 var twist twistCurve 20 21 for i := 0; i < testTimes; i++ { 22 P := randomPoint() 23 Q := gold.pull(gold.push(P)) // phi^-(phi^+(P)) 24 got := Q 25 want := gold.Double(gold.Double(P)) // 4P 26 if !got.IsEqual(want) { 27 test.ReportError(t, got, want, P) 28 } 29 got = twist.push(twist.pull(Q)) // phi^-(phi^+(Q)) 30 want = gold.Double(gold.Double(Q)) // 4Q 31 if !got.IsEqual(want) { 32 test.ReportError(t, got, want, P) 33 } 34 } 35 }