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
f1ac2451
Commit
f1ac2451
authored
2 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Fix argument inconsistency in bindings
parent
de963b36
No related branches found
No related tags found
2 merge requests
!510
Release
,
!301
Josh/backup bindings part3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backup/backup.go
+2
-2
2 additions, 2 deletions
backup/backup.go
backup/backupRestore.go
+3
-3
3 additions, 3 deletions
backup/backupRestore.go
cmd/backup.go
+33
-2
33 additions, 2 deletions
cmd/backup.go
with
38 additions
and
7 deletions
backup/backup.go
+
2
−
2
View file @
f1ac2451
...
...
@@ -90,7 +90,7 @@ type UpdateBackupFn func(encryptedBackup []byte)
// new backups.
// Call this to turn on backups for the first time or to replace the user's
// password.
func
InitializeBackup
(
password
string
,
updateBackupCb
UpdateBackupFn
,
func
InitializeBackup
(
backupPassphrase
string
,
updateBackupCb
UpdateBackupFn
,
container
*
xxdk
.
Container
,
e2e
E2e
,
session
Session
,
ud
UserDiscovery
,
kv
*
versioned
.
KV
,
rng
*
fastRNG
.
StreamGenerator
)
(
*
Backup
,
error
)
{
b
:=
&
Backup
{
...
...
@@ -115,7 +115,7 @@ func InitializeBackup(password string, updateBackupCb UpdateBackupFn,
params
.
Memory
=
64
*
1024
// 64 MiB
params
.
Threads
=
1
params
.
Time
=
5
key
:=
backup
.
DeriveKey
(
password
,
salt
,
params
)
key
:=
backup
.
DeriveKey
(
backupPassphrase
,
salt
,
params
)
// Save key, salt, and parameters to storage
err
=
saveBackup
(
key
,
salt
,
params
,
b
.
kv
)
...
...
This diff is collapsed.
Click to expand it.
backup/backupRestore.go
+
3
−
3
View file @
f1ac2451
...
...
@@ -25,12 +25,12 @@ import (
// a successful client creation, the function will return a
// JSON encoded list of the E2E partners contained in the backup and a
// json-encoded string containing parameters stored in the backup
func
NewCmixFromBackup
(
ndfJSON
,
storageDir
string
,
sessionPassword
,
backupPassphrase
[]
byte
,
backupFileContents
[]
byte
)
([]
*
id
.
ID
,
func
NewCmixFromBackup
(
ndfJSON
,
storageDir
,
backupPassphrase
string
,
sessionPassword
[]
byte
,
backupFileContents
[]
byte
)
([]
*
id
.
ID
,
string
,
error
)
{
backUp
:=
&
cryptoBackup
.
Backup
{}
err
:=
backUp
.
Decrypt
(
string
(
backupPassphrase
)
,
backupFileContents
)
err
:=
backUp
.
Decrypt
(
backupPassphrase
,
backupFileContents
)
if
err
!=
nil
{
return
nil
,
""
,
errors
.
WithMessage
(
err
,
"Failed to unmarshal decrypted client contents."
)
...
...
This diff is collapsed.
Click to expand it.
cmd/backup.go
+
33
−
2
View file @
f1ac2451
...
...
@@ -21,6 +21,14 @@ import (
"gitlab.com/xx_network/primitives/utils"
)
type
BackupReport
struct
{
// The JSON encoded list of E2E partner IDs
BackupIdListJson
[]
byte
// The backup parameters found within the backup file
BackupParams
[]
byte
}
// loadOrInitBackup will build a new xxdk.E2e from existing storage
// or from a new storage that it will create if none already exists
func
loadOrInitBackup
(
backupPath
string
,
backupPass
string
,
password
[]
byte
,
storeDir
string
,
...
...
@@ -50,12 +58,35 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
}
// Construct cMix from backup data
backupIdList
,
_
,
err
:=
backup
.
NewCmixFromBackup
(
string
(
ndfJson
),
storeDir
,
password
,
[]
byte
(
backupPass
)
,
backupFile
)
backupIdList
,
backupParams
,
err
:=
backup
.
NewCmixFromBackup
(
string
(
ndfJson
),
storeDir
,
backupPass
,
password
,
backupFile
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
backupIdListJson
,
err
:=
json
.
Marshal
(
backupIdList
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to marshal backup ID: %v"
,
err
)
}
buReport
:=
BackupReport
{
BackupIdListJson
:
backupIdListJson
,
BackupParams
:
[]
byte
(
backupParams
),
}
jww
.
INFO
.
Printf
(
""
)
jww
.
INFO
.
Printf
(
"backup Report obj: %v"
,
buReport
)
reportJson
,
err
:=
json
.
Marshal
(
buReport
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to marshal backup report: %v"
,
err
)
}
jww
.
INFO
.
Printf
(
"backupIdList: %v
\n
"
+
"backupParams: %s
\n
"
+
"backup Report obj: %v
\n
"
+
"backup report:
\n
%s"
,
backupIdList
,
backupParams
,
buReport
,
string
(
reportJson
))
backupIdListPath
:=
viper
.
GetString
(
backupIdListFlag
)
if
backupIdListPath
!=
""
{
// Marshal backed up ID list to JSON
...
...
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