using base58-encoded serialization
This commit is contained in:
@@ -97,15 +97,29 @@ fn print_signed_text(private_key: &identity::PrivateKey, text: &str) {
|
||||
}
|
||||
|
||||
fn print_signed_contract_msg(private_key: &identity::PrivateKey, raw_msg: &str) {
|
||||
let trimmed = raw_msg.trim();
|
||||
println!(">>> attempting to sign {trimmed}");
|
||||
|
||||
let Ok(decoded) = bs58::decode(trimmed).into_vec() else {
|
||||
println!("it seems you have incorrectly copied the message to sign. Make sure you didn't accidentally skip any characters");
|
||||
return;
|
||||
};
|
||||
|
||||
println!(">>> decoding the message...");
|
||||
|
||||
// we don't really care about what particular information is embedded inside of it,
|
||||
// we just want to know if user correctly copied the string, i.e. whether it's a valid json
|
||||
if serde_json::from_str::<serde_json::Value>(raw_msg).is_err() {
|
||||
println!("it seems you have incorrectly copied the message to sign. Make sure you didn't accidentally skip any characters")
|
||||
} else {
|
||||
let msg = raw_msg.trim();
|
||||
let signature = private_key.sign(msg.trim().as_bytes()).to_base58_string();
|
||||
println!("The base58-encoded signature on\n{msg}\nis:\n{signature}");
|
||||
}
|
||||
// we just want to know if user correctly copied the string, i.e. whether it's a valid bs58 encoded json
|
||||
if serde_json::from_slice::<serde_json::Value>(&decoded).is_err() {
|
||||
println!("it seems you have incorrectly copied the message to sign. Make sure you didn't accidentally skip any characters");
|
||||
return;
|
||||
};
|
||||
|
||||
// if this is a valid json, it MUST be a valid string
|
||||
let decoded_string = String::from_utf8(decoded.clone()).unwrap();
|
||||
println!(">>> message to sign: {decoded_string}");
|
||||
|
||||
let signature = private_key.sign(&decoded).to_base58_string();
|
||||
println!(">>> The base58-encoded signature is:\n{signature}");
|
||||
}
|
||||
|
||||
pub fn execute(args: Sign) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
|
||||
@@ -78,15 +78,29 @@ fn print_signed_text(private_key: &identity::PrivateKey, text: &str) {
|
||||
}
|
||||
|
||||
fn print_signed_contract_msg(private_key: &identity::PrivateKey, raw_msg: &str) {
|
||||
let trimmed = raw_msg.trim();
|
||||
println!(">>> attempting to sign {trimmed}");
|
||||
|
||||
let Ok(decoded) = bs58::decode(trimmed).into_vec() else {
|
||||
println!("it seems you have incorrectly copied the message to sign. Make sure you didn't accidentally skip any characters");
|
||||
return;
|
||||
};
|
||||
|
||||
println!(">>> decoding the message...");
|
||||
|
||||
// we don't really care about what particular information is embedded inside of it,
|
||||
// we just want to know if user correctly copied the string, i.e. whether it's a valid json
|
||||
if serde_json::from_str::<serde_json::Value>(raw_msg).is_err() {
|
||||
println!("it seems you have incorrectly copied the message to sign. Make sure you didn't accidentally skip any characters")
|
||||
} else {
|
||||
let msg = raw_msg.trim();
|
||||
let signature = private_key.sign(msg.trim().as_bytes()).to_base58_string();
|
||||
println!("The base58-encoded signature on\n{msg}\nis:\n{signature}");
|
||||
}
|
||||
// we just want to know if user correctly copied the string, i.e. whether it's a valid bs58 encoded json
|
||||
if serde_json::from_slice::<serde_json::Value>(&decoded).is_err() {
|
||||
println!("it seems you have incorrectly copied the message to sign. Make sure you didn't accidentally skip any characters");
|
||||
return;
|
||||
};
|
||||
|
||||
// if this is a valid json, it MUST be a valid string
|
||||
let decoded_string = String::from_utf8(decoded.clone()).unwrap();
|
||||
println!(">>> message to sign: {decoded_string}");
|
||||
|
||||
let signature = private_key.sign(&decoded).to_base58_string();
|
||||
println!(">>> The base58-encoded signature is:\n{signature}");
|
||||
}
|
||||
|
||||
pub(crate) fn execute(args: &Sign) {
|
||||
|
||||
@@ -35,7 +35,7 @@ async fn mixnode_bonding_msg_payload(
|
||||
let msg =
|
||||
create_mixnode_bonding_sign_payload(client, mixnode, cost_params, pledge_base, vesting)
|
||||
.await?;
|
||||
Ok(msg.to_json_string()?)
|
||||
Ok(msg.to_base58_string()?)
|
||||
}
|
||||
|
||||
async fn gateway_bonding_msg_payload(
|
||||
@@ -58,7 +58,7 @@ async fn gateway_bonding_msg_payload(
|
||||
// TODO: decide on exact structure here. Json? base58? some hash?
|
||||
// to be determined
|
||||
let msg = create_gateway_bonding_sign_payload(client, gateway, pledge_base, vesting).await?;
|
||||
Ok(msg.to_json_string()?)
|
||||
Ok(msg.to_base58_string()?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user