1// Code generated by protoc-gen-gogo. DO NOT EDIT. 2// source: envelope.proto 3 4package record_pb 5 6import ( 7 fmt "fmt" 8 proto "github.com/gogo/protobuf/proto" 9 pb "github.com/libp2p/go-libp2p-core/crypto/pb" 10 io "io" 11 math "math" 12 math_bits "math/bits" 13) 14 15// Reference imports to suppress errors if they are not otherwise used. 16var _ = proto.Marshal 17var _ = fmt.Errorf 18var _ = math.Inf 19 20// This is a compile-time assertion to ensure that this generated file 21// is compatible with the proto package it is being compiled against. 22// A compilation error at this line likely means your copy of the 23// proto package needs to be updated. 24const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package 25 26// Envelope encloses a signed payload produced by a peer, along with the public 27// key of the keypair it was signed with so that it can be statelessly validated 28// by the receiver. 29// 30// The payload is prefixed with a byte string that determines the type, so it 31// can be deserialized deterministically. Often, this byte string is a 32// multicodec. 33type Envelope struct { 34 // public_key is the public key of the keypair the enclosed payload was 35 // signed with. 36 PublicKey *pb.PublicKey `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` 37 // payload_type encodes the type of payload, so that it can be deserialized 38 // deterministically. 39 PayloadType []byte `protobuf:"bytes,2,opt,name=payload_type,json=payloadType,proto3" json:"payload_type,omitempty"` 40 // payload is the actual payload carried inside this envelope. 41 Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` 42 // signature is the signature produced by the private key corresponding to 43 // the enclosed public key, over the payload, prefixing a domain string for 44 // additional security. 45 Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` 46} 47 48func (m *Envelope) Reset() { *m = Envelope{} } 49func (m *Envelope) String() string { return proto.CompactTextString(m) } 50func (*Envelope) ProtoMessage() {} 51func (*Envelope) Descriptor() ([]byte, []int) { 52 return fileDescriptor_ee266e8c558e9dc5, []int{0} 53} 54func (m *Envelope) XXX_Unmarshal(b []byte) error { 55 return m.Unmarshal(b) 56} 57func (m *Envelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 58 if deterministic { 59 return xxx_messageInfo_Envelope.Marshal(b, m, deterministic) 60 } else { 61 b = b[:cap(b)] 62 n, err := m.MarshalToSizedBuffer(b) 63 if err != nil { 64 return nil, err 65 } 66 return b[:n], nil 67 } 68} 69func (m *Envelope) XXX_Merge(src proto.Message) { 70 xxx_messageInfo_Envelope.Merge(m, src) 71} 72func (m *Envelope) XXX_Size() int { 73 return m.Size() 74} 75func (m *Envelope) XXX_DiscardUnknown() { 76 xxx_messageInfo_Envelope.DiscardUnknown(m) 77} 78 79var xxx_messageInfo_Envelope proto.InternalMessageInfo 80 81func (m *Envelope) GetPublicKey() *pb.PublicKey { 82 if m != nil { 83 return m.PublicKey 84 } 85 return nil 86} 87 88func (m *Envelope) GetPayloadType() []byte { 89 if m != nil { 90 return m.PayloadType 91 } 92 return nil 93} 94 95func (m *Envelope) GetPayload() []byte { 96 if m != nil { 97 return m.Payload 98 } 99 return nil 100} 101 102func (m *Envelope) GetSignature() []byte { 103 if m != nil { 104 return m.Signature 105 } 106 return nil 107} 108 109func init() { 110 proto.RegisterType((*Envelope)(nil), "record.pb.Envelope") 111} 112 113func init() { proto.RegisterFile("envelope.proto", fileDescriptor_ee266e8c558e9dc5) } 114 115var fileDescriptor_ee266e8c558e9dc5 = []byte{ 116 // 205 bytes of a gzipped FileDescriptorProto 117 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0xcd, 0x2b, 0x4b, 118 0xcd, 0xc9, 0x2f, 0x48, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x2c, 0x4a, 0x4d, 0xce, 119 0x2f, 0x4a, 0xd1, 0x2b, 0x48, 0x92, 0x12, 0x4b, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x48, 120 0xd2, 0x87, 0xb0, 0x20, 0x4a, 0x94, 0x66, 0x31, 0x72, 0x71, 0xb8, 0x42, 0x75, 0x09, 0x19, 0x73, 121 0x71, 0x15, 0x94, 0x26, 0xe5, 0x64, 0x26, 0xc7, 0x67, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 122 0x70, 0x1b, 0x89, 0xe8, 0xc1, 0xd4, 0x27, 0xe9, 0x05, 0x80, 0x25, 0xbd, 0x53, 0x2b, 0x83, 0x38, 123 0x0b, 0x60, 0x4c, 0x21, 0x45, 0x2e, 0x9e, 0x82, 0xc4, 0xca, 0x9c, 0xfc, 0xc4, 0x94, 0xf8, 0x92, 124 0xca, 0x82, 0x54, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x9e, 0x20, 0x6e, 0xa8, 0x58, 0x48, 0x65, 0x41, 125 0xaa, 0x90, 0x04, 0x17, 0x3b, 0x94, 0x2b, 0xc1, 0x0c, 0x96, 0x85, 0x71, 0x85, 0x64, 0xb8, 0x38, 126 0x8b, 0x33, 0xd3, 0xf3, 0x12, 0x4b, 0x4a, 0x8b, 0x52, 0x25, 0x58, 0xc1, 0x72, 0x08, 0x01, 0x27, 127 0x89, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 128 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x48, 0x62, 0x03, 0xbb, 0xde, 0x18, 129 0x10, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x0b, 0xd9, 0x6d, 0xf2, 0x00, 0x00, 0x00, 130} 131 132func (m *Envelope) Marshal() (dAtA []byte, err error) { 133 size := m.Size() 134 dAtA = make([]byte, size) 135 n, err := m.MarshalToSizedBuffer(dAtA[:size]) 136 if err != nil { 137 return nil, err 138 } 139 return dAtA[:n], nil 140} 141 142func (m *Envelope) MarshalTo(dAtA []byte) (int, error) { 143 size := m.Size() 144 return m.MarshalToSizedBuffer(dAtA[:size]) 145} 146 147func (m *Envelope) MarshalToSizedBuffer(dAtA []byte) (int, error) { 148 i := len(dAtA) 149 _ = i 150 var l int 151 _ = l 152 if len(m.Signature) > 0 { 153 i -= len(m.Signature) 154 copy(dAtA[i:], m.Signature) 155 i = encodeVarintEnvelope(dAtA, i, uint64(len(m.Signature))) 156 i-- 157 dAtA[i] = 0x2a 158 } 159 if len(m.Payload) > 0 { 160 i -= len(m.Payload) 161 copy(dAtA[i:], m.Payload) 162 i = encodeVarintEnvelope(dAtA, i, uint64(len(m.Payload))) 163 i-- 164 dAtA[i] = 0x1a 165 } 166 if len(m.PayloadType) > 0 { 167 i -= len(m.PayloadType) 168 copy(dAtA[i:], m.PayloadType) 169 i = encodeVarintEnvelope(dAtA, i, uint64(len(m.PayloadType))) 170 i-- 171 dAtA[i] = 0x12 172 } 173 if m.PublicKey != nil { 174 { 175 size, err := m.PublicKey.MarshalToSizedBuffer(dAtA[:i]) 176 if err != nil { 177 return 0, err 178 } 179 i -= size 180 i = encodeVarintEnvelope(dAtA, i, uint64(size)) 181 } 182 i-- 183 dAtA[i] = 0xa 184 } 185 return len(dAtA) - i, nil 186} 187 188func encodeVarintEnvelope(dAtA []byte, offset int, v uint64) int { 189 offset -= sovEnvelope(v) 190 base := offset 191 for v >= 1<<7 { 192 dAtA[offset] = uint8(v&0x7f | 0x80) 193 v >>= 7 194 offset++ 195 } 196 dAtA[offset] = uint8(v) 197 return base 198} 199func (m *Envelope) Size() (n int) { 200 if m == nil { 201 return 0 202 } 203 var l int 204 _ = l 205 if m.PublicKey != nil { 206 l = m.PublicKey.Size() 207 n += 1 + l + sovEnvelope(uint64(l)) 208 } 209 l = len(m.PayloadType) 210 if l > 0 { 211 n += 1 + l + sovEnvelope(uint64(l)) 212 } 213 l = len(m.Payload) 214 if l > 0 { 215 n += 1 + l + sovEnvelope(uint64(l)) 216 } 217 l = len(m.Signature) 218 if l > 0 { 219 n += 1 + l + sovEnvelope(uint64(l)) 220 } 221 return n 222} 223 224func sovEnvelope(x uint64) (n int) { 225 return (math_bits.Len64(x|1) + 6) / 7 226} 227func sozEnvelope(x uint64) (n int) { 228 return sovEnvelope(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 229} 230func (m *Envelope) Unmarshal(dAtA []byte) error { 231 l := len(dAtA) 232 iNdEx := 0 233 for iNdEx < l { 234 preIndex := iNdEx 235 var wire uint64 236 for shift := uint(0); ; shift += 7 { 237 if shift >= 64 { 238 return ErrIntOverflowEnvelope 239 } 240 if iNdEx >= l { 241 return io.ErrUnexpectedEOF 242 } 243 b := dAtA[iNdEx] 244 iNdEx++ 245 wire |= uint64(b&0x7F) << shift 246 if b < 0x80 { 247 break 248 } 249 } 250 fieldNum := int32(wire >> 3) 251 wireType := int(wire & 0x7) 252 if wireType == 4 { 253 return fmt.Errorf("proto: Envelope: wiretype end group for non-group") 254 } 255 if fieldNum <= 0 { 256 return fmt.Errorf("proto: Envelope: illegal tag %d (wire type %d)", fieldNum, wire) 257 } 258 switch fieldNum { 259 case 1: 260 if wireType != 2 { 261 return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) 262 } 263 var msglen int 264 for shift := uint(0); ; shift += 7 { 265 if shift >= 64 { 266 return ErrIntOverflowEnvelope 267 } 268 if iNdEx >= l { 269 return io.ErrUnexpectedEOF 270 } 271 b := dAtA[iNdEx] 272 iNdEx++ 273 msglen |= int(b&0x7F) << shift 274 if b < 0x80 { 275 break 276 } 277 } 278 if msglen < 0 { 279 return ErrInvalidLengthEnvelope 280 } 281 postIndex := iNdEx + msglen 282 if postIndex < 0 { 283 return ErrInvalidLengthEnvelope 284 } 285 if postIndex > l { 286 return io.ErrUnexpectedEOF 287 } 288 if m.PublicKey == nil { 289 m.PublicKey = &pb.PublicKey{} 290 } 291 if err := m.PublicKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { 292 return err 293 } 294 iNdEx = postIndex 295 case 2: 296 if wireType != 2 { 297 return fmt.Errorf("proto: wrong wireType = %d for field PayloadType", wireType) 298 } 299 var byteLen int 300 for shift := uint(0); ; shift += 7 { 301 if shift >= 64 { 302 return ErrIntOverflowEnvelope 303 } 304 if iNdEx >= l { 305 return io.ErrUnexpectedEOF 306 } 307 b := dAtA[iNdEx] 308 iNdEx++ 309 byteLen |= int(b&0x7F) << shift 310 if b < 0x80 { 311 break 312 } 313 } 314 if byteLen < 0 { 315 return ErrInvalidLengthEnvelope 316 } 317 postIndex := iNdEx + byteLen 318 if postIndex < 0 { 319 return ErrInvalidLengthEnvelope 320 } 321 if postIndex > l { 322 return io.ErrUnexpectedEOF 323 } 324 m.PayloadType = append(m.PayloadType[:0], dAtA[iNdEx:postIndex]...) 325 if m.PayloadType == nil { 326 m.PayloadType = []byte{} 327 } 328 iNdEx = postIndex 329 case 3: 330 if wireType != 2 { 331 return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) 332 } 333 var byteLen int 334 for shift := uint(0); ; shift += 7 { 335 if shift >= 64 { 336 return ErrIntOverflowEnvelope 337 } 338 if iNdEx >= l { 339 return io.ErrUnexpectedEOF 340 } 341 b := dAtA[iNdEx] 342 iNdEx++ 343 byteLen |= int(b&0x7F) << shift 344 if b < 0x80 { 345 break 346 } 347 } 348 if byteLen < 0 { 349 return ErrInvalidLengthEnvelope 350 } 351 postIndex := iNdEx + byteLen 352 if postIndex < 0 { 353 return ErrInvalidLengthEnvelope 354 } 355 if postIndex > l { 356 return io.ErrUnexpectedEOF 357 } 358 m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) 359 if m.Payload == nil { 360 m.Payload = []byte{} 361 } 362 iNdEx = postIndex 363 case 5: 364 if wireType != 2 { 365 return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) 366 } 367 var byteLen int 368 for shift := uint(0); ; shift += 7 { 369 if shift >= 64 { 370 return ErrIntOverflowEnvelope 371 } 372 if iNdEx >= l { 373 return io.ErrUnexpectedEOF 374 } 375 b := dAtA[iNdEx] 376 iNdEx++ 377 byteLen |= int(b&0x7F) << shift 378 if b < 0x80 { 379 break 380 } 381 } 382 if byteLen < 0 { 383 return ErrInvalidLengthEnvelope 384 } 385 postIndex := iNdEx + byteLen 386 if postIndex < 0 { 387 return ErrInvalidLengthEnvelope 388 } 389 if postIndex > l { 390 return io.ErrUnexpectedEOF 391 } 392 m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) 393 if m.Signature == nil { 394 m.Signature = []byte{} 395 } 396 iNdEx = postIndex 397 default: 398 iNdEx = preIndex 399 skippy, err := skipEnvelope(dAtA[iNdEx:]) 400 if err != nil { 401 return err 402 } 403 if skippy < 0 { 404 return ErrInvalidLengthEnvelope 405 } 406 if (iNdEx + skippy) < 0 { 407 return ErrInvalidLengthEnvelope 408 } 409 if (iNdEx + skippy) > l { 410 return io.ErrUnexpectedEOF 411 } 412 iNdEx += skippy 413 } 414 } 415 416 if iNdEx > l { 417 return io.ErrUnexpectedEOF 418 } 419 return nil 420} 421func skipEnvelope(dAtA []byte) (n int, err error) { 422 l := len(dAtA) 423 iNdEx := 0 424 depth := 0 425 for iNdEx < l { 426 var wire uint64 427 for shift := uint(0); ; shift += 7 { 428 if shift >= 64 { 429 return 0, ErrIntOverflowEnvelope 430 } 431 if iNdEx >= l { 432 return 0, io.ErrUnexpectedEOF 433 } 434 b := dAtA[iNdEx] 435 iNdEx++ 436 wire |= (uint64(b) & 0x7F) << shift 437 if b < 0x80 { 438 break 439 } 440 } 441 wireType := int(wire & 0x7) 442 switch wireType { 443 case 0: 444 for shift := uint(0); ; shift += 7 { 445 if shift >= 64 { 446 return 0, ErrIntOverflowEnvelope 447 } 448 if iNdEx >= l { 449 return 0, io.ErrUnexpectedEOF 450 } 451 iNdEx++ 452 if dAtA[iNdEx-1] < 0x80 { 453 break 454 } 455 } 456 case 1: 457 iNdEx += 8 458 case 2: 459 var length int 460 for shift := uint(0); ; shift += 7 { 461 if shift >= 64 { 462 return 0, ErrIntOverflowEnvelope 463 } 464 if iNdEx >= l { 465 return 0, io.ErrUnexpectedEOF 466 } 467 b := dAtA[iNdEx] 468 iNdEx++ 469 length |= (int(b) & 0x7F) << shift 470 if b < 0x80 { 471 break 472 } 473 } 474 if length < 0 { 475 return 0, ErrInvalidLengthEnvelope 476 } 477 iNdEx += length 478 case 3: 479 depth++ 480 case 4: 481 if depth == 0 { 482 return 0, ErrUnexpectedEndOfGroupEnvelope 483 } 484 depth-- 485 case 5: 486 iNdEx += 4 487 default: 488 return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 489 } 490 if iNdEx < 0 { 491 return 0, ErrInvalidLengthEnvelope 492 } 493 if depth == 0 { 494 return iNdEx, nil 495 } 496 } 497 return 0, io.ErrUnexpectedEOF 498} 499 500var ( 501 ErrInvalidLengthEnvelope = fmt.Errorf("proto: negative length found during unmarshaling") 502 ErrIntOverflowEnvelope = fmt.Errorf("proto: integer overflow") 503 ErrUnexpectedEndOfGroupEnvelope = fmt.Errorf("proto: unexpected end of group") 504) 505