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
678f6278
Commit
678f6278
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix bindings comments
parent
87e81162
No related branches found
No related tags found
1 merge request
!510
Release
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/cmix.go
+13
-8
13 additions, 8 deletions
bindings/cmix.go
bindings/e2e.go
+19
-13
19 additions, 13 deletions
bindings/e2e.go
bindings/identity.go
+24
-10
24 additions, 10 deletions
bindings/identity.go
with
56 additions
and
31 deletions
bindings/cmix.go
+
13
−
8
View file @
678f6278
...
...
@@ -35,10 +35,10 @@ type Cmix struct {
id
int
}
// NewCmix creates user storage, generates keys, connects, and registers
//
with
the network. Note that this does not register a username/identity, but
//
merely
creates a new cryptographic identity for adding such information
//
at a later
date.
// NewCmix creates user storage, generates keys, connects, and registers
with
// the network. Note that this does not register a username/identity, but
merely
// creates a new cryptographic identity for adding such information
at a later
// date.
//
// Users of this function should delete the storage directory on error.
func
NewCmix
(
ndfJSON
,
storageDir
string
,
password
[]
byte
,
registrationCode
string
)
error
{
...
...
@@ -49,8 +49,9 @@ func NewCmix(ndfJSON, storageDir string, password []byte, registrationCode strin
return
nil
}
// LoadCmix will load an existing user storage from the storageDir using the password.
// This will fail if the user storage does not exist or the password is incorrect.
// LoadCmix will load an existing user storage from the storageDir using the
// password. This will fail if the user storage does not exist or the password
// is incorrect.
//
// The password is passed as a byte array so that it can be cleared from memory
// and stored as securely as possible using the MemGuard library.
...
...
@@ -82,6 +83,10 @@ func (c *Cmix) GetID() int {
return
c
.
id
}
////////////////////////////////////////////////////////////////////////////////
// cMix Tracker //
////////////////////////////////////////////////////////////////////////////////
// cmixTracker is a singleton used to keep track of extant Cmix objects,
// preventing race conditions created by passing it over the bindings.
type
cmixTracker
struct
{
...
...
@@ -90,8 +95,8 @@ type cmixTracker struct {
mux
sync
.
RWMutex
}
// make creates a Cmix from a xxdk.Cmix, assigns it a unique ID,and adds it
to
// the cmixTracker.
// make creates a Cmix from a
[
xxdk.Cmix
]
, assigns it a unique ID,
and adds it
//
to
the cmixTracker.
func
(
ct
*
cmixTracker
)
make
(
c
*
xxdk
.
Cmix
)
*
Cmix
{
ct
.
mux
.
Lock
()
defer
ct
.
mux
.
Unlock
()
...
...
This diff is collapsed.
Click to expand it.
bindings/e2e.go
+
19
−
13
View file @
678f6278
...
...
@@ -26,20 +26,20 @@ var e2eTrackerSingleton = &e2eTracker{
count
:
0
,
}
// E2e wraps the xxdk.E2e, implementing additional functions
//
to support the
bindings E2e interface.
// E2e wraps the xxdk.E2e, implementing additional functions
to support the
// bindings E2e interface.
type
E2e
struct
{
api
*
xxdk
.
E2e
id
int
}
// GetID returns the
e2eTracker
ID for th
e
E2e
object
.
// GetID returns the ID for th
is
E2e
in the e2eTracker
.
func
(
e
*
E2e
)
GetID
()
int
{
return
e
.
id
}
// Login creates and returns a new E2e object and adds it to the
// e2eTrackerSingleton.
i
dentity should be created via
// e2eTrackerSingleton.
I
dentity should be created via
// Cmix.MakeReceptionIdentity and passed in here. If callbacks is left nil, a
// default auth.Callbacks will be used.
func
Login
(
cmixId
int
,
callbacks
AuthCallbacks
,
identity
,
...
...
@@ -80,7 +80,7 @@ func Login(cmixId int, callbacks AuthCallbacks, identity,
}
// LoginEphemeral creates and returns a new ephemeral E2e object and adds it to
// the e2eTrackerSingleton.
i
dentity should be created via
// the e2eTrackerSingleton.
I
dentity should be created via
// Cmix.MakeReceptionIdentity or Cmix.MakeLegacyReceptionIdentity and passed in
// here. If callbacks is left nil, a default auth.Callbacks will be used.
func
LoginEphemeral
(
cmixId
int
,
callbacks
AuthCallbacks
,
identity
,
...
...
@@ -126,13 +126,15 @@ func (e *E2e) GetContact() []byte {
return
e
.
api
.
GetReceptionIdentity
()
.
GetContact
()
.
Marshal
()
}
// GetUdAddressFromNdf retrieve the User Discovery's network address fom the NDF.
// GetUdAddressFromNdf retrieve the User Discovery's network address fom the
// NDF.
func
(
e
*
E2e
)
GetUdAddressFromNdf
()
string
{
return
e
.
api
.
GetCmix
()
.
GetInstance
()
.
GetPartialNdf
()
.
Get
()
.
UDB
.
Address
}
// GetUdCertFromNdf retrieves the User Discovery's TLS certificate from the NDF.
// GetUdCertFromNdf retrieves the User Discovery's TLS certificate (in PEM
// format) from the NDF.
func
(
e
*
E2e
)
GetUdCertFromNdf
()
[]
byte
{
return
[]
byte
(
e
.
api
.
GetCmix
()
.
GetInstance
()
.
GetPartialNdf
()
.
Get
()
.
UDB
.
Cert
)
}
...
...
@@ -178,11 +180,11 @@ type authCallback struct {
}
// convertAuthCallbacks turns an auth.Callbacks into an AuthCallbacks.
func
convertAuthCallbacks
(
request
o
r
contact
.
Contact
,
func
convertAuthCallbacks
(
request
e
r
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
(
contact
[]
byte
,
receptionId
[]
byte
,
ephemeralId
int64
,
roundId
int64
)
{
contact
=
request
o
r
.
Marshal
()
contact
=
request
e
r
.
Marshal
()
receptionId
=
receptionID
.
Source
.
Marshal
()
ephemeralId
=
int64
(
receptionID
.
EphId
.
UInt64
())
roundId
=
int64
(
round
.
ID
)
...
...
@@ -207,6 +209,10 @@ func (a *authCallback) Reset(partner contact.Contact,
a
.
bindingsCbs
.
Reset
(
convertAuthCallbacks
(
partner
,
receptionID
,
round
))
}
////////////////////////////////////////////////////////////////////////////////
// E2E Tracker //
////////////////////////////////////////////////////////////////////////////////
// e2eTracker is a singleton used to keep track of extant E2e objects,
// preventing race conditions created by passing it over the bindings.
type
e2eTracker
struct
{
...
...
@@ -222,15 +228,15 @@ func (ct *e2eTracker) make(c *xxdk.E2e) *E2e {
ct
.
mux
.
Lock
()
defer
ct
.
mux
.
Unlock
()
id
:=
ct
.
count
e2eID
:=
ct
.
count
ct
.
count
++
ct
.
tracked
[
id
]
=
&
E2e
{
ct
.
tracked
[
e2eID
]
=
&
E2e
{
api
:
c
,
id
:
id
,
id
:
e2eID
,
}
return
ct
.
tracked
[
id
]
return
ct
.
tracked
[
e2eID
]
}
// get an E2e from the e2eTracker given its ID.
...
...
This diff is collapsed.
Click to expand it.
bindings/identity.go
+
24
−
10
View file @
678f6278
...
...
@@ -35,7 +35,7 @@ type ReceptionIdentity struct {
}
// StoreReceptionIdentity stores the given identity in Cmix storage with the
// given key.
This is the ideal way to securely store identities, as the caller
// given key. This is the ideal way to securely store identities, as the caller
// of this function is only required to store the given key separately rather
// than the keying material.
func
StoreReceptionIdentity
(
key
string
,
identity
[]
byte
,
cmixId
int
)
error
{
...
...
@@ -97,8 +97,13 @@ func (c *Cmix) GetReceptionRegistrationValidationSignature() []byte {
// Contact Functions //
////////////////////////////////////////////////////////////////////////////////
// GetIDFromContact accepts a marshalled contact.Contact object and returns a
// marshalled id.ID object.
// GetIDFromContact returns the ID in the [contact.Contact] object.
//
// Parameters:
// - marshaledContact - JSON marshalled bytes of [contact.Contact]
//
// Returns:
// - []byte - bytes of the [id.ID] object
func
GetIDFromContact
(
marshaledContact
[]
byte
)
([]
byte
,
error
)
{
cnt
,
err
:=
contact
.
Unmarshal
(
marshaledContact
)
if
err
!=
nil
{
...
...
@@ -108,8 +113,14 @@ func GetIDFromContact(marshaledContact []byte) ([]byte, error) {
return
cnt
.
ID
.
Marshal
(),
nil
}
// GetPubkeyFromContact accepts a marshalled contact.Contact object and returns
// a JSON marshalled large.Int DH public key.
// GetPubkeyFromContact returns the DH public key in the [contact.Contact]
// object.
//
// Parameters:
// - marshaledContact - JSON marshalled bytes of [contact.Contact]
//
// Returns:
// - []byte - JSON marshalled bytes of the [cyclic.Int] object
func
GetPubkeyFromContact
(
marshaledContact
[]
byte
)
([]
byte
,
error
)
{
cnt
,
err
:=
contact
.
Unmarshal
(
marshaledContact
)
if
err
!=
nil
{
...
...
@@ -127,8 +138,11 @@ func GetPubkeyFromContact(marshaledContact []byte) ([]byte, error) {
// pass in empty facts in order to clear the facts.
//
// Parameters:
// - marshaledContact - the JSON marshalled bytes of contact.Contact object.
// - factListJSON - the JSON marshalled bytes of [fact.FactList].
// - marshaledContact - the JSON marshalled bytes of [contact.Contact]
// - factListJSON - the JSON marshalled bytes of [fact.FactList]
//
// Returns:
// - []byte - marshalled bytes of the modified [contact.Contact]
func
SetFactsOnContact
(
marshaledContact
[]
byte
,
factListJSON
[]
byte
)
([]
byte
,
error
)
{
cnt
,
err
:=
contact
.
Unmarshal
(
marshaledContact
)
if
err
!=
nil
{
...
...
@@ -146,13 +160,13 @@ func SetFactsOnContact(marshaledContact []byte, factListJSON []byte) ([]byte, er
return
cnt
.
Marshal
(),
nil
}
// GetFactsFromContact returns the fact list in the contact.Contact object.
// GetFactsFromContact returns the fact list in the
[
contact.Contact
]
object.
//
// Parameters:
// - marshaledContact - the JSON marshalled bytes
by
of contact.Contact
object.
// - marshaledContact - the JSON marshalled bytes of
[
contact.Contact
]
//
// Returns:
// - []byte - the JSON marshalled bytes of [fact.FactList]
.
// - []byte - the JSON marshalled bytes of [fact.FactList]
func
GetFactsFromContact
(
marshaledContact
[]
byte
)
([]
byte
,
error
)
{
cnt
,
err
:=
contact
.
Unmarshal
(
marshaledContact
)
if
err
!=
nil
{
...
...
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