aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/miscellaneous.rst2
-rw-r--r--docs/units-and-global-variables.rst2
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp2
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp8
4 files changed, 5 insertions, 9 deletions
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index ca0cf593..804d69ef 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -286,7 +286,7 @@ Global Variables
- ``sha3(...) returns (bytes32)``: compute the Ethereum-SHA-3 (KECCAK-256) hash of the (tightly packed) arguments
- ``sha256(...) returns (bytes32)``: compute the SHA-256 hash of the (tightly packed) arguments
- ``ripemd160(...) returns (bytes20)``: compute the RIPEMD-160 hash of the (tightly packed) arguments
-- ``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``: recover address associated with the public key from elliptic curve signature
+- ``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``: recover address associated with the public key from elliptic curve signature, return zero on error
- ``addmod(uint x, uint y, uint k) returns (uint)``: compute ``(x + y) % k`` where the addition is performed with arbitrary precision and does not wrap around at ``2**256``
- ``mulmod(uint x, uint y, uint k) returns (uint)``: compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``
- ``this`` (current contract's type): the current contract, explicitly convertible to ``address``
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index 62b9158d..d1d578ed 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -95,7 +95,7 @@ Mathematical and Cryptographic Functions
``ripemd160(...) returns (bytes20)``:
compute RIPEMD-160 hash of the (tightly packed) arguments
``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``:
- recover the address associated with the public key from elliptic curve signature
+ recover the address associated with the public key from elliptic curve signature or return zero on error
In the above, "tightly packed" means that the arguments are concatenated without padding.
This means that the following are all identical::
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 50148901..65326669 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1571,8 +1571,6 @@ void ExpressionCompiler::appendExternalFunctionCall(
m_context << u256(32);
utils().fetchFreeMemoryPointer();
m_context << Instruction::SUB << Instruction::MLOAD;
- m_context << Instruction::DUP1 << Instruction::ISZERO;
- m_context.appendConditionalJumpTo(m_context.errorTag());
}
else if (!_functionType.returnParameterTypes().empty())
{
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 338a47da..345bac80 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6855,11 +6855,9 @@ BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length)
BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input)
{
- // ecrecover should throw for malformed input
+ // ecrecover should return zero for malformed input
// (v should be 27 or 28, not 1)
- // This is quite hard to test because the precompiled does NOT throw, instead it just
- // does not write to its output area, we have to check that and currently do it
- // by checking whether ecrecover "returns" zero.
+ // Note that the precompile does not return zero but returns nothing.
char const* sourceCode = R"(
contract C {
function f() returns (address) {
@@ -6868,7 +6866,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input)
}
)";
compileAndRun(sourceCode, 0, "C");
- BOOST_CHECK(callContractFunction("f()") == encodeArgs());
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
BOOST_AUTO_TEST_SUITE_END()