|
| 1 | +#include <stdbool.h> |
| 2 | +#include <stdint.h> |
| 3 | + |
| 4 | +#ifndef __curve_secp256k1_H__ |
| 5 | +#define __curve_secp256k1_H__ // Include guard |
| 6 | + |
| 7 | + #ifdef __cplusplus // Required for C++ compiler |
| 8 | +extern "C" { |
| 9 | + #endif |
| 10 | +//Forward Declarations |
| 11 | +struct PublicKey; |
| 12 | +struct SecretKey; |
| 13 | +struct Signature; |
| 14 | +struct PublicKeyCollection; |
| 15 | +struct EncryptedMessage; |
| 16 | + |
| 17 | +// Version |
| 18 | +char * curve_secp256k1_get_version(int *error_code); |
| 19 | + |
| 20 | +// String |
| 21 | +void curve_secp256k1_string_free(char *ptr); |
| 22 | + |
| 23 | +// PrivateKey |
| 24 | +struct SecretKey * curve_secp256k1_private_key_generate(); |
| 25 | +struct SecretKey * curve_secp256k1_private_key_parse(char *input, int *error_code); |
| 26 | +void curve_secp256k1_private_key_tweak_add_assign(struct SecretKey *key, struct SecretKey *tweak, int *error_code); |
| 27 | +void curve_secp256k1_private_key_tweak_mul_assign(struct SecretKey *key, struct SecretKey *tweak, int *error_code); |
| 28 | +void curve_secp256k1_private_key_inv_assign(struct SecretKey *key, int *error_code); |
| 29 | +struct SecretKey * curve_secp256k1_private_key_inv(struct SecretKey *key, int *error_code); |
| 30 | +struct PublicKey * curve_secp256k1_private_key_to_public_key(struct SecretKey *key, int *error_code); |
| 31 | +char * curve_secp256k1_private_key_serialize(struct SecretKey *key, int *error_code); |
| 32 | +void curve_secp256k1_private_key_free(struct SecretKey *key); |
| 33 | + |
| 34 | +// PublicKey |
| 35 | +struct PublicKey * curve_secp256k1_public_key_parse(char *input, int *error_code); |
| 36 | +char * curve_secp256k1_public_key_serialize(struct PublicKey *key, bool compress, int *error_code); |
| 37 | +void curve_secp256k1_public_key_tweak_add_assign(struct PublicKey *key, struct SecretKey *tweak, int *error_code); |
| 38 | +void curve_secp256k1_public_key_tweak_mul_assign(struct PublicKey *key, struct SecretKey *tweak, int *error_code); |
| 39 | +struct PublicKey * curve_secp256k1_public_key_tweak_mul(struct PublicKey *key, struct SecretKey *tweak, int *error_code); |
| 40 | +struct PublicKey * curve_secp256k1_public_key_combine(struct PublicKeyCollection* collection, int *error_code); |
| 41 | +void curve_secp256k1_public_key_free(struct PublicKey *key); |
| 42 | + |
| 43 | +// PublicKeyCollection |
| 44 | +struct PublicKeyCollection * curve_secp256k1_public_key_collection_new(); |
| 45 | +void curve_secp256k1_public_key_collection_add(struct PublicKeyCollection *collection, struct PublicKey *key, int *error_code); |
| 46 | +void curve_secp256k1_public_key_collection_free(struct PublicKeyCollection *collection); |
| 47 | + |
| 48 | +// Signature |
| 49 | +struct Signature * curve_secp256k1_ecdsa_signature_parse(char *input, int *error_code); |
| 50 | +char * curve_secp256k1_ecdsa_signature_serialize(struct Signature *sig, int *error_code); |
| 51 | +void curve_secp256k1_signature_free(struct Signature *signature); |
| 52 | + |
| 53 | +// ECDH |
| 54 | +char *curve_secp256k1_ecdh(struct SecretKey *secret_key, struct PublicKey *public_key, int *error_code); // sha256(pk.mul(sk).compress()) |
| 55 | +char *curve_secp256k1_standard_ecdh(struct SecretKey *secret_key, struct PublicKey *public_key, int *error_code); // Note: This is the standard ecdh which differs from libsecp256k1 |
| 56 | + |
| 57 | +// ECDSA |
| 58 | +struct Signature * curve_secp256k1_ecdsa_sign_recoverable(struct SecretKey *key, char *hash, int *error_code); |
| 59 | +struct PublicKey * curve_secp256k1_ecdsa_recover(struct Signature *signature, char *hash, int *error_code); |
| 60 | + |
| 61 | +// Encryption |
| 62 | +struct EncryptedMessage *curve_secp256k1_encrypted_message_from_components(char *ciphertext, struct PublicKey *ephemeral_public_key, char *iv, char *mac, int* error_code); |
| 63 | +char *curve_secp256k1_encrypted_message_get_ciphertext(struct EncryptedMessage *message, int* error_code); |
| 64 | +struct PublickKey *curve_secp256k1_encrypted_message_get_ephemeral_public_key(struct EncryptedMessage *message, int* error_code); |
| 65 | +char *curve_secp256k1_encrypted_message_get_mac(struct EncryptedMessage *message,int* error_code); |
| 66 | +char *curve_secp256k1_encrypted_message_get_iv(struct EncryptedMessage *message,int* error_code); |
| 67 | +void curve_secp256k1_encrypted_message_free(struct EncryptedMessage *message); |
| 68 | +struct EncryptedMessage *curve_secp256k1_aes_cbc_hmac_encrypt(struct PublicKey *public_key, char *plain_text, int *error_code); |
| 69 | +char *curve_secp256k1_aes_cbc_hmac_decrypt(struct SecretKey* secret_key, struct EncryptedMessage* encrypted, int* error_code ); |
| 70 | + |
| 71 | + #ifdef __cplusplus |
| 72 | +} // extern "C" |
| 73 | + #endif |
| 74 | +#endif // __curve_secp256k1_H__ |
0 commit comments