@@ -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 | +} |