/
ecc_secp256k1.h
57 lines (54 loc) · 2.31 KB
/
ecc_secp256k1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Sign an ECDSA Signature
* The message should be a hashed 32 bytes.
* Input: msg -> pointer to 32 bytes message.
* privkey -> pointer to 32 bytes private key.
* Output: sig_out -> pointer to a 64 bytes buffer.
* Returns:
* 1 - Finished successfully.
* 0 - Failed.
*/
int ecc_secp256k1_ecdsa_sign(unsigned char *sig_out, const unsigned char *msg, const unsigned char *privkey);
/**
* Verify a ECDSA Signature
* Accepts either compressed(33 btes) or uncompressed(65 bytes) public key. using the flag (1==compressed, 0==uncompressed).
* Input: sig -> pointer to 64 bytes signature.
* msg -> 32 bytes result of a hash. (***Make Sure you hash the message yourself! otherwise it's easily broken***)
* pubkey -> pointer to 33 or 65 bytes pubkey depending on the compressed flag.
* compressed -> 1 for compressed, 0 for uncompressed.
* Returns:
* 1 - The signature is valid.
* 0 - Signature is not valid.
* -1 - Some other problem.
*/
int ecc_secp256k1_ecdsa_verify(const unsigned char *sig,
const unsigned char *msg,
const unsigned char *pubkey,
int compressed);
/**
* Sign a Schnorr Signature
* The message should be a hashed 32 bytes.
* Input: msg -> pointer to 32 bytes message.
* privkey -> pointer to 32 bytes private key.
* Output: sig_out -> pointer to a 64 bytes buffer.
* Returns:
* 1 - Finished successfully.
* 0 - Failed.
*/
int ecc_secp256k1_schnorr_sign(unsigned char *sig_out, const unsigned char *msg, const unsigned char *privkey);
/**
* Verify a Schnorr Signature
* Accepts either compressed(33 btes) or uncompressed(65 bytes) public key. using the flag (1==compressed, 0==uncompressed).
* Input: sig -> pointer to 64 bytes signature.
* msg -> 32 bytes result of a hash. (***Make Sure you hash the message yourself! otherwise it's easily broken***)
* pubkey -> pointer to 33 or 65 bytes pubkey depending on the compressed flag.
* compressed -> 1 for compressed, 0 for uncompressed.
* Returns:
* 1 - The signature is valid.
* 0 - Signature is not valid.
* -1 - Some other problem.
*/
int ecc_secp256k1_schnorr_verify(const unsigned char *sig,
const unsigned char *msg,
const unsigned char *pubkey,
int compressed);