-
Notifications
You must be signed in to change notification settings - Fork 224
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
Canonicalize message on receive #431
Comments
The usual thing is to use the capnproto-rust/capnp/src/message.rs Lines 286 to 297 in c702d16
But that only works if your data-to-canonicalize is the root struct of a You need to do something like this: let size = txn.total_size()?.word_count;
let mut message = capnp::message::Builder::new(capnp::message::HeapAllocator::new().first_segment_words(size as u32));
message.set_root_canonical(root)?;
let output_segments = message.get_segments_for_output();
assert_eq!(1, output_segments.len());
let output = output_segments[0];
assert!((output.len() / BYTES_PER_WORD) as u64 <= size);
let mut result = crate::Word::allocate_zeroed_vec(output.len() / BYTES_PER_WORD);
crate::Word::words_to_bytes_mut(&mut result[..]).copy_from_slice(output); Probably we should add a function to the |
Thanks for the quick reply! In my case, |
What if you do let size = txn.total_size()?.word_count + 1; instead? I thought that maybe the |
That works! Thank you 🍻 Happy to try a PR for a built-in method if you want. |
Up to you. I don't intend to implement it myself in the near future. |
We have a client written in Go that is sending a struct and a signature to a server that uses
capnproto-rust
:In order to create the signature, we're doing something like this in Go:
Now, on the Rust side we need to verify the signature. My thought was that we'd need to canonicalize
Tx
to get the signature payload. I see canonicalize test (https://github.com/capnproto/capnproto-rust/blob/master/capnp/tests/canonicalize.rs), but having a hard time understanding how I can do that in the server'spush
implementation. eg,Thank you!
The text was updated successfully, but these errors were encountered: