Skip to content

Commit

Permalink
remove detritus from utils, rename to cryptography
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Nov 13, 2023
1 parent bfa12d7 commit a8d2514
Show file tree
Hide file tree
Showing 92 changed files with 343 additions and 2,340 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Apollo isn't designed for coins, rather as essentially a distributed multitenant

## Some Features
* Multitenant isolation enclaves using GraalVM Isolates
* Compact, self contained Crypto and Utility module - Self certifying, self describing Digests, Signatures and Identifiers as well as a generous sampling of solid Bloomfilters n cousins.
* Self contained cryptography module - Self describing Digests, Signatures and Identifiers, solid Bloomfilters.
* Decentralized Identifier based foundation and key managment infrastructure, based on the [Key Event Receipt Infrastructure](https://github.com/decentralized-identity/keri) (KERI)
* Secure and trusted attestation, identity boostrapping and secrets provisioning
* MTLS network communication - KERI for MTLS certificate authentication. Local communication simulation for simplified multinode simulation for single process (IDE) testing
* Multi instance GRPC service routing - Context keyed services and routing framework
* Byzantine intrusion tolerant secure membership and communications overlay providing virtually synchronous, stable membership views.
* Efficient and easy to reuse utility patterns for Fireflies ring style gossiping on membership contexts
* Efficient and easy to reuse communication patterns for Fireflies ring style gossiping on membership contexts
* Reliable Broadcast - garbage collected, context routed reliable broadcast
* Efficient atomic broadcast in asynchronous networks with byzantine nodes
* Dynamic, committee based, transaction causal ordering service producing linear logs - Replicated State Machines
Expand Down Expand Up @@ -85,7 +85,7 @@ Apollo is reasonably modularized mostly for the purpose of subsystem isolation a
* [Stereotomy Services](stereotomy-services) - GRPC services and protobuff interfaces for KERI services
* [Thoth](thoth/README.md) - Decentralized Stereotomy. Distributed hash table storage, protocols and API for managing KERI decentralized identity
* [Tron](tron/README.md) - Compact, sophisticated Finite State Machine model using Java Enums.
* [Utils](utils/README.md) - Base cryptography primitives and model. Bloom filters (of several varieties). Some general utility stuff.
* [Cryptography](cryptography/README.md) - Base cryptography primitives. Bloom filters (of several varieties). Some general utility stuff.


## Protobuf and GRPC
Expand Down
4 changes: 2 additions & 2 deletions choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import com.salesforce.apollo.membership.messaging.rbc.ReliableBroadcaster;
import com.salesforce.apollo.membership.messaging.rbc.ReliableBroadcaster.MessageAdapter;
import com.salesforce.apollo.membership.messaging.rbc.ReliableBroadcaster.Msg;
import com.salesforce.apollo.utils.RoundScheduler;
import com.salesforce.apollo.membership.RoundScheduler;
import com.salesforce.apollo.utils.Utils;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import io.grpc.StatusRuntimeException;
import org.h2.mvstore.MVMap;
import org.joou.ULong;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.salesforce.apollo.utils;
package com.salesforce.apollo.choam.support;

import java.time.Duration;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import com.salesforce.apollo.ring.RingIterator;
import com.salesforce.apollo.utils.Entropy;
import com.salesforce.apollo.utils.Pair;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter.ULongBloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter.ULongBloomFilter;
import org.joou.ULong;
import org.joou.Unsigned;
import org.slf4j.Logger;
Expand Down Expand Up @@ -279,7 +279,7 @@ private void computeGenesis(Map<Digest, Initial> votes) {
for (HashedCertifiedBlock cb : tally) {
int count = tally.count(cb);
if (count >= threshold) {
if (winner == null || count > winner.b) {
if (winner == null || count > winner.b()) {
winner = new Pair<>(cb, count);
}
}
Expand All @@ -291,7 +291,7 @@ private void computeGenesis(Map<Digest, Initial> votes) {
return;
}

genesis = winner.a;
genesis = winner.a();
log.info("Winner: {} on: {}", genesis.hash, params.member().getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.salesforce.apollo.membership.SigningMember;
import com.salesforce.apollo.ring.RingIterator;
import com.salesforce.apollo.utils.Entropy;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import org.h2.mvstore.MVMap;
import org.joou.ULong;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.salesfoce.apollo.choam.proto.Checkpoint;
import com.salesfoce.apollo.choam.proto.Slice;
import com.salesforce.apollo.utils.Utils;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;

/**
* @author hal.hildebrand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import com.salesfoce.apollo.choam.proto.Checkpoint;
import com.salesforce.apollo.crypto.Digest;
import com.salesforce.apollo.crypto.DigestAlgorithm;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;

/**
* Kind of a DAO for "nosql" block storage with MVStore from H2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.salesfoce.apollo.choam.proto.Validate;
import com.salesforce.apollo.ethereal.DataSource;
import com.salesforce.apollo.membership.Member;
import com.salesforce.apollo.utils.BatchingQueue;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.salesforce.apollo.utils;
package com.salesforce.apollo.choam.support;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -8,6 +8,8 @@

import java.time.Duration;

import com.salesforce.apollo.choam.support.BatchingQueue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.salesforce.apollo.stereotomy.StereotomyImpl;
import com.salesforce.apollo.stereotomy.mem.MemKERL;
import com.salesforce.apollo.stereotomy.mem.MemKeyStore;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import org.h2.mvstore.MVStore;
import org.joou.ULong;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.salesforce.apollo.stereotomy.mem.MemKERL;
import com.salesforce.apollo.stereotomy.mem.MemKeyStore;
import com.salesforce.apollo.utils.Utils;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import org.h2.mvstore.MVStore;
import org.joou.ULong;
import org.junit.jupiter.api.AfterEach;
Expand Down
2 changes: 2 additions & 0 deletions cryptography/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apollo Cryptography
Digests, signatures, keys, Bloom Filters, etc.
14 changes: 9 additions & 5 deletions utils/pom.xml → cryptography/pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.salesforce.apollo</groupId>
<artifactId>apollo.app</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>utils</artifactId>
<name>Utils</name>
<description>General utilities, Bloomfilters and cryptographic abstractions</description>

<artifactId>cryptography</artifactId>
<name>Cryptography</name>
<description>Digests, Signatures, Bloomfilters and cryptographic abstractions</description>

<dependencies>
<dependency>
Expand Down Expand Up @@ -73,4 +77,4 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.utils.bloomFilters;
package com.salesforce.apollo.bloomFilters;

import java.util.BitSet;
import java.util.function.Consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.utils.bloomFilters;
package com.salesforce.apollo.bloomFilters;

import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.utils.bloomFilters;

import static com.salesforce.apollo.utils.bloomFilters.Primes.PRIMES;
package com.salesforce.apollo.bloomFilters;

import java.nio.ByteBuffer;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -118,8 +116,8 @@ public int[] hashes(int k, M key, int m, long seed) {
hashes[i++] = hash;
// HITS++;
} else {
h2 += PRIMES[prime];
prime = ++prime % PRIMES.length;
h2 += Primes.PRIMES[prime];
prime = ++prime % Primes.PRIMES.length;
// MISSES++;
}
combinedHash += h2;
Expand Down Expand Up @@ -178,9 +176,9 @@ void process(int i) {
int reversed = Integer.reverse(i);
ByteBuffer bb = ByteBuffer.wrap(new byte[2 * 8]);
bb.putInt(i);
bb.putInt(i + PRIMES[(i & Integer.MAX_VALUE) % PRIMES.length]);
bb.putInt(i + Primes.PRIMES[(i & Integer.MAX_VALUE) % Primes.PRIMES.length]);
bb.putInt(reversed);
bb.putInt(reversed + PRIMES[((i + 1) & Integer.MAX_VALUE) % PRIMES.length]);
bb.putInt(reversed + Primes.PRIMES[((i + 1) & Integer.MAX_VALUE) % Primes.PRIMES.length]);
bb.flip();
process(bb);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.utils.bloomFilters;
package com.salesforce.apollo.bloomFilters;

/**
* @author hal.hildebrand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.salesfoce.apollo.utils.proto.Digeste.Builder;
import com.salesforce.apollo.utils.BUZ;
import com.salesforce.apollo.utils.Hex;
import com.salesforce.apollo.utils.bloomFilters.Hash;
import com.salesforce.apollo.bloomFilters.Hash;

/**
* A computed digest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.stream.Stream;

import com.salesfoce.apollo.utils.proto.HexBloome;
import com.salesforce.apollo.utils.bloomFilters.BloomFilter;
import com.salesforce.apollo.utils.bloomFilters.Primes;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import com.salesforce.apollo.bloomFilters.Primes;

/**
* Based on the paper <a href="https://eprint.iacr.org/2021/773.pdf">HEX-BLOOM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.causal;

import com.salesfoce.apollo.utils.proto.StampedClock;
package com.salesforce.apollo.utils;

/**
* @author hal.hildebrand
*
*/
public interface StampedClockValue<T extends Comparable<T>> extends ClockValue {

T instant();

int sum();

StampedClock toStampedClock();
public record Pair<A, B>(A a, B b) {
}
Loading

0 comments on commit a8d2514

Please sign in to comment.