use of com.hedera.services.legacy.proto.utils.AtomicCounter in project hedera-services by hashgraph.
the class JKeyUtils method genSampleComplexKey.
/**
* Generates a complex key of given depth with a mix of basic key, threshold key and key list.
*
* @param depth
* of the generated key
* @return generated key
*/
public static Key genSampleComplexKey(final int depth, final Map<String, PrivateKey> pubKey2privKeyMap) {
Key rv;
final int numKeys = 3;
final int threshold = 2;
if (depth == 1) {
rv = genSingleEd25519Key(pubKey2privKeyMap);
// verify the size
final int size = computeNumOfExpandedKeys(rv, 1, new AtomicCounter());
assertEquals(1, size);
} else if (depth == 2) {
final List<Key> keys = new ArrayList<>();
keys.add(genSingleEd25519Key(pubKey2privKeyMap));
keys.add(genSingleECDSASecp256k1Key(pubKey2privKeyMap));
keys.add(genThresholdKeyInstance(numKeys, threshold, pubKey2privKeyMap));
keys.add(genKeyListInstance(numKeys, pubKey2privKeyMap));
rv = genKeyList(keys);
// verify the size
final int size = computeNumOfExpandedKeys(rv, 1, new AtomicCounter());
assertEquals(2 + numKeys * 2, size);
} else {
throw new NotImplementedException("Not implemented yet.");
}
return rv;
}
use of com.hedera.services.legacy.proto.utils.AtomicCounter in project hedera-services by hashgraph.
the class JKeySerializerTest method genSampleComplexKey.
/**
* Generates a complex key of given depth with a mix of basic key, threshold key and key list.
*
* @param depth
* of the generated key
* @return generated key
*/
private static Key genSampleComplexKey(final int depth, final Map<String, PrivateKey> pubKey2privKeyMap) {
Key rv = null;
final int numKeys = 3;
final int threshold = 2;
if (depth == 1) {
rv = genSingleEd25519Key(pubKey2privKeyMap);
// verify the size
final int size = computeNumOfExpandedKeys(rv, 1, new AtomicCounter());
assertEquals(1, size);
} else if (depth == 2) {
final List<Key> keys = new ArrayList<>();
keys.add(genSingleEd25519Key(pubKey2privKeyMap));
keys.add(genSingleECDSASecp256k1Key(pubKey2privKeyMap));
keys.add(genThresholdKeyInstance(numKeys, threshold, pubKey2privKeyMap));
keys.add(genKeyListInstance(numKeys, pubKey2privKeyMap));
rv = genKeyList(keys);
// verify the size
final int size = computeNumOfExpandedKeys(rv, 1, new AtomicCounter());
assertEquals(2 + numKeys * 2, size);
} else {
throw new NotImplementedException("Not implemented yet.");
}
return rv;
}
Aggregations