github.com/sandwich-go/boost@v1.3.29/xcrypto/key/curve25519/generator_test.go (about)

     1  package curve25519
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "github.com/smartystreets/goconvey/convey"
     7  )
     8  
     9  func TestGenerator(t *testing.T) {
    10  	Convey("generate SecretKey/PublicKey/SharedKey", t, func() {
    11  		aliceSecretKey, err0 := GenerateSecretKey()
    12  		So(err0, ShouldBeNil)
    13  		t.Logf("aliceSecretKey: %v\n", aliceSecretKey)
    14  
    15  		bobSecretKey, err1 := GenerateSecretKey()
    16  		So(err1, ShouldBeNil)
    17  		t.Logf("bobSecretKey: %v\n", bobSecretKey)
    18  
    19  		alicePublicKey, err2 := GeneratePublicKey(aliceSecretKey)
    20  		So(err2, ShouldBeNil)
    21  		t.Logf("alicePublicKey: %v\n", alicePublicKey)
    22  
    23  		bobPublicKey, err3 := GeneratePublicKey(bobSecretKey)
    24  		So(err3, ShouldBeNil)
    25  		t.Logf("bobPublicKey: %v\n", bobPublicKey)
    26  
    27  		aliceSharedKey, err4 := GenerateSharedKey(aliceSecretKey, bobPublicKey)
    28  		So(err4, ShouldBeNil)
    29  		t.Logf("aliceSharedKey: %v\n", aliceSharedKey)
    30  
    31  		bobSharedKey, err5 := GenerateSharedKey(bobSecretKey, alicePublicKey)
    32  		So(err5, ShouldBeNil)
    33  		t.Logf("bobSharedKey: %v\n", bobSharedKey)
    34  
    35  		So(aliceSharedKey, ShouldResemble, bobSharedKey)
    36  	})
    37  }