Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
a23b9253
Commit
a23b9253
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Move udb login functions to xxdk/e2e.go
parent
71ca010f
No related branches found
No related tags found
2 merge requests
!510
Release
,
!245
Josh/fix ud
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
xxdk/cmix.go
+0
-108
0 additions, 108 deletions
xxdk/cmix.go
xxdk/e2e.go
+107
-0
107 additions, 0 deletions
xxdk/e2e.go
with
107 additions
and
108 deletions
xxdk/cmix.go
+
0
−
108
View file @
a23b9253
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
package
xxdk
package
xxdk
import
(
import
(
"encoding/json"
"math"
"math"
"time"
"time"
...
@@ -257,113 +256,6 @@ func LoadCmix(storageDir string, password []byte, parameters Params) (*Cmix, err
...
@@ -257,113 +256,6 @@ func LoadCmix(storageDir string, password []byte, parameters Params) (*Cmix, err
return
c
,
nil
return
c
,
nil
}
}
// LoginWithNewBaseNDF_UNSAFE initializes a client object from existing storage
// while replacing the base NDF. This is designed for some specific deployment
// procedures and is generally unsafe.
func
LoginWithNewBaseNDF_UNSAFE
(
storageDir
string
,
password
[]
byte
,
newBaseNdf
string
,
params
Params
)
(
*
E2e
,
error
)
{
jww
.
INFO
.
Printf
(
"LoginWithNewBaseNDF_UNSAFE()"
)
def
,
err
:=
ParseNDF
(
newBaseNdf
)
if
err
!=
nil
{
return
nil
,
err
}
c
,
err
:=
OpenCmix
(
storageDir
,
password
,
params
)
if
err
!=
nil
{
return
nil
,
err
}
//store the updated base NDF
c
.
storage
.
SetNDF
(
def
)
if
def
.
Registration
.
Address
!=
""
{
err
=
c
.
initPermissioning
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
jww
.
WARN
.
Printf
(
"Registration with permissioning skipped due "
+
"to blank permissionign address. Cmix will not be "
+
"able to register or track network."
)
}
err
=
c
.
network
.
Connect
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
registerFollower
()
if
err
!=
nil
{
return
nil
,
err
}
return
LoginLegacy
(
c
,
nil
)
}
// LoginWithProtoClient creates a client object with a protoclient
// JSON containing the cryptographic primitives. This is designed for
// some specific deployment procedures and is generally unsafe.
func
LoginWithProtoClient
(
storageDir
string
,
password
[]
byte
,
protoClientJSON
[]
byte
,
newBaseNdf
string
,
params
Params
)
(
*
E2e
,
error
)
{
jww
.
INFO
.
Printf
(
"LoginWithProtoClient()"
)
def
,
err
:=
ParseNDF
(
newBaseNdf
)
if
err
!=
nil
{
return
nil
,
err
}
protoUser
:=
&
user
.
Proto
{}
err
=
json
.
Unmarshal
(
protoClientJSON
,
protoUser
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
NewProtoClient_Unsafe
(
newBaseNdf
,
storageDir
,
password
,
protoUser
)
if
err
!=
nil
{
return
nil
,
err
}
c
,
err
:=
OpenCmix
(
storageDir
,
password
,
params
)
if
err
!=
nil
{
return
nil
,
err
}
c
.
storage
.
SetNDF
(
def
)
err
=
c
.
initPermissioning
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
network
.
Connect
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
c
.
network
.
AddIdentity
(
c
.
GetUser
()
.
ReceptionID
,
time
.
Time
{},
true
)
// FIXME: The callbacks need to be set, so I suppose we would need to
// either set them via a special type or add them
// to the login call?
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
registerFollower
()
if
err
!=
nil
{
return
nil
,
err
}
return
Login
(
c
,
nil
,
ReceptionIdentity
{
ID
:
protoUser
.
ReceptionID
,
RSAPrivatePem
:
protoUser
.
ReceptionRSA
,
Salt
:
protoUser
.
ReceptionSalt
,
DHKeyPrivate
:
protoUser
.
E2eDhPrivateKey
,
})
}
func
(
c
*
Cmix
)
initComms
()
error
{
func
(
c
*
Cmix
)
initComms
()
error
{
var
err
error
var
err
error
...
...
This diff is collapsed.
Click to expand it.
xxdk/e2e.go
+
107
−
0
View file @
a23b9253
...
@@ -82,6 +82,113 @@ func LoginLegacy(client *Cmix, callbacks auth.Callbacks) (m *E2e, err error) {
...
@@ -82,6 +82,113 @@ func LoginLegacy(client *Cmix, callbacks auth.Callbacks) (m *E2e, err error) {
return
m
,
err
return
m
,
err
}
}
// LoginWithNewBaseNDF_UNSAFE initializes a client object from existing storage
// while replacing the base NDF. This is designed for some specific deployment
// procedures and is generally unsafe.
func
LoginWithNewBaseNDF_UNSAFE
(
storageDir
string
,
password
[]
byte
,
newBaseNdf
string
,
params
Params
)
(
*
E2e
,
error
)
{
jww
.
INFO
.
Printf
(
"LoginWithNewBaseNDF_UNSAFE()"
)
def
,
err
:=
ParseNDF
(
newBaseNdf
)
if
err
!=
nil
{
return
nil
,
err
}
c
,
err
:=
OpenCmix
(
storageDir
,
password
,
params
)
if
err
!=
nil
{
return
nil
,
err
}
//store the updated base NDF
c
.
storage
.
SetNDF
(
def
)
if
def
.
Registration
.
Address
!=
""
{
err
=
c
.
initPermissioning
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
jww
.
WARN
.
Printf
(
"Registration with permissioning skipped due "
+
"to blank permissionign address. Cmix will not be "
+
"able to register or track network."
)
}
err
=
c
.
network
.
Connect
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
registerFollower
()
if
err
!=
nil
{
return
nil
,
err
}
return
LoginLegacy
(
c
,
nil
)
}
// LoginWithProtoClient creates a client object with a protoclient
// JSON containing the cryptographic primitives. This is designed for
// some specific deployment procedures and is generally unsafe.
func
LoginWithProtoClient
(
storageDir
string
,
password
[]
byte
,
protoClientJSON
[]
byte
,
newBaseNdf
string
,
params
Params
)
(
*
E2e
,
error
)
{
jww
.
INFO
.
Printf
(
"LoginWithProtoClient()"
)
def
,
err
:=
ParseNDF
(
newBaseNdf
)
if
err
!=
nil
{
return
nil
,
err
}
protoUser
:=
&
user
.
Proto
{}
err
=
json
.
Unmarshal
(
protoClientJSON
,
protoUser
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
NewProtoClient_Unsafe
(
newBaseNdf
,
storageDir
,
password
,
protoUser
)
if
err
!=
nil
{
return
nil
,
err
}
c
,
err
:=
OpenCmix
(
storageDir
,
password
,
params
)
if
err
!=
nil
{
return
nil
,
err
}
c
.
storage
.
SetNDF
(
def
)
err
=
c
.
initPermissioning
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
network
.
Connect
(
def
)
if
err
!=
nil
{
return
nil
,
err
}
c
.
network
.
AddIdentity
(
c
.
GetUser
()
.
ReceptionID
,
time
.
Time
{},
true
)
// FIXME: The callbacks need to be set, so I suppose we would need to
// either set them via a special type or add them
// to the login call?
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
registerFollower
()
if
err
!=
nil
{
return
nil
,
err
}
return
Login
(
c
,
nil
,
ReceptionIdentity
{
ID
:
protoUser
.
ReceptionID
,
RSAPrivatePem
:
protoUser
.
ReceptionRSA
,
Salt
:
protoUser
.
ReceptionSalt
,
DHKeyPrivate
:
protoUser
.
E2eDhPrivateKey
,
})
}
// login creates a new xxdk.E2e backed by the given versioned.KV
// login creates a new xxdk.E2e backed by the given versioned.KV
func
login
(
client
*
Cmix
,
callbacks
auth
.
Callbacks
,
func
login
(
client
*
Cmix
,
callbacks
auth
.
Callbacks
,
identity
ReceptionIdentity
,
kv
*
versioned
.
KV
)
(
m
*
E2e
,
err
error
)
{
identity
ReceptionIdentity
,
kv
*
versioned
.
KV
)
(
m
*
E2e
,
err
error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment