mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-02-26 08:50:15 +08:00
rename SignedEnvelope -> Envelope, unmarshal payload in ConsumeEnvelope
This commit is contained in:
parent
8dc249ddde
commit
77a03aaf83
@ -21,5 +21,5 @@ type EvtLocalAddressesUpdated struct {
|
||||
// for the local peer has been produced. This will happen whenever the set of listen
|
||||
// addresses changes.
|
||||
type EvtLocalPeerRecordUpdated struct {
|
||||
SignedRecord *record.SignedEnvelope
|
||||
SignedRecord *record.Envelope
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ func init() {
|
||||
record.RegisterPayloadType(PeerRecordEnvelopePayloadType, &PeerRecord{})
|
||||
}
|
||||
|
||||
// The domain string used for peer records contained in a SignedEnvelope.
|
||||
// The domain string used for peer records contained in a Envelope.
|
||||
const PeerRecordEnvelopeDomain = "libp2p-peer-record"
|
||||
|
||||
// The type hint used to identify peer records in a SignedEnvelope.
|
||||
// The type hint used to identify peer records in a Envelope.
|
||||
// TODO: register multicodec
|
||||
var PeerRecordEnvelopePayloadType = []byte("/libp2p/peer-record")
|
||||
|
||||
@ -36,15 +36,15 @@ var ErrPeerIdMismatch = errors.New("signing key does not match record.PeerID")
|
||||
// PeerRecords are intended to be signed by the peer they describe, and there are no
|
||||
// public methods for marshalling unsigned PeerRecords.
|
||||
//
|
||||
// To share a PeerRecord, first call Sign to wrap the record in a SignedEnvelope
|
||||
// To share a PeerRecord, first call Sign to wrap the record in a Envelope
|
||||
// and sign it with the local peer's private key:
|
||||
//
|
||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||
// envelope, err := rec.Sign(myPrivateKey)
|
||||
//
|
||||
// The resulting record.SignedEnvelope can be marshalled to a []byte and shared
|
||||
// The resulting record.Envelope can be marshalled to a []byte and shared
|
||||
// publicly. As a convenience, the MarshalSigned method will produce the
|
||||
// SignedEnvelope and marshal it to a []byte in one go:
|
||||
// Envelope and marshal it to a []byte in one go:
|
||||
//
|
||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||
// recordBytes, err := rec.MarshalSigned(myPrivateKey)
|
||||
@ -111,9 +111,9 @@ func (r *PeerRecord) MarshalRecord() ([]byte, error) {
|
||||
return proto.Marshal(&msg)
|
||||
}
|
||||
|
||||
// Sign wraps the PeerRecord in a routing.SignedEnvelope, signed with the given
|
||||
// Sign wraps the PeerRecord in a routing.Envelope, signed with the given
|
||||
// private key. The private key must match the PeerID field of the PeerRecord.
|
||||
func (r *PeerRecord) Sign(privKey crypto.PrivKey) (*record.SignedEnvelope, error) {
|
||||
func (r *PeerRecord) Sign(privKey crypto.PrivKey) (*record.Envelope, error) {
|
||||
p, err := IDFromPrivateKey(privKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -121,11 +121,11 @@ func (r *PeerRecord) Sign(privKey crypto.PrivKey) (*record.SignedEnvelope, error
|
||||
if p != r.PeerID {
|
||||
return nil, ErrPeerIdMismatch
|
||||
}
|
||||
return record.MakeEnvelopeFromRecord(privKey, PeerRecordEnvelopeDomain, r)
|
||||
return record.MakeEnvelopeWithRecord(privKey, PeerRecordEnvelopeDomain, r)
|
||||
}
|
||||
|
||||
// MarshalSigned is a convenience method that wraps the PeerRecord in a routing.SignedEnvelope,
|
||||
// and marshals the SignedEnvelope to a []byte.
|
||||
// MarshalSigned is a convenience method that wraps the PeerRecord in a routing.Envelope,
|
||||
// and marshals the Envelope to a []byte.
|
||||
func (r *PeerRecord) MarshalSigned(privKey crypto.PrivKey) ([]byte, error) {
|
||||
env, err := r.Sign(privKey)
|
||||
if err != nil {
|
||||
|
@ -123,7 +123,7 @@ type AddrBook interface {
|
||||
|
||||
// CertifiedAddrBook manages "self-certified" addresses for remote peers.
|
||||
// Self-certified addresses are contained in peer.PeerRecords
|
||||
// that are wraped in a record.SignedEnvelope and signed by the peer
|
||||
// that are wraped in a record.Envelope and signed by the peer
|
||||
// to whom they belong.
|
||||
//
|
||||
// This interface is most useful when combined with AddrBook.
|
||||
@ -137,7 +137,7 @@ type AddrBook interface {
|
||||
//
|
||||
type CertifiedAddrBook interface {
|
||||
// AddCertifiedAddrs adds addresses from a signed peer.PeerRecord (contained in
|
||||
// a routing.SignedEnvelope), which will expire after the given TTL.
|
||||
// a routing.Envelope), which will expire after the given TTL.
|
||||
//
|
||||
// Signed records added via this method will be stored without
|
||||
// alteration as long as the address TTLs remain valid. The SignedEnvelopes
|
||||
@ -160,12 +160,12 @@ type CertifiedAddrBook interface {
|
||||
// AddrBook.SetAddrs will be ignored. AddrBook.SetAddrs may still be used
|
||||
// to update the TTL of certified addresses if they have previously been
|
||||
// added via AddCertifiedAddrs.
|
||||
AddCertifiedAddrs(s *record.SignedEnvelope, ttl time.Duration) error
|
||||
AddCertifiedAddrs(s *record.Envelope, ttl time.Duration) error
|
||||
|
||||
// SignedPeerRecord returns a SignedEnvelope containing a PeerRecord for the
|
||||
// SignedPeerRecord returns a Envelope containing a PeerRecord for the
|
||||
// given peer id, if one exists.
|
||||
// Returns nil if no signed PeerRecord exists for the peer.
|
||||
SignedPeerRecord(p peer.ID) *record.SignedEnvelope
|
||||
SignedPeerRecord(p peer.ID) *record.Envelope
|
||||
}
|
||||
|
||||
// GetCertifiedAddrBook is a helper to "upcast" an AddrBook to a
|
||||
|
@ -14,13 +14,13 @@ import (
|
||||
"github.com/multiformats/go-varint"
|
||||
)
|
||||
|
||||
// SignedEnvelope contains an arbitrary []byte payload, signed by a libp2p peer.
|
||||
// Envelope contains an arbitrary []byte payload, signed by a libp2p peer.
|
||||
//
|
||||
// Envelopes are signed in the context of a particular "domain", which is a
|
||||
// string specified when creating and verifying the envelope. You must know the
|
||||
// domain string used to produce the envelope in order to verify the signature
|
||||
// and access the payload.
|
||||
type SignedEnvelope struct {
|
||||
type Envelope struct {
|
||||
// The public key that can be used to verify the signature and derive the peer id of the signer.
|
||||
PublicKey crypto.PubKey
|
||||
|
||||
@ -39,19 +39,24 @@ type SignedEnvelope struct {
|
||||
}
|
||||
|
||||
var ErrEmptyDomain = errors.New("envelope domain must not be empty")
|
||||
var ErrEmptyPayloadType = errors.New("payloadType must not be empty")
|
||||
var ErrInvalidSignature = errors.New("invalid signature or incorrect domain")
|
||||
|
||||
// MakeEnvelope constructs a new SignedEnvelope using the given privateKey.
|
||||
// MakeEnvelope constructs a new Envelope using the given privateKey.
|
||||
//
|
||||
// The required 'domain' string contextualizes the envelope for a particular purpose,
|
||||
// and must be supplied when verifying the signature.
|
||||
//
|
||||
// The 'PayloadType' field indicates what kind of data is contained and may be empty.
|
||||
func MakeEnvelope(privateKey crypto.PrivKey, domain string, payloadType []byte, payload []byte) (*SignedEnvelope, error) {
|
||||
// The 'PayloadType' field indicates what kind of data is contained and must be non-empty.
|
||||
func MakeEnvelope(privateKey crypto.PrivKey, domain string, payloadType []byte, payload []byte) (*Envelope, error) {
|
||||
if domain == "" {
|
||||
return nil, ErrEmptyDomain
|
||||
}
|
||||
|
||||
if len(payloadType) == 0 {
|
||||
return nil, ErrEmptyPayloadType
|
||||
}
|
||||
|
||||
seq := statelessSeqNo()
|
||||
unsigned, err := makeUnsigned(domain, payloadType, payload, seq)
|
||||
if err != nil {
|
||||
@ -64,7 +69,7 @@ func MakeEnvelope(privateKey crypto.PrivKey, domain string, payloadType []byte,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SignedEnvelope{
|
||||
return &Envelope{
|
||||
PublicKey: privateKey.GetPublic(),
|
||||
PayloadType: payloadType,
|
||||
RawPayload: payload,
|
||||
@ -73,7 +78,12 @@ func MakeEnvelope(privateKey crypto.PrivKey, domain string, payloadType []byte,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func MakeEnvelopeFromRecord(privateKey crypto.PrivKey, domain string, rec Record) (*SignedEnvelope, error) {
|
||||
// MakeEnvelopeWithRecord wraps the given Record in an Envelope, and signs it using the given key
|
||||
// and domain string.
|
||||
//
|
||||
// The Record's concrete type must be associated with a multicodec payload type identifier
|
||||
// (see record.RegisterPayloadType).
|
||||
func MakeEnvelopeWithRecord(privateKey crypto.PrivKey, domain string, rec Record) (*Envelope, error) {
|
||||
payloadType, ok := payloadTypeForRecord(rec)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unable to determine value for PayloadType field")
|
||||
@ -85,11 +95,11 @@ func MakeEnvelopeFromRecord(privateKey crypto.PrivKey, domain string, rec Record
|
||||
return MakeEnvelope(privateKey, domain, payloadType, payloadBytes)
|
||||
}
|
||||
|
||||
// ConsumeEnvelope unmarshals a serialized SignedEnvelope, and validates its
|
||||
// ConsumeEnvelope unmarshals a serialized Envelope, and validates its
|
||||
// signature using the provided 'domain' string. If validation fails, an error
|
||||
// is returned, along with the unmarshalled envelope so it can be inspected.
|
||||
// TODO(yusef): improve this doc comment before merge
|
||||
func ConsumeEnvelope(data []byte, domain string) (envelope *SignedEnvelope, contents Record, err error) {
|
||||
func ConsumeEnvelope(data []byte, domain string) (envelope *Envelope, rec Record, err error) {
|
||||
e, err := UnmarshalEnvelope(data)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed when unmarshalling the envelope: %w", err)
|
||||
@ -100,16 +110,15 @@ func ConsumeEnvelope(data []byte, domain string) (envelope *SignedEnvelope, cont
|
||||
return e, nil, fmt.Errorf("failed to validate envelope: %w", err)
|
||||
}
|
||||
|
||||
contents, err = unmarshalRecordPayload(e.PayloadType, e.RawPayload)
|
||||
rec, err = unmarshalRecordPayload(e.PayloadType, e.RawPayload)
|
||||
if err != nil {
|
||||
return e, nil, fmt.Errorf("failed to unmarshal envelope payload: %w", err)
|
||||
}
|
||||
|
||||
return e, contents, nil
|
||||
return e, rec, nil
|
||||
}
|
||||
|
||||
// TODO(yusef): doc comment before merge
|
||||
func ConsumeTypedEnvelope(data []byte, domain string, payloadDest Record) (envelope *SignedEnvelope, err error) {
|
||||
func ConsumeTypedEnvelope(data []byte, domain string, destRecord Record) (envelope *Envelope, err error) {
|
||||
e, err := UnmarshalEnvelope(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed when unmarshalling the envelope: %w", err)
|
||||
@ -120,18 +129,17 @@ func ConsumeTypedEnvelope(data []byte, domain string, payloadDest Record) (envel
|
||||
return e, fmt.Errorf("failed to validate envelope: %w", err)
|
||||
}
|
||||
|
||||
err = payloadDest.UnmarshalRecord(e.RawPayload)
|
||||
err = destRecord.UnmarshalRecord(e.RawPayload)
|
||||
if err != nil {
|
||||
return e, fmt.Errorf("failed to unmarshal envelope payload: %w", err)
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// UnmarshalEnvelope unmarshals a serialized SignedEnvelope protobuf message,
|
||||
// UnmarshalEnvelope unmarshals a serialized Envelope protobuf message,
|
||||
// without validating its contents. Most users should use ConsumeEnvelope.
|
||||
func UnmarshalEnvelope(data []byte) (*SignedEnvelope, error) {
|
||||
var e pb.SignedEnvelope
|
||||
func UnmarshalEnvelope(data []byte) (*Envelope, error) {
|
||||
var e pb.Envelope
|
||||
if err := proto.Unmarshal(data, &e); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -141,7 +149,7 @@ func UnmarshalEnvelope(data []byte) (*SignedEnvelope, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SignedEnvelope{
|
||||
return &Envelope{
|
||||
PublicKey: key,
|
||||
PayloadType: e.PayloadType,
|
||||
RawPayload: e.Payload,
|
||||
@ -151,14 +159,14 @@ func UnmarshalEnvelope(data []byte) (*SignedEnvelope, error) {
|
||||
}
|
||||
|
||||
// Marshal returns a byte slice containing a serialized protobuf representation
|
||||
// of a SignedEnvelope.
|
||||
func (e *SignedEnvelope) Marshal() ([]byte, error) {
|
||||
// of a Envelope.
|
||||
func (e *Envelope) Marshal() ([]byte, error) {
|
||||
key, err := crypto.PublicKeyToProto(e.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
msg := pb.SignedEnvelope{
|
||||
msg := pb.Envelope{
|
||||
PublicKey: key,
|
||||
PayloadType: e.PayloadType,
|
||||
Payload: e.RawPayload,
|
||||
@ -168,10 +176,10 @@ func (e *SignedEnvelope) Marshal() ([]byte, error) {
|
||||
return proto.Marshal(&msg)
|
||||
}
|
||||
|
||||
// Equal returns true if the other SignedEnvelope has the same public key,
|
||||
// Equal returns true if the other Envelope has the same public key,
|
||||
// payload, payload type, and signature. This implies that they were also
|
||||
// created with the same domain string.
|
||||
func (e *SignedEnvelope) Equal(other *SignedEnvelope) bool {
|
||||
func (e *Envelope) Equal(other *Envelope) bool {
|
||||
if other == nil {
|
||||
return e == nil
|
||||
}
|
||||
@ -184,7 +192,7 @@ func (e *SignedEnvelope) Equal(other *SignedEnvelope) bool {
|
||||
|
||||
// validate returns nil if the envelope signature is valid for the given 'domain',
|
||||
// or an error if signature validation fails.
|
||||
func (e *SignedEnvelope) validate(domain string) error {
|
||||
func (e *Envelope) validate(domain string) error {
|
||||
unsigned, err := makeUnsigned(domain, e.PayloadType, e.RawPayload, e.Seq)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -127,7 +127,7 @@ func TestEnvelopeValidateFailsForDifferentDomain(t *testing.T) {
|
||||
|
||||
RegisterPayloadType(payloadType, &simpleRecord{})
|
||||
|
||||
envelope, err := MakeEnvelopeFromRecord(priv, domain, rec)
|
||||
envelope, err := MakeEnvelopeWithRecord(priv, domain, rec)
|
||||
test.AssertNilError(t, err)
|
||||
|
||||
serialized, err := envelope.Marshal()
|
||||
@ -149,10 +149,10 @@ func TestEnvelopeValidateFailsIfTypeHintIsAltered(t *testing.T) {
|
||||
|
||||
RegisterPayloadType(payloadType, &simpleRecord{})
|
||||
|
||||
envelope, err := MakeEnvelopeFromRecord(priv, domain, rec)
|
||||
envelope, err := MakeEnvelopeWithRecord(priv, domain, rec)
|
||||
test.AssertNilError(t, err)
|
||||
|
||||
serialized := alterMessageAndMarshal(t, envelope, func(msg *pb.SignedEnvelope) {
|
||||
serialized := alterMessageAndMarshal(t, envelope, func(msg *pb.Envelope) {
|
||||
msg.PayloadType = []byte("foo")
|
||||
})
|
||||
|
||||
@ -173,10 +173,10 @@ func TestEnvelopeValidateFailsIfContentsAreAltered(t *testing.T) {
|
||||
|
||||
RegisterPayloadType(payloadType, &simpleRecord{})
|
||||
|
||||
envelope, err := MakeEnvelopeFromRecord(priv, domain, rec)
|
||||
envelope, err := MakeEnvelopeWithRecord(priv, domain, rec)
|
||||
test.AssertNilError(t, err)
|
||||
|
||||
serialized := alterMessageAndMarshal(t, envelope, func(msg *pb.SignedEnvelope) {
|
||||
serialized := alterMessageAndMarshal(t, envelope, func(msg *pb.Envelope) {
|
||||
msg.Payload = []byte("totally legit, trust me")
|
||||
})
|
||||
|
||||
@ -197,10 +197,10 @@ func TestEnvelopeValidateFailsIfSeqIsAltered(t *testing.T) {
|
||||
|
||||
RegisterPayloadType(payloadType, &simpleRecord{})
|
||||
|
||||
envelope, err := MakeEnvelopeFromRecord(priv, domain, rec)
|
||||
envelope, err := MakeEnvelopeWithRecord(priv, domain, rec)
|
||||
test.AssertNilError(t, err)
|
||||
|
||||
serialized := alterMessageAndMarshal(t, envelope, func(msg *pb.SignedEnvelope) {
|
||||
serialized := alterMessageAndMarshal(t, envelope, func(msg *pb.Envelope) {
|
||||
msg.Seq = envelope.Seq + 1
|
||||
})
|
||||
|
||||
@ -210,17 +210,17 @@ func TestEnvelopeValidateFailsIfSeqIsAltered(t *testing.T) {
|
||||
}
|
||||
|
||||
// Since we're outside of the crypto package (to avoid import cycles with test package),
|
||||
// we can't alter the fields in a SignedEnvelope directly. This helper marshals
|
||||
// we can't alter the fields in a Envelope directly. This helper marshals
|
||||
// the envelope to a protobuf and calls the alterMsg function, which should
|
||||
// alter the protobuf message.
|
||||
// Returns the serialized altered protobuf message.
|
||||
func alterMessageAndMarshal(t *testing.T, envelope *SignedEnvelope, alterMsg func(*pb.SignedEnvelope)) []byte {
|
||||
func alterMessageAndMarshal(t *testing.T, envelope *Envelope, alterMsg func(*pb.Envelope)) []byte {
|
||||
t.Helper()
|
||||
|
||||
serialized, err := envelope.Marshal()
|
||||
test.AssertNilError(t, err)
|
||||
|
||||
msg := pb.SignedEnvelope{}
|
||||
msg := pb.Envelope{}
|
||||
err = proto.Unmarshal(serialized, &msg)
|
||||
test.AssertNilError(t, err)
|
||||
|
||||
|
@ -23,7 +23,8 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type SignedEnvelope struct {
|
||||
// TODO(yusef): doc comments before merge
|
||||
type Envelope struct {
|
||||
PublicKey *pb.PublicKey `protobuf:"bytes,1,opt,name=publicKey,proto3" json:"publicKey,omitempty"`
|
||||
PayloadType []byte `protobuf:"bytes,2,opt,name=payloadType,proto3" json:"payloadType,omitempty"`
|
||||
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||
@ -31,18 +32,18 @@ type SignedEnvelope struct {
|
||||
Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) Reset() { *m = SignedEnvelope{} }
|
||||
func (m *SignedEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*SignedEnvelope) ProtoMessage() {}
|
||||
func (*SignedEnvelope) Descriptor() ([]byte, []int) {
|
||||
func (m *Envelope) Reset() { *m = Envelope{} }
|
||||
func (m *Envelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*Envelope) ProtoMessage() {}
|
||||
func (*Envelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ee266e8c558e9dc5, []int{0}
|
||||
}
|
||||
func (m *SignedEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
func (m *Envelope) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SignedEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *Envelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SignedEnvelope.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_Envelope.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -52,47 +53,47 @@ func (m *SignedEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *SignedEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SignedEnvelope.Merge(m, src)
|
||||
func (m *Envelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Envelope.Merge(m, src)
|
||||
}
|
||||
func (m *SignedEnvelope) XXX_Size() int {
|
||||
func (m *Envelope) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SignedEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SignedEnvelope.DiscardUnknown(m)
|
||||
func (m *Envelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Envelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SignedEnvelope proto.InternalMessageInfo
|
||||
var xxx_messageInfo_Envelope proto.InternalMessageInfo
|
||||
|
||||
func (m *SignedEnvelope) GetPublicKey() *pb.PublicKey {
|
||||
func (m *Envelope) GetPublicKey() *pb.PublicKey {
|
||||
if m != nil {
|
||||
return m.PublicKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) GetPayloadType() []byte {
|
||||
func (m *Envelope) GetPayloadType() []byte {
|
||||
if m != nil {
|
||||
return m.PayloadType
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) GetPayload() []byte {
|
||||
func (m *Envelope) GetPayload() []byte {
|
||||
if m != nil {
|
||||
return m.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) GetSeq() uint64 {
|
||||
func (m *Envelope) GetSeq() uint64 {
|
||||
if m != nil {
|
||||
return m.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) GetSignature() []byte {
|
||||
func (m *Envelope) GetSignature() []byte {
|
||||
if m != nil {
|
||||
return m.Signature
|
||||
}
|
||||
@ -100,30 +101,30 @@ func (m *SignedEnvelope) GetSignature() []byte {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*SignedEnvelope)(nil), "record.pb.SignedEnvelope")
|
||||
proto.RegisterType((*Envelope)(nil), "record.pb.Envelope")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("envelope.proto", fileDescriptor_ee266e8c558e9dc5) }
|
||||
|
||||
var fileDescriptor_ee266e8c558e9dc5 = []byte{
|
||||
// 216 bytes of a gzipped FileDescriptorProto
|
||||
// 210 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0xcd, 0x2b, 0x4b,
|
||||
0xcd, 0xc9, 0x2f, 0x48, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x2c, 0x4a, 0x4d, 0xce,
|
||||
0x2f, 0x4a, 0xd1, 0x2b, 0x48, 0x92, 0x12, 0x4b, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x48,
|
||||
0xd2, 0x87, 0xb0, 0x20, 0x4a, 0x94, 0x36, 0x30, 0x72, 0xf1, 0x05, 0x67, 0xa6, 0xe7, 0xa5, 0xa6,
|
||||
0xb8, 0x42, 0xf5, 0x0a, 0x19, 0x71, 0x71, 0x16, 0x94, 0x26, 0xe5, 0x64, 0x26, 0x7b, 0xa7, 0x56,
|
||||
0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x89, 0xe8, 0xc1, 0x34, 0x25, 0xe9, 0x05, 0xc0, 0xe4,
|
||||
0x82, 0x10, 0xca, 0x84, 0x14, 0xb8, 0xb8, 0x0b, 0x12, 0x2b, 0x73, 0xf2, 0x13, 0x53, 0x42, 0x2a,
|
||||
0x0b, 0x52, 0x25, 0x98, 0x14, 0x18, 0x35, 0x78, 0x82, 0x90, 0x85, 0x84, 0x24, 0xb8, 0xd8, 0xa1,
|
||||
0x5c, 0x09, 0x66, 0xb0, 0x2c, 0x8c, 0x2b, 0x24, 0xc0, 0xc5, 0x5c, 0x9c, 0x5a, 0x28, 0xc1, 0xa2,
|
||||
0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x62, 0x0a, 0xc9, 0x70, 0x71, 0x16, 0x67, 0xa6, 0xe7, 0x25, 0x96,
|
||||
0x94, 0x16, 0xa5, 0x4a, 0xb0, 0x82, 0x55, 0x23, 0x04, 0x9c, 0x24, 0x4e, 0x3c, 0x92, 0x63, 0xbc,
|
||||
0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63,
|
||||
0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x89, 0x0d, 0xec, 0x27, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff,
|
||||
0x57, 0x41, 0x23, 0x95, 0x08, 0x01, 0x00, 0x00,
|
||||
0xd2, 0x87, 0xb0, 0x20, 0x4a, 0x94, 0x56, 0x31, 0x72, 0x71, 0xb8, 0x42, 0x75, 0x09, 0x19, 0x71,
|
||||
0x71, 0x16, 0x94, 0x26, 0xe5, 0x64, 0x26, 0x7b, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70,
|
||||
0x1b, 0x89, 0xe8, 0xc1, 0x94, 0x27, 0xe9, 0x05, 0xc0, 0xe4, 0x82, 0x10, 0xca, 0x84, 0x14, 0xb8,
|
||||
0xb8, 0x0b, 0x12, 0x2b, 0x73, 0xf2, 0x13, 0x53, 0x42, 0x2a, 0x0b, 0x52, 0x25, 0x98, 0x14, 0x18,
|
||||
0x35, 0x78, 0x82, 0x90, 0x85, 0x84, 0x24, 0xb8, 0xd8, 0xa1, 0x5c, 0x09, 0x66, 0xb0, 0x2c, 0x8c,
|
||||
0x2b, 0x24, 0xc0, 0xc5, 0x5c, 0x9c, 0x5a, 0x28, 0xc1, 0xa2, 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x62,
|
||||
0x0a, 0xc9, 0x70, 0x71, 0x16, 0x67, 0xa6, 0xe7, 0x25, 0x96, 0x94, 0x16, 0xa5, 0x4a, 0xb0, 0x82,
|
||||
0x55, 0x23, 0x04, 0x9c, 0x24, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23,
|
||||
0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x89,
|
||||
0x0d, 0xec, 0x1b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xa1, 0x77, 0xca, 0x02, 0x01,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) Marshal() (dAtA []byte, err error) {
|
||||
func (m *Envelope) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -133,12 +134,12 @@ func (m *SignedEnvelope) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *Envelope) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SignedEnvelope) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *Envelope) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -195,7 +196,7 @@ func encodeVarintEnvelope(dAtA []byte, offset int, v uint64) int {
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *SignedEnvelope) Size() (n int) {
|
||||
func (m *Envelope) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -229,7 +230,7 @@ func sovEnvelope(x uint64) (n int) {
|
||||
func sozEnvelope(x uint64) (n int) {
|
||||
return sovEnvelope(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *SignedEnvelope) Unmarshal(dAtA []byte) error {
|
||||
func (m *Envelope) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -252,10 +253,10 @@ func (m *SignedEnvelope) Unmarshal(dAtA []byte) error {
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: SignedEnvelope: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: Envelope: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SignedEnvelope: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: Envelope: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
|
@ -4,7 +4,8 @@ package record.pb;
|
||||
|
||||
import "crypto/pb/crypto.proto";
|
||||
|
||||
message SignedEnvelope {
|
||||
// TODO(yusef): doc comments before merge
|
||||
message Envelope {
|
||||
crypto.pb.PublicKey publicKey = 1;
|
||||
bytes payloadType = 2;
|
||||
bytes payload = 3;
|
||||
|
Loading…
Reference in New Issue
Block a user