syntax = "proto3"; package p2p; message GeneralMsg{ string uuid = 99; oneof msg { ResponseError error = 1; PeerApprovePinnerRequest PeerApproveRequest = 2; PeerApprovePinnerResponse PeerApproveResponse = 3; ApplyToBePinnerRequest ApplyPinnerRequest = 4; ApplyToBePinnerResponse ApplyPinnerResponse = 5; ApplyToExecuteTaskRequest ApplyToExecuteTaskRequest = 6; WinnerExecutorCert WinnerExecutorCert = 7; ErrandExecutionRequest ErrandExecutionRequest = 8; ErrandExecutionFailedResponse ErrandExecutionFailedResponse = 9; ErrandAdhocCodeCapCheckerRequest ErrandAdhocCodeCapCheckerRequest = 10; ErrandAdhocCodeCapCheckerResponse ErrandAdhocCodeCapCheckerResponse = 11; ErrandExecutionSucceededResponse ErrandExecutionSucceededResponse = 12; TaskKeyGenerationApplyRequst TaskKeyGenerationApplyRequst = 13; TaskExecutionRequest TaskExecutionRequest = 14; TaskExecutionResponse TaskExecutionResponse = 15; TaskPinnerKeySliceRequest TaskPinnerKeySliceRequest = 16; TaskPinnerKeySliceResponse TaskPinnerKeySliceResponse = 17; PeerApproveRaRequest PeerApproveRaRequest = 18; PeerApproveRaResponse PeerApproveRaResponse = 19; TaskSignWithKeySlicesRequst TaskSignWithKeySlicesRequst = 20; TaskSignWithKeySlicesResponse TaskSignWithKeySlicesResponse = 21; TaskSignGetPinnerKeySliceRequest TaskSignGetPinnerKeySliceRequest = 22; TaskSignGetPinnerKeySliceResponse TaskSignGetPinnerKeySliceResponse = 23; TaskCommitSignResultRequest TaskCommitSignResultRequest = 24; KeyGenerationCandidateRequest KeyGenerationCandidateRequest = 25; SignCandidateRequest SignCandidateRequest = 26; } } message ResponseError{ string error = 1; } message PeerApprovePinnerRequest {//this message is used when Find Provider found another //peer claimed a provider, we need to ask him and verify if he actually is string deploymentId = 1;//this is cid of pinner_key's pub key uint32 nonce = 2; // this is an random number for verify string uuid = 3; // this is the uuid of pinner store item bytes properties = 4; // this is the properties passing to pinner bytes ephemeralId = 5;// this is used in remote attestation string sendToActor = 6; } message PeerApproveRaRequest { string uuid = 1; // this is the uuid of pinner store item bytes properties = 2; // this is the properties passing to pinner bytes ephemeralId = 3;// this is used in remote attestation string sendToActor = 4; } message PeerApproveRaResponse { string uuid = 1; // this is the uuid of pinner store item bytes ephemeralId = 2;// this is used in remote attestation string sendToActor = 3; } message PeerApprovePinnerResponse { string deploymentId = 1;//this is cid of pinner_key's pub key bytes signature = 2;//The Ed25519 sig for nonce string uuid = 3; // this is the uuid of pinner store item bytes pinnerEphemeralId = 4;//The Ehpemeral Id of the pinner string sendToActor = 5; } message ApplyToBePinnerRequest{ string deploymentId = 1;//this is cid of pinner_key's pub key bytes rsaPubKey = 2;//Delegate will use this RSA Pub Key to encrypt the key1 when sending to Executor. Format is tpm_protp::RsaKeyPairPemPcsk1.publicKey string.as_bytes() bytes wannabePinnerId = 3;//The ephemeral Id of the wannabe pinner bytes signature = 4;//The Ed25519 sig for concat bytes: wannabe_ephemeral_id + rsa_key_pub string uuid = 5;//This uuid has no use for delegator (upstream pinner). The wannabe pinner will need this uuid to retrieve PinnerStoreItem //when ApplyToBePinnerResponse received. Upstream pinner only need to return the same uuid back to the wannabe pinner without any process } message ApplyToBePinnerResponse{ string deploymentId = 1;//this is cid of pinner_key's pub key bytes pinnerKeyEncrypted = 2; //The full pinner key encoded by rsa_pubkey from wannabe pinner. bytes key1Encrypted = 3; //The key1 encoded by rsa_pubkey from upstream pinner. bytes upstreamPinnerTeaId = 4;//use the upstream tea_id to make a broacasting chain so that we can trace back when make payment or verify //we use tea_id instead of ephemeral_id because this chain would be a long life time use. ephemeral key changes // every time the tea node reboot. // Base on today's idea, the first revenue comes from hosting as pinner will 100% go to upstream pinner. after that // the revenue doens't need to share to upstream // problem: what if the data is only for one time use? bytes signature = 5;//The Ed25519 sig for concat bytes: pinner's ephemeral key + pinner_key_enc string uuid = 6;//This uuid has no use for delegator (upstream pinner). The wannabe pinner will need this uuid to retrieve PinnerStoreItem //when ApplyToBePinnerResponse received. Upstream pinner only need to return the same uuid back to the wannabe pinner without any process } message WinnerExecutorCert{ bytes refNum = 1; bytes winnerTeaId = 2;//the winner who send the application and lucky get approved by delegator bytes signature = 3;//signer is delegate, msg is tea_id(32bytes) + ref_num(32bytes) bytes secKeysRsaBytes = 4;//Delegate decrypt eKey1, then encrypt using Executor's rsa pub key } message ApplyToExecuteTaskRequest{ bytes refNum = 1;//[u8] NOT a base 64 string slices. but if encoded using base64, it will become the pubsub topic. bytes ekey1 = 2;//Send to delegate, asking him to decrypt and send back bytes rsaPubKey = 3;//Delegate will use this RSA Pub Key to encrypt the key1 when sending to Executor. Format is tpm_protp::RsaKeyPairPemPcsk1.publicKey string.as_bytes() bytes executorTeaId = 6;//The Tea Id of the executor who apply for this task bytes signature = 7;//The Ed25519 sig for concat bytes: executorTeaId + capcheckers[0] + ..+ capcheckers[n] } message ErrandExecutionRequest{ bytes delegatorEphemeralId = 1;//The Ehpemeral Id of the delegator bytes errandId = 2; // this is id of the errand oneof code { ErrandDeploymentCode DeploymentCode = 3; // this is deployment code for the errand ErrandAdhocCode AdhocCode = 4; // this is adhoc code for the errand } oneof data { ErrandDeploymentData DeploymentData = 5; // this is deployment data for the errand string AdhocData = 6; // this is adhoc data for the errand } bytes signature = 7; // The Ed25519 sig for concat bytes: executorEphemeralId + expiryTime + errandId + proofOfDelegation oneof dataSignature { bytes Code = 8; // this is signature about adhoc code bytes Data = 9; // this is signature about adhoc data bool None = 10; // fill this item if there is no signature } uint64 expiryTime = 11; // this is expiration layer1 height about this request bytes proofOfDelegation = 12; // this is proof of delegation string clientAccountId = 13; // this is account id of the client uint32 payment = 14; // this is payment amount for this errand oneof key3 { bytes Key3Buf = 16; // this is bytes of key3 bool HasKey3 = 17; // set to false if there is no key3 } bytes delegatorTeaId = 18; // tea id of the delegator string errandJsonCid = 19; // this is cid of the errand json uint32 delegatorPercentage = 20; //this is percentage of distribution for delegator string delegatorPaymentAccount = 21; //this is payment account about delegator } message ErrandExecutionFailedResponse { bytes executorEphemeralId = 1;//The Ephemeral Id of the executor bytes errandId = 2; // this is id of the errand bytes signature = 3; // The Ed25519 sig for concat bytes: executorEphemeralId + errandId } message ErrandExecutionSucceededResponse { bytes errandId = 1;// this is id of the errand bytes result = 2; // this is result of the errand execution } message ErrandDeploymentData{ string deploymentId = 1; //this is deployment is of deployed data uint32 payPerUse = 2; //this is payment for everytime to use this data } message ErrandDeploymentCode{ string deploymentId = 1; //this is deployment is of deployed code uint32 payPerUse = 2; //this is payment for everytime to use this data } message ErrandAdhocCode{ string code = 1; // this is base64 encoded wasm bin without encryption string capCid = 2; // this is cid of cap checker wasm string description = 3; // this is description of code that including execution manifest } message ErrandAdhocCodeCapCheckerRequest{ bytes errandId = 1; // this is id of the errand string capChecker = 2; // this is base64 encoded capabilities checker wasm with encryption } message ErrandAdhocCodeCapCheckerResponse{ bytes candidateEphemeralId = 1;//The Ephemeral Id of the candidate bytes errandId = 2; // this is id of the errand string capCid = 3; // this is cid of cap checker wasm bool result = 4; // this is cap check result bytes signature = 5; // The Ed25519 sig for concat bytes: candidateEphemeralId + errandId + capCid + result } message KeyGenerationCandidateRequest { string taskId = 1; uint32 n = 2; // splite the secret to `n` pieces, note we support range of u8 (0~127) uint32 k = 3; // if have k (k < n) pieces the secret can be recovered, note we support range of u8 (0~127) string keyType = 4; // identify key generation type bytes delegatorEphemeralId = 5; bool executor = 6; bytes signature = 7; // The Ed25519 sig for concat bytes: taskId + n + k + keyType + delegatorEphemeralId + executor } message TaskKeyGenerationApplyRequst { string taskId = 1; bytes rsaPubKey = 2; CapabilityDescription cap_desc = 3; bool applyExecutor = 4; // decide whether to apply executor or not, if true apply executor otherwise apply initial pinner } message CapabilityDescription { } message TaskExecutionInitialPinnerData { string peerId = 1; bytes rsaPubKey = 2; } message TaskExecutionRequest { string taskId = 1; repeated TaskExecutionInitialPinnerData initialPinners = 2; uint32 minimumRecoveryNumber = 3; // support range of u8 (0~127) string keyType = 4; bytes p1PublicKey = 5; } message TaskResultInitialPinnerData { string peerId = 1; bytes encryptedKeySlice = 2; } message TaskExecutionResponse { string taskId = 1; repeated TaskResultInitialPinnerData initialPinners = 2; bytes p2PublicKey = 3; bytes multiSigAccount = 4; } message TaskPinnerKeySliceRequest { string taskId = 1; bytes publicKey = 2; bytes encryptedKeySlice = 3; bytes multiSigAccount = 4; } message TaskPinnerKeySliceResponse { string taskId = 1; string deploymentId = 2; } message TaskSignWithKeySlicesRequst { string taskId = 1; bytes rsaPubKey = 2; CapabilityDescription cap_desc = 3; } message TaskSignWithKeySlicesResponse { string taskId = 1; bytes adhocData = 2; bytes p1Signature = 3; repeated bytes encryptedKeySlices = 4; string keyType = 5; } message TaskSignGetPinnerKeySliceRequest { string taskId = 1; bytes rsaPubKey = 2; // this the pub key for executor, used to encryt key slice string deploymentId = 3; } message TaskSignGetPinnerKeySliceResponse { string taskId = 1; bytes encryptedKeySlice = 2; string deploymentId = 3; } message TaskCommitSignResultRequest { string taskId = 1; repeated bytes witness = 2; } message SignCandidateRequest { string taskId = 1; bytes multiSigAccount = 2; uint32 n = 3; uint32 k = 4; string taskType = 5; } message P2pReplyMessage { string uuid = 1; string peerId = 2; string content = 3; P2pReplyType replyType = 4; P2pReplyError replyError = 5; } message P2pReplyError { string message = 1; } enum P2pReplyType { Success = 0; Cancelled = 1; Rejected = 2; Error = 3; }