Skip to content

refactor(rust): restructure codebase to facilitate server integration - #123

Merged
OffRange merged 9 commits into
v2from
refactor/separate-rust
Nov 4, 2026
Merged

OffRange merged 9 commits into
v2from
refactor/separate-rust

Conversation

@OffRange

@OffRange OffRange commented Nov 4, 2026

Copy link
Copy Markdown
Owner

No description provided.

OffRange and others added 9 commits November 3, 2026 15:13
Wrapping a key only needs its bytes, so `Wraps` now asks for `KeyMaterial`.
`SymmetricKey` keeps what only a key that can seal needs. This makes room
for wrapped keys that cannot wrap anything themselves, like a signing key.

Also rename `RootKEK` to `RootKek`, the spelling the docs already use.

No change to what is stored: the golden tests still pass unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server has to store wrapped keys, but keygo-core also carries app-only
code like TOTP, passkeys and the backup format. Move the key hierarchy, ids,
AADs, KDFs and `Sealed<T>` into a crate both can depend on.

Everything that can touch key material sits behind the `crypto` feature.
Without it `Sealed<VaultKey>` can still be parsed and stored, but a key cannot
be created, which is the view the server gets. The nonce is now plain bytes
so `Sealed` compiles without the cipher, and const assertions keep the
hard-coded lengths in line with it.

`BackupKey`, `BackupAad` and `KeySource` move too, so `symmetric_key!` and the
derive functions can stay private and no other crate can declare a key type.
That makes `BackupKey`'s constructors, `Argon2Params` and `new_salt` public.

keygo-core re-exports the crate as `crypto`, so its callers barely change. The
stored format and the generated Kotlin bindings are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A workspace build unifies features, so keygo-core turns `crypto` on and hides
any dependency that leaks out from behind it. Build the crate on its own and
fail if a cipher or KDF crate shows up in its tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…go-client

The shared crate now holds more than keys, and the old keygo-core was only
ever the app's: TOTP, passkeys, the backup format and the ARK session. The new
names say which crate the server may depend on.

Only names change. The generated Kotlin bindings are identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server will store wrapped keys, so it needs their names and `Sealed<T>`,
but must never be able to create a key.

A workspace build turns `crypto` on for it anyway, so it would hide a server
that uses it. Check the server on its own in CI too, and have the `serve` alias
use `-p`, so it runs what the Docker image ships rather than a build with
`crypto` on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The OPAQUE identifier test used one repeated byte, so it could not see a change
in byte order. Use distinct bytes, and pin the JSON form as well, before
`UserId` moves to the shared crate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both sides hold the same id: it is generated by the client and equals the
local user id. The shared type gains what the server relied on, `Deserialize`,
`From<Uuid>` and `as_uuid`, and `domain` re-exports it so most callers stay as
they are.

`opaque_identifier` is server-only, and a method on a foreign type is not
allowed, so it becomes a function. Its bytes and the JSON form are pinned by
the tests added in the previous commit, whose expected values did not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A workspace run unifies features, so keygo-client's crypto reached every
crate and the builds without it were linted but never tested. Test both
crates alone and leave keygo-server out of the workspace run. make test
runs the same commands.

The dependency checks could pass without checking anything: a failing
cargo tree counted as no match, and renaming the feature hid a leak.
Allow only the expected keygo-core deps, which also catches sha2 and any
new mandatory dep, and confirm the pattern still matches keygo-client.

Drop clippy -p keygo-server, as the new test step and clippy -p
keygo-core catch what it did. Make rust-test wait for rust-lint, as the
comments already said.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@OffRange
OffRange merged commit 469ea65 into v2 Nov 4, 2026
8 checks passed
@OffRange
OffRange deleted the refactor/separate-rust branch November 4, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant