lcx_ecschnorr.h | Developers

lcx_ecschnorr.h

Back to the files list

ECSDSA (Elliptic Curve-based Schnorr Digital Signature Algorithm). More...

Functions

cx_err_t cx_ecschnorr_sign_no_throw (const cx_ecfp_private_key_t *pvkey, uint32_t mode, cx_md_t hashID, const uint8_t *msg, size_t msg_len, uint8_t *sig, size_t *sig_len)
 Signs a digest message according to the given mode. More...
static int cx_ecschnorr_sign (const cx_ecfp_private_key_t *pvkey, int mode, cx_md_t hashID, const unsigned char *msg, unsigned int msg_len, unsigned char *sig, size_t sig_len, unsigned int *info)
 Signs a digest message according to the given mode. More...
bool cx_ecschnorr_verify (const cx_ecfp_public_key_t *pukey, uint32_t mode, cx_md_t hashID, const uint8_t *msg, size_t msg_len, const uint8_t *sig, size_t sig_len)
 Verifies a digest message signature according to the given mode. More...

Detailed Description

ECSDSA (Elliptic Curve-based Schnorr Digital Signature Algorithm).

Schnorr signature algorithm is a non-standard alternative to ECDSA. Several implementations of Schnorr signature algorithm are supported here.

Function Documentation

cx_ecschnorr_sign()

static int cx_ecschnorr_sign ( const cx_ecfp_private_key_t pvkey,
int  mode,
cx_md_t  hashID,
const unsigned char *  msg,
unsigned int  msg_len,
unsigned char *  sig,
size_t  sig_len,
unsigned int *  info 
)

Signs a digest message according to the given mode.

This function throws an exception if the computation doesn't succeed.

Warning
It is recommended to use cx_ecschnorr_sign_no_throw rather than this function.
Parameters
[in]pvkeyPointer to the private key initialized with cx_ecfp_init_private_key_no_throw beforehand.
[in]modeMode. Supported flag:
  • CX_ECSCHNORR_XY
  • CX_ECSCHNORR_ISO14888_X
  • CX_ECSCHNORR_BSI03111
  • CX_ECSCHNORR_LIBSECP
  • CX_ECSCHNORR_Z
  • CX_ECSCHNORR_BIP0340
[in]hashIDMessage digest algorithm identifier. This parameter is mandatory when using the CX_RND_RFC6979 pseudorandom number generator.
[in]msgInput data to sign.
[in]msg_lenLength of input data.
[out]sigECSchnorr signature encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s. This parameter holds the auxiliary random data when CX_ECSCHNORR_BIP0340 is used.
[in]sig_lenLength of the signature.
[in]infoAdditional information. This parameter is not used.
Returns
Length of the signature.
Exceptions
CX_EC_INVALID_CURVE
CX_INVALID_PARAMETER
CX_NOT_UNLOCKED
CX_INVALID_PARAMETER_SIZE
CX_NOT_LOCKED
CX_MEMORY_FULL
CX_EC_INVALID_POINT
CX_EC_INFINITE_POINT
CX_INVALID_PARAMETER_VALUE

cx_ecschnorr_sign_no_throw()

cx_err_t cx_ecschnorr_sign_no_throw ( const cx_ecfp_private_key_t pvkey,
uint32_t  mode,
cx_md_t  hashID,
const uint8_t *  msg,
size_t  msg_len,
uint8_t *  sig,
size_t *  sig_len 
)

Signs a digest message according to the given mode.

Parameters
[in]pvkeyPointer to the private key initialized with cx_ecfp_init_private_key_no_throw beforehand.
[in]modeMode. Supported flag:
  • CX_ECSCHNORR_XY
  • CX_ECSCHNORR_ISO14888_X
  • CX_ECSCHNORR_BSI03111
  • CX_ECSCHNORR_LIBSECP
  • CX_ECSCHNORR_Z
  • CX_ECSCHNORR_BIP0340
[in]hashIDMessage digest algorithm identifier. This parameter is mandatory when using the CX_RND_RFC6979 pseudorandom number generator.
[in]msgInput data to sign.
[in]msg_lenLength of input data.
[out]sigECSchnorr signature encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s. This parameter holds the auxiliary random data when CX_ECSCHNORR_BIP0340 is used.
[in]sig_lenLength of the signature.
Returns
Error code:
  • CX_OK on success
  • CX_EC_INVALID_CURVE
  • CX_INVALID_PARAMETER
  • CX_NOT_UNLOCKED
  • CX_INVALID_PARAMETER_SIZE
  • CX_NOT_LOCKED
  • CX_MEMORY_FULL
  • CX_EC_INVALID_POINT
  • CX_EC_INFINITE_POINT
  • CX_INVALID_PARAMETER_VALUE

cx_ecschnorr_verify()

bool cx_ecschnorr_verify ( const cx_ecfp_public_key_t pukey,
uint32_t  mode,
cx_md_t  hashID,
const uint8_t *  msg,
size_t  msg_len,
const uint8_t *  sig,
size_t  sig_len 
)

Verifies a digest message signature according to the given mode.

Parameters
[in]pukeyPointer to the public key initialized with cx_ecfp_init_private_key_no_throw beforehand.
[in]modeMode. Supported flag:
  • CX_ECSCHNORR_XY
  • CX_ECSCHNORR_ISO14888_X
  • CX_ECSCHNORR_BSI03111
  • CX_ECSCHNORR_LIBSECP
  • CX_ECSCHNORR_Z
  • CX_ECSCHNORR_BIP0340
[in]hashIDMessage digest algorithm identifier used to compute the input data.
[in]msgSigned input data to verify the signature.
[in]msg_lenLength of the input data.
[in]sigECSchnorr signature to verify encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s
[in]sig_lenLength of the signature.
Returns
1 if signature is verified, 0 otherwise.

Back to the files list


Did you find this page helpful?


How would you improve this page for developers?



Getting Started
Theme Features
Customization

Nano Apps