-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize state_out and state_in #333
Comments
Yes, that should totally be doable. The state is just the address of a 52 byte array, that can be safely moved to different hosts. |
@jedisct1 thanks, where that change should happen? in the parent libsodium library? |
No, just in the JavaScript code. I think it can be done even without changing |
First, I simply printed the the state_in and and state_out value. They seems to be numbers, which is not exactly what the @types/libsodium-wrappers is expecting. What's weird too is that even if I rebuild the project and run multiple times i always get the same numbers.
So I tried to read through the wrapper code to understand what's going on. I took a look at where the var h = new u(52).address;
if (0 == (0 | a._crypto_secretstream_xchacha20poly1305_init_pull(h, n, c))) {
var p = h;
return g(_),
p
}
b(_, "invalid usage") In this code:
and then where var s = new u(52).address,
c = new u(0 | a._crypto_secretstream_xchacha20poly1305_headerbytes()),
o = c.address;
if (t.push(o), 0 == (0 | a._crypto_secretstream_xchacha20poly1305_init_push(s, o, _))) {
var h = {
state: s,
header: y(c, r)
};
return g(t),
h
}
b(t, "invalid usage") In this code:
Now taking a look at the
Sounds like it's a binding to a malloc (probably to the C code?). What I get from this point is that the state and the header are constructed the same way with the The call to
So the
In the end the issue relies on the fact that for the state we return only the address Two options:
What do you think? |
Hello,
I'm wondering if there is a way to serialize the
state_in
and thestate_out
fromcrypto_secretstream_xchacha20poly1305_init_push
andcrypto_secretstream_xchacha20poly1305_init_pull
in order to store them in a persistent memory.My first use case is a client / server exchanges where the server is stateless and cannot keep in RAM the states.
My second use case is a client / server exchanges where the server is a set of multiple machines behind a load balancer where the client has no guarantee to hit the same machine in a row.
Thanks!
The text was updated successfully, but these errors were encountered: