9 Commits

Author SHA1 Message Date
kaichao
daeecbd679
Persist identity (#67)
* feat: storage for conversations

* fix: db types conversion

* feat: run migrations from sql files

* feat: persist identity

* fix: revert double ratchet storage refactor

* fix: clean

* refactor: use result wrapper for ffi

* refactor: uniform storage error into chat error

* fix: zeroize identity record

* fix: zeroize for secret keys in db operations

* fix: transactional sql migration

* fix: remove destroy_string

* refactor: inline identity record name clone
2026-03-25 08:45:22 +08:00
osmaczko
fa79b1c79c
chore(nim-bindings): replace dynlib dlopen with plain importc (#61)
* chore(nim-bindings): replace dynlib dlopen with plain importc

The dynlib pragma hard-coded a library path and resolved it via dlopen() at
runtime, preventing static linking and forcing a specific load-time path.
Using bare {.importc.} lets consumers choose: link liblibchat dynamically
at link time (--passL:-llibchat) or link it statically into their binary.

* Rust -> Nim ABI  (#62)

* Use correct build hook

* force sret like return from rust code for nim compatibility

* Fix target mismatch

* Update usages

* ci: add nim-bindings-test

* fix(nim-bindings): fix ABI mismatch in destroy_* FFI functions and add defer-based cleanup

Nim's C backend silently transforms large struct parameters (>16 bytes) into
pointer parameters when calling importc functions. The destroy_* functions were
declared taking T by value in Rust, but Nim always passed &T — causing Rust to
read garbage from the stack on x86-64 (SIGILL on CI) while accidentally working
on ARM64 macOS due to that ABI coincidentally also using pointers for large structs.

Fix by changing all destroy_* functions to take &mut T and using drop_in_place,
which is the correct idiom for dropping a value through a pointer.

On the Nim side, replace scattered manual destroy calls with defer, which
guarantees cleanup on all exit paths and prevents use-after-destroy bugs.

---------

Co-authored-by: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com>
2026-02-25 20:09:55 +01:00
Jazz Turner-Baggs
eb941387df
Add Installation name (#58)
* Add Identity name

* Update Context to accept a name

* Change constructor in bindings

* Add name retrieval to bindings

* Update constructor string type

* Remove uneeded files

* rename functions for symmetry
2026-02-19 17:25:42 -08:00
Patryk Osmaczko
cd737ea058 fix: make ci checks pass 2026-02-10 19:45:00 +01:00
Jazz Turner-Baggs
e3e3097947
Safer FFI Migration (#47)
* Use safer_ffi for all functions

* Clean up FFI docs and imports

* Update nim bindings

* Binding Memory Management

* Update tests
2026-02-09 06:37:47 -08:00
Jazz Turner-Baggs
1f0354f8e2
Add FFI functions for send_content and handle_payload (#29)
* Add api calls for handle_payload and send_content

* Add handle_payload and send_content to FFI
2026-01-28 10:50:41 -08:00
Jazz Turner-Baggs
15bb395475
Rust API - conversation creation (#24)
* Adds final changes for rust side API

* Add Safer_ffi impl

* Simplify api

* Add const handle offset
2026-01-28 09:59:07 -08:00
Jazz Turner-Baggs
fe23c39321
PrivateV1 Convo Initialization via Inbox (#13)
* Load orginal protofiles

* Change package name

* Add prost generation

* Remove placeholders

* Add generated files + imports

* replace with chat-proto

* Add XK0

* auto formatting

* Initial implementation of PrivateV1 initialization

* Add ConvoFactory trait

* Hook up indentity placeholder

* Remove RemoteInbox until it’s needed

* Simplify Identity ownership

* Clean up x3handshake

* Move inbox encryption

* Simplify inbox encryption

* Cleanup warnings

* Add todos

* Update chat-proto crate

* Publickey Handling

* Reorg Inbox handshake

* Update Inbox convoId

* Remove file structure headers

* Update ConvoID

* Add Domain Separator trait

* Remove Convo trait functions

* Rename Context

* Add SecretKey

* Add workspace dependency

* update KE name

* Update comments for clarity

* Remove Xk0 references

* Bump chat_proto version and relock
2026-01-21 15:39:09 -08:00
Jazz Turner-Baggs
04d6f8a84b
Add Project scaffolding (#1) 2025-12-22 09:40:46 -08:00