Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix verify-signed-message #4294

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading