Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
clients
Rust
Ğcli-v2s
Commits
a44be2f0
Commit
a44be2f0
authored
4 months ago
by
Nicolas80
Browse files
Options
Downloads
Patches
Plain Diff
Added extra confirmation when importing a G1v1/Cesium key; showing the old G1v1 public key
parent
4752e207
No related branches found
No related tags found
1 merge request
!41
Adding db persistence for all SecretFormat of vault keys as well as supporting derivations
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/commands/cesium.rs
+23
-3
23 additions, 3 deletions
src/commands/cesium.rs
src/commands/vault.rs
+14
-1
14 additions, 1 deletion
src/commands/vault.rs
with
37 additions
and
4 deletions
src/commands/cesium.rs
+
23
−
3
View file @
a44be2f0
use
crate
::
*
;
use
bs58
;
use
sp_core
::
ed25519
::
Pair
as
Ed25519Pair
;
/// define cesium subcommands
#[derive(Clone,
Default,
Debug,
clap::Parser)]
...
...
@@ -34,11 +35,30 @@ pub async fn handle_command(_data: Data, command: Subcommand) -> Result<(), Gcli
}
Subcommand
::
Prompt
=>
{
let
pair
=
prompt_secret_cesium
();
let
public
=
pair
.public
();
println!
(
"Pubkey: {}"
,
bs58
::
encode
(
public
)
.into_string
());
let
address
:
AccountId
=
public
.into
();
println!
(
"Pubkey: {}"
,
compute_g1v1_public_key_from_ed25519_pair
(
&
pair
)
?
);
let
address
:
AccountId
=
pair
.public
()
.into
();
println!
(
"Address: {}"
,
address
);
}
}
Ok
(())
}
/// Computes G1v1 public key from a KeyPair of type sp_core::ed25519::Pair - fails otherwise
pub
fn
compute_g1v1_public_key
(
key_pair
:
&
KeyPair
)
->
Result
<
String
,
GcliError
>
{
match
key_pair
{
KeyPair
::
Sr25519
(
_
)
=>
Err
(
GcliError
::
Logic
(
"key pair is not of type ed25519"
.to_string
(),
)),
KeyPair
::
Ed25519
(
key_pair
)
=>
Ok
(
compute_g1v1_public_key_from_ed25519_pair
(
key_pair
)
?
),
}
}
/// Computes G1v1 public key from an ed25519 Pair
pub
fn
compute_g1v1_public_key_from_ed25519_pair
(
ed25519_key_pair
:
&
Ed25519Pair
,
)
->
Result
<
String
,
GcliError
>
{
Ok
(
bs58
::
encode
(
ed25519_key_pair
.public
())
.into_string
())
}
This diff is collapsed.
Click to expand it.
src/commands/vault.rs
+
14
−
1
View file @
a44be2f0
use
crate
::
commands
::
cesium
::
compute_g1v1_public_key
;
use
crate
::
entities
::
vault_account
::
CryptoType
;
use
crate
::
entities
::{
vault_account
,
vault_derivation
};
use
crate
::
*
;
...
...
@@ -201,9 +202,21 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
let
vault_data_for_import
=
prompt_secret_and_compute_vault_data_to_import
(
secret_format
)
?
;
//Extra check for SecretFormat::Cesium / G1v1Seed - showing the G1v1 cesium public key for confirmation
if
secret_format
==
SecretFormat
::
Cesium
{
println!
(
"The G1v1 public key for the provided secret is: '{}'"
,
compute_g1v1_public_key
(
&
vault_data_for_import
.key_pair
)
?
);
let
confirmed
=
inputs
::
confirm_action
(
"Is it the correct one (if not, you should try again to input Cesium id/password) ?"
.to_string
())
?
;
if
!
confirmed
{
return
Ok
(());
}
}
let
address_to_import
=
vault_data_for_import
.key_pair
.address
()
.to_string
();
println!
(
"Trying to import for address :'{}'"
,
address_to_import
);
println!
(
"Trying to import for
SS58
address :'{}'"
,
address_to_import
);
if
let
Some
(
derivation
)
=
vault_derivation
::
Entity
::
find_by_id
(
&
address_to_import
)
.one
(
data
.connection
.as_ref
()
.unwrap
())
...
...
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