diff --git a/net/pb/net.pb.go b/net/pb/net.pb.go index 51b042c5fa..15cc032271 100644 --- a/net/pb/net.pb.go +++ b/net/pb/net.pb.go @@ -440,14 +440,28 @@ func (x *FetchEncryptionKeyRequest) GetSignature() []byte { return nil } -type GetHeadLogRequest struct { +// FetchEncryptionKeyReply is a response to FetchEncryptionKeyRequest request +// by a peer that holds the requested doc encryption key. +type FetchEncryptionKeyReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // encryptedKey is array or bytes representing encrypted doc encryption key + // It is prepended with the responder's ephemeral public key and a nonce for AES-GCM + EncryptedKey []byte `protobuf:"bytes,1,opt,name=encryptedKey,proto3" json:"encryptedKey,omitempty"` + // cid is the CID of the composite of the document. + Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` + // schemaRoot is the SchemaRoot of the collection that the document resides in. + SchemaRoot []byte `protobuf:"bytes,3,opt,name=schemaRoot,proto3" json:"schemaRoot,omitempty"` + // reqEphemeralPublicKey is an ephemeral public of the requesting peer to be used as session id + ReqEphemeralPublicKey []byte `protobuf:"bytes,4,opt,name=reqEphemeralPublicKey,proto3" json:"reqEphemeralPublicKey,omitempty"` + // signature is the responding peer's signature of the reply + Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` } -func (x *GetHeadLogRequest) Reset() { - *x = GetHeadLogRequest{} +func (x *FetchEncryptionKeyReply) Reset() { + *x = FetchEncryptionKeyReply{} if protoimpl.UnsafeEnabled { mi := &file_net_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -455,13 +469,13 @@ func (x *GetHeadLogRequest) Reset() { } } -func (x *GetHeadLogRequest) String() string { +func (x *FetchEncryptionKeyReply) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetHeadLogRequest) ProtoMessage() {} +func (*FetchEncryptionKeyReply) ProtoMessage() {} -func (x *GetHeadLogRequest) ProtoReflect() protoreflect.Message { +func (x *FetchEncryptionKeyReply) ProtoReflect() protoreflect.Message { mi := &file_net_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -473,19 +487,54 @@ func (x *GetHeadLogRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetHeadLogRequest.ProtoReflect.Descriptor instead. -func (*GetHeadLogRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use FetchEncryptionKeyReply.ProtoReflect.Descriptor instead. +func (*FetchEncryptionKeyReply) Descriptor() ([]byte, []int) { return file_net_proto_rawDescGZIP(), []int{9} } -type PushLogReply struct { +func (x *FetchEncryptionKeyReply) GetEncryptedKey() []byte { + if x != nil { + return x.EncryptedKey + } + return nil +} + +func (x *FetchEncryptionKeyReply) GetCid() []byte { + if x != nil { + return x.Cid + } + return nil +} + +func (x *FetchEncryptionKeyReply) GetSchemaRoot() []byte { + if x != nil { + return x.SchemaRoot + } + return nil +} + +func (x *FetchEncryptionKeyReply) GetReqEphemeralPublicKey() []byte { + if x != nil { + return x.ReqEphemeralPublicKey + } + return nil +} + +func (x *FetchEncryptionKeyReply) GetSignature() []byte { + if x != nil { + return x.Signature + } + return nil +} + +type GetHeadLogRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *PushLogReply) Reset() { - *x = PushLogReply{} +func (x *GetHeadLogRequest) Reset() { + *x = GetHeadLogRequest{} if protoimpl.UnsafeEnabled { mi := &file_net_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -493,13 +542,13 @@ func (x *PushLogReply) Reset() { } } -func (x *PushLogReply) String() string { +func (x *GetHeadLogRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PushLogReply) ProtoMessage() {} +func (*GetHeadLogRequest) ProtoMessage() {} -func (x *PushLogReply) ProtoReflect() protoreflect.Message { +func (x *GetHeadLogRequest) ProtoReflect() protoreflect.Message { mi := &file_net_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -511,33 +560,19 @@ func (x *PushLogReply) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PushLogReply.ProtoReflect.Descriptor instead. -func (*PushLogReply) Descriptor() ([]byte, []int) { +// Deprecated: Use GetHeadLogRequest.ProtoReflect.Descriptor instead. +func (*GetHeadLogRequest) Descriptor() ([]byte, []int) { return file_net_proto_rawDescGZIP(), []int{10} } -// FetchEncryptionKeyReply is a response to FetchEncryptionKeyRequest request -// by a peer that holds the requested doc encryption key. -type FetchEncryptionKeyReply struct { +type PushLogReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // encryptedKey is array or bytes representing encrypted doc encryption key - // It is prepended with the responder's ephemeral public key and a nonce for AES-GCM - EncryptedKey []byte `protobuf:"bytes,1,opt,name=encryptedKey,proto3" json:"encryptedKey,omitempty"` - // cid is the CID of the composite of the document. - Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` - // schemaRoot is the SchemaRoot of the collection that the document resides in. - SchemaRoot []byte `protobuf:"bytes,3,opt,name=schemaRoot,proto3" json:"schemaRoot,omitempty"` - // reqEphemeralPublicKey is an ephemeral public of the requesting peer to be used as session id - ReqEphemeralPublicKey []byte `protobuf:"bytes,4,opt,name=reqEphemeralPublicKey,proto3" json:"reqEphemeralPublicKey,omitempty"` - // signature is the responding peer's signature of the reply - Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` } -func (x *FetchEncryptionKeyReply) Reset() { - *x = FetchEncryptionKeyReply{} +func (x *PushLogReply) Reset() { + *x = PushLogReply{} if protoimpl.UnsafeEnabled { mi := &file_net_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -545,13 +580,13 @@ func (x *FetchEncryptionKeyReply) Reset() { } } -func (x *FetchEncryptionKeyReply) String() string { +func (x *PushLogReply) String() string { return protoimpl.X.MessageStringOf(x) } -func (*FetchEncryptionKeyReply) ProtoMessage() {} +func (*PushLogReply) ProtoMessage() {} -func (x *FetchEncryptionKeyReply) ProtoReflect() protoreflect.Message { +func (x *PushLogReply) ProtoReflect() protoreflect.Message { mi := &file_net_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -563,46 +598,11 @@ func (x *FetchEncryptionKeyReply) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use FetchEncryptionKeyReply.ProtoReflect.Descriptor instead. -func (*FetchEncryptionKeyReply) Descriptor() ([]byte, []int) { +// Deprecated: Use PushLogReply.ProtoReflect.Descriptor instead. +func (*PushLogReply) Descriptor() ([]byte, []int) { return file_net_proto_rawDescGZIP(), []int{11} } -func (x *FetchEncryptionKeyReply) GetEncryptedKey() []byte { - if x != nil { - return x.EncryptedKey - } - return nil -} - -func (x *FetchEncryptionKeyReply) GetCid() []byte { - if x != nil { - return x.Cid - } - return nil -} - -func (x *FetchEncryptionKeyReply) GetSchemaRoot() []byte { - if x != nil { - return x.SchemaRoot - } - return nil -} - -func (x *FetchEncryptionKeyReply) GetReqEphemeralPublicKey() []byte { - if x != nil { - return x.ReqEphemeralPublicKey - } - return nil -} - -func (x *FetchEncryptionKeyReply) GetSignature() []byte { - if x != nil { - return x.Signature - } - return nil -} - type GetHeadLogReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -764,22 +764,22 @@ var file_net_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, - 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, - 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0xc3, 0x01, 0x0a, 0x17, - 0x46, 0x65, 0x74, 0x63, 0x68, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, - 0x65, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x6e, 0x63, 0x72, 0x79, - 0x70, 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, - 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x63, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x1e, 0x0a, - 0x0a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x0a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x34, 0x0a, - 0x15, 0x72, 0x65, 0x71, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x15, 0x72, 0x65, - 0x71, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, - 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xc3, 0x01, 0x0a, 0x17, 0x46, 0x65, 0x74, 0x63, 0x68, + 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x4b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, + 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x52, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x34, 0x0a, 0x15, 0x72, 0x65, 0x71, 0x45, + 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x15, 0x72, 0x65, 0x71, 0x45, 0x70, 0x68, 0x65, + 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1c, + 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x13, 0x0a, 0x11, + 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, + 0x79, 0x22, 0x11, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x32, 0xae, 0x03, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, 0x1a, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, @@ -834,9 +834,9 @@ var file_net_proto_goTypes = []any{ (*GetLogReply)(nil), // 6: net.pb.GetLogReply (*PushLogRequest)(nil), // 7: net.pb.PushLogRequest (*FetchEncryptionKeyRequest)(nil), // 8: net.pb.FetchEncryptionKeyRequest - (*GetHeadLogRequest)(nil), // 9: net.pb.GetHeadLogRequest - (*PushLogReply)(nil), // 10: net.pb.PushLogReply - (*FetchEncryptionKeyReply)(nil), // 11: net.pb.FetchEncryptionKeyReply + (*FetchEncryptionKeyReply)(nil), // 9: net.pb.FetchEncryptionKeyReply + (*GetHeadLogRequest)(nil), // 10: net.pb.GetHeadLogRequest + (*PushLogReply)(nil), // 11: net.pb.PushLogReply (*GetHeadLogReply)(nil), // 12: net.pb.GetHeadLogReply (*PushLogRequest_Body)(nil), // 13: net.pb.PushLogRequest.Body } @@ -848,12 +848,12 @@ var file_net_proto_depIdxs = []int32{ 5, // 4: net.pb.Service.GetLog:input_type -> net.pb.GetLogRequest 7, // 5: net.pb.Service.PushLog:input_type -> net.pb.PushLogRequest 8, // 6: net.pb.Service.TryGenEncryptionKey:input_type -> net.pb.FetchEncryptionKeyRequest - 9, // 7: net.pb.Service.GetHeadLog:input_type -> net.pb.GetHeadLogRequest + 10, // 7: net.pb.Service.GetHeadLog:input_type -> net.pb.GetHeadLogRequest 2, // 8: net.pb.Service.GetDocGraph:output_type -> net.pb.GetDocGraphReply 4, // 9: net.pb.Service.PushDocGraph:output_type -> net.pb.PushDocGraphReply 6, // 10: net.pb.Service.GetLog:output_type -> net.pb.GetLogReply - 10, // 11: net.pb.Service.PushLog:output_type -> net.pb.PushLogReply - 11, // 12: net.pb.Service.TryGenEncryptionKey:output_type -> net.pb.FetchEncryptionKeyReply + 11, // 11: net.pb.Service.PushLog:output_type -> net.pb.PushLogReply + 9, // 12: net.pb.Service.TryGenEncryptionKey:output_type -> net.pb.FetchEncryptionKeyReply 12, // 13: net.pb.Service.GetHeadLog:output_type -> net.pb.GetHeadLogReply 8, // [8:14] is the sub-list for method output_type 2, // [2:8] is the sub-list for method input_type @@ -977,7 +977,7 @@ func file_net_proto_init() { } } file_net_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*GetHeadLogRequest); i { + switch v := v.(*FetchEncryptionKeyReply); i { case 0: return &v.state case 1: @@ -989,7 +989,7 @@ func file_net_proto_init() { } } file_net_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*PushLogReply); i { + switch v := v.(*GetHeadLogRequest); i { case 0: return &v.state case 1: @@ -1001,7 +1001,7 @@ func file_net_proto_init() { } } file_net_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*FetchEncryptionKeyReply); i { + switch v := v.(*PushLogReply); i { case 0: return &v.state case 1: diff --git a/net/pb/net.proto b/net/pb/net.proto index 4390cff258..7c44efe735 100644 --- a/net/pb/net.proto +++ b/net/pb/net.proto @@ -56,10 +56,6 @@ message FetchEncryptionKeyRequest { bytes signature = 6; } -message GetHeadLogRequest {} - -message PushLogReply {} - // FetchEncryptionKeyReply is a response to FetchEncryptionKeyRequest request // by a peer that holds the requested doc encryption key. message FetchEncryptionKeyReply { @@ -76,6 +72,10 @@ message FetchEncryptionKeyReply { bytes signature = 5; } +message GetHeadLogRequest {} + +message PushLogReply {} + message GetHeadLogReply {} // Service is the peer-to-peer network API for document sync diff --git a/net/pb/net_vtproto.pb.go b/net/pb/net_vtproto.pb.go index 0a7daf30ba..6bc4141229 100644 --- a/net/pb/net_vtproto.pb.go +++ b/net/pb/net_vtproto.pb.go @@ -445,7 +445,7 @@ func (m *FetchEncryptionKeyRequest) MarshalToSizedBufferVT(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *GetHeadLogRequest) MarshalVT() (dAtA []byte, err error) { +func (m *FetchEncryptionKeyReply) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -458,12 +458,12 @@ func (m *GetHeadLogRequest) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GetHeadLogRequest) MarshalToVT(dAtA []byte) (int, error) { +func (m *FetchEncryptionKeyReply) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *GetHeadLogRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *FetchEncryptionKeyReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -475,10 +475,45 @@ func (m *GetHeadLogRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x2a + } + if len(m.ReqEphemeralPublicKey) > 0 { + i -= len(m.ReqEphemeralPublicKey) + copy(dAtA[i:], m.ReqEphemeralPublicKey) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ReqEphemeralPublicKey))) + i-- + dAtA[i] = 0x22 + } + if len(m.SchemaRoot) > 0 { + i -= len(m.SchemaRoot) + copy(dAtA[i:], m.SchemaRoot) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SchemaRoot))) + i-- + dAtA[i] = 0x1a + } + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Cid))) + i-- + dAtA[i] = 0x12 + } + if len(m.EncryptedKey) > 0 { + i -= len(m.EncryptedKey) + copy(dAtA[i:], m.EncryptedKey) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.EncryptedKey))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } -func (m *PushLogReply) MarshalVT() (dAtA []byte, err error) { +func (m *GetHeadLogRequest) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -491,12 +526,12 @@ func (m *PushLogReply) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PushLogReply) MarshalToVT(dAtA []byte) (int, error) { +func (m *GetHeadLogRequest) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *PushLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *GetHeadLogRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -511,7 +546,7 @@ func (m *PushLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *FetchEncryptionKeyReply) MarshalVT() (dAtA []byte, err error) { +func (m *PushLogReply) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -524,12 +559,12 @@ func (m *FetchEncryptionKeyReply) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *FetchEncryptionKeyReply) MarshalToVT(dAtA []byte) (int, error) { +func (m *PushLogReply) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *FetchEncryptionKeyReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *PushLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -541,41 +576,6 @@ func (m *FetchEncryptionKeyReply) MarshalToSizedBufferVT(dAtA []byte) (int, erro i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x2a - } - if len(m.ReqEphemeralPublicKey) > 0 { - i -= len(m.ReqEphemeralPublicKey) - copy(dAtA[i:], m.ReqEphemeralPublicKey) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ReqEphemeralPublicKey))) - i-- - dAtA[i] = 0x22 - } - if len(m.SchemaRoot) > 0 { - i -= len(m.SchemaRoot) - copy(dAtA[i:], m.SchemaRoot) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SchemaRoot))) - i-- - dAtA[i] = 0x1a - } - if len(m.Cid) > 0 { - i -= len(m.Cid) - copy(dAtA[i:], m.Cid) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Cid))) - i-- - dAtA[i] = 0x12 - } - if len(m.EncryptedKey) > 0 { - i -= len(m.EncryptedKey) - copy(dAtA[i:], m.EncryptedKey) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.EncryptedKey))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -764,26 +764,6 @@ func (m *FetchEncryptionKeyRequest) SizeVT() (n int) { return n } -func (m *GetHeadLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - func (m *FetchEncryptionKeyReply) SizeVT() (n int) { if m == nil { return 0 @@ -814,6 +794,26 @@ func (m *FetchEncryptionKeyReply) SizeVT() (n int) { return n } +func (m *GetHeadLogRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *PushLogReply) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + func (m *GetHeadLogReply) SizeVT() (n int) { if m == nil { return 0 @@ -1776,108 +1776,6 @@ func (m *FetchEncryptionKeyRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetHeadLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetHeadLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetHeadLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushLogReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushLogReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *FetchEncryptionKeyReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2099,6 +1997,108 @@ func (m *FetchEncryptionKeyReply) UnmarshalVT(dAtA []byte) error { } return nil } +func (m *GetHeadLogRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetHeadLogRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetHeadLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PushLogReply) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PushLogReply: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PushLogReply: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *GetHeadLogReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/net/server.go b/net/server.go index 5a8f8b477d..d2bf37c381 100644 --- a/net/server.go +++ b/net/server.go @@ -251,19 +251,6 @@ func (s *server) verifyRequestSignature(req *pb.FetchEncryptionKeyRequest, pubKe return pubKey.Verify(hashFetchEncryptionKeyRequest(req), req.Signature) } -func (s *server) verifyPeerInfo(peerID libpeer.ID, pubKey libp2pCrypto.PubKey) error { - derivedID, err := peer.IDFromPublicKey(pubKey) - if err != nil { - return err - } - - if peerID != derivedID { - return errors.New("peer ID does not match public key") - } - - return nil -} - func hashFetchEncryptionKeyReply(res *pb.FetchEncryptionKeyReply) []byte { hash := sha256.New() hash.Write(res.EncryptedKey)