Skip to content

Commit

Permalink
update README to document the commit in message_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 committed Jun 20, 2024
1 parent 1fa5f60 commit c8a1186
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ to build the transaction and pay tx fees. There
are no restrictions on who the native transaction
signer/fee payer is.

In both `withdraw` and `withdrawAndCall` instructions,
the ECDSA signed message_hash must commit to the
`nonce`, `amount`, and recipient address. See the
check in these instructions like:
```rust
let mut concatenated_buffer = Vec::new();
concatenated_buffer.extend_from_slice(&nonce.to_be_bytes());
concatenated_buffer.extend_from_slice(&amount.to_be_bytes());
concatenated_buffer.extend_from_slice(&ctx.accounts.to.key().to_bytes());
require!(message_hash == hash(&concatenated_buffer[..]).to_bytes(), Errors::MessageHashMismatch);
```

# Build and Test Instructions

Prerequisites: a recent version of `rust` compiler
Expand Down

0 comments on commit c8a1186

Please sign in to comment.