Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kerl verifier #165

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class HexBloom {
public static final double DEFAULT_FPR = 0.0001;
public static final long DEFAULT_SEED = Primes.PRIMES[666];
private static final Function<Digest, Digest> IDENTITY = d -> d;
private static int MINIMUM_BFF_CARD = 100;
private static final int MINIMUM_BFF_CARD = 100;

private final int cardinality;
private final Digest[] crowns;
private BloomFilter<Digest> membership;
private final BloomFilter<Digest> membership;

public HexBloom(Digest initial, int count) {
assert count > 0;
Expand Down Expand Up @@ -567,10 +567,6 @@ public void add(Digest digest) {
public List<Digest> crowns() {
return accumulators.stream().map(ar -> ar.get()).toList();
}

public List<Digest> wrapped() {
return accumulators.stream().map(ar -> ar.get()).toList();
}
}

public static class HexAccumulator extends Accumulator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Sig toSig() {
@Override
public String toString() {
return "Sig[" + Arrays.asList(bytes).stream().map(b -> Hex.hexSubString(b, 12)).toList() + ":"
+ algorithm.signatureCode() + "]";
+ algorithm.signatureCode() + " #" + sequenceNumber + "]";
}

public boolean verify(SigningThreshold threshold, Map<Integer, PublicKey> keys, InputStream input) {
Expand Down Expand Up @@ -167,4 +167,8 @@ public boolean verify(SigningThreshold threshold, Map<Integer, PublicKey> keys,
int[] arrIndexes = verifiedSignatures.stream().mapToInt(i -> i.intValue()).toArray();
return SigningThreshold.thresholdMet(threshold, arrIndexes);
}

public ULong getSequenceNumber() {
return sequenceNumber;
}
}
71 changes: 36 additions & 35 deletions grpc/src/main/proto/stereotomy-services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,77 @@ import "google/protobuf/empty.proto";
import "crypto.proto";
import "stereotomy.proto";

package stereotomy.services;
package stereotomy.services;

message KeyStates {
repeated KeyState_ keyStates = 1;
repeated KeyState_ keyStates = 1;
}

message AttachmentsContext {
repeated AttachmentEvent attachments = 1;
repeated AttachmentEvent attachments = 1;
}

message KERLContext {
stereotomy.KERL_ kerl = 1;
repeated stereotomy.Validations validations = 2;
stereotomy.KERL_ kerl = 1;
repeated stereotomy.Validations validations = 2;
}

message KeyEventContext {
KeyEvent_ keyEvent = 1;
Validations validations = 2;
KeyEvent_ keyEvent = 1;
Validations validations = 2;
}

message KeyEventsContext {
repeated KeyEvent_ keyEvent = 1;
repeated stereotomy.Validations validations = 2;
repeated KeyEvent_ keyEvent = 1;
repeated stereotomy.Validations validations = 2;
}

message KeyEventWithAttachmentsContext {
repeated KeyEvent_ events = 1;
repeated AttachmentEvent attachments = 2;
repeated KeyEvent_ events = 1;
repeated AttachmentEvent attachments = 2;
}

message AttachmentEvents {
repeated AttachmentEvent attachments = 1;
message AttachmentEvents {
repeated AttachmentEvent attachments = 1;
}

service KERLService {
rpc append (KeyEventsContext) returns(KeyStates) {}
rpc appendKERL (KERLContext) returns(KeyStates) {}
rpc appendWithAttachments (KeyEventWithAttachmentsContext) returns(KeyStates) {}
rpc appendAttachments (AttachmentsContext) returns(google.protobuf.Empty) {}
rpc appendValidations (stereotomy.Validations ) returns (google.protobuf.Empty) {}
rpc append (KeyEventsContext) returns(KeyStates) {}
rpc appendKERL (KERLContext) returns(KeyStates) {}
rpc appendWithAttachments (KeyEventWithAttachmentsContext) returns(KeyStates) {}
rpc appendAttachments (AttachmentsContext) returns(google.protobuf.Empty) {}
rpc appendValidations (stereotomy.Validations) returns (google.protobuf.Empty) {}

rpc getAttachment (stereotomy.EventCoords) returns(Attachment) {}
rpc getKeyEvent (crypto.Digeste ) returns(KeyEvent_) {}
rpc getKeyEventCoords (stereotomy.EventCoords) returns(KeyEvent_) {}
rpc getKeyState (stereotomy.Ident) returns (stereotomy.KeyState_) {}
rpc getKeyStateCoords (stereotomy.EventCoords) returns (stereotomy.KeyState_) {}
rpc getKeyStateWithAttachments (stereotomy.EventCoords) returns (stereotomy.KeyStateWithAttachments_) {}
rpc getKeyStateWithEndorsementsAndValidations (stereotomy.EventCoords) returns (stereotomy.KeyStateWithEndorsementsAndValidations_) {}
rpc getKERL (stereotomy.Ident) returns (stereotomy.KERL_) {}
rpc getValidations (stereotomy.EventCoords) returns (stereotomy.Validations) {}
rpc getAttachment (stereotomy.EventCoords) returns(Attachment) {}
rpc getKeyEvent (crypto.Digeste) returns(KeyEvent_) {}
rpc getKeyEventCoords (stereotomy.EventCoords) returns(KeyEvent_) {}
rpc getKeyState (stereotomy.Ident) returns (stereotomy.KeyState_) {}
rpc getKeyStateSeqNum (stereotomy.IdentAndSeq) returns (stereotomy.KeyState_) {}
rpc getKeyStateCoords (stereotomy.EventCoords) returns (stereotomy.KeyState_) {}
rpc getKeyStateWithAttachments (stereotomy.EventCoords) returns (stereotomy.KeyStateWithAttachments_) {}
rpc getKeyStateWithEndorsementsAndValidations (stereotomy.EventCoords) returns (stereotomy.KeyStateWithEndorsementsAndValidations_) {}
rpc getKERL (stereotomy.Ident) returns (stereotomy.KERL_) {}
rpc getValidations (stereotomy.EventCoords) returns (stereotomy.Validations) {}
}

service EventObserver {
rpc publish(KERLContext) returns(google.protobuf.Empty) {}
rpc publishEvents (KeyEventsContext) returns(google.protobuf.Empty) {}
rpc publishAttachments (AttachmentsContext) returns(google.protobuf.Empty) {}
service EventObserver {
rpc publish(KERLContext) returns(google.protobuf.Empty) {}
rpc publishEvents (KeyEventsContext) returns(google.protobuf.Empty) {}
rpc publishAttachments (AttachmentsContext) returns(google.protobuf.Empty) {}
}

// Binding API for Resolver
service Binder {
rpc bind(stereotomy.Binding ) returns(google.protobuf.Empty) {}
rpc unbind(stereotomy.Ident) returns(google.protobuf.Empty) {}
rpc bind(stereotomy.Binding) returns(google.protobuf.Empty) {}
rpc unbind(stereotomy.Ident) returns(google.protobuf.Empty) {}
}

// Resolver API
service Resolver {
rpc lookup (stereotomy.Ident) returns (stereotomy.Binding) {}
rpc lookup (stereotomy.Ident) returns (stereotomy.Binding) {}
}

// Validator API
service Validator {
rpc validate(KeyEventContext) returns (google.protobuf.BoolValue) {}
rpc validate(KeyEventContext) returns (google.protobuf.BoolValue) {}
}
Loading