libbtc
bitcoinclibrary
ecc.h
Go to the documentation of this file.
1 /*
2 
3  The MIT License (MIT)
4 
5  Copyright (c) 2015 Jonas Schnelli
6 
7  Permission is hereby granted, free of charge, to any person obtaining
8  a copy of this software and associated documentation files (the "Software"),
9  to deal in the Software without restriction, including without limitation
10  the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  and/or sell copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following conditions:
13 
14  The above copyright notice and this permission notice shall be included
15  in all copies or substantial portions of the Software.
16 
17  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  OTHER DEALINGS IN THE SOFTWARE.
24 
25 */
26 
27 #ifndef __LIBBTC_ECC_H__
28 #define __LIBBTC_ECC_H__
29 
30 #include "btc.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdint.h>
37 
39 LIBBTC_API void ecc_start(void);
40 
42 LIBBTC_API void ecc_stop(void);
43 
45 LIBBTC_API void ecc_get_pubkey(const uint8_t* private_key, uint8_t* public_key, size_t* public_key_len, btc_bool compressed);
46 
48 LIBBTC_API btc_bool ecc_private_key_tweak_add(uint8_t* private_key, const uint8_t* tweak);
49 
51 LIBBTC_API btc_bool ecc_public_key_tweak_add(uint8_t* public_key_inout, const uint8_t* tweak);
52 
54 LIBBTC_API btc_bool ecc_verify_privatekey(const uint8_t* private_key);
55 
57 LIBBTC_API btc_bool ecc_verify_pubkey(const uint8_t* public_key, btc_bool compressed);
58 
59 LIBBTC_API btc_bool ecc_sign(const uint8_t* private_key, const uint8_t* hash, unsigned char* sigder, size_t* outlen);
60 LIBBTC_API btc_bool ecc_verify_sig(const uint8_t* public_key, btc_bool compressed, const uint8_t* hash, unsigned char* sigder, size_t siglen);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif //__LIBBTC_ECC_H__
uint8_t btc_bool
Definition: btc.h:34
LIBBTC_API void ecc_get_pubkey(const uint8_t *private_key, uint8_t *public_key, size_t *public_key_len, btc_bool compressed)
get public key from given private key
#define LIBBTC_API
Definition: btc.h:59
LIBBTC_API btc_bool ecc_verify_pubkey(const uint8_t *public_key, btc_bool compressed)
verifies a given public key (compressed[33] or uncompressed[65] bytes)
LIBBTC_API btc_bool ecc_private_key_tweak_add(uint8_t *private_key, const uint8_t *tweak)
ec mul tweak on given private key
LIBBTC_API btc_bool ecc_verify_sig(const uint8_t *public_key, btc_bool compressed, const uint8_t *hash, unsigned char *sigder, size_t siglen)
LIBBTC_API void ecc_start(void)
init static ecc context
LIBBTC_API btc_bool ecc_public_key_tweak_add(uint8_t *public_key_inout, const uint8_t *tweak)
ec mul tweak on given public key
LIBBTC_API btc_bool ecc_verify_privatekey(const uint8_t *private_key)
verifies a given 32byte key
LIBBTC_API void ecc_stop(void)
destroys the static ecc context
LIBBTC_API btc_bool ecc_sign(const uint8_t *private_key, const uint8_t *hash, unsigned char *sigder, size_t *outlen)