#include "../nostr_core/nostr_platform.h" #include #include int nostr_platform_random(unsigned char *buf, size_t len) { if (buf == NULL || len == 0) { return -1; } int fd = open("/dev/urandom", O_RDONLY); if (fd < 0) { return -1; } size_t total = 0; while (total < len) { ssize_t n = read(fd, buf + total, len - total); if (n <= 0) { close(fd); return -1; } total += (size_t)n; } close(fd); return 0; }