package dhellman import ( "context" "log" "math/big" "testing" "git.ali33.ru/fcg-xvii/curve/v2/tools" ) func TestMessage(t *testing.T) { c, err := tools.NewCurve( big.NewInt(2), big.NewInt(4), ) if err != nil { t.Fatal(err) } p := tools.SearchPrime(big.NewInt(1000000)) if err = c.SetP(p); err != nil { t.Fatal(err) } if err = c.SetGRandom(context.Background()); err != nil { t.Fatal(err) } p1, _ := randomCurveKeyPair(c) p2, _ := randomCurveKeyPair(c) message := []byte("Hello, WORLD!!!") encoded, err := p1.messageEncode(message, p2.pub) if err != nil { t.Fatal(err) } log.Println(encoded) data, err := p2.messageDecode(encoded, p1.pub) if err != nil { t.Fatal(err) } log.Println(string(data)) aPriv, err := p1.pub.attack(context.Background()) if err != nil { t.Fatal(err) } log.Println(aPriv.x, p1.priv.x) }