Skip to content
Snippets Groups Projects
Commit c87aa7fb authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

Merge remote-tracking branch 'origin/peppa/newClient' into peppa/newClient

parents 61d09121 61309e68
No related branches found
No related tags found
No related merge requests found
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
package cmix
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
package cmix
import (
......@@ -39,7 +45,7 @@ func NewStore(grp *cyclic.Group, kv *versioned.KV, priv *cyclic.Int) (*Store, er
s := &Store{
nodes: make(map[id.ID]*key),
dhPrivateKey: priv,
dhPublicKey: priv,
dhPublicKey: pub,
grp: grp,
kv: kv,
}
......@@ -188,7 +194,7 @@ func (s *Store) marshal() ([]byte, error) {
nodes := make([]id.ID, len(s.nodes))
index := 0
for nid, _ := range s.nodes {
for nid := range s.nodes {
nodes[index] = nid
}
......
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
package cmix
import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/elixxir/crypto/large"
"gitlab.com/elixxir/ekv"
"testing"
)
// Happy path
func TestNewStore(t *testing.T) {
kv := make(ekv.Memstore)
vkv := versioned.NewKV(kv)
grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(2))
priv := grp.NewInt(2)
pub := diffieHellman.GeneratePublicKey(priv, grp)
store, err := NewStore(grp, vkv, priv)
if err != nil {
t.Errorf(err.Error())
return
}
if store.nodes == nil {
t.Errorf("Failed to initialize nodes")
}
if store.dhPrivateKey == nil || store.dhPrivateKey.Cmp(priv) != 0 {
t.Errorf("Failed to set store.dhPrivateKey correctly")
}
if store.dhPublicKey == nil || store.dhPublicKey.Cmp(pub) != 0 {
t.Errorf("Failed to set store.dhPublicKey correctly")
}
if store.grp == nil {
t.Errorf("Failed to set store.grp")
}
if store.kv == nil {
t.Errorf("Failed to set store.kv")
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment