Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bee6049
added github workflow for makefile for all the branches
Gustbel Mar 25, 2026
d1451e9
added benchmarks example
Gustbel Mar 25, 2026
943ec9c
improved benchmark example
Gustbel Mar 25, 2026
d56cb49
added new signature function in monocypher lib
Gustbel Mar 25, 2026
04b66c0
implementing new monocypher signature function in microsui sign function
Gustbel Mar 25, 2026
8ff9370
added new check function in monocypher lib
Gustbel Mar 25, 2026
49b4e3a
implementing new monocypher check function in microsui verify function
Gustbel Mar 25, 2026
3d82df7
deleted compact25519 library include in sign function
Gustbel Mar 25, 2026
d126642
deleted now obsolete compact25519 library
Gustbel Mar 25, 2026
fbc6cee
deleted compact25519 references in makefiles and builders
Gustbel Mar 25, 2026
e087560
deleted compact25519 references in Readme
Gustbel Mar 25, 2026
13132e1
improved log in global Make
Gustbel Mar 26, 2026
aa913af
added signature verification functions with public key validation
Gustbel Mar 26, 2026
77e4e54
Merge pull request #18 from MicroSui/feat/adding-signature-improv-fun…
Gustbel Mar 27, 2026
6b5bfd8
renamed key_managment functions
Gustbel Mar 27, 2026
991b74c
refactor: update public key derivation methods in Keypair.c
Gustbel Mar 27, 2026
53f4821
refactor: rename private key functions
Gustbel Mar 27, 2026
82f5ce4
refactor: rename private key decoding and encoding functions
Gustbel Mar 27, 2026
9c71609
changing all private key terminologies to seed in cryptography file
Gustbel Mar 27, 2026
e48baa3
changing all private key terminologies to seed in key_managment file
Gustbel Mar 27, 2026
43e3c96
changing all private key terminologies to seed in sign file
Gustbel Mar 27, 2026
4226384
changing all private key terminologies to seed in sdk Keypair file
Gustbel Mar 27, 2026
8e01ac8
changing all private key terminologies to seed in examples
Gustbel Mar 27, 2026
a9c4215
changing all private key terminologies to seed in examples 2
Gustbel Mar 27, 2026
0fb16a1
Merge pull request #19 from MicroSui/refactor/changing-private-key-te…
Gustbel Mar 27, 2026
dca4177
clear sensitive data from memory in cryptography and key_management f…
Gustbel Mar 27, 2026
ed53ff4
added bechmark example and improved arduino examples
Gustbel Mar 31, 2026
84f9b29
improve bechmark code avoiding warnings
Gustbel Mar 31, 2026
88134de
refactor: rename output parameters for consistency in core functions
Gustbel Apr 1, 2026
953e566
update library files to new version
Gustbel Apr 1, 2026
c67f3f8
update changelog for new version 0.3.3
Gustbel Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build and Test

