# ECDSA verify signature

The algorithm to **verify a ECDSA signature** takes as input the signed message ***msg*** + the signature {***r***, ***s***} produced from the signing algorithm + the public key ***pubKey***, corresponding to the signer's private key. The output is boolean value: ***valid*** or ***invalid*** signature. The **ECDSA signature verify** algorithm works as follows (with minor simplifications):

1. Calculate the message **hash**, with the same cryptographic hash function used during the signing: ***h*** = hash(***msg***)
2. Calculate the modular inverse of the signature proof: ***s1*** = $$s^{-1} \pmod n$$
3. Recover the random point used during the signing: ***R'*** = (***h*** \* **s1**) \* **G** + (***r*** \* ***s1***) \* ***pubKey***
4. Take from ***R'*** its x-coordinate: ***r'*** = ***R'*****.x**
5. Calculate the signature validation **result** by comparing whether ***r'*** == ***r***

The general idea of the signature verification is to **recover the point** ***R'*** using the public key and check whether it is same point ***R***, generated randomly during the signing process.

[Source](https://cryptobook.nakov.com/digital-signatures/ecdsa-sign-verify-messages)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-protocol.loopring.io/resources/signature/ecdsa-signature/ecdsa-verify-signature.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
