docs: add comment about safety of u8 -> u64 cast in signature (#1704)

* docs: add comment about u8 -> u64 cast in signature

* fix: format

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Luke Tchang 2022-09-18 08:45:33 -07:00 committed by GitHub
parent f208fb9cd3
commit e034a8f979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,7 @@
### Unreleased
- Add comment about safety of u8 -> u64 cast in `ethers_core::types::Signature`
- Stop defaulting to the `"latest"` block in `eth_estimateGas` params [#1657](https://github.com/gakonst/ethers-rs/pull/1657)
- Fix geth trace types for debug_traceTransaction rpc
- Fix RLP decoding of legacy `Transaction`

View File

@ -215,6 +215,11 @@ impl From<&Signature> for [u8; 65] {
sig[32..64].copy_from_slice(&s_bytes);
// TODO: What if we try to serialize a signature where
// the `v` is not normalized?
// The u64 to u8 cast is safe because `sig.v` can only ever be 27 or 28
// here. Regarding EIP-155, the modification to `v` happens during tx
// creation only _after_ the transaction is signed using
// `ethers_signers::to_eip155_v`.
sig[64] = src.v as u8;
sig
}