Class GroupSendEndorsement
-
- All Implemented Interfaces:
public final class GroupSendEndorsement extends ByteArray
An endorsement for a user or set of users in a group.
GroupSendEndorsements provide a form of authorization by demonstrating that the holder of the endorsement is in a group with a particular user or set of users. They can be combined and removed in a set-like fashion.
The endorsement "flow" starts with receiving a GroupSendEndorsementsResponse from the group server, which contains endorsements for all members in a group (including the local user). The response object provides the single expiration for all the endorsements. From there, the
receivemethod produces a GroupSendEndorsementsResponse.ReceivedEndorsements, which exposes the individual endorsements as well as a combined endorsement for everyone but the local user. Clients should save these endorsements and the expiration with the group state.When it comes time to send a message to an individual user, clients should check to see if they have a GroupSendEndorsement.Token for that user, and generate and cache one using toToken if not. The token should then be converted to a full token using toFullToken, providing the expiration saved previously. Finally, the serialized full token can be used as authorization in a request to the chat server.
Similarly, when it comes time to send a message to the group, clients should start by removing the endorsements of any users they are excluding (say, because they need a Sender Key Distribution Message first), and then converting the resulting endorsement to a token. From there, the token can be converted to a full token and serialized as for an individual send. (Saving the repeated work of converting to a token is left to the clients here; worst case, it's still cheaper than a usual zkgroup presentation.)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classGroupSendEndorsement.TokenA minimal cacheable representation of an endorsement.
This contains the minimal information needed to represent this specific endorsement; it must be converted to a GroupSendFullToken before sending to the chat server. (It is valid to do this immediately; it just uses up extra space.)
Generated by toToken.
-
Field Summary
Fields Modifier and Type Field Description public final static ByteArray.UncheckedAndUnclonedUNCHECKED_AND_UNCLONED
-
Constructor Summary
Constructors Constructor Description GroupSendEndorsement(Array<byte> contents)
-
Method Summary
Modifier and Type Method Description static GroupSendEndorsementcombine(Collection<GroupSendEndorsement> endorsements)Combines several endorsements into one. GroupSendEndorsementbyRemoving(GroupSendEndorsement toRemove)Removes an endorsement (individual or combined) from this combined endorsement. GroupSendEndorsement.TokentoToken(GroupSecretParams groupParams)Generates a cacheable token used to authenticate sends. GroupSendFullTokentoFullToken(GroupSecretParams groupParams, Instant expiration)Generates a token used to authenticate sends, ready to put in an auth header. -
-
Constructor Detail
-
GroupSendEndorsement
GroupSendEndorsement(Array<byte> contents)
-
-
Method Detail
-
combine
static GroupSendEndorsement combine(Collection<GroupSendEndorsement> endorsements)
Combines several endorsements into one.
For example, if you have endorsements to send to Meredith and Aruna individually, then you can combine them to produce an endorsement to send a multi-recipient message to the two of them.
-
byRemoving
GroupSendEndorsement byRemoving(GroupSendEndorsement toRemove)
Removes an endorsement (individual or combined) from this combined endorsement.
If
thisis not a combined endorsement, ortoRemoveincludes endorsements that were not combined intothis, the result will not generate valid tokens.
-
toToken
GroupSendEndorsement.Token toToken(GroupSecretParams groupParams)
Generates a cacheable token used to authenticate sends.
The token is no longer associated with the group; it merely identifies the user or set of users referenced by this endorsement. (Of course, a set of users is a pretty good stand-in for a group.)
-
toFullToken
GroupSendFullToken toFullToken(GroupSecretParams groupParams, Instant expiration)
Generates a token used to authenticate sends, ready to put in an auth header.
expirationmust be the same expiration that was in the original , or the resulting token will fail to verify.Equivalent to toToken followed by toFullToken.
-
-
-
-