1

I want to create a smart contract that contains the public key of a party (the key is generated outside the blockchain) and contains a function to verify signed data. How can we implement this function in solidity? I took a look to ecrecover but I think it need an ethereum address instead of a public key.

[UPDATE] : the public key isn't related to any ethereum address.

0

When you need to verify public key, just use

address addrfrompub = address(bytes20(keccak256(pubkeyPart1, pubkeyPart2) << 96)));

address addrrecovered = ecrecover(hash, v, r, s);

Then compare them:

require(addrfrompub == addrrecovered);

Hope it helps.

  • thank u for your answer. but what I need is to verify a signature that it is generated outside the ethereum context using a private key. in other words I want to create a smart contract that will be able to verify old signatures made outside the blockchain, and the public key isn't related to any ethereum address – maroodb Apr 12 '18 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.