Session ids are, unfortunately, x25519 pubkeys rather than ed25519, and
there isn't a one-to-one conversion from x to ed, so we have to have the
client send along the ed25519 pubkey *along with* the 05-prefixed x25519
pubkey, then we also check that the given ed25519 converts to the x25519
pubkey when checking client signatures.
- Improve serialization versioning constants
- Use constants for version gating when `store` becomes recursive
- Don't do a background message distribution when we are using recursive
stores.
Remove superfluous `this->`. This is C++, not Python/Rust/etc. that
require `self` boilerplate.
Use optional/pair for optional multi-value return rather than mutable
lvalue arguments with a bool return (which wasn't even checked in one
place).
Redesigns the database to be a more appropriate, less duplicative design
using "owners" and "messages" with a foreign key between them.
Rewrites all the database code using SQLiteCpp which substantially
reduces the amount of boilerplate, duplicate code for query handling.
Makes the statement handlers thread_local for better thread safety; this
also allows the actual query to be where it is executed, rather than
having all the prepared queries in one place nowhere close to where they
are actually used.
- Eliminated storage::Item because it just duplicates message_t for no
useful reason.
- Always pass user pubkeys as user_pubkey_t, never as std::strings.
Pubkeys are not strings, and the same pubkey has multiple string
representations.
- Properly split up the pubkey as [type][pubkey] where type = byte (5
for Session) and pubkey is a type-dependent key (currently only
supporting 32-byte Ed25519 keys).
- Allow pubkeys to be loaded from either hex (66) or binary (33) values.
- Allow pubkey prefixes on testnet. A 32-byte key will be interpreted
as if the key was prefixed with a 0. Thus there is now just one
"proper" pubkey size of 33 bytes or 66 bytes, and we silently accept the
missing-prefix for testnet (but can do away with the proper sizes being
different).
- Expose pubkey stringification in different ways (prefixed/unprefixed,
hex/raw).
- Simplify time_point-to-integer conversion with new time.hpp functions
from_epoch_ms and to_epoch_ms.
- Restore old message hash format so that we can keep using it until the
mandatory transition point.
- Added a much more network efficient serialization format, using
standard b-encoding rather than NIH custom encoding. After the
mandatory upgrade we can remove the old format.
- Refactor swarm bootstrap code to be more efficient
This is a nice C++ wrapper that cleans up the data interface
considerably over using the C sqlite3 API.
I also evaluated (and started implementing) sqlite_orm for this, but ran
into considerable obstacles: the orm components get in the way without
being good enough to really solve anything (and essentially just making
you write queries in C++ code that is much less elegant than straight
queries), plus it fundamentally doesn't support threaded operation,
which sucks.
Without this you could submit an expiry request and someone could replay
it later as a delete request (when the expiry timestamp arrives).
With the method include this isn't possible.
- Further documents each endpoint
- Changes the expiry update endpoints to just return the hashes of
messages rather than hashes + timestamps as its quite a bit simpler
(especially for signing).
- implements delete_msgs/delete_before/expire_all/expire_msgs endpoint
processing logic.
It doesn't work as expected: rather it creates an "ed25519ph"
signature, which is a signature over a pre-hashed value, rather than a
regular Ed25519 signature.
Instead this now uses an allocation-minimized conversion/concatenation
of arguments to build the proper Ed25519 signature message.