Avoid assembly in signature V and S decomposition (#3060)

* Avoid assembly in signature V and S decomposition

* Update ECDSA.sol
This commit is contained in:
Anton Bukov
2021-12-29 18:22:39 +03:00
committed by GitHub
parent e3391cd65f
commit da3a9ae18b

View File

@ -117,12 +117,8 @@ library ECDSA {
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}