Browse Source

GenerateKeyPair -> GenerateKeyPairAlice.

Yes, this breaks the API, but it's cleaner this way.
Yawning Angel 2 years ago
parent
commit
249693e40e
4 changed files with 13 additions and 13 deletions
  1. 2 2
      newhope.go
  2. 7 7
      newhope_test.go
  3. 2 2
      newhope_testvectors_test.go
  4. 2 2
      newhope_testvectors_tor_test.go

+ 2 - 2
newhope.go

@@ -99,11 +99,11 @@ func (k *PrivateKeyAlice) Reset() {
 	k.sk.reset()
 }
 
-// GenerateKeyPair returns a private/public key pair.  The private key is
+// GenerateKeyPairAlice returns a private/public key pair.  The private key is
 // generated using the given reader, which must return random data.  The
 // receiver side of the key exchange (aka "Bob") MUST use KeyExchangeBob()
 // instead of this routine.
-func GenerateKeyPair(rand io.Reader) (*PrivateKeyAlice, *PublicKeyAlice, error) {
+func GenerateKeyPairAlice(rand io.Reader) (*PrivateKeyAlice, *PublicKeyAlice, error) {
 	var a, e, pk, r poly
 	var seed, noiseSeed [SeedBytes]byte
 

+ 7 - 7
newhope_test.go

@@ -15,7 +15,7 @@ import (
 
 func benchmarkKeyGen(b *testing.B) {
 	for i := 0; i < b.N; i++ {
-		GenerateKeyPair(rand.Reader)
+		GenerateKeyPairAlice(rand.Reader)
 	}
 }
 
@@ -32,9 +32,9 @@ func BenchmarkKeyGenTor(b *testing.B) {
 func benchmarkAlice(b *testing.B) {
 	for i := 0; i < b.N; i++ {
 		// Generate Alice's key's.
-		alicePriv, alicePub, err := GenerateKeyPair(rand.Reader)
+		alicePriv, alicePub, err := GenerateKeyPairAlice(rand.Reader)
 		if err != nil {
-			b.Fatalf("GenerateKeyPair failed: %v", err)
+			b.Fatalf("GenerateKeyPairAlice failed: %v", err)
 		}
 
 		// Finish Bob's handshake.
@@ -74,9 +74,9 @@ func benchmarkBob(b *testing.B) {
 		b.StopTimer()
 
 		// Generate Alice's key's.
-		alicePriv, alicePub, err := GenerateKeyPair(rand.Reader)
+		alicePriv, alicePub, err := GenerateKeyPairAlice(rand.Reader)
 		if err != nil {
-			b.Fatalf("GenerateKeyPair failed: %v", err)
+			b.Fatalf("GenerateKeyPairAlice failed: %v", err)
 		}
 
 		// Finish Bob's handshake.
@@ -112,9 +112,9 @@ func BenchmarkBobTor(b *testing.B) {
 func testIntegration(t *testing.T) {
 	for i := 0; i < 1024; i++ {
 		// Generate Alice's key's.
-		alicePriv, alicePub, err := GenerateKeyPair(rand.Reader)
+		alicePriv, alicePub, err := GenerateKeyPairAlice(rand.Reader)
 		if err != nil {
-			t.Fatalf("GenerateKeyPair failed: %v", err)
+			t.Fatalf("GenerateKeyPairAlice failed: %v", err)
 		}
 
 		// Finish Bob's handshake.

+ 2 - 2
newhope_testvectors_test.go

@@ -110,9 +110,9 @@ func TestNewHopeTestVectors(t *testing.T) {
 	r := newTestRng()
 
 	for i, v := range testVectors {
-		privAlice, pubAlice, err := GenerateKeyPair(r)
+		privAlice, pubAlice, err := GenerateKeyPairAlice(r)
 		if err != nil {
-			t.Fatalf("[%d]: GenerateKeyPair(r) failed: %v", i, err)
+			t.Fatalf("[%d]: GenerateKeyPairAlice(r) failed: %v", i, err)
 		}
 
 		vSndAlice, _ := hex.DecodeString(v.aliceSend)

+ 2 - 2
newhope_testvectors_tor_test.go

@@ -18,9 +18,9 @@ func TestNewHopeTestVectorsTor(t *testing.T) {
 	r := newTestRng()
 
 	for i, v := range testVectorsTor {
-		privAlice, pubAlice, err := GenerateKeyPair(r)
+		privAlice, pubAlice, err := GenerateKeyPairAlice(r)
 		if err != nil {
-			t.Fatalf("[%d]: GenerateKeyPair(r) failed: %v", i, err)
+			t.Fatalf("[%d]: GenerateKeyPairAlice(r) failed: %v", i, err)
 		}
 
 		vSndAlice, _ := hex.DecodeString(v.aliceSend)