index int64 0 0 | repo_id stringlengths 26 205 | file_path stringlengths 51 246 | content stringlengths 8 433k | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsQuery.java | /*
* Copyright 2021 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs;
import org.springframework.core.annotation.AliasFor;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DgsData(parentType = "Query")
@Inherited
public @interface DgsQuery {
@AliasFor(annotation = DgsData.class)
String field() default "";
}
| 4,100 |
0 | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsEnableDataFetcherInstrumentation.java | /*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface DgsEnableDataFetcherInstrumentation {
boolean value() default true;
}
| 4,101 |
0 | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs/conditionals/ConditionalOnJava21.java | /*
* Copyright 2023 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs.conditionals;
import org.springframework.context.annotation.Conditional;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Conditional(Java21Condition.class)
public @interface ConditionalOnJava21 {
}
| 4,102 |
0 | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs/conditionals/Java21Condition.java | /*
* Copyright 2023 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs.conditionals;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Condition used in @ConditionalOnJava21.
* Always returns false for the main implementation, but is re-implemented for JDK 21 only using the multi-release JAR feature.
*/
public class Java21Condition implements Condition {
@Override
public boolean matches(@NotNull ConditionContext context, @NotNull AnnotatedTypeMetadata metadata) {
return false;
}
} | 4,103 |
0 | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs/internal/VirtualThreadTaskExecutor.java | /*
* Copyright 2023 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs.internal;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.task.AsyncTaskExecutor;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
/**
* Unimplemented version of the VirtualThreadTaskExecutor just for reachability.
* The actual implementation is in the java21 source folder, using the multi-release JAR feature.
*/
public class VirtualThreadTaskExecutor implements AsyncTaskExecutor {
public VirtualThreadTaskExecutor() {
}
@Override
public void execute(@NotNull Runnable task) {
throw new UnsupportedOperationException("VirtualThreadTaskExecutor is only supported on JDK 21+");
}
@Override
public void execute(@NotNull Runnable task, long startTimeout) {
throw new UnsupportedOperationException("VirtualThreadTaskExecutor is only supported on JDK 21+");
}
@NotNull
@Override
public Future<?> submit(@NotNull Runnable task) {
throw new UnsupportedOperationException("VirtualThreadTaskExecutor is only supported on JDK 21+");
}
@NotNull
@Override
public <T> Future<T> submit(@NotNull Callable<T> task) {
throw new UnsupportedOperationException("VirtualThreadTaskExecutor is only supported on JDK 21+");
}
} | 4,104 |
0 | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs | Create_ds/dgs-framework/graphql-dgs/src/main/java/com/netflix/graphql/dgs/support/Unstable.java | /*
* Copyright 2021 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs.support;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
/**
* Used to mark a component as having an unstable API or implementation.
* This is used by the team to reflect components that most likely will change in the future due its maturity and proven usefulness.
* <p>
* <b>Usage of this component is discouraged, use at your own risk.</b>
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
public @interface Unstable {
String message() default "The API/implementation of this component is unstable, use at your own risk.";
}
| 4,105 |
0 | Create_ds/dgs-framework/graphql-dgs-extended-validation/src/main/java/com/netflix/graphql/dgs | Create_ds/dgs-framework/graphql-dgs-extended-validation/src/main/java/com/netflix/graphql/dgs/autoconfig/ValidationRulesBuilderCustomizer.java | /*
* Copyright 2021 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.graphql.dgs.autoconfig;
import graphql.validation.rules.ValidationRules;
@FunctionalInterface
public interface ValidationRulesBuilderCustomizer {
void customize(ValidationRules.Builder builder);
}
| 4,106 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/KeyServer.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
import com.facebook.research.asynchronousratchetingtree.crypto.SignedDHPubKey;
final public class KeyServer {
GroupMessagingState[] states;
public KeyServer(GroupMessagingState[] states) {
this.states = states;
}
public SignedDHPubKey getSignedPreKey(GroupMessagingState state, int peerNum) {
return states[peerNum].getSignedDHPreKeyFor(state.getPeerNum());
}
}
| 4,107 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/Stopwatch.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
public class Stopwatch {
private long nanos;
private long intervalStart;
public Stopwatch() {
reset();
}
public void startInterval() {
intervalStart = System.nanoTime();
}
public void endInterval() {
long intervalEnd = System.nanoTime();
nanos += intervalEnd - intervalStart;
}
public long getTotal() {
return nanos;
}
public void reset() {
nanos = 0;
intervalStart = -1;
}
}
| 4,108 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/Utils.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
import com.facebook.research.asynchronousratchetingtree.art.message.thrift.NodeStruct;
import com.facebook.research.asynchronousratchetingtree.art.tree.Node;
import org.apache.thrift.TBase;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TException;
import org.apache.thrift.TSerializer;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TSimpleJSONProtocol;
import javax.xml.bind.DatatypeConverter;
import java.text.SimpleDateFormat;
import java.util.Date;
final public class Utils {
public static void print(String a, Object... args) {
SimpleDateFormat f = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss.SSS");
System.out.printf("[" + f.format(new Date()) + "] " + a + "\n", args);
}
public static void printHex(byte[] a) {
print(DatatypeConverter.printHexBinary(a));
}
public static void printTree(Node tree) {
NodeStruct struct = Node.toThrift(tree);
TSerializer serialiser = new TSerializer(new TSimpleJSONProtocol.Factory());
try {
Utils.print(new String(serialiser.serialize(hexifyNodeStruct(struct))));
} catch (TException e) {
Utils.except(e);
}
}
public static NodeStruct hexifyNodeStruct(NodeStruct tree) {
if (tree == null) {
return null;
}
NodeStruct result = new NodeStruct();
result.setPublicKey(DatatypeConverter.printHexBinary(tree.getPublicKey()).getBytes());
result.setLeft(hexifyNodeStruct(tree.getLeft()));
result.setRight(hexifyNodeStruct(tree.getRight()));
return result;
}
/**
* Throw a RuntimeException to simplify the example code by avoiding Java's explicit error handling.
* Yet another reason that this could should absolutely never be used as-is.
* The method throws, but also has the exception as its return type, so we can make the compiler happy by throwing
* the output, or just call it raw.
*/
public static RuntimeException except(Exception e) {
print(e.getClass().getSimpleName());
print(e.getMessage());
e.printStackTrace();
throw new RuntimeException();
}
public static RuntimeException except(String s) {
print(s);
throw new RuntimeException();
}
public static byte[] serialise(TBase thrift) {
TSerializer serialiser = new TSerializer(new TCompactProtocol.Factory());
try {
return serialiser.serialize(thrift);
} catch (TException e) {
throw Utils.except(e);
}
}
public static <TObject extends TBase> void deserialise(TObject object, byte[] data) {
TDeserializer deserialiser = new TDeserializer(new TCompactProtocol.Factory());
try {
deserialiser.deserialize(object, data);
} catch (TException e) {
Utils.except(e);
}
}
public static long startBenchmark() {
return new Date().toInstant().toEpochMilli();
}
public static long getBenchmarkDelta(long start) {
return new Date().toInstant().toEpochMilli() - start;
}
}
| 4,109 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/GroupMessagingTestImplementation.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public interface GroupMessagingTestImplementation<TThreadState extends GroupMessagingState> {
byte[] setupMessageForPeer(TThreadState state, DHPubKey[] peers, KeyServer keyServer, int peer);
void processSetupMessage(TThreadState state, byte[] serialisedMessage, int participantNum);
MessageDistributer sendMessage(TThreadState state, byte[] plaintext);
byte[] receiveMessage(TThreadState state, byte[] serialisedMessage);
}
| 4,110 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/GroupMessagingState.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
import com.facebook.research.asynchronousratchetingtree.crypto.SignedDHPubKey;
import java.util.HashMap;
import java.util.Map;
abstract public class GroupMessagingState {
private int peerNum;
private int peerCount;
private DHKeyPair identityKeyPair;
private Map<Integer, DHKeyPair> preKeys = new HashMap<>();
private Map<Integer, SignedDHPubKey> signedPreKeys = new HashMap<>();
public GroupMessagingState(int peerNum, int peerCount) {
this.peerNum = peerNum;
this.peerCount = peerCount;
identityKeyPair = DHKeyPair.generate(true);
}
final public int getPeerNum() {
return peerNum;
}
final public int getPeerCount() {
return peerCount;
}
final public DHKeyPair getIdentityKeyPair() {
return identityKeyPair;
}
final public DHKeyPair getPreKeyFor(int peerNum) {
if (!preKeys.containsKey(peerNum)) {
preKeys.put(peerNum, DHKeyPair.generate(false));
}
return preKeys.get(peerNum);
}
final public SignedDHPubKey getSignedDHPreKeyFor(int peerNum) {
if (!signedPreKeys.containsKey(peerNum)) {
byte[] pkBytes = getPreKeyFor(peerNum).getPubKeyBytes();
byte[] signature = getIdentityKeyPair().sign(pkBytes);
signedPreKeys.put(peerNum, new SignedDHPubKey(pkBytes, signature));
}
return signedPreKeys.get(peerNum);
}
abstract public byte[] getKeyWithPeer(int n);
}
| 4,111 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/Main.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
import com.facebook.research.asynchronousratchetingtree.art.ARTTestImplementation;
import com.facebook.research.asynchronousratchetingtree.art.ARTSetupPhase;
import com.facebook.research.asynchronousratchetingtree.art.ARTState;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.dhratchet.DHRatchet;
import com.facebook.research.asynchronousratchetingtree.dhratchet.DHRatchetSetupPhase;
import com.facebook.research.asynchronousratchetingtree.dhratchet.DHRatchetState;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.*;
import javax.crypto.Cipher;
public class Main {
private static boolean debug = true;
public static void main(String[] args) {
checkForUnlimitedStrengthCrypto();
// Run a test run first to warm up the JIT
artTestRun(8, 8);
dhTestRun(8, 8);
List<TestResult> artResults = new LinkedList<>();
List<TestResult> dhResults = new LinkedList<>();
int test_size_limit = 1000;
double multiplier = 1.5;
// First run ART tests. Warm up the JIT with a few smallish values, and then start recording results.
for (int i = 2; i < 20; i += 2) {
artTestRun(i, i);
}
int lastNumber = 1;
for (double i = 2.0; i <= test_size_limit; i *= multiplier) {
int n = (int) i;
if (n == lastNumber) {
continue;
}
lastNumber = n;
System.gc();
artResults.add(artTestRun(n, n));
}
// Now run DH tests. Again, warm up the JIT with a few smallish values, and then start recording results.
for (int i = 2; i < 20; i += 2) {
dhTestRun(i, i);
}
lastNumber = 1;
for (double i = 2.0; i <= test_size_limit; i *= multiplier) {
int n = (int) i;
if (n == lastNumber) {
continue;
}
System.gc();
dhResults.add(dhTestRun(n, n));
}
TestResult.outputHeaderLine();
Iterator<TestResult> artIterator = artResults.iterator();
while (artIterator.hasNext()) {
TestResult r = artIterator.next();
r.output();
}
Iterator<TestResult> dhIterator = dhResults.iterator();
while (dhIterator.hasNext()) {
TestResult r = dhIterator.next();
r.output();
}
}
private static TestResult artTestRun(int n, int activePeers) {
ARTState[] states = new ARTState[n];
for (int i = 0; i < n; i++) {
states[i] = new ARTState(i, n);
}
return testRun(
n,
activePeers,
states,
new ARTSetupPhase(),
new ARTTestImplementation()
);
}
private static void checkForUnlimitedStrengthCrypto() {
boolean hasEnoughCrypto = true;
try {
if (Cipher.getMaxAllowedKeyLength("AES") < 256) {
hasEnoughCrypto = false;
}
} catch (NoSuchAlgorithmException e) {
hasEnoughCrypto = false;
}
if (!hasEnoughCrypto) {
Utils.except("Your JRE does not support unlimited-strength " +
"cryptography and thus cannot run ART. See README.md " +
"for Java Cryptography Extension (JCE) Unlimited " +
"Strength Jurisdiction Policy Files installation " +
"instructions.");
}
}
private static TestResult dhTestRun(int n, int activePeers) {
DHRatchetState[] states = new DHRatchetState[n];
for (int i = 0; i < n; i++) {
states[i] = new DHRatchetState(i, n);
}
return testRun(
n,
activePeers,
states,
new DHRatchetSetupPhase(),
new DHRatchet()
);
}
private static <TState extends GroupMessagingState> TestResult testRun(
int n,
int activeCount,
TState[] states,
GroupMessagingSetupPhase<TState> setupPhase,
GroupMessagingTestImplementation<TState> implementation
) {
String testName = implementation.getClass().getSimpleName();
if (debug) Utils.print("\nStarting " + testName + " test run with " + n + " participants, of which " + activeCount + " active.\n");
TestResult result = new TestResult(testName, n, activeCount);
if (debug) Utils.print("Creating random messages and senders.");
SecureRandom random = new SecureRandom();
Set<Integer> activeSet = new HashSet<>();
activeSet.add(0); // We always want the initiator in the set.
while (activeSet.size() < activeCount) {
activeSet.add(random.nextInt(n));
}
Integer[] active = activeSet.toArray(new Integer[0]);
int messagesToSend = 100;
int messageLength = 32; // Message length 32 bytes, so we can compare as if we were just sending a symmetric key.
int[] messageSenders = new int[messagesToSend];
byte[][] messages = new byte[messagesToSend][messageLength];
for (int i = 0; i < messagesToSend; i++) {
// We're only interested in ratcheting events, so senders should always be
// different from the previous sender.
messageSenders[i] = active[random.nextInt(activeCount)];
while (i != 0 && messageSenders[i] == messageSenders[i-1]) {
messageSenders[i] = active[random.nextInt(activeCount)];
}
random.nextBytes(messages[i]);
}
// Create the necessary setup tooling in advance.
DHPubKey[] identities = new DHPubKey[n];
for (int i = 0; i < n ; i++) {
identities[i] = states[i].getIdentityKeyPair().getPubKey();
}
KeyServer keyServer = new KeyServer(states);
// Create and cache the necessary PreKeys in advance.
setupPhase.generateNecessaryPreKeys(states);
// We'll need two timers; as some interleaving events are counted.
Stopwatch stopwatch1 = new Stopwatch();
Stopwatch stopwatch2 = new Stopwatch();
if (debug) Utils.print("Setting up session for initiator.");
stopwatch1.startInterval();
setupPhase.setupInitiator(implementation, states, identities, keyServer);
stopwatch1.endInterval();
if (debug) Utils.print("Took " + stopwatch1.getTotal() + " nanoseconds.");
if (debug) Utils.print("Initiator sent " + setupPhase.getBytesSentByInitiator() + " bytes.");
result.setInitiatorSetupTime(stopwatch1.getTotal());
result.setInitiatorSetupBytes(setupPhase.getBytesSentByInitiator());
stopwatch1.reset();
if (debug) Utils.print("Setting up session for " + activeCount + " peers.");
stopwatch1.startInterval();
setupPhase.setupAllOthers(implementation, states, active, identities, keyServer);
stopwatch1.endInterval();
if (debug) Utils.print("Took " + stopwatch1.getTotal() + " nanoseconds.");
if (debug) Utils.print("Others received " + setupPhase.getBytesReceivedByOthers() + " bytes.");
if (debug) Utils.print("Others sent " + setupPhase.getBytesSentByOthers() + " bytes.");
result.setOthersSetupTime(stopwatch1.getTotal());
result.setOthersSetupBytesReceived(setupPhase.getBytesReceivedByOthers());
result.setOthersSetupBytesSent(setupPhase.getBytesSentByOthers());
stopwatch1.reset();
// Use stopwatch1 for sender, stopwatch2 for receiving.
if (debug) Utils.print("Sending " + messagesToSend + " messages.");
int totalSendSizes = 0;
int totalReceiveSizes = 0;
for (int i = 0; i < messagesToSend; i++) {
int sender = messageSenders[i];
byte[] message = messages[i];
stopwatch1.startInterval();
MessageDistributer messageDistributer = implementation.sendMessage(states[sender], message);
stopwatch1.endInterval();
totalSendSizes += messageDistributer.totalSize();
for (int j = 0; j < activeCount; j++) {
int receiver = active[j];
if (receiver == sender) {
continue;
}
byte[] received = messageDistributer.getUpdateMessageForParticipantNum(receiver);
totalReceiveSizes += received.length;
stopwatch2.startInterval();
byte[] decrypted = implementation.receiveMessage(states[receiver], received);
stopwatch2.endInterval();
if (!Arrays.equals(message, decrypted)) {
Utils.except("Message doesn't match.");
}
}
}
if (debug) Utils.print("Total sending time " + stopwatch1.getTotal() + " nanoseconds.");
if (debug) Utils.print("Total receiving time " + stopwatch2.getTotal() + " nanoseconds.");
if (debug) Utils.print("Total bytes sent: " + totalSendSizes + ".");
if (debug) Utils.print("Total bytes received: " + totalReceiveSizes + ".");
result.setSendingTime(stopwatch1.getTotal());
result.setReceivingTime(stopwatch2.getTotal());
result.setBytesSent(totalSendSizes);
result.setBytesReceived(totalReceiveSizes);
if (debug) Utils.print("Ended test run with " + n + " participants.\n---------------\n");
return result;
}
}
| 4,112 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/MessageDistributer.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
public interface MessageDistributer {
public byte[] getUpdateMessageForParticipantNum(int participantNum);
public int totalSize();
}
| 4,113 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/GroupMessagingSetupPhase.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public interface GroupMessagingSetupPhase<TState extends GroupMessagingState> {
void generateNecessaryPreKeys(TState[] states);
void setupInitiator(GroupMessagingTestImplementation<TState> implementation, TState[] states, DHPubKey[] identities, KeyServer keyServer);
int getBytesSentByInitiator();
void setupAllOthers(GroupMessagingTestImplementation<TState> implementation, TState[] states, Integer[] active, DHPubKey[] identities, KeyServer keyServer);
int getBytesSentByOthers();
int getBytesReceivedByOthers();
}
| 4,114 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/TestResult.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree;
public class TestResult {
private String type;
private int groupSize;
private int activeUsers;
private long initiatorSetupTime;
private int initiatorSetupBytes;
private long othersSetupTime;
private int othersSetupBytesSent;
private int othersSetupBytesReceived;
private long sendingTime;
private long receivingTime;
private int bytesSent;
private int bytesReceived;
public TestResult(String type, int groupSize, int activeUsers) {
this.type = type;
this.groupSize = groupSize;
this.activeUsers = activeUsers;
}
public void setInitiatorSetupTime(long initiatorSetupTime) {
this.initiatorSetupTime = initiatorSetupTime;
}
public void setInitiatorSetupBytes(int initiatorSetupBytes) {
this.initiatorSetupBytes = initiatorSetupBytes;
}
public void setOthersSetupTime(long othersSetupTime) {
this.othersSetupTime = othersSetupTime;
}
public void setOthersSetupBytesSent(int othersSetupBytesSent) {
this.othersSetupBytesSent = othersSetupBytesSent;
}
public void setOthersSetupBytesReceived(int othersSetupBytesReceived) {
this.othersSetupBytesReceived = othersSetupBytesReceived;
}
public void setSendingTime(long sendingTime) {
this.sendingTime = sendingTime;
}
public void setReceivingTime(long receivingTime) {
this.receivingTime = receivingTime;
}
public void setBytesSent(int bytesSent) {
this.bytesSent = bytesSent;
}
public void setBytesReceived(int bytesReceived) {
this.bytesReceived = bytesReceived;
}
public static void outputHeaderLine() {
String[] columns = new String[] {
"type",
"participants",
"active_participants",
"init_setup_time",
"init_setup_bytes",
"others_setup_time",
"others_setup_bytes_sent",
"others_setup_bytes_received",
"send_time",
"receive_time",
"bytes_sent",
"bytes_received"
};
System.out.println(String.join(",", columns));
}
public void output() {
String[] columns = new String[] {
type,
String.valueOf(groupSize),
String.valueOf(activeUsers),
String.valueOf(initiatorSetupTime),
String.valueOf(initiatorSetupBytes),
String.valueOf(othersSetupTime),
String.valueOf(othersSetupBytesSent),
String.valueOf(othersSetupBytesReceived),
String.valueOf(sendingTime),
String.valueOf(receivingTime),
String.valueOf(bytesSent),
String.valueOf(bytesReceived)
};
System.out.println(String.join(",", columns));
}
}
| 4,115 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/crypto/DHPubKey.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.crypto;
import djb.Curve25519;
import java.security.MessageDigest;
import java.util.Arrays;
public class DHPubKey {
private byte[] pub;
protected DHPubKey(byte[] pub) {
this.pub = pub;
}
public static DHPubKey pubKey(byte[] pub) {
if (pub == null || pub.length == 0) {
return null;
}
return new DHPubKey(pub);
}
public byte[] getPubKeyBytes() {
return pub;
}
public boolean verify(byte[] data, byte[] sig) {
byte[] sig_first_part = Arrays.copyOfRange(sig, 0, Crypto.HASH_LENGTH);
byte[] sig_second_part = Arrays.copyOfRange(sig, Crypto.HASH_LENGTH, sig.length);
MessageDigest md = Crypto.startSHA256();
md.update(data);
md.update(getPubKeyBytes());
byte[] digest = md.digest();
byte[] output = new byte[Curve25519.KEY_SIZE];
Curve25519.verify(
output,
sig_second_part,
digest,
getPubKeyBytes()
);
return Arrays.equals(
Crypto.startSHA256().digest(output),
sig_first_part
);
}
}
| 4,116 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/crypto/SignedDHPubKey.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.crypto;
public class SignedDHPubKey extends DHPubKey {
private byte[] signature;
public SignedDHPubKey(byte[] pubKey, byte[] signature) {
super(pubKey);
this.signature = signature;
}
public byte[] getSignature() {
return signature;
}
}
| 4,117 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/crypto/Crypto.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.crypto;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.tree.Node;
import djb.Curve25519;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
/**
* This crypto class is put together simply to make coding the rest of the example program easier. Please never actually
* use it in production.
*/
public class Crypto {
final public static int HASH_LENGTH = 32;
public static MessageDigest startSHA256() {
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw Utils.except(e);
}
return md;
}
public static byte[] hmacSha256(byte[] data, byte[] key) {
Mac mac;
try {
mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(key, "HmacSHA256"));
} catch (Exception e) {
throw Utils.except(e);
}
mac.update(data);
return mac.doFinal();
}
public static byte[] hkdf(byte[] input_keying_material, byte[] salt, byte[] info, int num_bytes) {
// Extract step
byte[] pseudo_random_key = hmacSha256(salt, input_keying_material);
// Expand step
byte[] output_bytes = new byte[num_bytes];
byte[] t = new byte[0];
for (byte i = 0; i < (num_bytes + 31) / 32; i++) {
byte[] tInput = new byte[t.length + info.length + 1];
System.arraycopy(t, 0, tInput, 0, t.length);
System.arraycopy(info, 0, tInput, t.length, info.length);
tInput[tInput.length - 1] = i;
t = hmacSha256(pseudo_random_key, tInput);
int num_to_copy = num_bytes - (i * 32);
if (num_to_copy > 32) {
num_to_copy = 32;
}
System.arraycopy(t, 0, output_bytes, i * 32, num_to_copy);
}
return output_bytes;
}
public static byte[] artKDF(
byte[] lastStageKey,
byte[] treeKey,
DHPubKey[] identities,
Node tree
) {
byte[] serialisedTree = Utils.serialise(Node.toThrift(tree));
byte[] ikm = new byte[lastStageKey.length + treeKey.length + serialisedTree.length];
System.arraycopy(lastStageKey, 0, ikm, 0, lastStageKey.length);
System.arraycopy(treeKey, 0, ikm, lastStageKey.length, treeKey.length);
System.arraycopy(serialisedTree, 0, ikm, lastStageKey.length + treeKey.length, serialisedTree.length);
byte[] info = new byte[identities.length * Curve25519.KEY_SIZE];
for (int i = 0; i < identities.length; i++) {
System.arraycopy(identities[i].getPubKeyBytes(), 0, info, i * Curve25519.KEY_SIZE, Curve25519.KEY_SIZE);
}
return hkdf(ikm, new byte[0], info, 16);
}
public static byte[] randomBytes(int n) {
byte[] result = new byte[n];
SecureRandom rng = new SecureRandom();
rng.nextBytes(result);
return result;
}
public static byte[] encrypt(byte[] message, byte[] keyBytes) {
Cipher cipher;
Key key;
try {
cipher = Cipher.getInstance("AES/GCM/NoPadding");
byte[] nonce = randomBytes(12);
GCMParameterSpec paramSpec = new GCMParameterSpec(16 * 8, nonce);
key = new SecretKeySpec(keyBytes, "AES");
cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
int len = cipher.getOutputSize(message.length);
byte[] result = new byte[len + 12];
System.arraycopy(nonce, 0, result, 0, 12);
cipher.doFinal(
message,
0,
message.length,
result,
12
);
return result;
} catch (Exception e) {
throw Utils.except(e);
}
}
public static byte[] decrypt(byte[] encrypted, byte[] keyBytes) {
Cipher cipher;
Key key;
try {
cipher = Cipher.getInstance("AES/GCM/NoPadding");
byte[] nonce = Arrays.copyOfRange(encrypted, 0, 12);
byte[] ciphertext = Arrays.copyOfRange(encrypted, 12, encrypted.length);
GCMParameterSpec paramSpec = new GCMParameterSpec(16 * 8, nonce);
key = new SecretKeySpec(keyBytes, "AES");
cipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
return cipher.doFinal(ciphertext);
} catch (Exception e) {
throw Utils.except(e);
}
}
public static byte[] keyExchangeInitiate(
DHKeyPair selfIdentity,
DHPubKey remoteIdentity,
DHKeyPair keyExchangeKeyPair,
DHPubKey remoteEphemeralKey
) {
MessageDigest md = Crypto.startSHA256();
md.update(selfIdentity.exchange(remoteIdentity));
md.update(selfIdentity.exchange(remoteEphemeralKey));
md.update(keyExchangeKeyPair.exchange(remoteIdentity));
md.update(keyExchangeKeyPair.exchange(remoteEphemeralKey));
return md.digest();
}
public static byte[] keyExchangeReceive(
DHKeyPair selfIdentity,
DHPubKey remoteIdentity,
DHKeyPair ephemeralKey,
DHPubKey keyExchangeKey
) {
MessageDigest md = Crypto.startSHA256();
md.update(selfIdentity.exchange(remoteIdentity));
md.update(ephemeralKey.exchange(remoteIdentity));
md.update(selfIdentity.exchange(keyExchangeKey));
md.update(ephemeralKey.exchange(keyExchangeKey));
return md.digest();
}
}
| 4,118 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/crypto/DHKeyPair.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.crypto;
import com.facebook.research.asynchronousratchetingtree.Utils;
import djb.Curve25519;
import java.security.MessageDigest;
public class DHKeyPair extends DHPubKey {
private byte[] priv;
private byte[] privSign;
protected DHKeyPair(byte[] pub, byte[] priv, byte[] privSign) {
super(pub);
this.priv = priv;
this.privSign = privSign;
}
public static DHKeyPair generate(boolean allowSignatures) {
return DHKeyPair.fromBytes(Crypto.randomBytes(Curve25519.KEY_SIZE), allowSignatures);
}
public static DHKeyPair fromBytes(byte[] priv, boolean allowSignatures) {
byte[] pub = new byte[Curve25519.KEY_SIZE];
byte[] privSign;
if (allowSignatures) {
privSign = new byte[Curve25519.KEY_SIZE];
Curve25519.keygen(pub, privSign, priv);
} else {
privSign = null;
Curve25519.keygen(pub, null, priv);
}
return new DHKeyPair(pub, priv, privSign);
}
public byte[] getPrivKeyBytes() {
return priv;
}
public DHPubKey getPubKey() {
return pubKey(getPubKeyBytes());
}
public byte[] exchange(DHPubKey bob) {
byte[] result = new byte[Curve25519.KEY_SIZE];
Curve25519.curve(result, getPrivKeyBytes(), bob.getPubKeyBytes());
return result;
}
/**
* The Curve25519 library that we use implements KCDSA. The API provided accepts the first curve point
* as an argument, and returns the second part of the signature. The first part is a hash of the public
* curve point, so we append this ourselves.
* In DHPubKey, we then verify signatures by hashing the input data similarly, and checking that the
* output of the verification method equals the first part of the signature.
* http://grouper.ieee.org/groups/1363/P1363a/contributions/kcdsa1363.pdf
*/
public byte[] sign(byte[] data) {
if (privSign == null) {
Utils.except("Non-signing key cannot be used for signing.");
}
boolean success = false;
byte[] sig_second_part = new byte[0];
byte[] sig_first_part = new byte[0];
// Signature generation can fail, in which case we need to try a different Curve point.
while (!success) {
byte[] privCurvePoint = Crypto.randomBytes(Curve25519.KEY_SIZE);
byte[] pubCurvePoint = new byte[Curve25519.KEY_SIZE];
Curve25519.keygen(pubCurvePoint, null, privCurvePoint);
sig_first_part = Crypto.startSHA256().digest(pubCurvePoint);
MessageDigest md = Crypto.startSHA256();
md.update(data);
md.update(getPubKeyBytes());
byte[] digest = md.digest();
sig_second_part = new byte[Curve25519.KEY_SIZE];
success = Curve25519.sign(
sig_second_part,
digest,
privCurvePoint,
privSign
);
}
byte[] sig = new byte[Crypto.HASH_LENGTH + Curve25519.KEY_SIZE];
System.arraycopy(sig_first_part, 0, sig, 0, Crypto.HASH_LENGTH);
System.arraycopy(sig_second_part, 0, sig, Crypto.HASH_LENGTH, Curve25519.KEY_SIZE);
return sig;
}
}
| 4,119 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/ARTTestImplementation.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art;
import com.facebook.research.asynchronousratchetingtree.KeyServer;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.message.*;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingTestImplementation;
import com.facebook.research.asynchronousratchetingtree.MessageDistributer;
import com.facebook.research.asynchronousratchetingtree.art.message.CiphertextMessage;
import com.facebook.research.asynchronousratchetingtree.crypto.Crypto;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.crypto.SignedDHPubKey;
import com.facebook.research.asynchronousratchetingtree.art.message.ARTMessageDistributer;
import com.facebook.research.asynchronousratchetingtree.art.message.AuthenticatedMessage;
import java.util.*;
final public class ARTTestImplementation implements GroupMessagingTestImplementation<ARTState> {
public byte[] setupMessageForPeer(ARTState state, DHPubKey[] peers, KeyServer keyServer, int peer) {
byte[] setupMessageSerialised = state.getSetupMessage();
if (setupMessageSerialised == null) {
Map<Integer, DHPubKey> preKeys = new HashMap<>();
for (int i = 1; i < peers.length; i++) {
SignedDHPubKey signedPreKey = keyServer.getSignedPreKey(state, i);
if (!peers[i].verify(signedPreKey.getPubKeyBytes(), signedPreKey.getSignature())) {
Utils.except("PreKey signature check failed.");
}
preKeys.put(i, signedPreKey);
}
AuthenticatedMessage setupMessage = ART.setupGroup(state, peers, preKeys);
setupMessageSerialised = setupMessage.serialise();
state.setSetupMessage(setupMessageSerialised);
}
return setupMessageSerialised;
}
public void processSetupMessage(ARTState state, byte[] serialisedMessage, int leafNum) {
AuthenticatedMessage message = new AuthenticatedMessage(serialisedMessage);
ART.processSetupMessage(state, message, leafNum);
}
public MessageDistributer sendMessage(ARTState state, byte[] plaintext) {
AuthenticatedMessage updateMessage = ART.updateKey(state);
// All peers have the same key, so the "withPeer(0)" aspect of this is a no-op.
byte[] key = state.getKeyWithPeer(0);
byte[] ciphertext = Crypto.encrypt(plaintext, key);
CiphertextMessage message = new CiphertextMessage(updateMessage, ciphertext);
return new ARTMessageDistributer(message);
}
public byte[] receiveMessage(ARTState state, byte[] serialisedMessage) {
CiphertextMessage message = new CiphertextMessage(serialisedMessage);
ART.processUpdateMessage(state, message.getAuthenticatedMessage());
// All peers have the same key, so the "withPeer(0)" aspect of this is a no-op.
byte[] key = state.getKeyWithPeer(0);
return Crypto.decrypt(message.getCiphertext(), key);
}
}
| 4,120 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/ARTState.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingState;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.tree.SecretParentNode;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.art.tree.SecretNode;
public class ARTState extends GroupMessagingState {
private SecretParentNode tree;
private DHPubKey[] identities;
private byte[] stageKey = new byte[0];
private byte[] setupMessage;
public ARTState(int peerNum, int peerCount) {
super(peerNum, peerCount);
}
public SecretNode getTree() {
return tree;
}
public void setSetupMessage(byte[] setupMessage) {
this.setupMessage = setupMessage;
}
public byte[] getSetupMessage() {
return setupMessage;
}
public byte[] getKeyWithPeer(int n) {
return getStageKey();
}
public DHPubKey[] getIdentities() {
return identities;
}
public void setIdentities(DHPubKey[] identities) {
this.identities = identities;
}
public byte[] getStageKey() {
return stageKey;
}
public void setStageKey(byte[] stageKey) {
this.stageKey = stageKey;
}
public void setTree(SecretNode tree) {
if (!(tree instanceof SecretParentNode)) {
Utils.except("Tree cannot be a leaf.");
}
this.tree = (SecretParentNode) tree;
}
}
| 4,121 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/ART.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.message.AuthenticatedMessage;
import com.facebook.research.asynchronousratchetingtree.art.message.SetupMessage;
import com.facebook.research.asynchronousratchetingtree.art.message.UpdateMessage;
import com.facebook.research.asynchronousratchetingtree.art.tree.*;
import com.facebook.research.asynchronousratchetingtree.crypto.Crypto;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import java.util.*;
public class ART {
public static AuthenticatedMessage setupGroup(ARTState state, DHPubKey[] peers, Map<Integer, DHPubKey> preKeys) {
int numPeers = peers.length;
DHKeyPair selfLeaf = DHKeyPair.generate(false);
DHKeyPair keyExchangeKeyPair = DHKeyPair.generate(false);
DHKeyPair[] leaves = new DHKeyPair[numPeers];
leaves[0] = selfLeaf;
for (int i = 1; i < numPeers; i++) { // generate leaf keys for each agent
leaves[i] = DHKeyPair.fromBytes(
Crypto.keyExchangeInitiate(
state.getIdentityKeyPair(),
peers[i],
keyExchangeKeyPair,
preKeys.get(i)
),
false
);
}
SecretNode tree = createTree(leaves);
state.setIdentities(peers);
state.setTree(tree);
SetupMessage sm = new SetupMessage(
peers,
preKeys,
keyExchangeKeyPair.getPubKey(),
tree
);
byte[] serialisedSetupMessage = sm.serialise();
byte[] signature = state.getIdentityKeyPair().sign(serialisedSetupMessage);
deriveStageKey(state);
return new AuthenticatedMessage(serialisedSetupMessage, signature);
}
public static void processSetupMessage(ARTState state, AuthenticatedMessage signedMessage, int leafNum) {
SetupMessage message = new SetupMessage(signedMessage.getMessage());
boolean verified = message.getIdentities()[0].verify(signedMessage.getMessage(), signedMessage.getAuthenticator());
if (!verified) {
Utils.except("Signature verification failed on the setup message.");
}
if (!Arrays.equals(state.getPreKeyFor(0).getPubKey().getPubKeyBytes(), message.getEphemeralKeys().get(leafNum).getPubKeyBytes())) {
Utils.except("Used the wrong ephemeral key.");
}
SecretLeafNode leaf = new SecretLeafNode(
DHKeyPair.fromBytes(
Crypto.keyExchangeReceive(state.getIdentityKeyPair(), message.getIdentities()[0], state.getPreKeyFor(0), message.getKeyExchangeKey()),
false
)
);
state.setTree(
updateTreeWithSecretLeaf(
message.getTree(),
state.getPeerNum(),
leaf
)
);
state.setIdentities(
message.getIdentities()
);
deriveStageKey(state);
}
public static AuthenticatedMessage updateKey(ARTState state) {
SecretLeafNode newNode = new SecretLeafNode(DHKeyPair.generate(false));
SecretNode newTree = updateTreeWithSecretLeaf(state.getTree(), state.getPeerNum(), newNode);
state.setTree(newTree);
UpdateMessage m = new UpdateMessage(
state.getPeerNum(),
pathNodeKeys(state.getTree(), state.getPeerNum())
);
byte[] serialisedUpdateMessage = m.serialise();
byte[] mac = Crypto.hmacSha256(serialisedUpdateMessage, state.getStageKey());
deriveStageKey(state);
return new AuthenticatedMessage(serialisedUpdateMessage, mac);
}
public static void processUpdateMessage(ARTState state, AuthenticatedMessage message) {
byte[] mac = Crypto.hmacSha256(message.getMessage(), state.getStageKey());
if (!Arrays.equals(mac, message.getAuthenticator())) {
Utils.except("MAC is incorrect for update message.");
}
UpdateMessage updateMessage = new UpdateMessage(message.getMessage());
Node tree = state.getTree();
tree = updateTreeWithPublicPath(tree, updateMessage.getLeafNum(), updateMessage.getPath(), 0);
state.setTree((SecretNode) tree);
deriveStageKey(state);
}
private static SecretNode createTree(DHKeyPair[] leaves) {
int n = leaves.length;
if (n == 0) {
Utils.except("No leaves");
}
if (n == 1) {
return new SecretLeafNode(leaves[0]);
}
int l = leftTreeSize(n);
SecretNode left = createTree(Arrays.copyOfRange(leaves, 0, l));
Node right = createTree(Arrays.copyOfRange(leaves, l, n));
return new SecretParentNode(left, right);
}
private static void deriveStageKey(ARTState state) {
state.setStageKey(
Crypto.artKDF(
state.getStageKey(),
((SecretParentNode)state.getTree()).getRawSecretKey(),
state.getIdentities(),
state.getTree()
)
);
}
private static SecretNode updateTreeWithSecretLeaf(Node tree, int i, SecretLeafNode newLeaf) {
int l = leftTreeSize(tree.numLeaves());
if (tree.numLeaves() == 1) {
return newLeaf;
}
SecretParentNode result;
ParentNode treeParent = (ParentNode)tree;
if (i < l) {
result = new SecretParentNode(
updateTreeWithSecretLeaf(treeParent.getLeft(), i, newLeaf),
treeParent.getRight()
);
} else {
result = new SecretParentNode(
treeParent.getLeft(),
updateTreeWithSecretLeaf(treeParent.getRight(), i - l, newLeaf)
);
}
return result;
}
private static Node updateTreeWithPublicPath(Node tree, int i, DHPubKey[] newPath, int pathIndex) {
int l = leftTreeSize(tree.numLeaves());
if (newPath.length - 1 == pathIndex) {
return new PublicLeafNode(newPath[pathIndex]);
}
ParentNode result;
ParentNode treeAsParent = (ParentNode) tree;
Node newLeft;
Node newRight;
if (i < l) {
newLeft = updateTreeWithPublicPath(treeAsParent.getLeft(), i, newPath, pathIndex + 1);
newRight = treeAsParent.getRight();
} else {
newLeft = treeAsParent.getLeft();
newRight = updateTreeWithPublicPath(treeAsParent.getRight(), i - l, newPath, pathIndex + 1);
}
if (newLeft instanceof SecretNode) {
result = new SecretParentNode((SecretNode)newLeft, newRight);
} else if (newRight instanceof SecretNode) {
result = new SecretParentNode(newLeft, (SecretNode)newRight);
} else {
result = new PublicParentNode(
newPath[pathIndex],
newLeft,
newRight
);
}
if (!Arrays.equals(result.getPubKey().getPubKeyBytes(), newPath[pathIndex].getPubKeyBytes())) {
Utils.printTree(result);
Utils.except("Update operation inconsistent with provided path.");
}
return result;
}
protected static DHPubKey[] pathNodeKeys(Node tree, int i) {
List<DHPubKey> keys = new ArrayList<DHPubKey>();
while (tree.numLeaves() > 1) {
int l = leftTreeSize(tree.numLeaves());
ParentNode parentNode = (ParentNode) tree;
keys.add(tree.getPubKey());
if (i < l) {
tree = parentNode.getLeft();
} else {
tree = parentNode.getRight();
i -= l;
}
}
keys.add(tree.getPubKey());
return keys.toArray(new DHPubKey[] {});
}
private static int leftTreeSize(int numLeaves) {
return (int)Math.pow(2, Math.ceil(Math.log(numLeaves) / Math.log(2)) - 1);
}
}
| 4,122 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/ARTSetupPhase.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingSetupPhase;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingTestImplementation;
import com.facebook.research.asynchronousratchetingtree.KeyServer;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public class ARTSetupPhase implements GroupMessagingSetupPhase<ARTState> {
private byte[] setupMessage;
private int bytesReceivedByOthers = 0;
@Override
public void generateNecessaryPreKeys(ARTState[] states) {
// We only need PreKeys for the initiator.
for (int i = 1; i < states.length; i++) {
states[i].getSignedDHPreKeyFor(0);
}
}
@Override
public void setupInitiator(GroupMessagingTestImplementation<ARTState> implementation, ARTState[] states, DHPubKey[] identities, KeyServer keyServer) {
int n = states.length;
// Setup message is the same for all peers, so let's just do it once.
setupMessage = implementation.setupMessageForPeer(
states[0],
identities,
keyServer,
1
);
}
@Override
public int getBytesSentByInitiator() {
return setupMessage.length;
}
@Override
public void setupAllOthers(GroupMessagingTestImplementation<ARTState> implementation, ARTState[] states, Integer[] active, DHPubKey[] identities, KeyServer keyServer) {
for (int i = 0; i < active.length; i++) {
int which = active[i];
if (which == 0) { // Don't import the setup message to the initiator itself.
continue;
}
bytesReceivedByOthers += setupMessage.length;
implementation.processSetupMessage(states[which], setupMessage, which);
}
}
@Override
public int getBytesSentByOthers() {
return 0;
}
@Override
public int getBytesReceivedByOthers() {
return bytesReceivedByOthers;
}
}
| 4,123 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/SecretLeafNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
final public class SecretLeafNode extends LeafNode implements SecretNode {
private DHKeyPair keyPair;
public SecretLeafNode(DHKeyPair keyPair) {
this.keyPair = keyPair;
}
public DHPubKey getPubKey() {
return keyPair.getPubKey();
}
public DHKeyPair getKeyPair() {
return keyPair;
}
}
| 4,124 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/Node.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
import com.facebook.research.asynchronousratchetingtree.art.message.thrift.NodeStruct;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public interface Node {
DHPubKey getPubKey();
int numLeaves();
static Node fromThrift(NodeStruct thrift) {
if (thrift == null) {
return null;
}
DHPubKey pubKey = DHPubKey.pubKey(thrift.getPublicKey());
NodeStruct left = thrift.getLeft();
NodeStruct right = thrift.getRight();
if (left == null && right == null) {
return new PublicLeafNode(pubKey);
}
return new PublicParentNode(
pubKey,
fromThrift(left),
fromThrift(right)
);
}
static NodeStruct toThrift(Node tree) {
if (tree == null) {
return null;
}
NodeStruct struct = new NodeStruct();
struct.setPublicKey(tree.getPubKey().getPubKeyBytes());
if (tree instanceof ParentNode) {
struct.setLeft(Node.toThrift(((ParentNode) tree).getLeft()));
struct.setRight(Node.toThrift(((ParentNode) tree).getRight()));
}
return struct;
}
}
| 4,125 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/LeafNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
abstract public class LeafNode implements Node {
final public int numLeaves() {
return 1;
}
}
| 4,126 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/SecretParentNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
import com.facebook.research.asynchronousratchetingtree.crypto.Crypto;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
public class SecretParentNode extends ParentNode implements SecretNode {
private DHKeyPair keyPair;
public SecretParentNode(SecretNode left, Node right) {
this.left = left;
this.right = right;
byte[] dhOutput = left.getKeyPair().exchange(right.getPubKey());
// Derive both a private ECDH key and an AES-128 encryption key.
byte[] key = Crypto.hkdf(dhOutput, new byte[0], new byte[0], 32);
keyPair = DHKeyPair.fromBytes(key, false);
}
public SecretParentNode(Node left, SecretNode right) {
this.left = left;
this.right = right;
this.keyPair = DHKeyPair.fromBytes(right.getKeyPair().exchange(left.getPubKey()), false);
byte[] dhOutput = right.getKeyPair().exchange(left.getPubKey());
// Derive both a private ECDH key and an AES-128 encryption key.
byte[] key = Crypto.hkdf(dhOutput, new byte[0], new byte[0], 32);
keyPair = DHKeyPair.fromBytes(key, false);
}
public DHPubKey getPubKey() {
return keyPair.getPubKey();
}
public DHKeyPair getKeyPair() {
return keyPair;
}
public byte[] getRawSecretKey() {
return keyPair.getPrivKeyBytes();
}
}
| 4,127 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/SecretNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
public interface SecretNode extends Node {
public DHKeyPair getKeyPair();
}
| 4,128 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/PublicLeafNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public class PublicLeafNode extends LeafNode {
private DHPubKey pubKey;
public PublicLeafNode(DHPubKey pubKey) {
this.pubKey = pubKey;
}
public DHPubKey getPubKey() {
return pubKey;
}
}
| 4,129 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/PublicParentNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public class PublicParentNode extends ParentNode {
private DHPubKey pubKey;
public PublicParentNode(DHPubKey pubKey, Node left, Node right) {
this.pubKey = pubKey;
this.left = left;
this.right = right;
}
public DHPubKey getPubKey() {
return pubKey;
}
}
| 4,130 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/tree/ParentNode.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.tree;
abstract public class ParentNode implements Node {
protected Node left;
protected Node right;
public int numLeaves() {
return left.numLeaves() + right.numLeaves();
}
public Node getLeft() {
return left;
}
public Node getRight() {
return right;
}
}
| 4,131 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/UpdateMessage.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.message;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.message.thrift.UpdateMessageStruct;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
public class UpdateMessage {
int leafNum;
DHPubKey[] path;
public UpdateMessage(int leafNum, DHPubKey[] path) {
this.leafNum = leafNum;
this.path = path;
}
public UpdateMessage(byte[] thriftSerialised) {
UpdateMessageStruct struct = new UpdateMessageStruct();
Utils.deserialise(struct, thriftSerialised);
leafNum = struct.getLeafNum();
path = new DHPubKey[struct.getPathSize()];
for (int i = 0; i < path.length; i++) {
path[i] = DHPubKey.pubKey(
Base64.getDecoder().decode(struct.getPath().get(i))
);
}
}
public int getLeafNum() {
return leafNum;
}
public DHPubKey[] getPath() {
return path;
}
public byte[] serialise() {
List<String> path = new ArrayList<>();
for (int i = 0; i < this.path.length; i++) {
path.add(Base64.getEncoder().encodeToString(this.path[i].getPubKeyBytes()));
}
UpdateMessageStruct struct = new UpdateMessageStruct();
struct.setLeafNum(leafNum);
struct.setPath(path);
return Utils.serialise(struct);
}
}
| 4,132 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/SetupMessage.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.message;
import com.facebook.research.asynchronousratchetingtree.art.message.thrift.SetupMessageStruct;
import com.facebook.research.asynchronousratchetingtree.art.tree.Node;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import java.util.*;
public class SetupMessage {
private DHPubKey[] identities;
private Map<Integer, DHPubKey> ephemeralKeys;
private DHPubKey keyExchangeKey;
private Node tree;
public SetupMessage(DHPubKey[] identities, Map<Integer, DHPubKey> ephemeralKeys, DHPubKey keyExchangeKey, Node tree) {
this.identities = identities;
this.ephemeralKeys = ephemeralKeys;
this.keyExchangeKey = keyExchangeKey;
this.tree = tree;
}
public SetupMessage(byte[] thriftSerialised) {
SetupMessageStruct struct = new SetupMessageStruct();
Utils.deserialise(struct, thriftSerialised);
identities = new DHPubKey[struct.getIdentitiesSize()];
for (int i = 0; i < identities.length; i++) {
identities[i] = DHPubKey.pubKey(
Base64.getDecoder().decode(struct.getIdentities().get(i))
);
}
ephemeralKeys = new HashMap<>();
for (int i = 1; i < identities.length; i++) {
ephemeralKeys.put(
i,
DHPubKey.pubKey(
Base64.getDecoder().decode(struct.getEphemeralKeys().get(i))
)
);
}
keyExchangeKey = DHPubKey.pubKey(struct.getKeyExchangeKey());
tree = Node.fromThrift(struct.getTree());
}
public DHPubKey[] getIdentities() {
return identities;
}
public Map<Integer, DHPubKey> getEphemeralKeys() {
return ephemeralKeys;
}
public DHPubKey getKeyExchangeKey() {
return keyExchangeKey;
}
public Node getTree() {
return tree;
}
public byte[] serialise() {
List<String> identities = new ArrayList<>();
Map<Integer, String> ephemeralKeys = new HashMap<>();
for (int i = 0; i < this.identities.length; i++) {
identities.add(Base64.getEncoder().encodeToString(this.identities[i].getPubKeyBytes()));
}
for (int i = 1; i < this.identities.length; i++) {
ephemeralKeys.put(i, Base64.getEncoder().encodeToString(this.ephemeralKeys.get(i).getPubKeyBytes()));
}
SetupMessageStruct struct = new SetupMessageStruct();
struct.setIdentities(identities);
struct.setEphemeralKeys(ephemeralKeys);
struct.setKeyExchangeKey(keyExchangeKey.getPubKeyBytes());
struct.setTree(Node.toThrift(tree));
return Utils.serialise(struct);
}
}
| 4,133 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/AuthenticatedMessage.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.message;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.message.thrift.AuthenticatedMessageStruct;
public class AuthenticatedMessage {
private byte[] message;
private byte[] authenticator;
public AuthenticatedMessage(
byte[] message,
byte[] authenticator
) {
this.message = message;
this.authenticator = authenticator;
}
public AuthenticatedMessage(byte[] thriftSerialised) {
AuthenticatedMessageStruct struct = new AuthenticatedMessageStruct();
Utils.deserialise(struct, thriftSerialised);
message = struct.getMessage();
authenticator = struct.getAuthenticator();
}
public AuthenticatedMessage(AuthenticatedMessageStruct struct) {
message = struct.getMessage();
authenticator = struct.getAuthenticator();
}
public byte[] getMessage() {
return message;
}
public byte[] getAuthenticator() {
return authenticator;
}
public AuthenticatedMessageStruct getThriftStruct() {
AuthenticatedMessageStruct struct = new AuthenticatedMessageStruct();
struct.setMessage(message);
struct.setAuthenticator(authenticator);
return struct;
}
public byte[] serialise() {
return Utils.serialise(getThriftStruct());
}
}
| 4,134 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/ARTMessageDistributer.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.message;
import com.facebook.research.asynchronousratchetingtree.MessageDistributer;
public class ARTMessageDistributer implements MessageDistributer {
private byte[] serialised;
public ARTMessageDistributer(CiphertextMessage updateMessage) {
serialised = updateMessage.serialise();
}
@Override
public byte[] getUpdateMessageForParticipantNum(int participantNum) {
return serialised;
}
@Override
public int totalSize() {
return serialised.length;
}
}
| 4,135 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/CiphertextMessage.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.art.message;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.art.message.thrift.CiphertextMessageStruct;
public class CiphertextMessage {
private AuthenticatedMessage authenticatedMessage;
private byte[] ciphertext;
public CiphertextMessage(AuthenticatedMessage authenticatedMessage, byte[] ciphertext) {
this.authenticatedMessage = authenticatedMessage;
this.ciphertext = ciphertext;
}
public CiphertextMessage(byte[] thriftSerialised) {
CiphertextMessageStruct struct = new CiphertextMessageStruct();
Utils.deserialise(struct, thriftSerialised);
authenticatedMessage = new AuthenticatedMessage(struct.getAuthenticatedMessage());
ciphertext = struct.getCiphertext();
}
public AuthenticatedMessage getAuthenticatedMessage() {
return authenticatedMessage;
}
public byte[] getCiphertext() {
return ciphertext;
}
public byte[] serialise() {
CiphertextMessageStruct struct = new CiphertextMessageStruct();
struct.setAuthenticatedMessage(authenticatedMessage.getThriftStruct());
struct.setCiphertext(ciphertext);
return Utils.serialise(struct);
}
}
| 4,136 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/thrift/SetupMessageStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.art.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class SetupMessageStruct implements org.apache.thrift.TBase<SetupMessageStruct, SetupMessageStruct._Fields>, java.io.Serializable, Cloneable, Comparable<SetupMessageStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SetupMessageStruct");
private static final org.apache.thrift.protocol.TField LEAF_NUM_FIELD_DESC = new org.apache.thrift.protocol.TField("leafNum", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField IDENTITIES_FIELD_DESC = new org.apache.thrift.protocol.TField("identities", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField EPHEMERAL_KEYS_FIELD_DESC = new org.apache.thrift.protocol.TField("ephemeralKeys", org.apache.thrift.protocol.TType.MAP, (short)3);
private static final org.apache.thrift.protocol.TField KEY_EXCHANGE_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("keyExchangeKey", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final org.apache.thrift.protocol.TField TREE_FIELD_DESC = new org.apache.thrift.protocol.TField("tree", org.apache.thrift.protocol.TType.STRUCT, (short)5);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new SetupMessageStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new SetupMessageStructTupleSchemeFactory();
public int leafNum; // required
public java.util.List<java.lang.String> identities; // required
public java.util.Map<java.lang.Integer,java.lang.String> ephemeralKeys; // required
public java.nio.ByteBuffer keyExchangeKey; // required
public NodeStruct tree; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
LEAF_NUM((short)1, "leafNum"),
IDENTITIES((short)2, "identities"),
EPHEMERAL_KEYS((short)3, "ephemeralKeys"),
KEY_EXCHANGE_KEY((short)4, "keyExchangeKey"),
TREE((short)5, "tree");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // LEAF_NUM
return LEAF_NUM;
case 2: // IDENTITIES
return IDENTITIES;
case 3: // EPHEMERAL_KEYS
return EPHEMERAL_KEYS;
case 4: // KEY_EXCHANGE_KEY
return KEY_EXCHANGE_KEY;
case 5: // TREE
return TREE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __LEAFNUM_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.LEAF_NUM, new org.apache.thrift.meta_data.FieldMetaData("leafNum", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.IDENTITIES, new org.apache.thrift.meta_data.FieldMetaData("identities", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
tmpMap.put(_Fields.EPHEMERAL_KEYS, new org.apache.thrift.meta_data.FieldMetaData("ephemeralKeys", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
tmpMap.put(_Fields.KEY_EXCHANGE_KEY, new org.apache.thrift.meta_data.FieldMetaData("keyExchangeKey", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.TREE, new org.apache.thrift.meta_data.FieldMetaData("tree", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "NodeStruct")));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SetupMessageStruct.class, metaDataMap);
}
public SetupMessageStruct() {
}
public SetupMessageStruct(
int leafNum,
java.util.List<java.lang.String> identities,
java.util.Map<java.lang.Integer,java.lang.String> ephemeralKeys,
java.nio.ByteBuffer keyExchangeKey,
NodeStruct tree)
{
this();
this.leafNum = leafNum;
setLeafNumIsSet(true);
this.identities = identities;
this.ephemeralKeys = ephemeralKeys;
this.keyExchangeKey = org.apache.thrift.TBaseHelper.copyBinary(keyExchangeKey);
this.tree = tree;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public SetupMessageStruct(SetupMessageStruct other) {
__isset_bitfield = other.__isset_bitfield;
this.leafNum = other.leafNum;
if (other.isSetIdentities()) {
java.util.List<java.lang.String> __this__identities = new java.util.ArrayList<java.lang.String>(other.identities);
this.identities = __this__identities;
}
if (other.isSetEphemeralKeys()) {
java.util.Map<java.lang.Integer,java.lang.String> __this__ephemeralKeys = new java.util.HashMap<java.lang.Integer,java.lang.String>(other.ephemeralKeys);
this.ephemeralKeys = __this__ephemeralKeys;
}
if (other.isSetKeyExchangeKey()) {
this.keyExchangeKey = org.apache.thrift.TBaseHelper.copyBinary(other.keyExchangeKey);
}
if (other.isSetTree()) {
this.tree = new NodeStruct(other.tree);
}
}
public SetupMessageStruct deepCopy() {
return new SetupMessageStruct(this);
}
@Override
public void clear() {
setLeafNumIsSet(false);
this.leafNum = 0;
this.identities = null;
this.ephemeralKeys = null;
this.keyExchangeKey = null;
this.tree = null;
}
public int getLeafNum() {
return this.leafNum;
}
public SetupMessageStruct setLeafNum(int leafNum) {
this.leafNum = leafNum;
setLeafNumIsSet(true);
return this;
}
public void unsetLeafNum() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __LEAFNUM_ISSET_ID);
}
/** Returns true if field leafNum is set (has been assigned a value) and false otherwise */
public boolean isSetLeafNum() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __LEAFNUM_ISSET_ID);
}
public void setLeafNumIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __LEAFNUM_ISSET_ID, value);
}
public int getIdentitiesSize() {
return (this.identities == null) ? 0 : this.identities.size();
}
public java.util.Iterator<java.lang.String> getIdentitiesIterator() {
return (this.identities == null) ? null : this.identities.iterator();
}
public void addToIdentities(java.lang.String elem) {
if (this.identities == null) {
this.identities = new java.util.ArrayList<java.lang.String>();
}
this.identities.add(elem);
}
public java.util.List<java.lang.String> getIdentities() {
return this.identities;
}
public SetupMessageStruct setIdentities(java.util.List<java.lang.String> identities) {
this.identities = identities;
return this;
}
public void unsetIdentities() {
this.identities = null;
}
/** Returns true if field identities is set (has been assigned a value) and false otherwise */
public boolean isSetIdentities() {
return this.identities != null;
}
public void setIdentitiesIsSet(boolean value) {
if (!value) {
this.identities = null;
}
}
public int getEphemeralKeysSize() {
return (this.ephemeralKeys == null) ? 0 : this.ephemeralKeys.size();
}
public void putToEphemeralKeys(int key, java.lang.String val) {
if (this.ephemeralKeys == null) {
this.ephemeralKeys = new java.util.HashMap<java.lang.Integer,java.lang.String>();
}
this.ephemeralKeys.put(key, val);
}
public java.util.Map<java.lang.Integer,java.lang.String> getEphemeralKeys() {
return this.ephemeralKeys;
}
public SetupMessageStruct setEphemeralKeys(java.util.Map<java.lang.Integer,java.lang.String> ephemeralKeys) {
this.ephemeralKeys = ephemeralKeys;
return this;
}
public void unsetEphemeralKeys() {
this.ephemeralKeys = null;
}
/** Returns true if field ephemeralKeys is set (has been assigned a value) and false otherwise */
public boolean isSetEphemeralKeys() {
return this.ephemeralKeys != null;
}
public void setEphemeralKeysIsSet(boolean value) {
if (!value) {
this.ephemeralKeys = null;
}
}
public byte[] getKeyExchangeKey() {
setKeyExchangeKey(org.apache.thrift.TBaseHelper.rightSize(keyExchangeKey));
return keyExchangeKey == null ? null : keyExchangeKey.array();
}
public java.nio.ByteBuffer bufferForKeyExchangeKey() {
return org.apache.thrift.TBaseHelper.copyBinary(keyExchangeKey);
}
public SetupMessageStruct setKeyExchangeKey(byte[] keyExchangeKey) {
this.keyExchangeKey = keyExchangeKey == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(keyExchangeKey.clone());
return this;
}
public SetupMessageStruct setKeyExchangeKey(java.nio.ByteBuffer keyExchangeKey) {
this.keyExchangeKey = org.apache.thrift.TBaseHelper.copyBinary(keyExchangeKey);
return this;
}
public void unsetKeyExchangeKey() {
this.keyExchangeKey = null;
}
/** Returns true if field keyExchangeKey is set (has been assigned a value) and false otherwise */
public boolean isSetKeyExchangeKey() {
return this.keyExchangeKey != null;
}
public void setKeyExchangeKeyIsSet(boolean value) {
if (!value) {
this.keyExchangeKey = null;
}
}
public NodeStruct getTree() {
return this.tree;
}
public SetupMessageStruct setTree(NodeStruct tree) {
this.tree = tree;
return this;
}
public void unsetTree() {
this.tree = null;
}
/** Returns true if field tree is set (has been assigned a value) and false otherwise */
public boolean isSetTree() {
return this.tree != null;
}
public void setTreeIsSet(boolean value) {
if (!value) {
this.tree = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case LEAF_NUM:
if (value == null) {
unsetLeafNum();
} else {
setLeafNum((java.lang.Integer)value);
}
break;
case IDENTITIES:
if (value == null) {
unsetIdentities();
} else {
setIdentities((java.util.List<java.lang.String>)value);
}
break;
case EPHEMERAL_KEYS:
if (value == null) {
unsetEphemeralKeys();
} else {
setEphemeralKeys((java.util.Map<java.lang.Integer,java.lang.String>)value);
}
break;
case KEY_EXCHANGE_KEY:
if (value == null) {
unsetKeyExchangeKey();
} else {
if (value instanceof byte[]) {
setKeyExchangeKey((byte[])value);
} else {
setKeyExchangeKey((java.nio.ByteBuffer)value);
}
}
break;
case TREE:
if (value == null) {
unsetTree();
} else {
setTree((NodeStruct)value);
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case LEAF_NUM:
return getLeafNum();
case IDENTITIES:
return getIdentities();
case EPHEMERAL_KEYS:
return getEphemeralKeys();
case KEY_EXCHANGE_KEY:
return getKeyExchangeKey();
case TREE:
return getTree();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case LEAF_NUM:
return isSetLeafNum();
case IDENTITIES:
return isSetIdentities();
case EPHEMERAL_KEYS:
return isSetEphemeralKeys();
case KEY_EXCHANGE_KEY:
return isSetKeyExchangeKey();
case TREE:
return isSetTree();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof SetupMessageStruct)
return this.equals((SetupMessageStruct)that);
return false;
}
public boolean equals(SetupMessageStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_leafNum = true;
boolean that_present_leafNum = true;
if (this_present_leafNum || that_present_leafNum) {
if (!(this_present_leafNum && that_present_leafNum))
return false;
if (this.leafNum != that.leafNum)
return false;
}
boolean this_present_identities = true && this.isSetIdentities();
boolean that_present_identities = true && that.isSetIdentities();
if (this_present_identities || that_present_identities) {
if (!(this_present_identities && that_present_identities))
return false;
if (!this.identities.equals(that.identities))
return false;
}
boolean this_present_ephemeralKeys = true && this.isSetEphemeralKeys();
boolean that_present_ephemeralKeys = true && that.isSetEphemeralKeys();
if (this_present_ephemeralKeys || that_present_ephemeralKeys) {
if (!(this_present_ephemeralKeys && that_present_ephemeralKeys))
return false;
if (!this.ephemeralKeys.equals(that.ephemeralKeys))
return false;
}
boolean this_present_keyExchangeKey = true && this.isSetKeyExchangeKey();
boolean that_present_keyExchangeKey = true && that.isSetKeyExchangeKey();
if (this_present_keyExchangeKey || that_present_keyExchangeKey) {
if (!(this_present_keyExchangeKey && that_present_keyExchangeKey))
return false;
if (!this.keyExchangeKey.equals(that.keyExchangeKey))
return false;
}
boolean this_present_tree = true && this.isSetTree();
boolean that_present_tree = true && that.isSetTree();
if (this_present_tree || that_present_tree) {
if (!(this_present_tree && that_present_tree))
return false;
if (!this.tree.equals(that.tree))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + leafNum;
hashCode = hashCode * 8191 + ((isSetIdentities()) ? 131071 : 524287);
if (isSetIdentities())
hashCode = hashCode * 8191 + identities.hashCode();
hashCode = hashCode * 8191 + ((isSetEphemeralKeys()) ? 131071 : 524287);
if (isSetEphemeralKeys())
hashCode = hashCode * 8191 + ephemeralKeys.hashCode();
hashCode = hashCode * 8191 + ((isSetKeyExchangeKey()) ? 131071 : 524287);
if (isSetKeyExchangeKey())
hashCode = hashCode * 8191 + keyExchangeKey.hashCode();
hashCode = hashCode * 8191 + ((isSetTree()) ? 131071 : 524287);
if (isSetTree())
hashCode = hashCode * 8191 + tree.hashCode();
return hashCode;
}
@Override
public int compareTo(SetupMessageStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetLeafNum()).compareTo(other.isSetLeafNum());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLeafNum()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.leafNum, other.leafNum);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetIdentities()).compareTo(other.isSetIdentities());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetIdentities()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.identities, other.identities);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetEphemeralKeys()).compareTo(other.isSetEphemeralKeys());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEphemeralKeys()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ephemeralKeys, other.ephemeralKeys);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetKeyExchangeKey()).compareTo(other.isSetKeyExchangeKey());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetKeyExchangeKey()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.keyExchangeKey, other.keyExchangeKey);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetTree()).compareTo(other.isSetTree());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTree()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tree, other.tree);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("SetupMessageStruct(");
boolean first = true;
sb.append("leafNum:");
sb.append(this.leafNum);
first = false;
if (!first) sb.append(", ");
sb.append("identities:");
if (this.identities == null) {
sb.append("null");
} else {
sb.append(this.identities);
}
first = false;
if (!first) sb.append(", ");
sb.append("ephemeralKeys:");
if (this.ephemeralKeys == null) {
sb.append("null");
} else {
sb.append(this.ephemeralKeys);
}
first = false;
if (!first) sb.append(", ");
sb.append("keyExchangeKey:");
if (this.keyExchangeKey == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.keyExchangeKey, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("tree:");
if (this.tree == null) {
sb.append("null");
} else {
sb.append(this.tree);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class SetupMessageStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public SetupMessageStructStandardScheme getScheme() {
return new SetupMessageStructStandardScheme();
}
}
private static class SetupMessageStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<SetupMessageStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, SetupMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // LEAF_NUM
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.leafNum = iprot.readI32();
struct.setLeafNumIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // IDENTITIES
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
struct.identities = new java.util.ArrayList<java.lang.String>(_list0.size);
java.lang.String _elem1;
for (int _i2 = 0; _i2 < _list0.size; ++_i2)
{
_elem1 = iprot.readString();
struct.identities.add(_elem1);
}
iprot.readListEnd();
}
struct.setIdentitiesIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // EPHEMERAL_KEYS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map3 = iprot.readMapBegin();
struct.ephemeralKeys = new java.util.HashMap<java.lang.Integer,java.lang.String>(2*_map3.size);
int _key4;
java.lang.String _val5;
for (int _i6 = 0; _i6 < _map3.size; ++_i6)
{
_key4 = iprot.readI32();
_val5 = iprot.readString();
struct.ephemeralKeys.put(_key4, _val5);
}
iprot.readMapEnd();
}
struct.setEphemeralKeysIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // KEY_EXCHANGE_KEY
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.keyExchangeKey = iprot.readBinary();
struct.setKeyExchangeKeyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // TREE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.tree = new NodeStruct();
struct.tree.read(iprot);
struct.setTreeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, SetupMessageStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(LEAF_NUM_FIELD_DESC);
oprot.writeI32(struct.leafNum);
oprot.writeFieldEnd();
if (struct.identities != null) {
oprot.writeFieldBegin(IDENTITIES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.identities.size()));
for (java.lang.String _iter7 : struct.identities)
{
oprot.writeString(_iter7);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
if (struct.ephemeralKeys != null) {
oprot.writeFieldBegin(EPHEMERAL_KEYS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRING, struct.ephemeralKeys.size()));
for (java.util.Map.Entry<java.lang.Integer, java.lang.String> _iter8 : struct.ephemeralKeys.entrySet())
{
oprot.writeI32(_iter8.getKey());
oprot.writeString(_iter8.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
if (struct.keyExchangeKey != null) {
oprot.writeFieldBegin(KEY_EXCHANGE_KEY_FIELD_DESC);
oprot.writeBinary(struct.keyExchangeKey);
oprot.writeFieldEnd();
}
if (struct.tree != null) {
oprot.writeFieldBegin(TREE_FIELD_DESC);
struct.tree.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class SetupMessageStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public SetupMessageStructTupleScheme getScheme() {
return new SetupMessageStructTupleScheme();
}
}
private static class SetupMessageStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<SetupMessageStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, SetupMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetLeafNum()) {
optionals.set(0);
}
if (struct.isSetIdentities()) {
optionals.set(1);
}
if (struct.isSetEphemeralKeys()) {
optionals.set(2);
}
if (struct.isSetKeyExchangeKey()) {
optionals.set(3);
}
if (struct.isSetTree()) {
optionals.set(4);
}
oprot.writeBitSet(optionals, 5);
if (struct.isSetLeafNum()) {
oprot.writeI32(struct.leafNum);
}
if (struct.isSetIdentities()) {
{
oprot.writeI32(struct.identities.size());
for (java.lang.String _iter9 : struct.identities)
{
oprot.writeString(_iter9);
}
}
}
if (struct.isSetEphemeralKeys()) {
{
oprot.writeI32(struct.ephemeralKeys.size());
for (java.util.Map.Entry<java.lang.Integer, java.lang.String> _iter10 : struct.ephemeralKeys.entrySet())
{
oprot.writeI32(_iter10.getKey());
oprot.writeString(_iter10.getValue());
}
}
}
if (struct.isSetKeyExchangeKey()) {
oprot.writeBinary(struct.keyExchangeKey);
}
if (struct.isSetTree()) {
struct.tree.write(oprot);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, SetupMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(5);
if (incoming.get(0)) {
struct.leafNum = iprot.readI32();
struct.setLeafNumIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TList _list11 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.identities = new java.util.ArrayList<java.lang.String>(_list11.size);
java.lang.String _elem12;
for (int _i13 = 0; _i13 < _list11.size; ++_i13)
{
_elem12 = iprot.readString();
struct.identities.add(_elem12);
}
}
struct.setIdentitiesIsSet(true);
}
if (incoming.get(2)) {
{
org.apache.thrift.protocol.TMap _map14 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.ephemeralKeys = new java.util.HashMap<java.lang.Integer,java.lang.String>(2*_map14.size);
int _key15;
java.lang.String _val16;
for (int _i17 = 0; _i17 < _map14.size; ++_i17)
{
_key15 = iprot.readI32();
_val16 = iprot.readString();
struct.ephemeralKeys.put(_key15, _val16);
}
}
struct.setEphemeralKeysIsSet(true);
}
if (incoming.get(3)) {
struct.keyExchangeKey = iprot.readBinary();
struct.setKeyExchangeKeyIsSet(true);
}
if (incoming.get(4)) {
struct.tree = new NodeStruct();
struct.tree.read(iprot);
struct.setTreeIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,137 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/thrift/CiphertextMessageStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.art.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class CiphertextMessageStruct implements org.apache.thrift.TBase<CiphertextMessageStruct, CiphertextMessageStruct._Fields>, java.io.Serializable, Cloneable, Comparable<CiphertextMessageStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CiphertextMessageStruct");
private static final org.apache.thrift.protocol.TField AUTHENTICATED_MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("authenticatedMessage", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField CIPHERTEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("ciphertext", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new CiphertextMessageStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new CiphertextMessageStructTupleSchemeFactory();
public AuthenticatedMessageStruct authenticatedMessage; // required
public java.nio.ByteBuffer ciphertext; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
AUTHENTICATED_MESSAGE((short)1, "authenticatedMessage"),
CIPHERTEXT((short)2, "ciphertext");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // AUTHENTICATED_MESSAGE
return AUTHENTICATED_MESSAGE;
case 2: // CIPHERTEXT
return CIPHERTEXT;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.AUTHENTICATED_MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("authenticatedMessage", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "AuthenticatedMessageStruct")));
tmpMap.put(_Fields.CIPHERTEXT, new org.apache.thrift.meta_data.FieldMetaData("ciphertext", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CiphertextMessageStruct.class, metaDataMap);
}
public CiphertextMessageStruct() {
}
public CiphertextMessageStruct(
AuthenticatedMessageStruct authenticatedMessage,
java.nio.ByteBuffer ciphertext)
{
this();
this.authenticatedMessage = authenticatedMessage;
this.ciphertext = org.apache.thrift.TBaseHelper.copyBinary(ciphertext);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public CiphertextMessageStruct(CiphertextMessageStruct other) {
if (other.isSetAuthenticatedMessage()) {
this.authenticatedMessage = new AuthenticatedMessageStruct(other.authenticatedMessage);
}
if (other.isSetCiphertext()) {
this.ciphertext = org.apache.thrift.TBaseHelper.copyBinary(other.ciphertext);
}
}
public CiphertextMessageStruct deepCopy() {
return new CiphertextMessageStruct(this);
}
@Override
public void clear() {
this.authenticatedMessage = null;
this.ciphertext = null;
}
public AuthenticatedMessageStruct getAuthenticatedMessage() {
return this.authenticatedMessage;
}
public CiphertextMessageStruct setAuthenticatedMessage(AuthenticatedMessageStruct authenticatedMessage) {
this.authenticatedMessage = authenticatedMessage;
return this;
}
public void unsetAuthenticatedMessage() {
this.authenticatedMessage = null;
}
/** Returns true if field authenticatedMessage is set (has been assigned a value) and false otherwise */
public boolean isSetAuthenticatedMessage() {
return this.authenticatedMessage != null;
}
public void setAuthenticatedMessageIsSet(boolean value) {
if (!value) {
this.authenticatedMessage = null;
}
}
public byte[] getCiphertext() {
setCiphertext(org.apache.thrift.TBaseHelper.rightSize(ciphertext));
return ciphertext == null ? null : ciphertext.array();
}
public java.nio.ByteBuffer bufferForCiphertext() {
return org.apache.thrift.TBaseHelper.copyBinary(ciphertext);
}
public CiphertextMessageStruct setCiphertext(byte[] ciphertext) {
this.ciphertext = ciphertext == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(ciphertext.clone());
return this;
}
public CiphertextMessageStruct setCiphertext(java.nio.ByteBuffer ciphertext) {
this.ciphertext = org.apache.thrift.TBaseHelper.copyBinary(ciphertext);
return this;
}
public void unsetCiphertext() {
this.ciphertext = null;
}
/** Returns true if field ciphertext is set (has been assigned a value) and false otherwise */
public boolean isSetCiphertext() {
return this.ciphertext != null;
}
public void setCiphertextIsSet(boolean value) {
if (!value) {
this.ciphertext = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case AUTHENTICATED_MESSAGE:
if (value == null) {
unsetAuthenticatedMessage();
} else {
setAuthenticatedMessage((AuthenticatedMessageStruct)value);
}
break;
case CIPHERTEXT:
if (value == null) {
unsetCiphertext();
} else {
if (value instanceof byte[]) {
setCiphertext((byte[])value);
} else {
setCiphertext((java.nio.ByteBuffer)value);
}
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case AUTHENTICATED_MESSAGE:
return getAuthenticatedMessage();
case CIPHERTEXT:
return getCiphertext();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case AUTHENTICATED_MESSAGE:
return isSetAuthenticatedMessage();
case CIPHERTEXT:
return isSetCiphertext();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof CiphertextMessageStruct)
return this.equals((CiphertextMessageStruct)that);
return false;
}
public boolean equals(CiphertextMessageStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_authenticatedMessage = true && this.isSetAuthenticatedMessage();
boolean that_present_authenticatedMessage = true && that.isSetAuthenticatedMessage();
if (this_present_authenticatedMessage || that_present_authenticatedMessage) {
if (!(this_present_authenticatedMessage && that_present_authenticatedMessage))
return false;
if (!this.authenticatedMessage.equals(that.authenticatedMessage))
return false;
}
boolean this_present_ciphertext = true && this.isSetCiphertext();
boolean that_present_ciphertext = true && that.isSetCiphertext();
if (this_present_ciphertext || that_present_ciphertext) {
if (!(this_present_ciphertext && that_present_ciphertext))
return false;
if (!this.ciphertext.equals(that.ciphertext))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetAuthenticatedMessage()) ? 131071 : 524287);
if (isSetAuthenticatedMessage())
hashCode = hashCode * 8191 + authenticatedMessage.hashCode();
hashCode = hashCode * 8191 + ((isSetCiphertext()) ? 131071 : 524287);
if (isSetCiphertext())
hashCode = hashCode * 8191 + ciphertext.hashCode();
return hashCode;
}
@Override
public int compareTo(CiphertextMessageStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetAuthenticatedMessage()).compareTo(other.isSetAuthenticatedMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetAuthenticatedMessage()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authenticatedMessage, other.authenticatedMessage);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetCiphertext()).compareTo(other.isSetCiphertext());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCiphertext()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ciphertext, other.ciphertext);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("CiphertextMessageStruct(");
boolean first = true;
sb.append("authenticatedMessage:");
if (this.authenticatedMessage == null) {
sb.append("null");
} else {
sb.append(this.authenticatedMessage);
}
first = false;
if (!first) sb.append(", ");
sb.append("ciphertext:");
if (this.ciphertext == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.ciphertext, sb);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class CiphertextMessageStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public CiphertextMessageStructStandardScheme getScheme() {
return new CiphertextMessageStructStandardScheme();
}
}
private static class CiphertextMessageStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<CiphertextMessageStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, CiphertextMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // AUTHENTICATED_MESSAGE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.authenticatedMessage = new AuthenticatedMessageStruct();
struct.authenticatedMessage.read(iprot);
struct.setAuthenticatedMessageIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // CIPHERTEXT
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.ciphertext = iprot.readBinary();
struct.setCiphertextIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, CiphertextMessageStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.authenticatedMessage != null) {
oprot.writeFieldBegin(AUTHENTICATED_MESSAGE_FIELD_DESC);
struct.authenticatedMessage.write(oprot);
oprot.writeFieldEnd();
}
if (struct.ciphertext != null) {
oprot.writeFieldBegin(CIPHERTEXT_FIELD_DESC);
oprot.writeBinary(struct.ciphertext);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class CiphertextMessageStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public CiphertextMessageStructTupleScheme getScheme() {
return new CiphertextMessageStructTupleScheme();
}
}
private static class CiphertextMessageStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<CiphertextMessageStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, CiphertextMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetAuthenticatedMessage()) {
optionals.set(0);
}
if (struct.isSetCiphertext()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetAuthenticatedMessage()) {
struct.authenticatedMessage.write(oprot);
}
if (struct.isSetCiphertext()) {
oprot.writeBinary(struct.ciphertext);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, CiphertextMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.authenticatedMessage = new AuthenticatedMessageStruct();
struct.authenticatedMessage.read(iprot);
struct.setAuthenticatedMessageIsSet(true);
}
if (incoming.get(1)) {
struct.ciphertext = iprot.readBinary();
struct.setCiphertextIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,138 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/thrift/NodeStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.art.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class NodeStruct implements org.apache.thrift.TBase<NodeStruct, NodeStruct._Fields>, java.io.Serializable, Cloneable, Comparable<NodeStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("NodeStruct");
private static final org.apache.thrift.protocol.TField PUBLIC_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("publicKey", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField LEFT_FIELD_DESC = new org.apache.thrift.protocol.TField("left", org.apache.thrift.protocol.TType.STRUCT, (short)2);
private static final org.apache.thrift.protocol.TField RIGHT_FIELD_DESC = new org.apache.thrift.protocol.TField("right", org.apache.thrift.protocol.TType.STRUCT, (short)3);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new NodeStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new NodeStructTupleSchemeFactory();
public java.nio.ByteBuffer publicKey; // required
public NodeStruct left; // optional
public NodeStruct right; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
PUBLIC_KEY((short)1, "publicKey"),
LEFT((short)2, "left"),
RIGHT((short)3, "right");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // PUBLIC_KEY
return PUBLIC_KEY;
case 2: // LEFT
return LEFT;
case 3: // RIGHT
return RIGHT;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.LEFT,_Fields.RIGHT};
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.PUBLIC_KEY, new org.apache.thrift.meta_data.FieldMetaData("publicKey", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.LEFT, new org.apache.thrift.meta_data.FieldMetaData("left", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "NodeStruct")));
tmpMap.put(_Fields.RIGHT, new org.apache.thrift.meta_data.FieldMetaData("right", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "NodeStruct")));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(NodeStruct.class, metaDataMap);
}
public NodeStruct() {
}
public NodeStruct(
java.nio.ByteBuffer publicKey)
{
this();
this.publicKey = org.apache.thrift.TBaseHelper.copyBinary(publicKey);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public NodeStruct(NodeStruct other) {
if (other.isSetPublicKey()) {
this.publicKey = org.apache.thrift.TBaseHelper.copyBinary(other.publicKey);
}
if (other.isSetLeft()) {
this.left = new NodeStruct(other.left);
}
if (other.isSetRight()) {
this.right = new NodeStruct(other.right);
}
}
public NodeStruct deepCopy() {
return new NodeStruct(this);
}
@Override
public void clear() {
this.publicKey = null;
this.left = null;
this.right = null;
}
public byte[] getPublicKey() {
setPublicKey(org.apache.thrift.TBaseHelper.rightSize(publicKey));
return publicKey == null ? null : publicKey.array();
}
public java.nio.ByteBuffer bufferForPublicKey() {
return org.apache.thrift.TBaseHelper.copyBinary(publicKey);
}
public NodeStruct setPublicKey(byte[] publicKey) {
this.publicKey = publicKey == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(publicKey.clone());
return this;
}
public NodeStruct setPublicKey(java.nio.ByteBuffer publicKey) {
this.publicKey = org.apache.thrift.TBaseHelper.copyBinary(publicKey);
return this;
}
public void unsetPublicKey() {
this.publicKey = null;
}
/** Returns true if field publicKey is set (has been assigned a value) and false otherwise */
public boolean isSetPublicKey() {
return this.publicKey != null;
}
public void setPublicKeyIsSet(boolean value) {
if (!value) {
this.publicKey = null;
}
}
public NodeStruct getLeft() {
return this.left;
}
public NodeStruct setLeft(NodeStruct left) {
this.left = left;
return this;
}
public void unsetLeft() {
this.left = null;
}
/** Returns true if field left is set (has been assigned a value) and false otherwise */
public boolean isSetLeft() {
return this.left != null;
}
public void setLeftIsSet(boolean value) {
if (!value) {
this.left = null;
}
}
public NodeStruct getRight() {
return this.right;
}
public NodeStruct setRight(NodeStruct right) {
this.right = right;
return this;
}
public void unsetRight() {
this.right = null;
}
/** Returns true if field right is set (has been assigned a value) and false otherwise */
public boolean isSetRight() {
return this.right != null;
}
public void setRightIsSet(boolean value) {
if (!value) {
this.right = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case PUBLIC_KEY:
if (value == null) {
unsetPublicKey();
} else {
if (value instanceof byte[]) {
setPublicKey((byte[])value);
} else {
setPublicKey((java.nio.ByteBuffer)value);
}
}
break;
case LEFT:
if (value == null) {
unsetLeft();
} else {
setLeft((NodeStruct)value);
}
break;
case RIGHT:
if (value == null) {
unsetRight();
} else {
setRight((NodeStruct)value);
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case PUBLIC_KEY:
return getPublicKey();
case LEFT:
return getLeft();
case RIGHT:
return getRight();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case PUBLIC_KEY:
return isSetPublicKey();
case LEFT:
return isSetLeft();
case RIGHT:
return isSetRight();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof NodeStruct)
return this.equals((NodeStruct)that);
return false;
}
public boolean equals(NodeStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_publicKey = true && this.isSetPublicKey();
boolean that_present_publicKey = true && that.isSetPublicKey();
if (this_present_publicKey || that_present_publicKey) {
if (!(this_present_publicKey && that_present_publicKey))
return false;
if (!this.publicKey.equals(that.publicKey))
return false;
}
boolean this_present_left = true && this.isSetLeft();
boolean that_present_left = true && that.isSetLeft();
if (this_present_left || that_present_left) {
if (!(this_present_left && that_present_left))
return false;
if (!this.left.equals(that.left))
return false;
}
boolean this_present_right = true && this.isSetRight();
boolean that_present_right = true && that.isSetRight();
if (this_present_right || that_present_right) {
if (!(this_present_right && that_present_right))
return false;
if (!this.right.equals(that.right))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetPublicKey()) ? 131071 : 524287);
if (isSetPublicKey())
hashCode = hashCode * 8191 + publicKey.hashCode();
hashCode = hashCode * 8191 + ((isSetLeft()) ? 131071 : 524287);
if (isSetLeft())
hashCode = hashCode * 8191 + left.hashCode();
hashCode = hashCode * 8191 + ((isSetRight()) ? 131071 : 524287);
if (isSetRight())
hashCode = hashCode * 8191 + right.hashCode();
return hashCode;
}
@Override
public int compareTo(NodeStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetPublicKey()).compareTo(other.isSetPublicKey());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPublicKey()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.publicKey, other.publicKey);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetLeft()).compareTo(other.isSetLeft());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLeft()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.left, other.left);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetRight()).compareTo(other.isSetRight());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRight()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.right, other.right);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("NodeStruct(");
boolean first = true;
sb.append("publicKey:");
if (this.publicKey == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.publicKey, sb);
}
first = false;
if (isSetLeft()) {
if (!first) sb.append(", ");
sb.append("left:");
if (this.left == null) {
sb.append("null");
} else {
sb.append(this.left);
}
first = false;
}
if (isSetRight()) {
if (!first) sb.append(", ");
sb.append("right:");
if (this.right == null) {
sb.append("null");
} else {
sb.append(this.right);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class NodeStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public NodeStructStandardScheme getScheme() {
return new NodeStructStandardScheme();
}
}
private static class NodeStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<NodeStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, NodeStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // PUBLIC_KEY
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.publicKey = iprot.readBinary();
struct.setPublicKeyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // LEFT
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.left = new NodeStruct();
struct.left.read(iprot);
struct.setLeftIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // RIGHT
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.right = new NodeStruct();
struct.right.read(iprot);
struct.setRightIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, NodeStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.publicKey != null) {
oprot.writeFieldBegin(PUBLIC_KEY_FIELD_DESC);
oprot.writeBinary(struct.publicKey);
oprot.writeFieldEnd();
}
if (struct.left != null) {
if (struct.isSetLeft()) {
oprot.writeFieldBegin(LEFT_FIELD_DESC);
struct.left.write(oprot);
oprot.writeFieldEnd();
}
}
if (struct.right != null) {
if (struct.isSetRight()) {
oprot.writeFieldBegin(RIGHT_FIELD_DESC);
struct.right.write(oprot);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class NodeStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public NodeStructTupleScheme getScheme() {
return new NodeStructTupleScheme();
}
}
private static class NodeStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<NodeStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, NodeStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetPublicKey()) {
optionals.set(0);
}
if (struct.isSetLeft()) {
optionals.set(1);
}
if (struct.isSetRight()) {
optionals.set(2);
}
oprot.writeBitSet(optionals, 3);
if (struct.isSetPublicKey()) {
oprot.writeBinary(struct.publicKey);
}
if (struct.isSetLeft()) {
struct.left.write(oprot);
}
if (struct.isSetRight()) {
struct.right.write(oprot);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, NodeStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
struct.publicKey = iprot.readBinary();
struct.setPublicKeyIsSet(true);
}
if (incoming.get(1)) {
struct.left = new NodeStruct();
struct.left.read(iprot);
struct.setLeftIsSet(true);
}
if (incoming.get(2)) {
struct.right = new NodeStruct();
struct.right.read(iprot);
struct.setRightIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,139 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/thrift/UpdateMessageStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.art.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class UpdateMessageStruct implements org.apache.thrift.TBase<UpdateMessageStruct, UpdateMessageStruct._Fields>, java.io.Serializable, Cloneable, Comparable<UpdateMessageStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UpdateMessageStruct");
private static final org.apache.thrift.protocol.TField LEAF_NUM_FIELD_DESC = new org.apache.thrift.protocol.TField("leafNum", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("path", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UpdateMessageStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UpdateMessageStructTupleSchemeFactory();
public int leafNum; // required
public java.util.List<java.lang.String> path; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
LEAF_NUM((short)1, "leafNum"),
PATH((short)2, "path");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // LEAF_NUM
return LEAF_NUM;
case 2: // PATH
return PATH;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __LEAFNUM_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.LEAF_NUM, new org.apache.thrift.meta_data.FieldMetaData("leafNum", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.PATH, new org.apache.thrift.meta_data.FieldMetaData("path", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UpdateMessageStruct.class, metaDataMap);
}
public UpdateMessageStruct() {
}
public UpdateMessageStruct(
int leafNum,
java.util.List<java.lang.String> path)
{
this();
this.leafNum = leafNum;
setLeafNumIsSet(true);
this.path = path;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public UpdateMessageStruct(UpdateMessageStruct other) {
__isset_bitfield = other.__isset_bitfield;
this.leafNum = other.leafNum;
if (other.isSetPath()) {
java.util.List<java.lang.String> __this__path = new java.util.ArrayList<java.lang.String>(other.path);
this.path = __this__path;
}
}
public UpdateMessageStruct deepCopy() {
return new UpdateMessageStruct(this);
}
@Override
public void clear() {
setLeafNumIsSet(false);
this.leafNum = 0;
this.path = null;
}
public int getLeafNum() {
return this.leafNum;
}
public UpdateMessageStruct setLeafNum(int leafNum) {
this.leafNum = leafNum;
setLeafNumIsSet(true);
return this;
}
public void unsetLeafNum() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __LEAFNUM_ISSET_ID);
}
/** Returns true if field leafNum is set (has been assigned a value) and false otherwise */
public boolean isSetLeafNum() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __LEAFNUM_ISSET_ID);
}
public void setLeafNumIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __LEAFNUM_ISSET_ID, value);
}
public int getPathSize() {
return (this.path == null) ? 0 : this.path.size();
}
public java.util.Iterator<java.lang.String> getPathIterator() {
return (this.path == null) ? null : this.path.iterator();
}
public void addToPath(java.lang.String elem) {
if (this.path == null) {
this.path = new java.util.ArrayList<java.lang.String>();
}
this.path.add(elem);
}
public java.util.List<java.lang.String> getPath() {
return this.path;
}
public UpdateMessageStruct setPath(java.util.List<java.lang.String> path) {
this.path = path;
return this;
}
public void unsetPath() {
this.path = null;
}
/** Returns true if field path is set (has been assigned a value) and false otherwise */
public boolean isSetPath() {
return this.path != null;
}
public void setPathIsSet(boolean value) {
if (!value) {
this.path = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case LEAF_NUM:
if (value == null) {
unsetLeafNum();
} else {
setLeafNum((java.lang.Integer)value);
}
break;
case PATH:
if (value == null) {
unsetPath();
} else {
setPath((java.util.List<java.lang.String>)value);
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case LEAF_NUM:
return getLeafNum();
case PATH:
return getPath();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case LEAF_NUM:
return isSetLeafNum();
case PATH:
return isSetPath();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof UpdateMessageStruct)
return this.equals((UpdateMessageStruct)that);
return false;
}
public boolean equals(UpdateMessageStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_leafNum = true;
boolean that_present_leafNum = true;
if (this_present_leafNum || that_present_leafNum) {
if (!(this_present_leafNum && that_present_leafNum))
return false;
if (this.leafNum != that.leafNum)
return false;
}
boolean this_present_path = true && this.isSetPath();
boolean that_present_path = true && that.isSetPath();
if (this_present_path || that_present_path) {
if (!(this_present_path && that_present_path))
return false;
if (!this.path.equals(that.path))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + leafNum;
hashCode = hashCode * 8191 + ((isSetPath()) ? 131071 : 524287);
if (isSetPath())
hashCode = hashCode * 8191 + path.hashCode();
return hashCode;
}
@Override
public int compareTo(UpdateMessageStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetLeafNum()).compareTo(other.isSetLeafNum());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLeafNum()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.leafNum, other.leafNum);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetPath()).compareTo(other.isSetPath());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPath()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.path, other.path);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("UpdateMessageStruct(");
boolean first = true;
sb.append("leafNum:");
sb.append(this.leafNum);
first = false;
if (!first) sb.append(", ");
sb.append("path:");
if (this.path == null) {
sb.append("null");
} else {
sb.append(this.path);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class UpdateMessageStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public UpdateMessageStructStandardScheme getScheme() {
return new UpdateMessageStructStandardScheme();
}
}
private static class UpdateMessageStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<UpdateMessageStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, UpdateMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // LEAF_NUM
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.leafNum = iprot.readI32();
struct.setLeafNumIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // PATH
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list18 = iprot.readListBegin();
struct.path = new java.util.ArrayList<java.lang.String>(_list18.size);
java.lang.String _elem19;
for (int _i20 = 0; _i20 < _list18.size; ++_i20)
{
_elem19 = iprot.readString();
struct.path.add(_elem19);
}
iprot.readListEnd();
}
struct.setPathIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, UpdateMessageStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(LEAF_NUM_FIELD_DESC);
oprot.writeI32(struct.leafNum);
oprot.writeFieldEnd();
if (struct.path != null) {
oprot.writeFieldBegin(PATH_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.path.size()));
for (java.lang.String _iter21 : struct.path)
{
oprot.writeString(_iter21);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class UpdateMessageStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public UpdateMessageStructTupleScheme getScheme() {
return new UpdateMessageStructTupleScheme();
}
}
private static class UpdateMessageStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<UpdateMessageStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, UpdateMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetLeafNum()) {
optionals.set(0);
}
if (struct.isSetPath()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetLeafNum()) {
oprot.writeI32(struct.leafNum);
}
if (struct.isSetPath()) {
{
oprot.writeI32(struct.path.size());
for (java.lang.String _iter22 : struct.path)
{
oprot.writeString(_iter22);
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, UpdateMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.leafNum = iprot.readI32();
struct.setLeafNumIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TList _list23 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.path = new java.util.ArrayList<java.lang.String>(_list23.size);
java.lang.String _elem24;
for (int _i25 = 0; _i25 < _list23.size; ++_i25)
{
_elem24 = iprot.readString();
struct.path.add(_elem24);
}
}
struct.setPathIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,140 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/art/message/thrift/AuthenticatedMessageStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.art.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class AuthenticatedMessageStruct implements org.apache.thrift.TBase<AuthenticatedMessageStruct, AuthenticatedMessageStruct._Fields>, java.io.Serializable, Cloneable, Comparable<AuthenticatedMessageStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthenticatedMessageStruct");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField AUTHENTICATOR_FIELD_DESC = new org.apache.thrift.protocol.TField("authenticator", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new AuthenticatedMessageStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new AuthenticatedMessageStructTupleSchemeFactory();
public java.nio.ByteBuffer message; // required
public java.nio.ByteBuffer authenticator; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short)1, "message"),
AUTHENTICATOR((short)2, "authenticator");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // MESSAGE
return MESSAGE;
case 2: // AUTHENTICATOR
return AUTHENTICATOR;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.AUTHENTICATOR, new org.apache.thrift.meta_data.FieldMetaData("authenticator", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthenticatedMessageStruct.class, metaDataMap);
}
public AuthenticatedMessageStruct() {
}
public AuthenticatedMessageStruct(
java.nio.ByteBuffer message,
java.nio.ByteBuffer authenticator)
{
this();
this.message = org.apache.thrift.TBaseHelper.copyBinary(message);
this.authenticator = org.apache.thrift.TBaseHelper.copyBinary(authenticator);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public AuthenticatedMessageStruct(AuthenticatedMessageStruct other) {
if (other.isSetMessage()) {
this.message = org.apache.thrift.TBaseHelper.copyBinary(other.message);
}
if (other.isSetAuthenticator()) {
this.authenticator = org.apache.thrift.TBaseHelper.copyBinary(other.authenticator);
}
}
public AuthenticatedMessageStruct deepCopy() {
return new AuthenticatedMessageStruct(this);
}
@Override
public void clear() {
this.message = null;
this.authenticator = null;
}
public byte[] getMessage() {
setMessage(org.apache.thrift.TBaseHelper.rightSize(message));
return message == null ? null : message.array();
}
public java.nio.ByteBuffer bufferForMessage() {
return org.apache.thrift.TBaseHelper.copyBinary(message);
}
public AuthenticatedMessageStruct setMessage(byte[] message) {
this.message = message == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(message.clone());
return this;
}
public AuthenticatedMessageStruct setMessage(java.nio.ByteBuffer message) {
this.message = org.apache.thrift.TBaseHelper.copyBinary(message);
return this;
}
public void unsetMessage() {
this.message = null;
}
/** Returns true if field message is set (has been assigned a value) and false otherwise */
public boolean isSetMessage() {
return this.message != null;
}
public void setMessageIsSet(boolean value) {
if (!value) {
this.message = null;
}
}
public byte[] getAuthenticator() {
setAuthenticator(org.apache.thrift.TBaseHelper.rightSize(authenticator));
return authenticator == null ? null : authenticator.array();
}
public java.nio.ByteBuffer bufferForAuthenticator() {
return org.apache.thrift.TBaseHelper.copyBinary(authenticator);
}
public AuthenticatedMessageStruct setAuthenticator(byte[] authenticator) {
this.authenticator = authenticator == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(authenticator.clone());
return this;
}
public AuthenticatedMessageStruct setAuthenticator(java.nio.ByteBuffer authenticator) {
this.authenticator = org.apache.thrift.TBaseHelper.copyBinary(authenticator);
return this;
}
public void unsetAuthenticator() {
this.authenticator = null;
}
/** Returns true if field authenticator is set (has been assigned a value) and false otherwise */
public boolean isSetAuthenticator() {
return this.authenticator != null;
}
public void setAuthenticatorIsSet(boolean value) {
if (!value) {
this.authenticator = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
if (value instanceof byte[]) {
setMessage((byte[])value);
} else {
setMessage((java.nio.ByteBuffer)value);
}
}
break;
case AUTHENTICATOR:
if (value == null) {
unsetAuthenticator();
} else {
if (value instanceof byte[]) {
setAuthenticator((byte[])value);
} else {
setAuthenticator((java.nio.ByteBuffer)value);
}
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
case AUTHENTICATOR:
return getAuthenticator();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case MESSAGE:
return isSetMessage();
case AUTHENTICATOR:
return isSetAuthenticator();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof AuthenticatedMessageStruct)
return this.equals((AuthenticatedMessageStruct)that);
return false;
}
public boolean equals(AuthenticatedMessageStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_message = true && this.isSetMessage();
boolean that_present_message = true && that.isSetMessage();
if (this_present_message || that_present_message) {
if (!(this_present_message && that_present_message))
return false;
if (!this.message.equals(that.message))
return false;
}
boolean this_present_authenticator = true && this.isSetAuthenticator();
boolean that_present_authenticator = true && that.isSetAuthenticator();
if (this_present_authenticator || that_present_authenticator) {
if (!(this_present_authenticator && that_present_authenticator))
return false;
if (!this.authenticator.equals(that.authenticator))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
if (isSetMessage())
hashCode = hashCode * 8191 + message.hashCode();
hashCode = hashCode * 8191 + ((isSetAuthenticator()) ? 131071 : 524287);
if (isSetAuthenticator())
hashCode = hashCode * 8191 + authenticator.hashCode();
return hashCode;
}
@Override
public int compareTo(AuthenticatedMessageStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessage()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetAuthenticator()).compareTo(other.isSetAuthenticator());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetAuthenticator()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authenticator, other.authenticator);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("AuthenticatedMessageStruct(");
boolean first = true;
sb.append("message:");
if (this.message == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.message, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("authenticator:");
if (this.authenticator == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.authenticator, sb);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class AuthenticatedMessageStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public AuthenticatedMessageStructStandardScheme getScheme() {
return new AuthenticatedMessageStructStandardScheme();
}
}
private static class AuthenticatedMessageStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<AuthenticatedMessageStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, AuthenticatedMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // MESSAGE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.message = iprot.readBinary();
struct.setMessageIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // AUTHENTICATOR
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.authenticator = iprot.readBinary();
struct.setAuthenticatorIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, AuthenticatedMessageStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.message != null) {
oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
oprot.writeBinary(struct.message);
oprot.writeFieldEnd();
}
if (struct.authenticator != null) {
oprot.writeFieldBegin(AUTHENTICATOR_FIELD_DESC);
oprot.writeBinary(struct.authenticator);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class AuthenticatedMessageStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public AuthenticatedMessageStructTupleScheme getScheme() {
return new AuthenticatedMessageStructTupleScheme();
}
}
private static class AuthenticatedMessageStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<AuthenticatedMessageStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, AuthenticatedMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetMessage()) {
optionals.set(0);
}
if (struct.isSetAuthenticator()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetMessage()) {
oprot.writeBinary(struct.message);
}
if (struct.isSetAuthenticator()) {
oprot.writeBinary(struct.authenticator);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, AuthenticatedMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.message = iprot.readBinary();
struct.setMessageIsSet(true);
}
if (incoming.get(1)) {
struct.authenticator = iprot.readBinary();
struct.setAuthenticatorIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,141 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/DHRatchetState.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingState;
import com.facebook.research.asynchronousratchetingtree.crypto.Crypto;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public class DHRatchetState extends GroupMessagingState {
private byte[][] rootKeys;
private DHKeyPair[] selfRatchetKeys;
private DHPubKey[] remoteRatchetKeys;
private boolean[] ratchetFlags;
private boolean[] isSetup;
public DHRatchetState(int peerNum, int peerCount) {
super(peerNum, peerCount);
rootKeys = new byte[peerCount][];
selfRatchetKeys = new DHKeyPair[peerCount];
remoteRatchetKeys = new DHPubKey[peerCount];
ratchetFlags = new boolean[peerCount];
isSetup = new boolean[peerCount];
}
public void setRootKey(int i, byte[] rootKey) {
rootKeys[i] = rootKey;
}
public byte[] getRootKey(int i) {
return rootKeys[i];
}
public void setSelfRatchetKey(int i, DHKeyPair ratchetKey) {
selfRatchetKeys[i] = ratchetKey;
}
public DHKeyPair getSelfRatchetKey(int i) {
return selfRatchetKeys[i];
}
public void setRemoteRatchetKey(int i, DHPubKey ratchetKey) {
remoteRatchetKeys[i] = ratchetKey;
}
public DHPubKey getRemoteRatchetKey(int i) {
return remoteRatchetKeys[i];
}
public void setRatchetFlag(int i, boolean flag) {
ratchetFlags[i] = flag;
}
public boolean getRatchetFlag(int i) {
return ratchetFlags[i];
}
public byte[] getKeyWithPeer(int n) {
return Crypto.hkdf(rootKeys[n], new byte[0], new byte[0], 16);
}
public void setIsSetup(int i) {
isSetup[i] = true;
}
public boolean getIsSetup(int i) {
return isSetup[i];
}
}
| 4,142 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/DHRatchet.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet;
import com.facebook.research.asynchronousratchetingtree.KeyServer;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingTestImplementation;
import com.facebook.research.asynchronousratchetingtree.MessageDistributer;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.crypto.Crypto;
import com.facebook.research.asynchronousratchetingtree.crypto.DHKeyPair;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.crypto.SignedDHPubKey;
import com.facebook.research.asynchronousratchetingtree.dhratchet.message.DHRatchetMessageDistributer;
import com.facebook.research.asynchronousratchetingtree.dhratchet.message.DHRatchetSetupMessage;
import com.facebook.research.asynchronousratchetingtree.dhratchet.message.DHRatchetMessage;
public class DHRatchet implements GroupMessagingTestImplementation<DHRatchetState> {
@Override
public byte[] setupMessageForPeer(DHRatchetState state, DHPubKey[] peers, KeyServer keyServer, int i) {
DHKeyPair identityKeyPair = state.getIdentityKeyPair();
SignedDHPubKey signedPreKey = keyServer.getSignedPreKey(state, i);
if (!peers[i].verify(signedPreKey.getPubKeyBytes(), signedPreKey.getSignature())) {
Utils.except("PreKey signature check failed.");
}
DHKeyPair ratchetKey = DHKeyPair.generate(false);
state.setRootKey(
i,
Crypto.keyExchangeInitiate(
identityKeyPair,
peers[i],
ratchetKey,
keyServer.getSignedPreKey(state, i)
)
);
state.setSelfRatchetKey(i, ratchetKey);
state.setRatchetFlag(i, false);
state.setIsSetup(i);
DHRatchetSetupMessage setupMessage = new DHRatchetSetupMessage(
state.getPeerNum(),
identityKeyPair.getPubKey(),
ratchetKey.getPubKey()
);
return setupMessage.serialise();
}
@Override
public void processSetupMessage(DHRatchetState state, byte[] serialisedMessage, int participantNum) {
DHRatchetSetupMessage message = new DHRatchetSetupMessage(serialisedMessage);
int peerNum = message.getPeerNum();
state.setRootKey(
peerNum,
Crypto.keyExchangeReceive(
state.getIdentityKeyPair(),
message.getIdentity(),
state.getPreKeyFor(peerNum),
message.getEphemeralKey()
)
);
state.setRemoteRatchetKey(peerNum, message.getEphemeralKey());
state.setRatchetFlag(peerNum, true);
state.setIsSetup(peerNum);
}
@Override
public MessageDistributer sendMessage(DHRatchetState state, byte[] plaintext) {
byte[][] messages = new byte[state.getPeerCount()][];
for (int i = 0; i < state.getPeerCount(); i++) {
if (i == state.getPeerNum()) {
continue;
}
byte[] rootKey = state.getRootKey(i);
if (state.getRatchetFlag(i)) {
DHKeyPair selfRatchetKey = DHKeyPair.generate(false);
state.setSelfRatchetKey(i, selfRatchetKey);
rootKey = Crypto.hmacSha256(
rootKey,
selfRatchetKey.exchange(state.getRemoteRatchetKey(i))
);
state.setRootKey(i, rootKey);
state.setRatchetFlag(i, false);
}
byte[] ciphertext = Crypto.encrypt(plaintext, rootKey);
DHRatchetMessage message = new DHRatchetMessage(
state.getPeerNum(),
state.getSelfRatchetKey(i).getPubKey(),
ciphertext
);
messages[i] = message.serialise();
}
return new DHRatchetMessageDistributer(messages);
}
@Override
public byte[] receiveMessage(DHRatchetState state, byte[] serialisedMessage) {
DHRatchetMessage message = new DHRatchetMessage(serialisedMessage);
int i = message.getPeerNum();
byte[] rootKey = state.getRootKey(i);
if (!state.getRatchetFlag(i)) {
DHKeyPair selfRatchetKey = state.getSelfRatchetKey(i);
DHPubKey remoteRatchetKey = message.getRatchetKey();
rootKey = Crypto.hmacSha256(
rootKey,
selfRatchetKey.exchange(remoteRatchetKey)
);
state.setRootKey(i, rootKey);
state.setRemoteRatchetKey(
i,
remoteRatchetKey
);
state.setRatchetFlag(i, true);
}
return Crypto.decrypt(message.getCiphertext(), rootKey);
}
}
| 4,143 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/DHRatchetSetupPhase.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingSetupPhase;
import com.facebook.research.asynchronousratchetingtree.GroupMessagingTestImplementation;
import com.facebook.research.asynchronousratchetingtree.KeyServer;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
public class DHRatchetSetupPhase implements GroupMessagingSetupPhase<DHRatchetState> {
private byte[][] setupMessages;
private int bytesReceivedByOthers = 0;
private int bytesSentByOthers = 0;
@Override
public void generateNecessaryPreKeys(DHRatchetState[] states) {
// We need PreKeys from each user to each user with a lower ID than them.
for (int i = 0; i < states.length; i++) {
for (int j = i + 1; j < states.length; j++) {
states[j].getSignedDHPreKeyFor(i);
}
}
}
@Override
public void setupInitiator(GroupMessagingTestImplementation<DHRatchetState> implementation, DHRatchetState[] states, DHPubKey[] identities, KeyServer keyServer) {
int n = states.length;
setupMessages = new byte[n][];
for (int i = 1; i < n; i++) {
setupMessages[i] = implementation.setupMessageForPeer(states[0], identities, keyServer, i);
}
}
@Override
public int getBytesSentByInitiator() {
int total = 0;
for (int i = 1; i < setupMessages.length; i++) {
total += setupMessages[i].length;
}
return total;
}
/**
* Here we aim to scale the total number of key exchanges performed proportionate to the number of active users.
* This involves ensuring that every active user has done a key exchange for each of the others, and that they have
* all done an unreciprocated key exchange with all other users.
*/
@Override
public void setupAllOthers(GroupMessagingTestImplementation<DHRatchetState> implementation, DHRatchetState[] states, Integer[] active, DHPubKey[] identities, KeyServer keyServer) {
int n = states.length;
// We need all active users to create and import each others' setup messages.
for (int i = 0; i < active.length; i++) {
int sender = active[i];
if (sender == 0) {
continue;
}
// First let's import the initiator's state.
bytesReceivedByOthers += setupMessages[sender].length;
implementation.processSetupMessage(states[sender], setupMessages[sender], sender);
for (int j = i + 1; j < active.length; j++) {
int receiver = active[j];
if (receiver == 0) {
continue;
}
byte[] setupMessage = implementation.setupMessageForPeer(states[sender], identities, keyServer, receiver);
bytesSentByOthers += setupMessage.length;
bytesReceivedByOthers += setupMessage.length;
implementation.processSetupMessage(states[receiver], setupMessage, receiver);
}
}
// Active users should still create state for inactive ones, it just shouldn't be imported.
for (int i = 0; i < active.length; i++) {
int sender = active[i];
for (int j = 0; j < n; j++) {
if (states[sender].getIsSetup(j)) {
continue;
}
byte[] setupMessage = implementation.setupMessageForPeer(states[sender], identities, keyServer, j);
bytesSentByOthers += setupMessage.length;
bytesReceivedByOthers += setupMessage.length;
implementation.processSetupMessage(states[j], setupMessage, j);
}
}
}
@Override
public int getBytesSentByOthers() {
return bytesSentByOthers;
}
@Override
public int getBytesReceivedByOthers() {
return bytesReceivedByOthers;
}
}
| 4,144 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message/DHRatchetMessage.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet.message;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.dhratchet.message.thrift.DHRatchetMessageStruct;
public class DHRatchetMessage {
private int peerNum;
private DHPubKey ratchetKey;
private byte[] ciphertext;
public DHRatchetMessage(
int peerNum,
DHPubKey ratchetKey,
byte[] ciphertext
) {
this.peerNum = peerNum;
this.ratchetKey = ratchetKey;
this.ciphertext = ciphertext;
}
public DHRatchetMessage(byte[] thriftSerialised) {
DHRatchetMessageStruct struct = new DHRatchetMessageStruct();
Utils.deserialise(struct, thriftSerialised);
peerNum = struct.peerNum;
ratchetKey = DHPubKey.pubKey(struct.getRatchetKey());
ciphertext = struct.getCiphertext();
}
public int getPeerNum() {
return peerNum;
}
public DHPubKey getRatchetKey() {
return ratchetKey;
}
public byte[] getCiphertext() {
return ciphertext;
}
public byte[] serialise() {
DHRatchetMessageStruct struct = new DHRatchetMessageStruct();
struct.setPeerNum(peerNum);
struct.setRatchetKey(ratchetKey.getPubKeyBytes());
struct.setCiphertext(ciphertext);
return Utils.serialise(struct);
}
}
| 4,145 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message/DHRatchetSetupMessage.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet.message;
import com.facebook.research.asynchronousratchetingtree.Utils;
import com.facebook.research.asynchronousratchetingtree.crypto.DHPubKey;
import com.facebook.research.asynchronousratchetingtree.dhratchet.message.thrift.DHRatchetSetupMessageStruct;
public class DHRatchetSetupMessage {
private int peerNum;
private DHPubKey identity;
private DHPubKey ephemeralKey;
public DHRatchetSetupMessage(
int peerNum,
DHPubKey identity,
DHPubKey ephemeralKey
) {
this.peerNum = peerNum;
this.identity = identity;
this.ephemeralKey = ephemeralKey;
}
public DHRatchetSetupMessage(byte[] thriftSerialised) {
DHRatchetSetupMessageStruct struct = new DHRatchetSetupMessageStruct();
Utils.deserialise(struct, thriftSerialised);
peerNum = struct.getPeerNum();
identity = DHPubKey.pubKey(struct.getIdentityKey());
ephemeralKey = DHPubKey.pubKey(struct.getEphemeralKey());
}
public int getPeerNum() {
return peerNum;
}
public DHPubKey getIdentity() {
return identity;
}
public DHPubKey getEphemeralKey() {
return ephemeralKey;
}
public byte[] serialise() {
DHRatchetSetupMessageStruct struct = new DHRatchetSetupMessageStruct();
struct.setPeerNum(peerNum);
struct.setIdentityKey(identity.getPubKeyBytes());
struct.setEphemeralKey(ephemeralKey.getPubKeyBytes());
return Utils.serialise(struct);
}
}
| 4,146 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message/DHRatchetMessageDistributer.java | /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet.message;
import com.facebook.research.asynchronousratchetingtree.MessageDistributer;
public class DHRatchetMessageDistributer implements MessageDistributer {
private byte[][] updateMessages;
public DHRatchetMessageDistributer(byte[][] updateMessages) {
this.updateMessages = updateMessages;
}
@Override
public byte[] getUpdateMessageForParticipantNum(int participantNum) {
return updateMessages[participantNum];
}
@Override
public int totalSize() {
int size = 0;
for (int i = 0; i < updateMessages.length; i++) {
if (updateMessages[i] == null) {
continue;
}
size += updateMessages[i].length;
}
return size;
}
}
| 4,147 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message/thrift/DHRatchetSetupMessageStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class DHRatchetSetupMessageStruct implements org.apache.thrift.TBase<DHRatchetSetupMessageStruct, DHRatchetSetupMessageStruct._Fields>, java.io.Serializable, Cloneable, Comparable<DHRatchetSetupMessageStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DHRatchetSetupMessageStruct");
private static final org.apache.thrift.protocol.TField PEER_NUM_FIELD_DESC = new org.apache.thrift.protocol.TField("peerNum", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField IDENTITY_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("identityKey", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField EPHEMERAL_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("ephemeralKey", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new DHRatchetSetupMessageStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new DHRatchetSetupMessageStructTupleSchemeFactory();
public int peerNum; // required
public java.nio.ByteBuffer identityKey; // required
public java.nio.ByteBuffer ephemeralKey; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
PEER_NUM((short)1, "peerNum"),
IDENTITY_KEY((short)2, "identityKey"),
EPHEMERAL_KEY((short)3, "ephemeralKey");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // PEER_NUM
return PEER_NUM;
case 2: // IDENTITY_KEY
return IDENTITY_KEY;
case 3: // EPHEMERAL_KEY
return EPHEMERAL_KEY;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __PEERNUM_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.PEER_NUM, new org.apache.thrift.meta_data.FieldMetaData("peerNum", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.IDENTITY_KEY, new org.apache.thrift.meta_data.FieldMetaData("identityKey", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.EPHEMERAL_KEY, new org.apache.thrift.meta_data.FieldMetaData("ephemeralKey", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(DHRatchetSetupMessageStruct.class, metaDataMap);
}
public DHRatchetSetupMessageStruct() {
}
public DHRatchetSetupMessageStruct(
int peerNum,
java.nio.ByteBuffer identityKey,
java.nio.ByteBuffer ephemeralKey)
{
this();
this.peerNum = peerNum;
setPeerNumIsSet(true);
this.identityKey = org.apache.thrift.TBaseHelper.copyBinary(identityKey);
this.ephemeralKey = org.apache.thrift.TBaseHelper.copyBinary(ephemeralKey);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public DHRatchetSetupMessageStruct(DHRatchetSetupMessageStruct other) {
__isset_bitfield = other.__isset_bitfield;
this.peerNum = other.peerNum;
if (other.isSetIdentityKey()) {
this.identityKey = org.apache.thrift.TBaseHelper.copyBinary(other.identityKey);
}
if (other.isSetEphemeralKey()) {
this.ephemeralKey = org.apache.thrift.TBaseHelper.copyBinary(other.ephemeralKey);
}
}
public DHRatchetSetupMessageStruct deepCopy() {
return new DHRatchetSetupMessageStruct(this);
}
@Override
public void clear() {
setPeerNumIsSet(false);
this.peerNum = 0;
this.identityKey = null;
this.ephemeralKey = null;
}
public int getPeerNum() {
return this.peerNum;
}
public DHRatchetSetupMessageStruct setPeerNum(int peerNum) {
this.peerNum = peerNum;
setPeerNumIsSet(true);
return this;
}
public void unsetPeerNum() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PEERNUM_ISSET_ID);
}
/** Returns true if field peerNum is set (has been assigned a value) and false otherwise */
public boolean isSetPeerNum() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PEERNUM_ISSET_ID);
}
public void setPeerNumIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PEERNUM_ISSET_ID, value);
}
public byte[] getIdentityKey() {
setIdentityKey(org.apache.thrift.TBaseHelper.rightSize(identityKey));
return identityKey == null ? null : identityKey.array();
}
public java.nio.ByteBuffer bufferForIdentityKey() {
return org.apache.thrift.TBaseHelper.copyBinary(identityKey);
}
public DHRatchetSetupMessageStruct setIdentityKey(byte[] identityKey) {
this.identityKey = identityKey == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(identityKey.clone());
return this;
}
public DHRatchetSetupMessageStruct setIdentityKey(java.nio.ByteBuffer identityKey) {
this.identityKey = org.apache.thrift.TBaseHelper.copyBinary(identityKey);
return this;
}
public void unsetIdentityKey() {
this.identityKey = null;
}
/** Returns true if field identityKey is set (has been assigned a value) and false otherwise */
public boolean isSetIdentityKey() {
return this.identityKey != null;
}
public void setIdentityKeyIsSet(boolean value) {
if (!value) {
this.identityKey = null;
}
}
public byte[] getEphemeralKey() {
setEphemeralKey(org.apache.thrift.TBaseHelper.rightSize(ephemeralKey));
return ephemeralKey == null ? null : ephemeralKey.array();
}
public java.nio.ByteBuffer bufferForEphemeralKey() {
return org.apache.thrift.TBaseHelper.copyBinary(ephemeralKey);
}
public DHRatchetSetupMessageStruct setEphemeralKey(byte[] ephemeralKey) {
this.ephemeralKey = ephemeralKey == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(ephemeralKey.clone());
return this;
}
public DHRatchetSetupMessageStruct setEphemeralKey(java.nio.ByteBuffer ephemeralKey) {
this.ephemeralKey = org.apache.thrift.TBaseHelper.copyBinary(ephemeralKey);
return this;
}
public void unsetEphemeralKey() {
this.ephemeralKey = null;
}
/** Returns true if field ephemeralKey is set (has been assigned a value) and false otherwise */
public boolean isSetEphemeralKey() {
return this.ephemeralKey != null;
}
public void setEphemeralKeyIsSet(boolean value) {
if (!value) {
this.ephemeralKey = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case PEER_NUM:
if (value == null) {
unsetPeerNum();
} else {
setPeerNum((java.lang.Integer)value);
}
break;
case IDENTITY_KEY:
if (value == null) {
unsetIdentityKey();
} else {
if (value instanceof byte[]) {
setIdentityKey((byte[])value);
} else {
setIdentityKey((java.nio.ByteBuffer)value);
}
}
break;
case EPHEMERAL_KEY:
if (value == null) {
unsetEphemeralKey();
} else {
if (value instanceof byte[]) {
setEphemeralKey((byte[])value);
} else {
setEphemeralKey((java.nio.ByteBuffer)value);
}
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case PEER_NUM:
return getPeerNum();
case IDENTITY_KEY:
return getIdentityKey();
case EPHEMERAL_KEY:
return getEphemeralKey();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case PEER_NUM:
return isSetPeerNum();
case IDENTITY_KEY:
return isSetIdentityKey();
case EPHEMERAL_KEY:
return isSetEphemeralKey();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof DHRatchetSetupMessageStruct)
return this.equals((DHRatchetSetupMessageStruct)that);
return false;
}
public boolean equals(DHRatchetSetupMessageStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_peerNum = true;
boolean that_present_peerNum = true;
if (this_present_peerNum || that_present_peerNum) {
if (!(this_present_peerNum && that_present_peerNum))
return false;
if (this.peerNum != that.peerNum)
return false;
}
boolean this_present_identityKey = true && this.isSetIdentityKey();
boolean that_present_identityKey = true && that.isSetIdentityKey();
if (this_present_identityKey || that_present_identityKey) {
if (!(this_present_identityKey && that_present_identityKey))
return false;
if (!this.identityKey.equals(that.identityKey))
return false;
}
boolean this_present_ephemeralKey = true && this.isSetEphemeralKey();
boolean that_present_ephemeralKey = true && that.isSetEphemeralKey();
if (this_present_ephemeralKey || that_present_ephemeralKey) {
if (!(this_present_ephemeralKey && that_present_ephemeralKey))
return false;
if (!this.ephemeralKey.equals(that.ephemeralKey))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + peerNum;
hashCode = hashCode * 8191 + ((isSetIdentityKey()) ? 131071 : 524287);
if (isSetIdentityKey())
hashCode = hashCode * 8191 + identityKey.hashCode();
hashCode = hashCode * 8191 + ((isSetEphemeralKey()) ? 131071 : 524287);
if (isSetEphemeralKey())
hashCode = hashCode * 8191 + ephemeralKey.hashCode();
return hashCode;
}
@Override
public int compareTo(DHRatchetSetupMessageStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetPeerNum()).compareTo(other.isSetPeerNum());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPeerNum()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.peerNum, other.peerNum);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetIdentityKey()).compareTo(other.isSetIdentityKey());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetIdentityKey()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.identityKey, other.identityKey);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetEphemeralKey()).compareTo(other.isSetEphemeralKey());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEphemeralKey()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ephemeralKey, other.ephemeralKey);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("DHRatchetSetupMessageStruct(");
boolean first = true;
sb.append("peerNum:");
sb.append(this.peerNum);
first = false;
if (!first) sb.append(", ");
sb.append("identityKey:");
if (this.identityKey == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.identityKey, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("ephemeralKey:");
if (this.ephemeralKey == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.ephemeralKey, sb);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class DHRatchetSetupMessageStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public DHRatchetSetupMessageStructStandardScheme getScheme() {
return new DHRatchetSetupMessageStructStandardScheme();
}
}
private static class DHRatchetSetupMessageStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<DHRatchetSetupMessageStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, DHRatchetSetupMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // PEER_NUM
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.peerNum = iprot.readI32();
struct.setPeerNumIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // IDENTITY_KEY
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.identityKey = iprot.readBinary();
struct.setIdentityKeyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // EPHEMERAL_KEY
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.ephemeralKey = iprot.readBinary();
struct.setEphemeralKeyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, DHRatchetSetupMessageStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(PEER_NUM_FIELD_DESC);
oprot.writeI32(struct.peerNum);
oprot.writeFieldEnd();
if (struct.identityKey != null) {
oprot.writeFieldBegin(IDENTITY_KEY_FIELD_DESC);
oprot.writeBinary(struct.identityKey);
oprot.writeFieldEnd();
}
if (struct.ephemeralKey != null) {
oprot.writeFieldBegin(EPHEMERAL_KEY_FIELD_DESC);
oprot.writeBinary(struct.ephemeralKey);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class DHRatchetSetupMessageStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public DHRatchetSetupMessageStructTupleScheme getScheme() {
return new DHRatchetSetupMessageStructTupleScheme();
}
}
private static class DHRatchetSetupMessageStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<DHRatchetSetupMessageStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, DHRatchetSetupMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetPeerNum()) {
optionals.set(0);
}
if (struct.isSetIdentityKey()) {
optionals.set(1);
}
if (struct.isSetEphemeralKey()) {
optionals.set(2);
}
oprot.writeBitSet(optionals, 3);
if (struct.isSetPeerNum()) {
oprot.writeI32(struct.peerNum);
}
if (struct.isSetIdentityKey()) {
oprot.writeBinary(struct.identityKey);
}
if (struct.isSetEphemeralKey()) {
oprot.writeBinary(struct.ephemeralKey);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, DHRatchetSetupMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
struct.peerNum = iprot.readI32();
struct.setPeerNumIsSet(true);
}
if (incoming.get(1)) {
struct.identityKey = iprot.readBinary();
struct.setIdentityKeyIsSet(true);
}
if (incoming.get(2)) {
struct.ephemeralKey = iprot.readBinary();
struct.setEphemeralKeyIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,148 |
0 | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message | Create_ds/asynchronousratchetingtree/AsynchronousRatchetingTree/src/main/java/com/facebook/research/asynchronousratchetingtree/dhratchet/message/thrift/DHRatchetMessageStruct.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.facebook.research.asynchronousratchetingtree.dhratchet.message.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2018-01-05")
public class DHRatchetMessageStruct implements org.apache.thrift.TBase<DHRatchetMessageStruct, DHRatchetMessageStruct._Fields>, java.io.Serializable, Cloneable, Comparable<DHRatchetMessageStruct> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DHRatchetMessageStruct");
private static final org.apache.thrift.protocol.TField PEER_NUM_FIELD_DESC = new org.apache.thrift.protocol.TField("peerNum", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField RATCHET_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("ratchetKey", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField CIPHERTEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("ciphertext", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new DHRatchetMessageStructStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new DHRatchetMessageStructTupleSchemeFactory();
public int peerNum; // required
public java.nio.ByteBuffer ratchetKey; // required
public java.nio.ByteBuffer ciphertext; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
PEER_NUM((short)1, "peerNum"),
RATCHET_KEY((short)2, "ratchetKey"),
CIPHERTEXT((short)3, "ciphertext");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // PEER_NUM
return PEER_NUM;
case 2: // RATCHET_KEY
return RATCHET_KEY;
case 3: // CIPHERTEXT
return CIPHERTEXT;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __PEERNUM_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.PEER_NUM, new org.apache.thrift.meta_data.FieldMetaData("peerNum", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.RATCHET_KEY, new org.apache.thrift.meta_data.FieldMetaData("ratchetKey", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.CIPHERTEXT, new org.apache.thrift.meta_data.FieldMetaData("ciphertext", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(DHRatchetMessageStruct.class, metaDataMap);
}
public DHRatchetMessageStruct() {
}
public DHRatchetMessageStruct(
int peerNum,
java.nio.ByteBuffer ratchetKey,
java.nio.ByteBuffer ciphertext)
{
this();
this.peerNum = peerNum;
setPeerNumIsSet(true);
this.ratchetKey = org.apache.thrift.TBaseHelper.copyBinary(ratchetKey);
this.ciphertext = org.apache.thrift.TBaseHelper.copyBinary(ciphertext);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public DHRatchetMessageStruct(DHRatchetMessageStruct other) {
__isset_bitfield = other.__isset_bitfield;
this.peerNum = other.peerNum;
if (other.isSetRatchetKey()) {
this.ratchetKey = org.apache.thrift.TBaseHelper.copyBinary(other.ratchetKey);
}
if (other.isSetCiphertext()) {
this.ciphertext = org.apache.thrift.TBaseHelper.copyBinary(other.ciphertext);
}
}
public DHRatchetMessageStruct deepCopy() {
return new DHRatchetMessageStruct(this);
}
@Override
public void clear() {
setPeerNumIsSet(false);
this.peerNum = 0;
this.ratchetKey = null;
this.ciphertext = null;
}
public int getPeerNum() {
return this.peerNum;
}
public DHRatchetMessageStruct setPeerNum(int peerNum) {
this.peerNum = peerNum;
setPeerNumIsSet(true);
return this;
}
public void unsetPeerNum() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PEERNUM_ISSET_ID);
}
/** Returns true if field peerNum is set (has been assigned a value) and false otherwise */
public boolean isSetPeerNum() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PEERNUM_ISSET_ID);
}
public void setPeerNumIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PEERNUM_ISSET_ID, value);
}
public byte[] getRatchetKey() {
setRatchetKey(org.apache.thrift.TBaseHelper.rightSize(ratchetKey));
return ratchetKey == null ? null : ratchetKey.array();
}
public java.nio.ByteBuffer bufferForRatchetKey() {
return org.apache.thrift.TBaseHelper.copyBinary(ratchetKey);
}
public DHRatchetMessageStruct setRatchetKey(byte[] ratchetKey) {
this.ratchetKey = ratchetKey == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(ratchetKey.clone());
return this;
}
public DHRatchetMessageStruct setRatchetKey(java.nio.ByteBuffer ratchetKey) {
this.ratchetKey = org.apache.thrift.TBaseHelper.copyBinary(ratchetKey);
return this;
}
public void unsetRatchetKey() {
this.ratchetKey = null;
}
/** Returns true if field ratchetKey is set (has been assigned a value) and false otherwise */
public boolean isSetRatchetKey() {
return this.ratchetKey != null;
}
public void setRatchetKeyIsSet(boolean value) {
if (!value) {
this.ratchetKey = null;
}
}
public byte[] getCiphertext() {
setCiphertext(org.apache.thrift.TBaseHelper.rightSize(ciphertext));
return ciphertext == null ? null : ciphertext.array();
}
public java.nio.ByteBuffer bufferForCiphertext() {
return org.apache.thrift.TBaseHelper.copyBinary(ciphertext);
}
public DHRatchetMessageStruct setCiphertext(byte[] ciphertext) {
this.ciphertext = ciphertext == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(ciphertext.clone());
return this;
}
public DHRatchetMessageStruct setCiphertext(java.nio.ByteBuffer ciphertext) {
this.ciphertext = org.apache.thrift.TBaseHelper.copyBinary(ciphertext);
return this;
}
public void unsetCiphertext() {
this.ciphertext = null;
}
/** Returns true if field ciphertext is set (has been assigned a value) and false otherwise */
public boolean isSetCiphertext() {
return this.ciphertext != null;
}
public void setCiphertextIsSet(boolean value) {
if (!value) {
this.ciphertext = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case PEER_NUM:
if (value == null) {
unsetPeerNum();
} else {
setPeerNum((java.lang.Integer)value);
}
break;
case RATCHET_KEY:
if (value == null) {
unsetRatchetKey();
} else {
if (value instanceof byte[]) {
setRatchetKey((byte[])value);
} else {
setRatchetKey((java.nio.ByteBuffer)value);
}
}
break;
case CIPHERTEXT:
if (value == null) {
unsetCiphertext();
} else {
if (value instanceof byte[]) {
setCiphertext((byte[])value);
} else {
setCiphertext((java.nio.ByteBuffer)value);
}
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case PEER_NUM:
return getPeerNum();
case RATCHET_KEY:
return getRatchetKey();
case CIPHERTEXT:
return getCiphertext();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case PEER_NUM:
return isSetPeerNum();
case RATCHET_KEY:
return isSetRatchetKey();
case CIPHERTEXT:
return isSetCiphertext();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof DHRatchetMessageStruct)
return this.equals((DHRatchetMessageStruct)that);
return false;
}
public boolean equals(DHRatchetMessageStruct that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_peerNum = true;
boolean that_present_peerNum = true;
if (this_present_peerNum || that_present_peerNum) {
if (!(this_present_peerNum && that_present_peerNum))
return false;
if (this.peerNum != that.peerNum)
return false;
}
boolean this_present_ratchetKey = true && this.isSetRatchetKey();
boolean that_present_ratchetKey = true && that.isSetRatchetKey();
if (this_present_ratchetKey || that_present_ratchetKey) {
if (!(this_present_ratchetKey && that_present_ratchetKey))
return false;
if (!this.ratchetKey.equals(that.ratchetKey))
return false;
}
boolean this_present_ciphertext = true && this.isSetCiphertext();
boolean that_present_ciphertext = true && that.isSetCiphertext();
if (this_present_ciphertext || that_present_ciphertext) {
if (!(this_present_ciphertext && that_present_ciphertext))
return false;
if (!this.ciphertext.equals(that.ciphertext))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + peerNum;
hashCode = hashCode * 8191 + ((isSetRatchetKey()) ? 131071 : 524287);
if (isSetRatchetKey())
hashCode = hashCode * 8191 + ratchetKey.hashCode();
hashCode = hashCode * 8191 + ((isSetCiphertext()) ? 131071 : 524287);
if (isSetCiphertext())
hashCode = hashCode * 8191 + ciphertext.hashCode();
return hashCode;
}
@Override
public int compareTo(DHRatchetMessageStruct other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetPeerNum()).compareTo(other.isSetPeerNum());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPeerNum()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.peerNum, other.peerNum);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetRatchetKey()).compareTo(other.isSetRatchetKey());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRatchetKey()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ratchetKey, other.ratchetKey);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetCiphertext()).compareTo(other.isSetCiphertext());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCiphertext()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ciphertext, other.ciphertext);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("DHRatchetMessageStruct(");
boolean first = true;
sb.append("peerNum:");
sb.append(this.peerNum);
first = false;
if (!first) sb.append(", ");
sb.append("ratchetKey:");
if (this.ratchetKey == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.ratchetKey, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("ciphertext:");
if (this.ciphertext == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.ciphertext, sb);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class DHRatchetMessageStructStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public DHRatchetMessageStructStandardScheme getScheme() {
return new DHRatchetMessageStructStandardScheme();
}
}
private static class DHRatchetMessageStructStandardScheme extends org.apache.thrift.scheme.StandardScheme<DHRatchetMessageStruct> {
public void read(org.apache.thrift.protocol.TProtocol iprot, DHRatchetMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // PEER_NUM
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.peerNum = iprot.readI32();
struct.setPeerNumIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // RATCHET_KEY
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.ratchetKey = iprot.readBinary();
struct.setRatchetKeyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // CIPHERTEXT
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.ciphertext = iprot.readBinary();
struct.setCiphertextIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, DHRatchetMessageStruct struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(PEER_NUM_FIELD_DESC);
oprot.writeI32(struct.peerNum);
oprot.writeFieldEnd();
if (struct.ratchetKey != null) {
oprot.writeFieldBegin(RATCHET_KEY_FIELD_DESC);
oprot.writeBinary(struct.ratchetKey);
oprot.writeFieldEnd();
}
if (struct.ciphertext != null) {
oprot.writeFieldBegin(CIPHERTEXT_FIELD_DESC);
oprot.writeBinary(struct.ciphertext);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class DHRatchetMessageStructTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public DHRatchetMessageStructTupleScheme getScheme() {
return new DHRatchetMessageStructTupleScheme();
}
}
private static class DHRatchetMessageStructTupleScheme extends org.apache.thrift.scheme.TupleScheme<DHRatchetMessageStruct> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, DHRatchetMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetPeerNum()) {
optionals.set(0);
}
if (struct.isSetRatchetKey()) {
optionals.set(1);
}
if (struct.isSetCiphertext()) {
optionals.set(2);
}
oprot.writeBitSet(optionals, 3);
if (struct.isSetPeerNum()) {
oprot.writeI32(struct.peerNum);
}
if (struct.isSetRatchetKey()) {
oprot.writeBinary(struct.ratchetKey);
}
if (struct.isSetCiphertext()) {
oprot.writeBinary(struct.ciphertext);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, DHRatchetMessageStruct struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
struct.peerNum = iprot.readI32();
struct.setPeerNumIsSet(true);
}
if (incoming.get(1)) {
struct.ratchetKey = iprot.readBinary();
struct.setRatchetKeyIsSet(true);
}
if (incoming.get(2)) {
struct.ciphertext = iprot.readBinary();
struct.setCiphertextIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 4,149 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps-inter-module/lambda1/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps-inter-module/lambda1/src/main/java/aws/lambdabuilders/Lambda1_Main.java | package aws.lambdabuilders;
public class Lambda1_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,150 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps-inter-module/lambda2/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps-inter-module/lambda2/src/main/java/aws/lambdabuilders/Lambda2_Main.java | package aws.lambdabuilders;
public class Lambda2_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,151 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps-inter-module/common/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps-inter-module/common/src/main/java/aws/lambdabuilders/Foo.java | package aws.lambdabuilders;
public class Foo {
public void sayHello() {
System.out.println("Hello world!");
}
}
| 4,152 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps/lambda1/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps/lambda1/src/main/java/aws/lambdabuilders/Lambda1_Main.java | package aws.lambdabuilders;
public class Lambda1_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,153 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps/lambda2/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java17/with-deps/lambda2/src/main/java/aws/lambdabuilders/Lambda2_Main.java | package aws.lambdabuilders;
public class Lambda2_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,154 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps-inter-module/lambda1/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps-inter-module/lambda1/src/main/java/aws/lambdabuilders/Lambda1_Main.java | package aws.lambdabuilders;
public class Lambda1_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,155 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps-inter-module/lambda2/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps-inter-module/lambda2/src/main/java/aws/lambdabuilders/Lambda2_Main.java | package aws.lambdabuilders;
public class Lambda2_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,156 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps-inter-module/common/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps-inter-module/common/src/main/java/aws/lambdabuilders/Foo.java | package aws.lambdabuilders;
public class Foo {
public void sayHello() {
System.out.println("Hello world!");
}
}
| 4,157 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps/lambda1/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps/lambda1/src/main/java/aws/lambdabuilders/Lambda1_Main.java | package aws.lambdabuilders;
public class Lambda1_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,158 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps/lambda2/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java8/with-deps/lambda2/src/main/java/aws/lambdabuilders/Lambda2_Main.java | package aws.lambdabuilders;
public class Lambda2_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,159 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps-inter-module/lambda1/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps-inter-module/lambda1/src/main/java/aws/lambdabuilders/Lambda1_Main.java | package aws.lambdabuilders;
public class Lambda1_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,160 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps-inter-module/lambda2/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps-inter-module/lambda2/src/main/java/aws/lambdabuilders/Lambda2_Main.java | package aws.lambdabuilders;
public class Lambda2_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,161 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps-inter-module/common/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps-inter-module/common/src/main/java/aws/lambdabuilders/Foo.java | package aws.lambdabuilders;
public class Foo {
public void sayHello() {
System.out.println("Hello world!");
}
}
| 4,162 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps/lambda1/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps/lambda1/src/main/java/aws/lambdabuilders/Lambda1_Main.java | package aws.lambdabuilders;
public class Lambda1_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,163 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps/lambda2/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/multi-build/java11/with-deps/lambda2/src/main/java/aws/lambdabuilders/Lambda2_Main.java | package aws.lambdabuilders;
public class Lambda2_Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,164 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-deps-gradlew/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-deps-gradlew/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,165 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-deps-broken/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-deps-broken/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,166 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/layer/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/layer/src/main/java/aws/lambdabuilders/CommonCode.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class CommonCode {
public static void doSomethingOnLayer(final LambdaLogger logger, final String s) {
logger.log("Doing something on layer" + s);
}
}
| 4,167 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-layer-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-layer-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import aws.lambdabuilders.CommonCode;
public class Main implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
final LambdaLogger logger = context.getLogger();
CommonCode.doSomethingOnLayer(logger, "fromLambdaFunction");
System.out.println("Hello AWS Lambda Builders!");
return "Done";
}
}
| 4,168 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,169 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-test-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-test-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,170 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-resources/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java17/with-resources/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,171 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-deps-gradlew/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-deps-gradlew/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,172 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-deps-broken/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-deps-broken/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,173 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/layer/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/layer/src/main/java/aws/lambdabuilders/CommonCode.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class CommonCode {
public static void doSomethingOnLayer(final LambdaLogger logger, final String s) {
logger.log("Doing something on layer" + s);
}
}
| 4,174 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-layer-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-layer-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import aws.lambdabuilders.CommonCode;
public class Main implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
final LambdaLogger logger = context.getLogger();
CommonCode.doSomethingOnLayer(logger, "fromLambdaFunction");
System.out.println("Hello AWS Lambda Builders!");
return "Done";
}
}
| 4,175 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,176 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-test-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-test-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,177 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-resources/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java8/with-resources/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,178 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-deps-gradlew/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-deps-gradlew/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,179 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-deps-broken/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-deps-broken/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,180 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/layer/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/layer/src/main/java/aws/lambdabuilders/CommonCode.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class CommonCode {
public static void doSomethingOnLayer(final LambdaLogger logger, final String s) {
logger.log("Doing something on layer" + s);
}
}
| 4,181 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-layer-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-layer-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import aws.lambdabuilders.CommonCode;
public class Main implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
final LambdaLogger logger = context.getLogger();
CommonCode.doSomethingOnLayer(logger, "fromLambdaFunction");
System.out.println("Hello AWS Lambda Builders!");
return "Done";
}
}
| 4,182 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,183 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-test-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-test-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,184 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-resources/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_gradle/testdata/single-build/java11/with-resources/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,185 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/with-deps-broken/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/with-deps-broken/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,186 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/layer/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/layer/src/main/java/aws/lambdabuilders/CommonCode.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class CommonCode {
public static void doSomethingOnLayer(final LambdaLogger logger, final String s) {
logger.log("Doing something on layer" + s);
}
}
| 4,187 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/with-layer-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/with-layer-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import aws.lambdabuilders.CommonCode;
public class Main implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
final LambdaLogger logger = context.getLogger();
CommonCode.doSomethingOnLayer(logger, "fromLambdaFunction");
System.out.println("Hello AWS Lambda Builders!");
return "Done";
}
}
| 4,188 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/with-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/with-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,189 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/no-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java17/no-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,190 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/with-deps-broken/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/with-deps-broken/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,191 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/layer/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/layer/src/main/java/aws/lambdabuilders/CommonCode.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class CommonCode {
public static void doSomethingOnLayer(final LambdaLogger logger, final String s) {
logger.log("Doing something on layer" + s);
}
}
| 4,192 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/with-layer-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/with-layer-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import aws.lambdabuilders.CommonCode;
public class Main implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
final LambdaLogger logger = context.getLogger();
CommonCode.doSomethingOnLayer(logger, "fromLambdaFunction");
System.out.println("Hello AWS Lambda Builders!");
return "Done";
}
}
| 4,193 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/with-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/with-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,194 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/no-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java8/no-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,195 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/with-deps-broken/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/with-deps-broken/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,196 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/layer/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/layer/src/main/java/aws/lambdabuilders/CommonCode.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class CommonCode {
public static void doSomethingOnLayer(final LambdaLogger logger, final String s) {
logger.log("Doing something on layer" + s);
}
}
| 4,197 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/with-layer-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/with-layer-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import aws.lambdabuilders.CommonCode;
public class Main implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
final LambdaLogger logger = context.getLogger();
CommonCode.doSomethingOnLayer(logger, "fromLambdaFunction");
System.out.println("Hello AWS Lambda Builders!");
return "Done";
}
}
| 4,198 |
0 | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/with-deps/src/main/java/aws | Create_ds/aws-lambda-builders/tests/integration/workflows/java_maven/testdata/single-build/java11/with-deps/src/main/java/aws/lambdabuilders/Main.java | package aws.lambdabuilders;
public class Main {
public static void main(String[] args) {
System.out.println("Hello AWS Lambda Builders!");
}
}
| 4,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.