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

[EPROD-1099] fix signature v #214

Merged
merged 13 commits into from
Dec 20, 2024
Prev Previous commit
Next Next commit
fmt
  • Loading branch information
ufoscout committed Dec 19, 2024
commit d3f96a45f2f9d0e6e34f7a134f708ccbc1618985
12 changes: 8 additions & 4 deletions src/did/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ pub enum Parity {
}

impl Parity {

/// Returns the parity bool value
pub fn as_bool(&self) -> bool {
match self {
Expand All @@ -204,7 +203,6 @@ impl Parity {
Parity::Even
}
}

}

/// Transaction type and Chain id data required to generate the Signature V value for EIP-155
Expand All @@ -220,7 +218,11 @@ impl Signature {
pub fn new_from_rsv(r: U256, s: U256, v: u64) -> Result<Self, EvmError> {
let y_parity_is_odd =
normalize_v(v).ok_or_else(|| EvmError::InvalidSignatureParity(format!("{}", v)))?;
Ok(Self { r, s, y_parity: Parity::from_y_parity_is_odd(y_parity_is_odd) })
Ok(Self {
r,
s,
y_parity: Parity::from_y_parity_is_odd(y_parity_is_odd),
})
}

/// Recovers an [`Address`] from this signature and the given prehashed message.
Expand All @@ -239,7 +241,9 @@ impl Signature {
/// - For other transactions, the V value is the Y parity value
pub fn v(&self, info: TxChainInfo) -> u64 {
match info {
TxChainInfo::LegacyTx { chain_id } => to_eip155_value(self.y_parity.as_bool(), chain_id) as u64,
TxChainInfo::LegacyTx { chain_id } => {
to_eip155_value(self.y_parity.as_bool(), chain_id) as u64
}
TxChainInfo::OtherTx => self.y_parity.as_bool() as u64,
}
}
Expand Down
1 change: 0 additions & 1 deletion src/eth-signer/src/ic_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl IcSigner {

Self.sign_digest(*hash, pubkey, key_id, derivation_path)
.await

}

/// Signs the digest using `ManagementCanister::sign_with_ecdsa()` call.
Expand Down
Loading