added keys.h, sleep_crypto.h; worked sleep.h, sleep_tree.c, sleep_crypto.c

This commit is contained in:
2025-10-04 13:28:24 -04:00
parent e51f5c7bc8
commit 23c037e02e
12 changed files with 126 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
#ifndef KEYS_H
#define KEYS_H
#include <stdint.h>
#define SLEEP_PUB_KEY_BYTES 32
#define SLEEP_SECRET_KEY_BYTES 64
#define SLEEP_SIGNATURE_BYES 64
#define SLEEP_BLAKE2B_BYES 32
typedef struct {
uint8_t pubkey[SLEEP_PUB_KEY_BYTES];
uint8_t seckey[SLEEP_SECRET_KEY_BYES];
} sleep_keypair_t;
#endif /* KEYS_H */

View File

@@ -1,3 +1,4 @@
// ॐ सूक्ष्म शरीर
#ifndef SLEEP_H
#define SLEEP_H
// TODO implement SLEEP

22
inc/sleep_crypto.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef SLEEP_CRYPTO_H
#define SLEEP_CRYPTO_H
#include <stddef.h>
#include <stdint.h>
#include "keys.h"
//#include "sleep.h"
int sleep_gen_keypair(sleep_keypair_t *kp);
int sleep_save_pubkey(const char *path, const uint8_t pubkey[SLEEP_PUBLIC_KEY_BYTES]);
int sleep_load_pubkey(const char *path, uint8_t pubkey[SLEEP_PUBLIC_KEY_BYTES]);
int sleep_blake2b(uint8_t out[SLEEP_BLAKE2B_BYTES], const uint8_t *in, size_t inlen);
int sleep_sign(uint8_t sig[SLEEP_BLAKE2B_BYTES], const uint8_t *msg, size_t msglen, const sleep_keypair_t *kp);
int sleep_verify(const uint8_t sig[SLEEP_SIGNATURE_BYTES], const uint8_t *msg, size_t msglen, const uint8_t pubkey[SLEEP_PUBLIC_KEY_BYTES]);
int sleep_sign_roots(uint8_t sig[SLEEP_SIGNATURE_BYTES], const uint8_t *roots, size_t nroots, const uint64_t *indices, const uint64_t *lengths, const sleep_keypair_t *kp);
int sleep_verify_roots(const uint8_t sig[SLEEP_SIGNATURE_BYTES], const uint8_t *roots, size_t nroots, const uint64_t *indices, const uint64_t *lengths, const uint8_t pub[SLEEP_PUBLIC_KEY_BYTES]);
#endif /* SLEEP_CRYPTO_H */