Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

[OR-219] Enable send API to accept privacy group Id #235

Merged
merged 8 commits into from
Jun 7, 2019

Conversation

Puneetha17
Copy link
Contributor

Send API can be invoked in 2 ways, with the following arguments -

  1. from, to and payload
  2. from, privacyGroupId and payload.

Both invocations return key.

When /send is called with from and to, the privacy group Id is stored. It is also stored when we call /privacyGroupId.

Assumptions:

  • The privacy group Id is already in the storage before invoking send with the privacy group.

@@ -117,6 +118,7 @@ public static void configureRoutes(
ConcurrentNetworkNodes networkNodes,
Enclave enclave,
Storage<EncryptedPayload> storage,
Storage<String[]> privacyGroupStorage,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the EncryptedPayload encrypted at rest? If so, then leaking the privacy group mapping is not a good idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not encrypted at rest so ignore this

@@ -78,7 +82,7 @@ public void handle(RoutingContext routingContext) {
}
log.debug(sendRequest);

if (sendRequest.to().length == 0) {
if (sendRequest.to() == null && !sendRequest.privacyGroupId().isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

cool, we should propagate this change to pantheon when it is released

final List<Box.PublicKey> toKeys =
Arrays.stream(sendRequest.to()).map(enclave::readKey).collect(Collectors.toList());
if (!sendRequest.privacyGroupId().isPresent()) {
List<Box.PublicKey> toKeys = Arrays.stream(sendRequest.to()).map(enclave::readKey).collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

you do not need to stream the to keys twice.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, you do. Ignore this.

@@ -53,6 +60,13 @@ public SendRequest(
this(decodePayload(payload), from, to);
}

@JsonAnySetter
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a dedicated @JsonSetter("privacyGroupId") if it is possible. It is much cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact you should create another constructor with a @JsonProperty("privacyGroupId") instead of @JsonProperty("to").

I am also tempted to make to an Optional here because you will either get the to array or a privacyGroupId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not entirely sure about making to optional as - if there is a case where they pass null aa a third parameter, it will conflict when trying to resolve to either String or String[].

@lucassaldanha lucassaldanha merged commit a80b73d into Consensys:master Jun 7, 2019
@Puneetha17 Puneetha17 deleted the features/sendPrivGrp branch June 12, 2019 14:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants