Updating Initialize Identity Interface

This commit is contained in:
Sarah Jamie Lewis 2019-08-08 12:07:13 -07:00
parent 164e91fa17
commit 875690aff2
4 changed files with 10 additions and 10 deletions

View File

@ -34,7 +34,7 @@ func (ea AuthApp) NewInstance() tapir.Application {
// or the connection is closed.
func (ea AuthApp) Init(connection tapir.Connection) {
longTermPubKey := ed25519.PublicKey(connection.ID().PublicKeyBytes())
ephemeralIdentity, _ := primitives.InitializeEphemeral()
ephemeralIdentity, _ := primitives.InitializeEphemeralIdentity()
authMessage := AuthMessage{LongTermPublicKey: longTermPubKey, EphemeralPublicKey: ephemeralIdentity.PublicKey()}
serialized, _ := json.Marshal(authMessage)
connection.Send(serialized)

View File

@ -15,7 +15,7 @@ type MockConnection struct {
}
func (mc *MockConnection) Init(outbound bool) {
mc.id, _ = primitives.InitializeEphemeral()
mc.id, _ = primitives.InitializeEphemeralIdentity()
mc.outbound = outbound
return
}

View File

@ -16,17 +16,17 @@ type Identity struct {
edpubk *ed25519.PublicKey
}
// Initialize is a courtesy function for initializing a V3 Identity in-code.
func Initialize(name string, pk *ed25519.PrivateKey, pubk *ed25519.PublicKey) Identity {
// InitializeIdentity is a courtesy function for initializing a V3 Identity in-code.
func InitializeIdentity(name string, pk *ed25519.PrivateKey, pubk *ed25519.PublicKey) Identity {
return Identity{name, pk, pubk}
}
// InitializeEphemeral generates a new ephemeral identity, the private key of this identity is provided in the response.
func InitializeEphemeral() (Identity, ed25519.PrivateKey) {
// InitializeEphemeralIdentity generates a new ephemeral identity, the private key of this identity is provided in the response.
func InitializeEphemeralIdentity() (Identity, ed25519.PrivateKey) {
epk, esk, _ := ed25519.GenerateKey(rand.Reader)
ephemeralPublicKey := ed25519.PublicKey(epk)
ephemeralPrivateKey := ed25519.PrivateKey(esk)
ephemeralIdentity := Initialize("", &ephemeralPrivateKey, &ephemeralPublicKey)
ephemeralIdentity := InitializeIdentity("", &ephemeralPrivateKey, &ephemeralPublicKey)
return ephemeralIdentity, ephemeralPrivateKey
}
@ -41,7 +41,7 @@ func (i *Identity) PublicKey() ed25519.PublicKey {
return *i.edpubk
}
// EDH performs a diffie helman operation on this identities private key with the given public key.
// EDH performs a diffie-helman operation on this identities private key with the given public key.
func (i *Identity) EDH(key ed25519.PublicKey) []byte {
secret := utils.EDH(*i.edpk, key)
return secret[:]

View File

@ -65,7 +65,7 @@ func TestTapir(t *testing.T) {
acn.WaitTillBootstrapped()
// Generate Server Keys
id, sk := primitives.InitializeEphemeral()
id, sk := primitives.InitializeEphemeralIdentity()
// Init the Server running the Simple App.
var service tapir.Service
@ -105,7 +105,7 @@ func TestTapir(t *testing.T) {
}
func genclient(acn connectivity.ACN) (tapir.Service, string) {
id, sk := primitives.InitializeEphemeral()
id, sk := primitives.InitializeEphemeralIdentity()
var client tapir.Service
client = new(tor.BaseOnionService)
client.Init(acn, sk, &id)