You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function validates an ECDSA signature as \textit{ecc\_verify\_hash} but with a choice of signature formats.
5610
+
5582
5611
{\bf BEWARE:} With ECC if you try to sign a hash that is bigger than your ECC key you can run into problems. The math
5583
5612
will still work, and in effect the signature will still work. With ECC keys the strength of the signature is limited
5584
5613
by the size of the hash, or the size of the key, whichever is smaller. For example, if you sign with SHA256 and a
5585
5614
P--192 key, you have in effect 96--bits of security. The library will not warn you if you make this mistake, so it
5586
5615
is important to check yourself before using the signatures.
5587
5616
5617
+
\subsection{Public Key Recovery}
5618
+
\index{ecc\_recover\_key()}
5619
+
\begin{verbatim}
5620
+
int ecc_recover_key(const unsigned char *sig,
5621
+
unsigned long siglen,
5622
+
const unsigned char *hash,
5623
+
unsigned long hashlen,
5624
+
int recid,
5625
+
ecc_signature_type sigformat,
5626
+
ecc_key *key);
5627
+
\end{verbatim}
5628
+
5629
+
This function will recover (a) public key from the ECDSA signature in the array pointed to by \textit{sig} of length \textit{siglen} octets, the message digest
5630
+
pointed to by the array \textit{hash} of length \textit{hashlen}, and the recovery id \textit{recid}. It will store the recovered
5631
+
key into \textit{key} and return CRYPT\_OK if recovery succeeds, or an error if recovery fails.
5632
+
This is for compatibility with the (v,r,s) signatures used in Ethereum, where public keys are not explicitly shared,
5633
+
only the parity of the public key. For curves like secp256k1, recid will take values of 0 or 1, corresponding to the
5634
+
parity of the public key's y coordinate. For curves like secp112r2, with a cofactor of 4, values 0..7 are possible,
5635
+
with the low bit corresponding to the parity and the higher bits specifying the public key's x coordinate's multiple
5636
+
of the curve's order.
5637
+
If the signature format contains the recovery id (currently only \textit{LTC\_ECCSIG\_ETH27}), \textit{recid} can be -1
5638
+
which signals that the recovery id from the signature blob should be used. This means an application does not need to
5639
+
extract the recovery id from such a signature in order to use this function.
5640
+
The function \textit{ecc\_recover\_key} implements multiple signature formats, and the output is compliant for GF(p) curves.
0 commit comments