zephyrfs/zephyrfs-proto / 0169688

Browse files

add comprehensive P2P protocol definitions with security, capability, and reputation services + Makefile build system

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
0169688499b379719fd62bbd465331691e692454
Parents
3549e51
Tree
ffc5a81

3 changed files

StatusFile+-
A Makefile 87 0
M README.md bin
A protobuff/security.proto 147 0
Makefileadded
@@ -0,0 +1,87 @@
1
+# ZephyrFS Protocol Buffer Makefile
2
+
3
+# Directories
4
+PROTO_DIR = protobuff
5
+GEN_DIR = generated
6
+RUST_OUT = $(GEN_DIR)/rust
7
+GO_OUT = $(GEN_DIR)/go
8
+TS_OUT = $(GEN_DIR)/typescript
9
+
10
+# Proto files
11
+PROTO_FILES = $(wildcard $(PROTO_DIR)/*.proto)
12
+
13
+# Tools
14
+PROTOC = protoc
15
+RUST_PLUGIN = --rust_out=$(RUST_OUT) --rust-grpc_out=$(RUST_OUT)
16
+GO_PLUGIN = --go_out=$(GO_OUT) --go-grpc_out=$(GO_OUT)
17
+TS_PLUGIN = --ts_out=$(TS_OUT) --grpc-web_out=import_style=typescript,mode=grpcweb:$(TS_OUT)
18
+
19
+.PHONY: all clean rust go typescript setup
20
+
21
+all: setup rust go typescript
22
+
23
+setup:
24
+	@mkdir -p $(RUST_OUT) $(GO_OUT) $(TS_OUT)
25
+
26
+rust: setup
27
+	@echo "Generating Rust code from protobuf files..."
28
+	@for proto in $(PROTO_FILES); do \
29
+		$(PROTOC) --proto_path=$(PROTO_DIR) $(RUST_PLUGIN) $$proto; \
30
+	done
31
+	@echo "Rust protobuf generation complete"
32
+
33
+go: setup
34
+	@echo "Generating Go code from protobuf files..."
35
+	@for proto in $(PROTO_FILES); do \
36
+		$(PROTOC) --proto_path=$(PROTO_DIR) $(GO_PLUGIN) $$proto; \
37
+	done
38
+	@echo "Go protobuf generation complete"
39
+
40
+typescript: setup
41
+	@echo "Generating TypeScript code from protobuf files..."
42
+	@for proto in $(PROTO_FILES); do \
43
+		$(PROTOC) --proto_path=$(PROTO_DIR) $(TS_PLUGIN) $$proto; \
44
+	done
45
+	@echo "TypeScript protobuf generation complete"
46
+
47
+clean:
48
+	@echo "Cleaning generated files..."
49
+	@rm -rf $(GEN_DIR)
50
+	@echo "Clean complete"
51
+
52
+install-deps:
53
+	@echo "Installing protobuf compiler dependencies..."
54
+	# Install protoc (platform-specific)
55
+	@if command -v apt-get >/dev/null 2>&1; then \
56
+		sudo apt-get update && sudo apt-get install -y protobuf-compiler; \
57
+	elif command -v brew >/dev/null 2>&1; then \
58
+		brew install protobuf; \
59
+	elif command -v pacman >/dev/null 2>&1; then \
60
+		sudo pacman -S protobuf; \
61
+	else \
62
+		echo "Please install protobuf compiler manually"; \
63
+		exit 1; \
64
+	fi
65
+	# Install Rust protobuf plugins
66
+	@cargo install protobuf-codegen protoc-gen-rust grpc-compiler
67
+	# Install Go protobuf plugins
68
+	@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
69
+	@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
70
+	# Install TypeScript protobuf plugins
71
+	@npm install -g protoc-gen-ts protoc-gen-grpc-web
72
+
73
+validate:
74
+	@echo "Validating protobuf files..."
75
+	@for proto in $(PROTO_FILES); do \
76
+		echo "Validating $$proto..."; \
77
+		$(PROTOC) --proto_path=$(PROTO_DIR) --descriptor_set_out=/dev/null $$proto || exit 1; \
78
+	done
79
+	@echo "All protobuf files are valid"
80
+
81
+docs:
82
+	@echo "Generating protocol documentation..."
83
+	@mkdir -p docs/generated
84
+	@$(PROTOC) --proto_path=$(PROTO_DIR) --doc_out=docs/generated --doc_opt=html,index.html $(PROTO_FILES)
85
+	@echo "Documentation generated in docs/generated/"
86
+
87
+.PHONY: install-deps validate docs
README.mdmodified
Binary file changed.
protobuff/security.protoadded
@@ -0,0 +1,147 @@
1
+syntax = "proto3";
2
+
3
+package zephyrfs.security;
4
+
5
+option go_package = "github.com/ZephyrFS/zephyrfs-proto/gen/go/security";
6
+
7
+// Security service for encryption and capability management
8
+service SecurityService {
9
+  // Capability-based access control
10
+  rpc ValidateCapability(ValidateCapabilityRequest) returns (ValidateCapabilityResponse);
11
+  rpc GenerateCapability(GenerateCapabilityRequest) returns (GenerateCapabilityResponse);
12
+  rpc RevokeCapability(RevokeCapabilityRequest) returns (RevokeCapabilityResponse);
13
+
14
+  // Proof-of-storage challenges
15
+  rpc IssueChallenge(IssueChallengeRequest) returns (IssueChallengeResponse);
16
+  rpc SubmitProof(SubmitProofRequest) returns (SubmitProofResponse);
17
+
18
+  // Trust and reputation
19
+  rpc UpdateReputation(UpdateReputationRequest) returns (UpdateReputationResponse);
20
+  rpc GetReputation(GetReputationRequest) returns (GetReputationResponse);
21
+}
22
+
23
+// Capability management messages
24
+message ValidateCapabilityRequest {
25
+  string capability_token = 1;
26
+  string resource_id = 2;
27
+  string operation = 3; // "read", "write", "share", "delete"
28
+}
29
+
30
+message ValidateCapabilityResponse {
31
+  bool valid = 1;
32
+  string message = 2;
33
+  CapabilityInfo capability_info = 3;
34
+}
35
+
36
+message GenerateCapabilityRequest {
37
+  string resource_id = 1;
38
+  repeated string permissions = 2;
39
+  int64 expires_at = 3; // Unix timestamp, 0 for no expiration
40
+  string issuer_node_id = 4;
41
+}
42
+
43
+message GenerateCapabilityResponse {
44
+  bool success = 1;
45
+  string message = 2;
46
+  string capability_token = 3;
47
+  CapabilityInfo capability_info = 4;
48
+}
49
+
50
+message RevokeCapabilityRequest {
51
+  string capability_token = 1;
52
+  string reason = 2;
53
+}
54
+
55
+message RevokeCapabilityResponse {
56
+  bool success = 1;
57
+  string message = 2;
58
+}
59
+
60
+// Proof-of-storage messages
61
+message IssueChallengeRequest {
62
+  string node_id = 1;
63
+  string chunk_id = 2;
64
+  bytes challenge_data = 3;
65
+  int64 expires_at = 4;
66
+}
67
+
68
+message IssueChallengeResponse {
69
+  bool success = 1;
70
+  string message = 2;
71
+  string challenge_id = 3;
72
+}
73
+
74
+message SubmitProofRequest {
75
+  string challenge_id = 1;
76
+  string node_id = 2;
77
+  bytes proof_data = 3;
78
+  string merkle_root = 4;
79
+  repeated bytes merkle_path = 5;
80
+}
81
+
82
+message SubmitProofResponse {
83
+  bool valid = 1;
84
+  string message = 2;
85
+  double reputation_delta = 3;
86
+}
87
+
88
+// Reputation management messages
89
+message UpdateReputationRequest {
90
+  string node_id = 1;
91
+  double score_delta = 2;
92
+  string event_type = 3; // "storage_success", "storage_failure", "audit_pass", "audit_fail"
93
+  string evidence = 4;
94
+}
95
+
96
+message UpdateReputationResponse {
97
+  bool success = 1;
98
+  string message = 2;
99
+  double new_score = 3;
100
+}
101
+
102
+message GetReputationRequest {
103
+  string node_id = 1;
104
+  bool include_history = 2;
105
+}
106
+
107
+message GetReputationResponse {
108
+  bool success = 1;
109
+  string message = 2;
110
+  ReputationInfo reputation = 3;
111
+}
112
+
113
+// Data structures
114
+message CapabilityInfo {
115
+  string capability_id = 1;
116
+  string resource_id = 2;
117
+  repeated string permissions = 3;
118
+  int64 issued_at = 4;
119
+  int64 expires_at = 5;
120
+  string issuer_node_id = 6;
121
+  bool revoked = 7;
122
+  int32 usage_count = 8;
123
+}
124
+
125
+message ReputationInfo {
126
+  string node_id = 1;
127
+  double current_score = 2;
128
+  int64 last_updated = 3;
129
+  repeated ReputationEvent history = 4;
130
+  ReputationStats stats = 5;
131
+}
132
+
133
+message ReputationEvent {
134
+  int64 timestamp = 1;
135
+  string event_type = 2;
136
+  double score_delta = 3;
137
+  string details = 4;
138
+}
139
+
140
+message ReputationStats {
141
+  int32 total_challenges = 1;
142
+  int32 successful_challenges = 2;
143
+  int32 failed_challenges = 3;
144
+  double uptime_percentage = 4;
145
+  int64 storage_provided_bytes = 5;
146
+  int64 data_served_bytes = 6;
147
+}