Skip to content
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

Add docstrings for 7 more Rust API modules #287

Closed
wants to merge 2 commits into from

Conversation

cosmicexplorer
Copy link
Contributor

This is the second in a set of planned PRs to add docstrings to the Rust API, see #285.

I took care to make these changes highly orthogonal, and have split each module's changes into its own commit.

Notably, this does not depend on #286!

Copy link
Contributor

@jrose-signal jrose-signal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many comments, apologies for the onslaught. :-)

pub const MAX_RECEIVER_CHAINS: usize = 5;
pub const ARCHIVED_STATES_MAX_LENGTH: usize = 40;
pub const MAX_SENDER_KEY_STATES: usize = 5;
//! Magic numbers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of these types or values need to be made public. That doesn't mean it's not worth documenting them, but I'm more inclined to filter them back into the relevant files that reference them than add more structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I have marked both of crate::consts::{types,limits} as pub(crate) in 2ff52da. Does that address your concern? I think that the tiny little module structure here is useful for documentation of these values. If you're not seeing it, we can totally do away with that as well though!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still tend to prefer keeping types and constants close to their primary use site, but clearly the code isn't doing that today. I'll come back to this.

rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/storage/traits.rs Outdated Show resolved Hide resolved
@@ -62,6 +85,7 @@ pub trait PreKeyStore {
async fn remove_pre_key(&mut self, prekey_id: PreKeyId, ctx: Context) -> Result<()>;
}

/// Interface for storing signed pre-keys downloaded from a server. (TODO: ???)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll come back with an explanation of pre-keys and signed pre-keys later; for now feel free to leave this generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[marking this unresolved so I'm less likely to forget about it]

rust/protocol/src/storage/traits.rs Outdated Show resolved Hide resolved
rust/protocol/src/storage/traits.rs Outdated Show resolved Hide resolved
rust/protocol/src/identity_key.rs Outdated Show resolved Hide resolved
@jrose-signal
Copy link
Contributor

cc @rubdos and @Be-ing, also interested in using libsignal-client as a Rust library directly.

@rubdos
Copy link
Contributor

rubdos commented May 4, 2021

cc @gferon and @boxdot, thanks for the heads up @jrose-signal.

@cosmicexplorer You may be interested in the libraries and work at https://github.com/whisperfish. Feel free to join our Matrix channel to coordinate some other work; we are planning to submit some PRs into here wrt. some crypto code. Cfr also #152.

@jrose-signal would you appreciate a review from me and Gabriel on #286 and this one? I'm not sure whether we can catch any more than you already did, but I'd rather ask whether it'd be appreciated or not.

@jrose-signal
Copy link
Contributor

@jrose-signal would you appreciate a review from me and Gabriel on #286 and this one? I'm not sure whether we can catch any more than you already did, but I'd rather ask whether it'd be appreciated or not.

I think it's reasonable for multiple perspectives, but I don't want to stress out @cosmicexplorer either. @cosmicexplorer, what do you think?

@cosmicexplorer cosmicexplorer force-pushed the docs-2 branch 2 times, most recently from 5dcfd7d to 2ff52da Compare May 4, 2021 19:02
@cosmicexplorer
Copy link
Contributor Author

I'd be wholly unstressed for people to give this a more thorough review!

rust/protocol/src/consts.rs Outdated Show resolved Hide resolved
@Be-ing
Copy link

Be-ing commented May 4, 2021

Thanks for working on this! And yes please join us in the Whisperfish Matrix room at #whisperfish:rubdos.be. I'm not sure what your goal is with using this library, but we're working towards a GUI client written in Rust and QML with the qmetaobject-rs crate. Currently Whisperfish uses Jolla's proprietary QML libraries so it only works on Sailfish OS, but I just got a PinePhone so I'll be working on adapting it to also work with KDE's Kirigami QML libraries without Sailfish OS. At the moment Whisperfish only supports text messages and GroupsV2 but we intend to make it feature complete. I presume you're probably writing a Signal client, in which case you'll probably be interested in the libsignal-service-rs library which now uses this libsignal-client library. @gferon is also working on using libsignal-service-rs for CLI clients and bots with Presage.

@cosmicexplorer cosmicexplorer force-pushed the docs-2 branch 9 times, most recently from 54dbdd7 to eea8618 Compare May 4, 2021 22:12
@cosmicexplorer
Copy link
Contributor Author

cosmicexplorer commented May 4, 2021

@Be-ing I'm working on what should become a CLI tool very analogous to gpg that performs forward-secret encrypted messaging and document signing! I had been working on a Rust wrapper to libsignal-protocol-c a while ago before to my amazement the whole thing was rewritten in Rust! I had been expecting to have to write a lot more stuff myself too so diverted my excitement towards documenting what was already done here instead.

I can see there are already a lot of extensions in the whisperfish org you linked above, so I'm seeing whether any of those solve more problems I thought I had.

@cosmicexplorer cosmicexplorer force-pushed the docs-2 branch 4 times, most recently from e46ceca to f649b9a Compare May 5, 2021 04:54
Copy link
Contributor

@rubdos rubdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already such an improvement! Thanks for taking this on ❤️

I've added 22 comments; most of them are really nit-picky. I figured, if we're doing this, let's do this the best we can already.

rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/crypto.rs Outdated Show resolved Hide resolved
rust/protocol/src/storage/inmem.rs Outdated Show resolved Hide resolved
rust/protocol/src/storage/traits.rs Outdated Show resolved Hide resolved
rust/protocol/src/storage/traits.rs Outdated Show resolved Hide resolved
rust/protocol/src/storage/traits.rs Outdated Show resolved Hide resolved
// SPDX-License-Identifier: AGPL-3.0-only
//

//! Traits defining several stores used throughout the Signal Protocol.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a word about the usage of async-trait, including the fact that it's async_trait(?Send). Maybe some example/dummy implementation would be really great here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly the ?Send part has been a bit weird in practice; probably these should all require Send after all. That means newtype-ing Context but that's also a good idea.

*cough* but that's for another PR. I agree that some mention of async-trait is a good idea if only so people know that they have to use that when implementing the traits.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to look into having the store traits require Send, just to see how far I could go, would you mind if I open an issue so that we can discuss it in more details there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gferon That sounds great, thank you!

@cosmicexplorer cosmicexplorer force-pushed the docs-2 branch 3 times, most recently from eeddf75 to 201a3fb Compare May 8, 2021 16:58
- requires the `unstable_internals` feature to be enabled for doctests to work
- [NON RUST/RENAME] rename "DJB_TYPE" to "CURVE_25519_TYPE" in java and swift
- [1+CRYPTO CRATE] make swift/build-ffi.sh --generate-ffi work
- [1+CURVE] add docs and the Keyed trait to `curve*.rs`
@cosmicexplorer
Copy link
Contributor Author

This is now closed in favor of #475 and the other remaining tasks on the tracking issue #467!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants