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
177a4494
Commit
177a4494
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Add GetSavedChannelPrivateKeyUNSAFE, which returns the private key associated with a channel
parent
488207f9
No related branches found
No related tags found
2 merge requests
!510
Release
,
!340
Project/channels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/channels.go
+38
-1
38 additions, 1 deletion
bindings/channels.go
with
38 additions
and
1 deletion
bindings/channels.go
+
38
−
1
View file @
177a4494
...
@@ -9,6 +9,7 @@ package bindings
...
@@ -9,6 +9,7 @@ package bindings
import
(
import
(
"crypto/ed25519"
"crypto/ed25519"
"encoding/base64"
"encoding/json"
"encoding/json"
"github.com/pkg/errors"
"github.com/pkg/errors"
"gitlab.com/elixxir/client/channels"
"gitlab.com/elixxir/client/channels"
...
@@ -441,7 +442,43 @@ func saveChannelPrivateKey(cmix *Cmix, channelID *id.ID, pk rsa.PrivateKey) erro
...
@@ -441,7 +442,43 @@ func saveChannelPrivateKey(cmix *Cmix, channelID *id.ID, pk rsa.PrivateKey) erro
})
})
}
}
func
loadChannelPrivateKey
(
cmix
Cmix
,
channelID
*
id
.
ID
)
(
rsa
.
PrivateKey
,
error
)
{
// GetSavedChannelPrivateKeyUNSAFE loads the private key from storage for the
// given channel ID.
//
// NOTE: This function is unsafe and only for debugging purposes only.
//
// Parameters:
// - cmixID - ID of [Cmix] object in tracker.
// - channelIdBase64 - The [id.ID] of the channel in base 64 encoding.
//
// Returns:
// - The PEM file of the private key.
func
GetSavedChannelPrivateKeyUNSAFE
(
cmixID
int
,
channelIdBase64
string
)
(
string
,
error
)
{
cmix
,
err
:=
cmixTrackerSingleton
.
get
(
cmixID
)
if
err
!=
nil
{
return
""
,
err
}
channelIdBytes
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
channelIdBase64
)
if
err
!=
nil
{
return
""
,
errors
.
Errorf
(
"failed to decode channel ID: %+v"
,
err
)
}
channelID
,
err
:=
id
.
Unmarshal
(
channelIdBytes
)
if
err
!=
nil
{
return
""
,
errors
.
Errorf
(
"invalid channel ID: %+v"
,
err
)
}
privKey
,
err
:=
loadChannelPrivateKey
(
cmix
,
channelID
)
if
err
!=
nil
{
return
""
,
errors
.
Errorf
(
"failed to load private key from storage: %+v"
,
err
)
}
return
string
(
privKey
.
MarshalPem
()),
nil
}
func
loadChannelPrivateKey
(
cmix
*
Cmix
,
channelID
*
id
.
ID
)
(
rsa
.
PrivateKey
,
error
)
{
obj
,
err
:=
cmix
.
api
.
GetStorage
()
.
Get
(
obj
,
err
:=
cmix
.
api
.
GetStorage
()
.
Get
(
makeChannelPrivateKeyStoreKey
(
channelID
))
makeChannelPrivateKeyStoreKey
(
channelID
))
if
err
!=
nil
{
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