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

added user keys to cmix

parent 14a57593
No related branches found
No related tags found
No related merge requests found
...@@ -20,8 +20,8 @@ build: ...@@ -20,8 +20,8 @@ build:
go mod tidy go mod tidy
update_release: update_release:
GOFLAGS="" go get -u gitlab.com/elixxir/primitives@ben/newSwitchboard GOFLAGS="" go get -u gitlab.com/elixxir/primitives@peppa/newClient
GOFLAGS="" go get -u gitlab.com/elixxir/crypto@Optimus-E2E GOFLAGS="" go get -u gitlab.com/elixxir/crypto@peppa/newClient
GOFLAGS="" go get -u gitlab.com/xx_network/crypto@release GOFLAGS="" go get -u gitlab.com/xx_network/crypto@release
GOFLAGS="" go get -u gitlab.com/elixxir/comms@release GOFLAGS="" go get -u gitlab.com/elixxir/comms@release
GOFLAGS="" go get -u gitlab.com/xx_network/comms@release GOFLAGS="" go get -u gitlab.com/xx_network/comms@release
......
...@@ -15,10 +15,10 @@ require ( ...@@ -15,10 +15,10 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.2 github.com/spf13/viper v1.6.2
gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8 gitlab.com/elixxir/comms v0.0.0-20200827170208-d1f872422b7e
gitlab.com/elixxir/crypto v0.0.0-20200826034538-c67fec536436 gitlab.com/elixxir/crypto v0.0.0-20200827170914-14227f20900c
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842 gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842
gitlab.com/elixxir/primitives v0.0.0-20200826021242-53c364245a52 gitlab.com/elixxir/primitives v0.0.0-20200827170420-5d50351f99b4
gitlab.com/xx_network/comms v0.0.0-20200825213037-f58fa7c0a641 gitlab.com/xx_network/comms v0.0.0-20200825213037-f58fa7c0a641
gitlab.com/xx_network/crypto v0.0.0-20200812183430-c77a5281c686 gitlab.com/xx_network/crypto v0.0.0-20200812183430-c77a5281c686
gitlab.com/xx_network/primitives v0.0.0-20200812183720-516a65a4a9b2 gitlab.com/xx_network/primitives v0.0.0-20200812183720-516a65a4a9b2
......
...@@ -167,6 +167,8 @@ gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741 h1:yIjgre8xSDpnhJkDz ...@@ -167,6 +167,8 @@ gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741 h1:yIjgre8xSDpnhJkDz
gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741/go.mod h1:hEi6dhcR1v6TGcp3tBy+QFuE25zux206xymuB+PpUqs= gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741/go.mod h1:hEi6dhcR1v6TGcp3tBy+QFuE25zux206xymuB+PpUqs=
gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8 h1:6kwb++vm3XUf+AoR18bDfqNsKR8qghFkDERYmVAlwsU= gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8 h1:6kwb++vm3XUf+AoR18bDfqNsKR8qghFkDERYmVAlwsU=
gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8/go.mod h1:HW3Ige10aeJeyb2fcQ/YOBPiyzY/4jHau1Cj6/1WBHc= gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8/go.mod h1:HW3Ige10aeJeyb2fcQ/YOBPiyzY/4jHau1Cj6/1WBHc=
gitlab.com/elixxir/comms v0.0.0-20200827170208-d1f872422b7e h1:BEBxLOW6yMdT53rBvxlDifsGSPYKA88K233DOpKY5Zw=
gitlab.com/elixxir/comms v0.0.0-20200827170208-d1f872422b7e/go.mod h1:HW3Ige10aeJeyb2fcQ/YOBPiyzY/4jHau1Cj6/1WBHc=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.0-20200805174804-bdf909f2a16d/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ= gitlab.com/elixxir/crypto v0.0.0-20200805174804-bdf909f2a16d/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ=
...@@ -186,6 +188,8 @@ gitlab.com/elixxir/crypto v0.0.0-20200826022234-44afcd036724 h1:9QUjB0U+fuAhMFWd ...@@ -186,6 +188,8 @@ gitlab.com/elixxir/crypto v0.0.0-20200826022234-44afcd036724 h1:9QUjB0U+fuAhMFWd
gitlab.com/elixxir/crypto v0.0.0-20200826022234-44afcd036724/go.mod h1:xELLVpaOMc4c14h6Lh3LlD++KYdEihWtRkHQI0FjjXc= gitlab.com/elixxir/crypto v0.0.0-20200826022234-44afcd036724/go.mod h1:xELLVpaOMc4c14h6Lh3LlD++KYdEihWtRkHQI0FjjXc=
gitlab.com/elixxir/crypto v0.0.0-20200826034538-c67fec536436 h1:NvymTKdu5Zjf1tMpI6/TDvfok3xJx6EIrI3ZMWzmWx0= gitlab.com/elixxir/crypto v0.0.0-20200826034538-c67fec536436 h1:NvymTKdu5Zjf1tMpI6/TDvfok3xJx6EIrI3ZMWzmWx0=
gitlab.com/elixxir/crypto v0.0.0-20200826034538-c67fec536436/go.mod h1:xELLVpaOMc4c14h6Lh3LlD++KYdEihWtRkHQI0FjjXc= gitlab.com/elixxir/crypto v0.0.0-20200826034538-c67fec536436/go.mod h1:xELLVpaOMc4c14h6Lh3LlD++KYdEihWtRkHQI0FjjXc=
gitlab.com/elixxir/crypto v0.0.0-20200827170914-14227f20900c h1:1vkxQ0Ol/Kr6szWaa8mMcJXW+Dqy73DOarJPswrzb3Q=
gitlab.com/elixxir/crypto v0.0.0-20200827170914-14227f20900c/go.mod h1:D65u4dPjMLSHiENn7fvnleWUcuuSeT48Ttw760Wt3xQ=
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842 h1:m1zDQ6UadpuMnV7nvnyR+DUXE3AisRnVjajTb1xZE4c= gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842 h1:m1zDQ6UadpuMnV7nvnyR+DUXE3AisRnVjajTb1xZE4c=
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s= gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s=
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d h1:OKWTmYN5q8XVHo8JXThIH0TCuvl/fLXR7MGVacpqfRg= gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d h1:OKWTmYN5q8XVHo8JXThIH0TCuvl/fLXR7MGVacpqfRg=
...@@ -201,6 +205,8 @@ gitlab.com/elixxir/primitives v0.0.0-20200812191102-31c01f08b4dc h1:43innow2sbJL ...@@ -201,6 +205,8 @@ gitlab.com/elixxir/primitives v0.0.0-20200812191102-31c01f08b4dc h1:43innow2sbJL
gitlab.com/elixxir/primitives v0.0.0-20200812191102-31c01f08b4dc/go.mod h1:pJx2DZk9s8vVMnLN7x0hIPngDjbNSdOP6kk3RLlRxHg= gitlab.com/elixxir/primitives v0.0.0-20200812191102-31c01f08b4dc/go.mod h1:pJx2DZk9s8vVMnLN7x0hIPngDjbNSdOP6kk3RLlRxHg=
gitlab.com/elixxir/primitives v0.0.0-20200826021242-53c364245a52 h1:J+T7B6EurXrABFEWCRUPoJAXq93r1YCuv28RN0ICzaA= gitlab.com/elixxir/primitives v0.0.0-20200826021242-53c364245a52 h1:J+T7B6EurXrABFEWCRUPoJAXq93r1YCuv28RN0ICzaA=
gitlab.com/elixxir/primitives v0.0.0-20200826021242-53c364245a52/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE= gitlab.com/elixxir/primitives v0.0.0-20200826021242-53c364245a52/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE=
gitlab.com/elixxir/primitives v0.0.0-20200827170420-5d50351f99b4 h1:Vb8N4164sSk3qCtTiXieTXio3Lh9Rc2ObDE1eZgXcMk=
gitlab.com/elixxir/primitives v0.0.0-20200827170420-5d50351f99b4/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE=
gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw=
gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba h1:7nozLSNBX0CfP53DDiDNLJx9obhYGfGf5na0/c9rMso= gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba h1:7nozLSNBX0CfP53DDiDNLJx9obhYGfGf5na0/c9rMso=
gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba/go.mod h1:idLzPGYig57XE7xuU93OlIF9s6NgSJj7OArQvsd5DjY= gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba/go.mod h1:idLzPGYig57XE7xuU93OlIF9s6NgSJj7OArQvsd5DjY=
......
package cmix package cmix
import ( import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/crypto/cmix" "gitlab.com/elixxir/crypto/cmix"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
...@@ -11,9 +12,14 @@ import ( ...@@ -11,9 +12,14 @@ import (
type RoundKeys []*cyclic.Int type RoundKeys []*cyclic.Int
// Encrypts the given message for CMIX // Encrypts the given message for CMIX
// Panics if the passed message format // Panics if the passed message is not sized correctly for the group
func (rk RoundKeys) Encrypt(grp *cyclic.Group, msg format.Message, func (rk RoundKeys) Encrypt(grp *cyclic.Group, msg format.Message,
salt []byte) (format.Message, [][]byte, error) { salt []byte) (format.Message, [][]byte) {
if msg.GetPrimeByteLen() != grp.GetP().ByteLen() {
jww.FATAL.Panicf("Cannot encrypt message whose size does not " +
"align with the size of the prime")
}
ecrMsg := cmix.ClientEncrypt(grp, msg, salt, rk) ecrMsg := cmix.ClientEncrypt(grp, msg, salt, rk)
......
package cmix package cmix
import "testing" import (
"bytes"
"gitlab.com/elixxir/crypto/csprng"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/large"
"gitlab.com/elixxir/primitives/format"
"math/rand"
"reflect"
"testing"
)
func TestRoundKeys_Encrypt_Consistancy(t *testing.T) { // tests that the encrypted paylaods and kmacs generated are consistent
func TestRoundKeys_Encrypt_Consistency(t *testing.T) {
const numKeys = 5
expectedPayload := []byte{80, 118, 187, 96, 114, 221, 253, 46, 231, 113,
200, 88, 90, 42, 236, 96, 82, 244, 197, 32, 147, 185, 33, 27, 55, 128,
63, 247, 24, 218, 177, 8, 153, 34, 177, 57, 2, 153, 44, 134, 66, 57,
212, 140, 254, 125, 34, 173, 58, 39, 130, 130, 12, 114, 81, 254, 120,
194, 181, 159, 166, 167, 67, 172, 201, 191, 150, 161, 217, 178, 234, 65,
31, 240, 120, 69, 195, 196, 80, 206, 119, 14, 233, 193, 9, 108, 212,
157, 13, 160, 48, 171, 244, 106, 109, 48, 216, 117, 60, 98, 166, 26, 5,
26, 98, 115, 184, 87, 123, 197, 69, 159, 136, 247, 43, 165, 86, 11, 27,
7, 73, 189, 199, 68, 75, 34, 123, 245, 65, 169, 192, 46, 250, 47, 192,
238, 211, 196, 26, 254, 33, 53, 92, 9, 138, 197, 34, 209, 102, 58, 170,
119, 118, 73, 249, 235, 109, 81, 114, 186, 20, 247, 61, 94, 158, 50, 12,
217, 207, 216, 175, 83, 34, 244, 48, 159, 9, 101, 149, 92, 21, 4, 135,
91, 14, 142, 43, 5, 140, 197, 63, 216, 105, 20, 73, 38, 38, 250, 158,
140, 149, 187, 166, 194, 59, 75, 92, 21, 91, 166, 245, 54, 37, 103, 27,
168, 214, 252, 121, 175, 125, 190, 163, 178, 138, 1, 114, 247, 205, 105,
14, 248, 177, 89, 190, 205, 10, 109, 193, 189, 73, 117, 239, 179, 10,
164, 248, 251, 235, 232, 215, 56, 56, 250, 203, 114, 34, 208, 116, 94,
204, 165, 70, 109, 26, 155, 11, 210, 64, 8, 37, 34, 84, 30, 106, 41, 98,
135, 63, 62, 225, 212, 251, 245, 36, 238, 166, 142, 76, 192, 46, 169,
18, 55, 87, 245, 101, 224, 213, 225, 164, 109, 248, 50, 142, 122, 14,
76, 52, 179, 118, 95, 58, 86, 73, 12, 169, 85, 1, 19, 125, 190, 244,
231, 233, 95, 72, 101, 178, 230, 107, 59, 109, 220, 114, 155, 138, 96,
208, 167, 169, 143, 94, 145, 141, 24, 56, 167, 135, 128, 85, 147, 22,
67, 199, 154, 127, 174, 220, 210, 220, 5, 237, 28, 225, 234, 187, 83,
124, 215, 185, 38, 149, 87, 1, 29, 109, 31, 132, 145, 85, 90, 195, 226,
252, 60, 113, 155, 82, 238, 120, 154, 185, 36, 164, 199, 4, 146, 76, 3,
243, 19, 215, 192, 133, 159, 34, 27, 37, 138, 246, 45, 170, 99, 169, 46,
253, 98, 203, 52, 242, 203, 106, 141, 75, 140, 90, 118, 38, 162, 107,
182, 181, 6, 105, 208, 97, 66, 82, 72, 235, 56, 173, 242, 87, 241, 48,
29, 191, 72, 89, 200, 163, 192, 252, 187, 181, 54, 144, 53, 173, 137,
142, 19, 207, 3, 207, 169, 12, 148, 198, 225, 195, 118, 85, 153, 159,
168, 245, 16, 229, 227, 89, 224, 30, 127, 217, 193, 212, 52, 211, 120,
73, 204, 82, 82, 253, 238, 96, 186, 243, 26, 246, 157, 241, 120, 47,
170, 83, 175, 58, 179}
expectedKmacs := [][]byte{
{241, 132, 2, 131, 104, 92, 89, 120, 177, 8, 201,
194, 41, 63, 99, 30, 82, 44, 125, 204, 55, 145, 29, 62, 228, 57,
55, 208, 221, 195, 73, 50},
{108, 243, 239, 28, 162, 109, 196, 127, 8, 41, 134, 241, 44, 112, 225,
90, 138, 107, 6, 41, 123, 210, 194, 241, 176, 240, 35, 70, 196,
149, 48, 77},
{102, 155, 236, 6, 96, 155, 93, 100, 25, 38, 132, 2, 109, 216, 56, 157,
60, 100, 99, 226, 123, 181, 99, 157, 115, 215, 104, 243, 48, 161,
220, 184},
{154, 237, 87, 227, 221, 68, 206, 8, 163, 133, 253, 96, 96, 220, 215,
167, 62, 5, 47, 209, 95, 125, 13, 244, 211, 184, 77, 78, 226, 26,
24, 239},
{211, 180, 44, 51, 228, 147, 142, 94, 48, 99, 224, 101, 48, 43, 223, 23,
231, 0, 11, 229, 126, 247, 202, 97, 149, 163, 107, 68, 120, 251, 158,
33}}
cmixGrp := cyclic.NewGroup(
large.NewIntFromString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"+
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD"+
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"+
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"+
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"+
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"+
"83655D23DCA3AD961C62F356208552BB9ED529077096966D"+
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"+
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"+
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510"+
"15728E5A8AACAA68FFFFFFFFFFFFFFFF", 16),
large.NewIntFromString("2", 16))
prng := rand.New(rand.NewSource(42))
rk := RoundKeys(make([]*cyclic.Int, numKeys))
for i := 0; i < numKeys; i++ {
keyBytes, _ := csprng.GenerateInGroup(cmixGrp.GetPBytes(), cmixGrp.GetP().ByteLen(), prng)
rk[i] = cmixGrp.NewIntFromBytes(keyBytes)
}
salt := make([]byte, 32)
prng.Read(salt)
msg := format.NewMessage(cmixGrp.GetP().ByteLen())
contents := make([]byte, msg.ContentsSize())
prng.Read(contents)
msg.SetContents(contents)
encMsg, kmacs := rk.Encrypt(cmixGrp, msg, salt)
if !bytes.Equal(encMsg.GetData(), expectedPayload) {
t.Errorf("Encrypted messages do not match")
}
if !reflect.DeepEqual(kmacs, expectedKmacs) {
t.Errorf("kmacs do not match")
}
} }
...@@ -3,7 +3,6 @@ package cmix ...@@ -3,7 +3,6 @@ package cmix
import ( import (
"encoding/json" "encoding/json"
"github.com/pkg/errors" "github.com/pkg/errors"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/comms/connect"
...@@ -13,10 +12,15 @@ import ( ...@@ -13,10 +12,15 @@ import (
) )
const currentStoreVersion = 0 const currentStoreVersion = 0
const currentKeyStoreVersion = 0
const storeKey = "cmixKeyStore" const storeKey = "cmixKeyStore"
const pubKeyKey = "cmixDhPubKey"
const privKeyKey = "cmixDhPrivKey"
type Store struct { type Store struct {
nodes map[id.ID]*key nodes map[id.ID]*key
dhPrivateKey *cyclic.Int
dhPublicKey *cyclic.Int
kv *versioned.KV kv *versioned.KV
...@@ -24,16 +28,34 @@ type Store struct { ...@@ -24,16 +28,34 @@ type Store struct {
} }
// returns a new cmix storage object // returns a new cmix storage object
func NewStore(kv *versioned.KV) *Store { func NewStore(kv *versioned.KV, pub, priv *cyclic.Int) (*Store, error) {
return &Store{ s := &Store{
nodes: make(map[id.ID]*key), nodes: make(map[id.ID]*key),
dhPrivateKey: priv,
dhPublicKey: priv,
kv: kv, kv: kv,
} }
err := storeDhKey(kv, pub, pubKeyKey)
if err != nil {
return nil,
errors.WithMessage(err, "Failed to store cmix DH public key")
}
err = storeDhKey(kv, priv, privKeyKey)
if err != nil {
return nil, errors.WithMessage(err, "Failed to store cmix DH private key")
}
return s, s.save()
} }
// loads the cmix storage object // loads the cmix storage object
func LoadStore(kv *versioned.KV) (*Store, error) { func LoadStore(kv *versioned.KV) (*Store, error) {
s := NewStore(kv) s := &Store{
nodes: make(map[id.ID]*key),
kv: kv,
}
obj, err := kv.Get(storeKey) obj, err := kv.Get(storeKey)
if err != nil { if err != nil {
...@@ -148,12 +170,52 @@ func (s *Store) unmarshal(b []byte) error { ...@@ -148,12 +170,52 @@ func (s *Store) unmarshal(b []byte) error {
} }
for _, nid := range nodes { for _, nid := range nodes {
k, err := loadKey(s.s, &nid) k, err := loadKey(s.kv, &nid)
if err != nil { if err != nil {
return errors.WithMessagef(err, "could not load node key for %s", &nid) return errors.WithMessagef(err, "could not load node key for %s", &nid)
} }
s.nodes[nid] = k s.nodes[nid] = k
} }
s.dhPrivateKey, err = loadDhKey(s.kv, privKeyKey)
if err != nil {
return errors.WithMessage(err,
"Failed to load cmix DH private key")
}
s.dhPublicKey, err = loadDhKey(s.kv, pubKeyKey)
if err != nil {
return errors.WithMessage(err,
"Failed to load cmix DH public key")
}
return nil return nil
} }
func storeDhKey(kv *versioned.KV, dh *cyclic.Int, key string) error {
now := time.Now()
data, err := dh.GobEncode()
if err != nil {
return err
}
obj := versioned.Object{
Version: currentKeyVersion,
Timestamp: now,
Data: data,
}
return kv.Set(key, &obj)
}
func loadDhKey(kv *versioned.KV, key string) (*cyclic.Int, error) {
vo, err := kv.Get(key)
if err != nil {
return nil, err
}
dhKey := &cyclic.Int{}
return dhKey, dhKey.GobDecode(vo.Data)
}
\ No newline at end of file
...@@ -304,7 +304,6 @@ func (s *Session) generate() { ...@@ -304,7 +304,6 @@ func (s *Session) generate() {
s.ttl = uint32(keysTTL) s.ttl = uint32(keysTTL)
//create the new state vectors. This will cause disk operations storing them //create the new state vectors. This will cause disk operations storing them
s.keyState = newStateVector(s.manager.ctx, keyEKVPrefix, numKeys) s.keyState = newStateVector(s.manager.ctx, keyEKVPrefix, numKeys)
//register keys for reception if this is a reception session //register keys for reception if this is a reception session
......
...@@ -34,7 +34,7 @@ type stateVectorDisk struct { ...@@ -34,7 +34,7 @@ type stateVectorDisk struct {
Numkeys uint32 Numkeys uint32
} }
func newStateVector(ctx *context, key string, numkeys uint32) *stateVector { func newStateVector(ctx *context, key string, numkeys uint32) (*stateVector, error) {
numBlocks := (numkeys + 63) / 64 numBlocks := (numkeys + 63) / 64
sv := &stateVector{ sv := &stateVector{
...@@ -46,7 +46,7 @@ func newStateVector(ctx *context, key string, numkeys uint32) *stateVector { ...@@ -46,7 +46,7 @@ func newStateVector(ctx *context, key string, numkeys uint32) *stateVector {
numkeys: numkeys, numkeys: numkeys,
} }
return sv return sv, sv.save()
} }
func loadStateVector(ctx *context, key string) (*stateVector, error) { func loadStateVector(ctx *context, key string) (*stateVector, error) {
......
package storage
type RegistrationStatus uint32
const (
NotStarted RegistrationStatus = 0 // Set on session creation
KeyGenComplete RegistrationStatus = 10000 // Set upon generation of session information
PermissioningComplete RegistrationStatus = 20000 // Set upon completion of RegisterWithPermissioning
UDBComplete RegistrationStatus = 30000 // Set upon completion of RegisterWithUdb
)
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"bytes" "bytes"
"encoding/gob" "encoding/gob"
"gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/storage/cmix"
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/client/user" "gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/ekv" "gitlab.com/elixxir/ekv"
...@@ -31,6 +32,9 @@ type Session struct { ...@@ -31,6 +32,9 @@ type Session struct {
// Contacts controls // Contacts controls
contacts map[string]*Contact contacts map[string]*Contact
contactsLck sync.Mutex contactsLck sync.Mutex
//keystores
cmixKeys cmix.Store
} }
// Initialize a new Session object // Initialize a new Session object
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"encoding/gob" "encoding/gob"
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"time" "time"
) )
......
...@@ -5,8 +5,8 @@ import ( ...@@ -5,8 +5,8 @@ import (
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/large" "gitlab.com/elixxir/crypto/large"
"gitlab.com/elixxir/crypto/signature/rsa"
"gitlab.com/elixxir/ekv" "gitlab.com/elixxir/ekv"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"math/rand" "math/rand"
"reflect" "reflect"
......
...@@ -18,9 +18,7 @@ import ( ...@@ -18,9 +18,7 @@ import (
"gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/keyStore" "gitlab.com/elixxir/client/keyStore"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/switchboard" "gitlab.com/elixxir/primitives/switchboard"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"io" "io"
"sync" "sync"
...@@ -108,9 +106,9 @@ func LoadSession(store globals.Storage, password string) (Session, error) { ...@@ -108,9 +106,9 @@ func LoadSession(store globals.Storage, password string) (Session, error) {
session.KeyMaps.ReconstructKeys(session.E2EGrp, session.KeyMaps.ReconstructKeys(session.E2EGrp,
session.CurrentUser) session.CurrentUser)
// Create switchboard // Create switchboard
session.listeners = switchboard.New() //session.listeners = switchboard.New()
// Create quit channel for reception runner // Create quit channel for reception runner
session.quitReceptionRunner = make(chan struct{}) //session.quitReceptionRunner = make(chan struct{})
// Set storage pointer // Set storage pointer
session.store = store session.store = store
...@@ -330,11 +328,11 @@ func (s *SessionObj) GetRekeyManager() *keyStore.RekeyManager { ...@@ -330,11 +328,11 @@ func (s *SessionObj) GetRekeyManager() *keyStore.RekeyManager {
} }
func (s *SessionObj) GetSwitchboard() *switchboard.Switchboard { func (s *SessionObj) GetSwitchboard() *switchboard.Switchboard {
return s.listeners return nil //s.listeners
} }
func (s *SessionObj) GetQuitChan() chan struct{} { func (s *SessionObj) GetQuitChan() chan struct{} {
return s.quitReceptionRunner return nil //s.quitReceptionRunner
} }
func (s *SessionObj) getSessionData() ([]byte, error) { func (s *SessionObj) getSessionData() ([]byte, error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment