Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
frtget committed Oct 5, 2023
1 parent 507736f commit 23fb35a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion include/session/config/groups/info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ class Info final : public ConfigBase {
/// API: groups/Info::get_delete_attach_before
///
/// Returns the delete-attachments-before unix timestamp (seconds) for the group; clients should
/// delete all attachments from the closed group with timestamps earlier than this value, if set.
/// delete all attachments from the closed group with timestamps earlier than this value, if
/// set.
///
/// Returns std::nullopt if no delete-attachments-before timestamp is set.
///
Expand Down
3 changes: 2 additions & 1 deletion include/session/config/groups/keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ class Keys final : public ConfigSig {
/// - `group_ed25519_pubkey` is the public key of the group, used to verify message signatures
/// on key updates. Required. Should not include the `03` prefix.
/// - `group_ed25519_secretkey` is the secret key of the group, used to sign config messages and
/// swarm authentication tokens and to encrypt and decrypt encryption keys for regular messages.
/// swarm authentication tokens and to encrypt and decrypt encryption keys for regular
/// messages.
/// This is only possessed by the group admin(s), and must be provided
/// in order to make and push config changes.
/// - `dumped` -- either `std::nullopt` to construct a new, empty object; or binary state data
Expand Down
5 changes: 3 additions & 2 deletions include/session/config/groups/members.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ class Members final : public ConfigBase {
/// To construct a blank members object (i.e. with no pre-existing dumped data to load) pass
/// `std::nullopt` as the third argument.
///
/// Encryption keys must be loaded before the Members object can be modified or parse other Members
/// messages, and are typically loaded by providing the `Members` object to the `Keys` class.
/// Encryption keys must be loaded before the Members object can be modified or parse other
/// Members messages, and are typically loaded by providing the `Members` object to the `Keys`
/// class.
///
/// Inputs:
/// - `ed25519_pubkey` is the public key of this group, used to validate config messages.
Expand Down
19 changes: 10 additions & 9 deletions src/config/groups/keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ ustring Keys::key_supplement(const std::vector<std::string>& sids) const {
// (66 chars), in sorted order.
// - keysdata is the unencrypted inner value that we are encrypting for each supplemental member
// - H2(.) = 32-byte BLAKE2b keyed hash of the sodium group secret key seed (just the 32 byte,
// not the full 64 byte with the pubkey in the second half), key "SessionGroupNonceSeed"
// not the full 64 byte with the pubkey in the second half), key
// "SessionGroupNonceSeed"

std::string supp_keys;
{
Expand All @@ -458,8 +459,7 @@ ustring Keys::key_supplement(const std::vector<std::string>& sids) const {

crypto_generichash_blake2b_state st;

crypto_generichash_blake2b_init(
&st, nonce_hash_key.data(), nonce_hash_key.size(), h1.size());
crypto_generichash_blake2b_init(&st, nonce_hash_key.data(), nonce_hash_key.size(), h1.size());

for (const auto& sid : sids)
crypto_generichash_blake2b_update(&st, to_unsigned(sid.data()), sid.size());
Expand Down Expand Up @@ -525,8 +525,8 @@ ustring Keys::key_supplement(const std::vector<std::string>& sids) const {

d.append("G", keys_.back().generation);

// Finally we sign the message and put the signature as the ~ key (which is 0x7f, and thus comes later than
// any other ascii key).
// Finally we sign the message and put the signature as the ~ key (which is 0x7f, and thus comes
// later than any other ascii key).
auto to_sign = to_unsigned_sv(d.view());
// The view contains the trailing "e", but we don't sign it (we are going to append the
// signature there instead):
Expand Down Expand Up @@ -693,7 +693,8 @@ Keys::swarm_auth Keys::swarm_subaccount_sign(
// token is now set: flags || kT
ustring_view kT{to_unsigned(token.data() + 4), 32};

// sub_sig is just the admin's signature, sitting at the end of sign_val (after p || f || 0 || 0 || k):
// sub_sig is just the admin's signature, sitting at the end of sign_val (after p || f || 0 || 0
// || k):
sub_sig = from_unsigned_sv(sign_val.substr(36));

// Our signing private scalar is kt, where t = ±s according to whether we had to negate S to
Expand Down Expand Up @@ -1158,9 +1159,9 @@ void Keys::remove_expired() {
active_msgs_.erase(
active_msgs_.begin(), active_msgs_.lower_bound(keys_.front().generation));
else
// Keys is empty, which means we aren't keeping *any* keys around (or they are all invalid or
// something) and so it isn't really up to us to keep them alive, since that's a history of
// the group we apparently don't have access to.
// Keys is empty, which means we aren't keeping *any* keys around (or they are all invalid
// or something) and so it isn't really up to us to keep them alive, since that's a history
// of the group we apparently don't have access to.
active_msgs_.clear();
}

Expand Down
4 changes: 2 additions & 2 deletions src/xed25519.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ bytes<64> sign(ustring_view curve25519_privkey, ustring_view msg) {
crypto_core_ed25519_scalar_negate(neg_a.data(), a.data());
constant_time_conditional_assign(a, neg_a, negative);

// We now have our a, A private/public keypair. (Note that a is just the private key scalar, *not* the
// ed25519 secret key).
// We now have our a, A private/public keypair. (Note that a is just the private key scalar,
// *not* the ed25519 secret key).

bytes<32> r = xed25519_compute_r(a, msg);
bytes<64> signature; // R || S
Expand Down

0 comments on commit 23fb35a

Please sign in to comment.