-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add libsalty and rename some directories
- Loading branch information
Showing
2 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#ifndef salty_h | ||
#define salty_h | ||
|
||
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ | ||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define salty_COMPRESSED_Y_LENGTH 32 | ||
#define salty_PUBLICKEY_SERIALIZED_LENGTH 32 | ||
#define salty_SCALAR_LENGTH 32 | ||
#define salty_SECRETKEY_NONCE_LENGTH 32 | ||
#define salty_SECRETKEY_SCALAR_LENGTH 32 | ||
#define salty_SECRETKEY_SEED_LENGTH 32 | ||
#define salty_SECRETKEY_SERIALIZED_LENGTH 32 | ||
#define salty_SHA256_LENGTH 64 | ||
#define salty_SHA512_LENGTH 64 | ||
#define salty_SIGNATURE_SERIALIZED_LENGTH 64 | ||
|
||
/** | ||
* Extensible error type for all `salty` operations. | ||
* | ||
* This enum has a hidden member, to prevent exhaustively checking for errors. | ||
*/ | ||
typedef enum { | ||
/** | ||
* Never occurs, simplifies C bindings | ||
*/ | ||
NoError = 0, | ||
/** | ||
* Bytes do not correspond to a canonical base field element | ||
*/ | ||
NonCanonicalFieldElement, | ||
/** | ||
* Public key bytes invalid | ||
*/ | ||
PublicKeyBytesInvalid, | ||
/** | ||
* Signature verification failed | ||
*/ | ||
SignatureInvalid, | ||
/** | ||
* Context for prehashed signatures too long | ||
*/ | ||
ContextTooLong, | ||
_Extensible, | ||
} salty_Error; | ||
|
||
/** | ||
* Generates a public key from a secret seed. Use to verify signatures. | ||
*/ | ||
void salty_public_key(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH], | ||
uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH]); | ||
|
||
/** | ||
* Signs the data, based on the keypair generated from the secret seed. | ||
*/ | ||
void salty_sign(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH], | ||
const uint8_t *data_ptr, | ||
uintptr_t data_len, | ||
uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]); | ||
|
||
/** | ||
* Signs the data for a context, based on the keypair generated from the secret seed. | ||
*/ | ||
salty_Error salty_sign_with_context(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH], | ||
const uint8_t *data_ptr, | ||
uintptr_t data_len, | ||
const uint8_t *context_ptr, | ||
uintptr_t context_len, | ||
uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]); | ||
|
||
/** | ||
* Signs the prehashed data, based on the keypair generated from the secret seed. | ||
* An optional context can also be passed (this is recommended). | ||
*/ | ||
salty_Error salty_sign_prehashed(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH], | ||
const uint8_t (*prehashed_data)[salty_SHA512_LENGTH], | ||
const uint8_t *context_ptr, | ||
uintptr_t context_len, | ||
uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]); | ||
|
||
/** | ||
* Verify a presumed signature on the given data. | ||
*/ | ||
salty_Error salty_verify(const uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH], | ||
const uint8_t *data_ptr, | ||
uintptr_t data_len, | ||
const uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]); | ||
|
||
/** | ||
* Verify a presumed signature on the given data for a context. | ||
*/ | ||
salty_Error salty_verify_with_context(const uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH], | ||
const uint8_t *data_ptr, | ||
uintptr_t data_len, | ||
const uint8_t *context_ptr, | ||
uintptr_t context_len, | ||
const uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]); | ||
|
||
/** | ||
* Verify a presumed signature on the given data. | ||
*/ | ||
salty_Error salty_verify_prehashed(const uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH], | ||
const uint8_t (*prehashed_data)[salty_SHA512_LENGTH], | ||
const uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH], | ||
const uint8_t *context_ptr, | ||
uintptr_t context_len); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* salty_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters