Skip to content

Commit

Permalink
feat: shadowing wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Jasuwienas <[email protected]>
  • Loading branch information
arianejasuwienas committed Oct 11, 2024
1 parent 5d057b3 commit 224a17b
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.Objects;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jcajce.provider.digest.Keccak;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public record EthTxData(
byte[] rawTx,
Expand All @@ -45,11 +47,13 @@ public record EthTxData(
BigInteger value, // weibar, always positive - note that high-bit might be ON in RLP encoding: still positive
byte[] callData,
byte[] accessList,
int recId, // "recovery id" part of a v,r,s ECDSA signature - range 0..1
byte[] v, // actual `v` value, incoming, recovery id (`recId` above) (possibly) encoded with chain id
int recId,
byte[] v,
byte[] r,
byte[] s) {

private static final Logger log = LogManager.getLogger(EthTxData.class);

/**
* A "wiebar" is 10⁻¹⁸ of an hbar. The relationship is weibar : hbar as wei : ether. Ethereum
* transactions come in with transfer amounts in units of weibar. Elsewhere in Hedera we use
Expand Down Expand Up @@ -154,11 +158,6 @@ EthTxData replaceValue(@NonNull final BigInteger replacementValue) {
s);
}

// For more information on "recovery id" see
// https://coinsbench.com/understanding-digital-signatures-the-role-of-v-r-s-in-cryptographic-security-and-signature-b9d2b89bbc0c

// For more information on encoding `v` see EIP-155 - https://eips.ethereum.org/EIPS/eip-155

public byte[] encodeTx() {
if (accessList != null && accessList.length > 0) {
throw new IllegalStateException("Re-encoding access list is unsupported");
Expand Down Expand Up @@ -340,6 +339,7 @@ public boolean hasToAddress() {
}

public boolean matchesChainId(final byte[] hederaChainId) {
log.info("DEBUGGED CHAIN ID", chainId);
// first two checks handle the unprotected ethereum transactions
// before EIP155 - source: [https://eips.ethereum.org/EIPS/eip-155](https://eips.ethereum.org/EIPS/eip-155)
if (chainId == null || chainId.length == 0) {
Expand Down Expand Up @@ -493,4 +493,4 @@ private static EthTxData populateEip2390EthTxData(RLPItem rlpItem, byte[] rawTx)
private static boolean isLegacyUnprotectedEtx(@NonNull BigInteger vBI) {
return vBI.compareTo(LEGACY_V_BYTE_SIGNATURE_0) == 0 || vBI.compareTo(LEGACY_V_BYTE_SIGNATURE_1) == 0;
}
}
}

0 comments on commit 224a17b

Please sign in to comment.