on:
push:
branches: ["**"]
pull_request:
branches: ["**"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev

- name: Run make
run: make

- name: Confirm success
run: echo "Makefile executed successfully"
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## \[0.3.3] - 2026-04-01

- Added new mod functions to Monocypher library (these functions are more efficient than the compact25519 ones).
- Implemented new functions in `microsui_sign.c`, replacing the compact25519 ones.
- Deleted the now-obsolete _compact25519 library_.
- Refactor: rename output parameters for consistency in core functions.
- Refactor: `private/secret key` in bytes now is renamed to `seed` for avoid imprecisions.
- Added new Signature verification/check with public key function.
- Added new examples (Signature and Benchmark).
- Updated Makefiles.
- Added GitHub `make` workflow.
- General improvements and minor bugs fixed.

## \[0.3.2] - 2026-01-27

This release introduces ***Signature Verification*** support and improves developer experience with clearer examples.
This release introduces **_Signature Verification_** support and improves developer experience with clearer examples.

### Added

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ all:
fi \
done
@echo ""
@echo "✅ All examples built successfully!"
@echo "---------------------------------------"
@for dir in $(EXAMPLE_DIRS); do \
if [ -f $$dir/Makefile ]; then \
Expand All @@ -23,4 +22,7 @@ all:
fi \
fi \
done
@echo ""
@echo "✅ All examples built successfully!"
@echo "---------------------------------------"

20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="assets/microsui-with-sui.png" align="right" height="190" />

*MicroSui Library* is a lightweight C library designed primarily for embedded systems to interact with the ***Sui Network Blockchain***.
_MicroSui Library_ is a lightweight C library designed primarily for embedded systems to interact with the **_Sui Network Blockchain_**.

Full compatibility with _ESP32 microcontrollers_ and _traditional desktop OS_. More device support coming soon.

Expand All @@ -11,6 +11,10 @@ This library is **_Arduino and PlatformIO Compatible_**
[![microsui-lib on Arduino Registry](https://www.ardu-badge.com/badge/MicroSui.svg)](https://www.ardu-badge.com/MicroSui/ide)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/gustavogb/library/microsui-lib.svg)](https://registry.platformio.org/libraries/gustavogb/microsui-lib)

### Documentation API Reference Page:

[![Docs](https://img.shields.io/badge/docs-docs.microsui.com-blue?logo=bookstack&logoColor=white)](https://docs.microsui.com)

## The Library:

### Build all the examples:
Expand All @@ -22,7 +26,7 @@ In Windows, macOS or Linux it will be necessary to install `cURL`:
##### In Linux:

```
sudo apt install -y libcurl4-openssl-dev pkg-config build-essential
sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
```

##### In macOS:
Expand All @@ -45,7 +49,11 @@ In root, run
make
```

You will find the `.out` binaries to run in each example folder.
You will find the `.out` binaries to run in each example folder. Run every example with

```bash
./example.out
```

## Project Directory Structure:

Expand All @@ -58,8 +66,6 @@ microsui-lib/
│ ├── microsui_core
│ │ ├── lib/ # Third-party dependencies
│ │ │ ├── monocypher/
│ │ │ ├── compact25519/
│ │ │ │ └── c25519/
│ │ │ └── jsmn/
│ │ ├── impl/ # Platform/board specific implementation
│ │ │ ├── http/
Expand Down Expand Up @@ -89,9 +95,7 @@ microsui-lib/
### 📦 Dependencies (`/lib`)

- `monocypher`:
Lightweight cryptographic primitives.
- `compact25519`:
Ed25519 key format support.
Lightweight Ed25519 cryptographic primitives.
- `jsmn`:
Lightweight minimalistic JSON parser for C.

Expand Down
3 changes: 2 additions & 1 deletion examples/ArduinoExamples/OfflineSign/OfflineSign.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Arduino.h>
#include <MicroSui.h>

// --- PRIVATE KEY (EXAMPLE / DO NOT USE IN PRODUCTION) ---
Expand All @@ -15,7 +16,7 @@ void setup() {
delay(500);

Serial.println();
Serial.println(F("=== MicroSui ESP32 — Offline Sign Transaction Message - Obtain Sui Signature with PK ==="));
Serial.println(F("=== MicroSui Arduino — Offline Sign Transaction Message - Obtain Sui Signature with PK ==="));

// 1) Load keypair from Bech32 secret key
Serial.println(F("\n [1/2] Loading keypair from Bech32..."));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Arduino.h>
#include <MicroSui.h>

// --- WiFi credentials (example) ---
Expand All @@ -22,7 +23,8 @@ void setup() {
delay(500);

Serial.println();
Serial.println(F("=== MicroSui ESP32 — Sign & Execute Transaction ==="));
Serial.println(F("=== MicroSui Arduino — Sign & Execute Transaction ==="));
Serial.println(F("=== Note: This example is guaranteed to work on ESP32 family, but may not work on other boards for the moment ==="));

// 1) Connect WiFi
Serial.println(F("\n [1/5] Connecting WiFi..."));
Expand Down
65 changes: 65 additions & 0 deletions examples/ArduinoExamples/SignatureBechmark/SignatureBechmark.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <Arduino.h>
#include <MicroSui.h>

// Sample Sui message and private key for testing
const uint8_t private_key[32] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const char *message_hex = "00000200080065cd1d0000000000202e3d52393c9035afd1ef38abd7fce2dad71f0e276b522fb274f4e14d1df974720202000101000001010300000000010100d79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379d0180dc491e55e7caabfcdd1b0f538928d8d54107b9c1def3ed0baa3aa5106ba8674f0dd01400000000204b7e9da00f30cd1edf4d40710213c15a862e1fc175f2edb2b2c870c8559d65cdd79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379de80300000000000040ab3c000000000000";

size_t message_len;
uint8_t message[512];
uint8_t sui_sig[97];

void setup()
{
Serial.begin(115200);

message_len = strlen(message_hex) / 2; // 2 hex chars = 1 byte
hex_to_bytes(message_hex, message, message_len);
}

void loop()
{
Serial.println(F("=== MicroSui Arduino — Bechmark Signature and Verification ==="));
// Creating Signature
Serial.println(F("\n\n Generating Signature...\n"));

unsigned long start_time = millis();
microsui_sign_ed25519(sui_sig, message, message_len, private_key);
unsigned long end_time = millis();
// Calculate the time taken for signing
unsigned long time_taken_signature = end_time - start_time;

Serial.println(F("\t Signature created successfully\n"));

// Validating Signature
Serial.println(F(" Verifying Signature...\n"));
start_time = millis();
int verification_result = microsui_verify_signature(sui_sig, message, message_len);
end_time = millis();
// Calculate the time taken for verification
unsigned long time_taken_verification = end_time - start_time;

if(verification_result == 0) {
Serial.println(F("\t Signature verified successfully\n\n"));
} else {
Serial.println(F("\t Signature verification failed\n"));
Serial.print(F("\t Error code: "));
Serial.println(verification_result);
}

Serial.print(F(" Time taken for signing: "));
Serial.print(time_taken_signature);
Serial.println(F(" ms"));

Serial.print(F(" Time taken for verification: "));
Serial.print(time_taken_verification);
Serial.println(F(" ms\n"));

Serial.println(F(" Done."));

delay(1000);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Arduino.h>
#include <MicroSui.h>

// --- PRIVATE KEY (EXAMPLE / DO NOT USE IN PRODUCTION) ---
Expand All @@ -15,7 +16,7 @@ void setup()
delay(500);

Serial.println();
Serial.println(F("=== MicroSui ESP32 — Validation of a Sui Signature ==="));
Serial.println(F("=== MicroSui Arduino — Validation of a Sui Signature ==="));

// 1) Generating Keypair, and Transactions Objects
Serial.println(F("\n [1/4] Generating Keypair, and Transactions Objects..."));
Expand Down Expand Up @@ -47,7 +48,7 @@ void setup()
// 4) Validating Message2 with the signature (Must be FAILED)
Serial.println(F("\n [4/4] Validating Message2 with the signature (Must be FAILED)..."));
int verification_result_2 = microsui_verify_signature(sig.bytes, tx2.tx_bytes.data, tx2.tx_bytes.length);
if (verification_result_2 == 0)
if (verification_result_2 != 0)
Serial.println(F("\t - Signature Verification is FAILED for Message 2 -- OK\n\n"));

Serial.println(F(" Done."));
Expand Down
47 changes: 47 additions & 0 deletions examples/core_examples/benchmarks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ROOT_DIR := ../../..
SRC := $(ROOT_DIR)/src
INCLUDE := $(ROOT_DIR)/include
MICROSUI_CORE := $(ROOT_DIR)/src/microsui_core
UTILS := $(MICROSUI_CORE)/utils
LIB := $(MICROSUI_CORE)/lib

MONOCYPHER := $(LIB)/monocypher
JSMN := $(LIB)/jsmn

HTTP_CURL_FILE = $(MICROSUI_CORE)/impl/http/http_curl.c # This Makefile needs cURL installed in the system
HTTP_UNSUPPORTED_FILE = $(MICROSUI_CORE)/impl/http/http_unsupported.c # This file is used when make is made on a system without cURL support
HTTP_LIBS = -lcurl $(if $(filter Windows_NT,$(OS)),-lws2_32 -lbcrypt -lwldap32 -lcrypt32)

WIFI_DESKTOP_FILE = $(MICROSUI_CORE)/impl/wifi/wifi_desktop.c
WIFI_UNSUPPORTED_FILE = $(MICROSUI_CORE)/impl/wifi/wifi_unsupported.c # This file is used when make is made on a system without WiFi support

CFLAGS := -Wall -Wextra -I$(INCLUDE) -I$(SRC) -I$(MICROSUI_CORE) -I$(UTILS) -I$(LIB) -I$(MONOCYPHER) -I$(JSMN)

SOURCES := benchmarks.c \
$(wildcard $(SRC)/*.c) \
$(wildcard $(MICROSUI_CORE)/*.c) \
$(wildcard $(UTILS)/*.c) \
$(wildcard $(JSMN)/*.c) \
$(wildcard $(MONOCYPHER)/*.c) \
$(HTTP_CURL_FILE) \
$(HTTP_UNSUPPORTED_FILE) \
$(WIFI_DESKTOP_FILE) \
$(WIFI_UNSUPPORTED_FILE)

OUTPUT := benchmarks.out

all: clean_before_build $(OUTPUT)

$(OUTPUT): $(SOURCES)
@echo "Compiling example: $@"
gcc $(CFLAGS) $^ -o $@ $(HTTP_LIBS)

.PHONY: clean clean_before_build

clean_before_build:
@echo "Cleaning old binary if it exists..."
@rm -f $(OUTPUT)

clean:
@echo "Removing binary..."
@rm -f $(OUTPUT)
95 changes: 95 additions & 0 deletions examples/core_examples/benchmarks/benchmarks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>

#include "MicroSui.h"

// Sui Message in hex format (this message must be signed)
const char* message_hex = "00000200080065cd1d0000000000202e3d52393c9035afd1ef38abd7fce2dad71f0e276b522fb274f4e14d1df974720202000101000001010300000000010100d79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379d0180dc491e55e7caabfcdd1b0f538928d8d54107b9c1def3ed0baa3aa5106ba8674f0dd01400000000204b7e9da00f30cd1edf4d40710213c15a862e1fc175f2edb2b2c870c8559d65cdd79a4c7a655aa80cf92069bbac9666705f1d7181ff9c2d59efbc7e6ec4c3379de80300000000000040ab3c000000000000";

// You must place your seed private key (in bytes format) here.
const uint8_t private_key_seed[32] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

uint64_t millis(void);

int main() {
printf("\n\t\t\t --- MicroSui Operations Benchmarks ---\n");
printf("\n\tOriginal Message: %s", message_hex);

// Converting the message from hex to bytes
size_t message_len = strlen(message_hex) / 2; // 2 hex chars = 1 byte
uint8_t message[message_len];
hex_to_bytes(message_hex, message, message_len);

// Generating the Sui Signature from the message and private key
uint8_t sui_sig[97];
printf("\n\n\n Generating Signature...\n");

uint64_t start_time = millis();
microsui_sign_ed25519(sui_sig, message, message_len, private_key_seed);
uint64_t end_time = millis();
printf("\t Signature created successfully\n");

// Calculate the time taken for verification
uint64_t time_taken_signature = end_time - start_time;

// Verifying the Sui Signature
start_time = millis();
int verification_result = microsui_verify_signature(sui_sig, message, message_len);
end_time = millis();

// Calculate the time taken for verification
uint64_t time_taken_verification = end_time - start_time;
if(verification_result == 0) {
printf("\t Signature verified successfully\n\n");
} else {
printf("\t Signature verification failed\n");
printf("\t Error code: %d\n\n", verification_result);
}


printf("\t Benchmarks Results:\n");
printf("\t\t Time taken for signing: ");
if (time_taken_signature > 100000) {
printf("%llu ms\n", (unsigned long long)(time_taken_signature / 1000));
} else {
printf("%.2f ms (%llu us) \n", (double)time_taken_signature / 1000.0, (unsigned long long)time_taken_signature);
}

printf("\t\t Time taken for verification: ");
if (time_taken_verification > 100000) {
printf("%llu ms\n", (unsigned long long)(time_taken_verification / 1000));
} else {
printf("%.2f ms (%llu us) \n", (double)time_taken_verification / 1000.0, (unsigned long long)time_taken_verification);
}
printf("\n End of benchmarks.\n");

return 0;
}

uint64_t millis(void)
{
#if defined(_WIN32) || defined(_WIN64)
// Windows: QueryPerformanceCounter (high-resolution timer)
static LARGE_INTEGER freq = {0};
LARGE_INTEGER now;

if (freq.QuadPart == 0)
QueryPerformanceFrequency(&freq);

QueryPerformanceCounter(&now);
return (uint64_t)((now.QuadPart * 1000000) / freq.QuadPart);

#else
// Linux y macOS: clock_gettime(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)(ts.tv_sec) + (ts.tv_nsec / 1000ULL);
#endif
}
Loading
Loading