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
The expected types of the arguments to that macro are\code{(ecc\_key*, const char*)}.
5837
+
To parametrize the signature API, a specific type\code{ltc\_ecc\_sig\_opts} exists, which must be populated with the desired values.
5842
5838
5843
-
\index{ecc\_sign\_hash\_rfc7518()}
5839
+
\index{ltc\_ecc\_sig\_opts}
5840
+
\begin{small}
5844
5841
\begin{verbatim}
5845
-
int ecc_sign_hash_rfc7518(const unsigned char *in,
5846
-
unsigned long inlen,
5847
-
unsigned char *out,
5848
-
unsigned long *outlen,
5849
-
prng_state *prng,
5850
-
int wprng,
5851
-
const ecc_key *key);
5852
-
\end{verbatim}
5842
+
typedef struct ltc_ecc_sig_opts {
5843
+
/** Signature type */
5844
+
ecc_signature_type type;
5845
+
/** The PRNG to use.
5846
+
* This must be set in case deterministic signature generation
5847
+
* according to RFC6979 is not enabled.
5848
+
*/
5849
+
prng_state *prng;
5850
+
int wprng;
5853
5851
5854
-
This function creates the same \textit{ECDSA} signature as \code{ecc\_sign\_hash()} only the output format is different.
5855
-
The format follows \url{https://tools.ietf.org/html/rfc7518#section-3.4}, sometimes it is also called plain signature.
5852
+
/** Enable generation of a recovery ID.
5853
+
* This must be set in case one requires the recovery ID of a
5854
+
* signature operation.
5855
+
*/
5856
+
int *recid;
5856
5857
5857
-
\index{ecc\_sign\_hash\_rfc7518\_ex()}
5858
-
\begin{verbatim}
5859
-
int ecc_sign_hash_rfc7518_ex(const unsigned char *in,
5860
-
unsigned long inlen,
5861
-
unsigned char *out,
5862
-
unsigned long *outlen,
5863
-
prng_state *prng,
5864
-
int wprng,
5865
-
int *recid,
5866
-
const ecc_key *key);
5858
+
/** The hash algorithm to use when creating a signature.
5859
+
* Setting this will enable RFC6979 compatible signature generation.
5860
+
*/
5861
+
const char *rfc6979_hash_alg;
5862
+
} ltc_ecc_sig_opts;
5867
5863
\end{verbatim}
5864
+
\end{small}
5868
5865
5869
-
This function is an extended version of the \textit{ECDSA} signature in \code{ecc\_sign\_hash\_rfc7518()}, but with an additional output of the recovery ID
5870
-
for use with \code{ecc\_recover\_key()}.
5866
+
\subsection{Signature Generation}
5867
+
\label{ecc-sign}
5868
+
To sign a message digest (hash) use the following function:
5871
5869
5872
-
\index{ecc\_sign\_hash\_rfc5656()}
5870
+
\index{ecc\_sign\_hash\_v2()}
5873
5871
\begin{verbatim}
5874
-
int ecc_sign_hash_rfc5656(const unsigned char *in,
5875
-
unsigned long inlen,
5876
-
unsigned char *out,
5877
-
unsigned long *outlen,
5878
-
prng_state *prng,
5879
-
int wprng,
5880
-
const ecc_key *key);
5872
+
int ecc_sign_hash_v2(const unsigned char *in,
5873
+
unsigned long inlen,
5874
+
unsigned char *out,
5875
+
unsigned long *outlen,
5876
+
ltc_ecc_sig_opts *opts,
5877
+
const ecc_key *key);
5881
5878
\end{verbatim}
5882
5879
5883
-
This function creates an \textit{ECDSA} signature and the output format is according to \textit{RFC5656}, i.e. \textit{SSH} compatible.
5880
+
This function will \textit{ECDSA} sign the message digest stored in the array pointed to by \code{in} of length \code{inlen} octets. The signature
5881
+
will be stored in the array pointed to by \code{out} of length \code{outlen} octets. The function requires that the \textit{ECC}
5882
+
\code{key} provided must be a private key.
5884
5883
5885
-
\index{ecc\_sign\_hash\_eth27()}
5886
-
\begin{verbatim}
5887
-
int ecc_sign_hash_eth27(const unsigned char *in,
5888
-
unsigned long inlen,
5889
-
unsigned char *out,
5890
-
unsigned long *outlen,
5891
-
prng_state *prng,
5892
-
int wprng,
5893
-
const ecc_key *key);
5894
-
\end{verbatim}
5884
+
In order to execute standard \textit{ECDSA} it requires a properly seeded \textit{PRNG} which gets passed via \code{opts.prng} and \code{opts.wprng}.
5895
5885
5896
-
This function creates an \textit{ECDSA} signature and the output format is according to the Ethereum format.
5897
-
With this API the curve is limited to \textit{secp256k1}.
5886
+
The deterministic signature mechanism according to \textit{RFC6979} is also supported. This does not require a \textit{PRNG}, but
5887
+
instead a valid hash function name shall be set in the options' field \code{opts.rfc6979\_hash\_alg}.
5898
5888
5899
5889
\subsection{Signature Verification}
5900
-
\index{ecc\_verify\_hash()}
5901
-
\begin{verbatim}
5902
-
int ecc_verify_hash(const unsigned char *sig,
5903
-
unsigned long siglen,
5904
-
const unsigned char *hash,
5905
-
unsigned long hashlen,
5906
-
int *stat,
5907
-
const ecc_key *key);
5890
+
\label{ecc-verify}
5891
+
\index{ecc\_verify\_hash\_v2()}
5892
+
\begin{verbatim}
5893
+
int ecc_verify_hash_v2(const unsigned char *sig,
5894
+
unsigned long siglen,
5895
+
const unsigned char *hash,
5896
+
unsigned long hashlen,
5897
+
ltc_ecc_sig_opts *opts,
5898
+
int *stat,
5899
+
const ecc_key *key);
5908
5900
\end{verbatim}
5909
5901
5910
5902
This function will verify the \textit{ECDSA} signature in the array pointed to by \code{sig} of length \code{siglen} octets, against the message digest
5911
5903
pointed to by the array \code{hash} of length \code{hashlen}. It will store a non--zero value in \code{stat} if the signature is valid. Note:
5912
5904
the function will not return an error if the signature is invalid. It will return an error, if the actual signature payload is an invalid format.
5913
5905
The \textit{ECC} \code{key} must be the public (or private) \textit{ECC} key corresponding to the key that performed the signature.
5914
-
The function \code{ecc\_verify\_hash()} implements signature format according to \textit{ANSI X9.62} EC\textit{DSA}, and the output is compliant for GF(p) curves.
5915
-
5916
-
\index{ecc\_verify\_hash\_rfc7518()}
5917
-
\begin{verbatim}
5918
-
int ecc_verify_hash_rfc7518(const unsigned char *sig,
5919
-
unsigned long siglen,
5920
-
const unsigned char *hash,
5921
-
unsigned long hashlen,
5922
-
int *stat,
5923
-
const ecc_key *key);
5924
-
\end{verbatim}
5925
-
5926
-
This function validates the \textit{ECDSA} signature as \code{ecc\_verify\_hash()}, only the signature input format
0 commit comments