Skip to content

Commit

Permalink
fix verify-signed-message (#4294)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjiao authored Nov 24, 2024
1 parent f9ced31 commit b631b82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/starcoin/src/account/verify_sign_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ impl CommandAction for VerifySignMessageCmd {
let opt = ctx.opt();
let state = ctx.state();
let signed_message = opt.signed_message.clone();
let account_resource = state.get_account_resource(signed_message.account)?;
let account_resource = state.get_account_resource(signed_message.account).ok();

let result = signed_message.check_signature().and_then(|_| {
signed_message.check_account(state.net().chain_id(), Some(&account_resource))
signed_message.check_account(state.net().chain_id(), account_resource.as_ref())
});
Ok(VerifyResult {
ok: result.is_ok(),
Expand Down
5 changes: 3 additions & 2 deletions vm/framework/starcoin-framework/doc/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,10 @@ is returned. This way, the caller of this function can publish additional resour

<pre><code><b>fun</b> <a href="account.md#0x1_account_create_account_unchecked">create_account_unchecked</a>(new_address: <b>address</b>): <a href="../../move-stdlib/doc/signer.md#0x1_signer">signer</a> {
<b>let</b> new_account = <a href="create_signer.md#0x1_create_signer">create_signer</a>(new_address);
<b>let</b> authentication_key = <a href="../../move-stdlib/doc/bcs.md#0x1_bcs_to_bytes">bcs::to_bytes</a>(&new_address);
// fixme: create authentication key from <b>address</b>.
<b>let</b> authentication_key = <a href="account.md#0x1_account_ZERO_AUTH_KEY">ZERO_AUTH_KEY</a>;
<b>assert</b>!(
<a href="../../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&authentication_key) == 16,
<a href="../../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&authentication_key) == 32,
<a href="../../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="account.md#0x1_account_EMALFORMED_AUTHENTICATION_KEY">EMALFORMED_AUTHENTICATION_KEY</a>)
);

Expand Down
5 changes: 3 additions & 2 deletions vm/framework/starcoin-framework/sources/account.move
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ module starcoin_framework::account {

fun create_account_unchecked(new_address: address): signer {
let new_account = create_signer(new_address);
let authentication_key = bcs::to_bytes(&new_address);
// fixme: create authentication key from address.
let authentication_key = ZERO_AUTH_KEY;
assert!(
vector::length(&authentication_key) == 16,
vector::length(&authentication_key) == 32,
error::invalid_argument(EMALFORMED_AUTHENTICATION_KEY)
);

Expand Down

0 comments on commit b631b82

Please sign in to comment.